Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support constraining reference types #42

Merged
merged 2 commits into from
Nov 22, 2024
Merged

Support constraining reference types #42

merged 2 commits into from
Nov 22, 2024

Conversation

nc6
Copy link
Collaborator

@nc6 nc6 commented Nov 22, 2024

Before this commit, it wasn't possible to apply constraints (e.g.
'.size') to references, only directly to Value types. This gives us some
nice type safety (you can't apply '.cbor' to an integer, for example),
it also doesn't allow us to constrain types which are passed as generic
parameters, or where we genuinely want to constrain another rule.

This commit changes that by allowing references (both direct and
generic) to be constrained. Obviously we don't have any guarantees here
that what we are constraining makes sense, but we never had that in CDDL
anyway. And we retain the type safety for anything that isn't a
reference.

This resolves issue #31

nc6 added 2 commits November 22, 2024 12:02
This addresses part of #36 - comments are still not supported
_everywhere_, but they are allowed on group entries, which represent the
area (other than top-level rules) where comments are the most useful.

The same "comment" syntax is used as with top-level rules.

Note that this does not (yet) work within groups - that will be
addressed as part of #32.

As yet, the parser still does not deal with comments, or attribute them
to any entity. The tests are likewise oblivious to comments. But this
does allow Huddle to define comments and have them reflected in the
generated CDDL, which was the principal outcome.
Before this commit, it wasn't possible to apply constraints (e.g.
'.size') to references, only directly to Value types. This gives us some
nice type safety (you can't apply '.cbor' to an integer, for example),
it also doesn't allow us to constrain types which are passed as generic
parameters, or where we genuinely want to constrain another rule.

This commit changes that by allowing references (both direct and
generic) to be constrained. Obviously we don't have any guarantees here
that what we are constraining makes sense, but we never had that in CDDL
anyway. And we retain the type safety for anything that _isn't_ a
reference.

This resolves issue #31
@nc6 nc6 requested a review from Soupstraw November 22, 2024 15:37
@nc6 nc6 merged commit 7874af0 into master Nov 22, 2024
4 checks passed
@nc6 nc6 deleted the nc/sizedRef branch November 22, 2024 15:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant