-
-
Notifications
You must be signed in to change notification settings - Fork 36
Add Missing Selector Annotation error #431
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
Conversation
Meh. I don't think we should do this. I would rather do one of the following: (a) Make
(b) Syntactically require the annotation, e.g.: switch = matcher *variant
matcher = match 1*selector
; annotation is not optional unlike in expression
selector = "{" [s] (operand s annotation)/(annotation) [s] "}" This makes the selector function explicit and makes it a parse error not to say which one to use. It also means that you can't use a declaration for the selector (only as the value of a selector), which I agree is kind of odd. I'll also call out: in our discussion of mutable vs. immutable variables, @mihnita's "13/42" example comes into play here. If we say that this evaluates as "13 and 42":
... but then say that a selector is late binding:
... that seems like an inconsistency in favor of "42 42" |
I don't think this kind of message is at all common, so I would find it odd to have it be the default behaviour. What is the benefit we get from not requiring a selector here?
I don't like this. This would mean we'd need two different expression parsers, which seems really cumbersome. Requiring an annotation would also guide developers towards using different options bags for the selection vs. formatting.
The way that I would read this is that we first create a "plural" instance and assign it to |
That's fair. 😅 The main beneficiary of requiring annotations on selectors is translation tooling, which can then better handle locale-sensitive selectors such as plurals. A secondary benefit is the avoidance of apparently-but-not-really valid messages, such as the one presented by @macchiati in #425 (comment):
|
@aphillips @macchiati @mihnita @stasm I've now updated this proposal following our discussion, to also account for transitive references to annotated expressions. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor change requested.
Co-authored-by: Addison Phillips <[email protected]>
Note: I filed #433 to track choosing a name for |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM after dropping the "at most one jump" requirement on annotations in local variables.
See #425 for context.
Adds this requirement to the spec, and a corresponding data model error:
Edit: Added "directly or indirectly" to the original proposal, to account for messages like: