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

Allow metadata keywords in field position #1768

Merged
merged 1 commit into from
Jan 19, 2024

Conversation

yannham
Copy link
Member

@yannham yannham commented Jan 19, 2024

Closes #1765.

Metadata keywords (optional, default, etc.) are numerous and they can't clash with field names, because they don't appear in the same positions. Thus, to avoid having user to quote their fields, this PR allows unambiguously the usage of metadata keyword in field position.

I suspect we could actually proceed with even more keywords of the language, but let's start small and avoid shooting ourselves in the foot. The metadata keywords is the set which isn't small and is likely to grow, while the other keywords should stay relatively stable.

Note that currently metadata keyword are rejected within let destucturing, because destructuring binds variables, and variables which are keywords can't be accessed in the current syntax. We might change that if we ever implement raw identifiers.

Metadata keywords (optional, default, etc.) are numerous and they can't
clash with field names, because they don't appear in the same positions.
Thus, to avoid having user to quote their fields, this commit allows
unambiguously the usage of metadata keyword in field position.
@@ -1,141 +1,165 @@
# test.type = 'pass'
Copy link
Member Author

@yannham yannham Jan 19, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file has a big diff because I formatted it with Topiary. You can ignore most of the changes but the very end, where I added a test for metadata keyword in field position.

@yannham yannham requested a review from vkleen January 19, 2024 10:28
@github-actions github-actions bot temporarily deployed to pull request January 19, 2024 10:31 Inactive
@@ -557,6 +557,30 @@ Match: Match = {
// A default annotation in a pattern.
DefaultAnnot: RichTerm = "?" <t: Term> => t;

// A metadata keyword returned as an indent. In some positions, those are
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we do this for all (or most) of our keywords? I think even a let or rec should be unambiguous in field name positions.

Copy link
Member Author

@yannham yannham Jan 19, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would vote for doing this for metadata keyword only at first. Although I don't have right now any example of an existing keyword or a future extension that could cause an issue, let's just give it a bit more thinking (metadata keywords are much more restricted in where they can appear). At worst we can do that in a follow-up PR.

@yannham yannham added this pull request to the merge queue Jan 19, 2024
Merged via the queue into master with commit 8a1e538 Jan 19, 2024
5 checks passed
@yannham yannham deleted the syntax/metadata-keyword-field-names branch January 19, 2024 11:30
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.

It shouldn't be necessary to quote keywords
2 participants