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

Add Resolved Values and Function Handler sections to formatting #728

Merged
merged 14 commits into from
Oct 7, 2024
Merged
8 changes: 4 additions & 4 deletions spec/errors.md
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ a reference to a function which cannot be resolved.
### Bad Selector

A **_<dfn>Bad Selector</dfn>_** error occurs when a message includes a _selector_
with a resolved value which does not support selection.
with a _resolved value_ which does not support selection.
Copy link
Member

Choose a reason for hiding this comment

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

I'm confused. Can you give an example of a selector that supports selection where its resolved value doesn't?

That is, if I have
.input {$num :number}
.match $num
...
How could :number ever have a resolved value that didn't support selection? I think the notion of 'resolved value' doesn't help.

Suggested change
with a _resolved value_ which does not support selection.
that does not support selection.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

How could :number ever have a resolved value that didn't support selection?

Going with the example you posted above, if that message is formatted without a num argument, then the first step of Function Resolution applies:

If the expression includes an operand, resolve its value. If this fails, use a fallback value for the expression.

And then this part of Fallback Resolution applies:

Pattern selection is not supported for fallback values.

And so we end up emitting two errors when formatting:

  1. Unresolved Variable
  2. Bad Selector

Copy link
Member

Choose a reason for hiding this comment

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

I think @macchiati's finger is on the right thing. It's not a technical problem. This is just hard to understand. Perhaps:

Suggested change
with a _resolved value_ which does not support selection.
A **_<dfn>Bad Selector</dfn>_** error is an error that occurs when a _message_
includes a _selector_ whose _resolved value_
contains a _function handler_ which does not support selection,
is missing a _function handler_,
or consists of a _fallback value_.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Could we spin this suggestion off into a separate PR? As is, the only change that is being applied here is linkifying resolved value.

Copy link
Member

Choose a reason for hiding this comment

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

Works for me as a solution.


> For example, attempting to format this message
> would result in a _Bad Selector_ error:
Expand All @@ -283,10 +283,10 @@ with a resolved value which does not support selection.
## Message Function Errors

A **_<dfn>Message Function Error</dfn>_** is any error that occurs
when calling a message function implementation
when calling a _function handler_
or which depends on validation associated with a specific function.

Implementations SHOULD provide a way for _functions_ to emit
Implementations SHOULD provide a way for _function handlers_ to emit
Copy link
Member

Choose a reason for hiding this comment

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

I couldn't find a definition of what a "function handler" is. Which file is that in?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It's added by this PR to spec/formatting.md.

Copy link
Member

Choose a reason for hiding this comment

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

I don't see a definition; just references.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

(or cause to be emitted) any of the types of error defined in this section.
Implementations MAY also provide implementation-defined _Message Function Error_ types.

Expand All @@ -300,7 +300,7 @@ Implementations MAY also provide implementation-defined _Message Function Error_
> 3. Uses a `:get` message function which requires its argument to be an object and
> an option `field` to be provided with a string value.
>
> The exact type of _Message Function Error_ is determined by the message function implementation.
> The exact type of _Message Function Error_ is determined by the _function handler_.
>
> ```
> Hello, {horse :get field=name}!
Expand Down
Loading