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

[FEEDBACK] function use outside its intent #852

Closed
janishorsts opened this issue Aug 1, 2024 · 6 comments
Closed

[FEEDBACK] function use outside its intent #852

janishorsts opened this issue Aug 1, 2024 · 6 comments
Labels
errors Issues related to the errors section of the spec formatting Preview-Feedback Feedback gathered during the technical preview

Comments

@janishorsts
Copy link

What should happen when the function is used outside its intent?

  • when func :x is defined for selection only and used for formatting
  • when func :x is defined for formatting only and used for selecting
@janishorsts janishorsts added the Preview-Feedback Feedback gathered during the technical preview label Aug 1, 2024
@aphillips aphillips added formatting errors Issues related to the errors section of the spec LDML46 LDML46 Release (Tech Preview - October 2024) labels Aug 1, 2024
@aphillips
Copy link
Member

This does seem to be a specification gap.

@eemeli
Copy link
Collaborator

eemeli commented Aug 1, 2024

when func :x is defined for selection only and used for formatting

This is addressed in Formatting:

Resolved values cannot always be formatted by a given implementation.
When such an error occurs during _formatting_,
an implementation SHOULD emit an appropriate _Message Function Error_ and produce a
_fallback value_ for the _placeholder_ that produced the error.
A formatting function MAY substitute a value to use instead of a _fallback value_.

when func :x is defined for formatting only and used for selecting

This is addressed in Resolve Selectors step 2.iii.:

1. If selection is supported for `rv`:
1. Append `rv` as the last element of the list `res`.
1. Else:
1. Let `nomatch` be a resolved value for which selection always fails.
1. Append `nomatch` as the last element of the list `res`.
1. Emit a _Bad Selector_ error.

@janishorsts
Copy link
Author

@eemeli Indeed, it is explained clearly. How did I overlook them?! Thanks!

@janishorsts
Copy link
Author

janishorsts commented Aug 6, 2024

When the value cannot be formatted by a given function, none of the Message Function Error errors fit the intent and purpose:

  • Bad Operand,
  • Bad Option or
  • Bad Variant Key.

@eemeli, would you consider adding a new error to cover this scenario? Or do you rely on implementation defined Message Function Error?

Implementations MAY also provide implementation-defined _Message Function Error_ types.

@eemeli
Copy link
Collaborator

eemeli commented Aug 6, 2024

We used to have something like that (Formatting Error), but it was dropped in #774 in favour of Message Function Error, which implementations are indeed welcome to implement any necessary cases of.

The default set of functions doesn't include any that are only selectors so we've not ended up enumerating an explicit error for it. However, we do define :test:select that could be used to test for such an error.

If you're able to sign the CLA, we'd welcome a PR adding such a Message Function Error for consideration?

@aphillips
Copy link
Member

We discussed this in the 2024-08-12 telecon. The WG believes that "Whan the value cannot be formatted by a given function" is covered by text at line 253 in formatting.md:

Implementations of a function SHOULD emit a
Bad Operand error for operands whose resolved value
or type is not supported.

The value is the operand, so this seems to cover it. What are we missing? (Closing per telecon, reopen if not satisfied)

@aphillips aphillips removed Agenda+ LDML46 LDML46 Release (Tech Preview - October 2024) labels Aug 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
errors Issues related to the errors section of the spec formatting Preview-Feedback Feedback gathered during the technical preview
Projects
None yet
Development

No branches or pull requests

3 participants