diff --git a/spec/errors.md b/spec/errors.md index 5e49c1cd38..71f72ec3fd 100644 --- a/spec/errors.md +++ b/spec/errors.md @@ -238,6 +238,34 @@ or for private implementation use that is not supported by the current implement > * {{The value is not one.}} > ``` +### Invalid Expression + +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. + +An **_Operand Mismatch Error_** is an _Invalid Expression_ error that occurs when +an _operand_ provided to a _function_ during _function resolution_ does not match one of the +expected implementation-defined types for that function; +or in which a literal _operand_ value does not have the required format +and thus cannot be processed into one of the expected implementation-defined types +for that specific _function_. + +> For example, the following _message_ produces an _Operand Mismatch Error_ +> (a type of _Invalid Expression_ error) +> because the literal `|horse|` does not match the production `number-literal`, +> which is a requirement of the function `:number` for its operand: +> ``` +> .local $horse = {horse :number} +> {{You have a {$horse}.}} +> ``` +> The following _message_ might produce an _Invalid Expression_ error if the +> the function `:function` threw an exception or otherwise emitted an error +> rather than returning a valid value: +>``` +> {{This has an invalid expression {$var :function} because it has a bug in it.}} +>``` + ### Unsupported Statement An **_Unsupported Statement_** error occurs when a message includes a _reserved statement_. diff --git a/spec/formatting.md b/spec/formatting.md index dd71c96a0f..2379301cbb 100644 --- a/spec/formatting.md +++ b/spec/formatting.md @@ -237,8 +237,17 @@ the following steps are taken: 5. If the call succeeds, resolve the value of the _expression_ as the result of that function call. + If the call fails or does not return a valid value, - emit a _Resolution Error_ and use a _fallback value_ for the _expression_. + emit a _Invalid Expression_ error. + + Implementations MAY provide a mechanism for the _function_ to provide + additional detail about internal failures. + Specifically, if the cause of the failure was that the datatype, value, or format of the + _operand_ did not match that expected by the _function_, + the _function_ might cause an _Operand Mismatch Error_ to be emitted. + + In all failure cases, use the _fallback value_ for the _expression_ as the resolved value. #### Option Resolution