message-format-wg icon indicating copy to clipboard operation
message-format-wg copied to clipboard

Is it an error to pass a bad option to a function?

Open catamorphism opened this issue 1 year ago • 5 comments

I was looking at the following test case in https://github.com/unicode-org/message-format-wg/blob/main/test/test-functions.json :

{
      "src": ".input {$foo :number minimumFractionDigits=foo} {{bar {$foo}}}",
      "params": { "foo": 4.2 },
      "exp": "bar {$foo}",
      "errors": [{ "type": "bad-option" }]
    },

This means that the message ".input {$foo :number minimumFractionDigits=foo} {{bar {$foo}}}" is supposed to trigger an error because the string "foo" can't be parsed as an integer.

However, there is no error in errors.md that corresponds to "bad-option" in the test description. Should there be one? It's not really covered by "invalid expression error" (or at least I don't think so); it's definitely not covered by "Operand Mismatch Error" since the description of that error only refers to the function's operand and not its options.

If this is really an error, I think there should be a separate "Option Mismatch Error" to go with "Operand Mismatch Error".

See #706 for the general issue to create a list of error names that can be used in spec tests. I thought this should be a separate issue since the registry spec doesn't say much about error handling for bad option values.

catamorphism avatar Mar 19 '24 19:03 catamorphism

It's not really covered by "invalid expression error"

Why not? The description of that error is:

An Invalid Expression error occurs when a message includes an expression whose implementation-defined internal requirements produce an error during function resolution or when a function returns a value (such as null) that the implementation does not support.

The value of options is an implementation-defined internal requirement...

aphillips avatar Mar 19 '24 19:03 aphillips

It's not really covered by "invalid expression error"

Why not? The description of that error is:

An Invalid Expression error occurs when a message includes an expression whose implementation-defined internal requirements produce an error during function resolution or when a function returns a value (such as null) that the implementation does not support.

In the message, the value of the option isn't an expression. Though I guess you could argue that the expression as a whole, including the options, is invalid if one of the options is invalid.

Still, since the test suite does use a separate error name for this case, I thought it was worth discussing.

catamorphism avatar Mar 19 '24 19:03 catamorphism

I thought it was worth discussing.

Totally worth the discussion.

aphillips avatar Mar 19 '24 19:03 aphillips

This could be either a Resolution Error or a Formatting Error:

Formatting Errors occur during the formatting of a resolved value, for example when encountering a value with an unsupported type or an internally inconsistent set of options.

eemeli avatar Mar 19 '24 21:03 eemeli