Skip to content

Commit 28b7bf6

Browse files
authored
Address #629: create invalid expression error (#630)
* Address #629: create invalid expression error * Update formatting.md * Change `type` to `operand` As discussed in 2024-02-12 teleconference
1 parent 2891433 commit 28b7bf6

File tree

2 files changed

+38
-1
lines changed

2 files changed

+38
-1
lines changed

spec/errors.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,34 @@ or for private implementation use that is not supported by the current implement
238238
> * {{The value is not one.}}
239239
> ```
240240
241+
### Invalid Expression
242+
243+
An **_<dfn>Invalid Expression</dfn>_** error occurs when a _message_ includes an _expression_
244+
whose implementation-defined internal requirements produce an error during _function resolution_
245+
or when a _function_ returns a value (such as `null`) that the implementation does not support.
246+
247+
An **_<dfn>Operand Mismatch Error</dfn>_** is an _Invalid Expression_ error that occurs when
248+
an _operand_ provided to a _function_ during _function resolution_ does not match one of the
249+
expected implementation-defined types for that function;
250+
or in which a literal _operand_ value does not have the required format
251+
and thus cannot be processed into one of the expected implementation-defined types
252+
for that specific _function_.
253+
254+
> For example, the following _message_ produces an _Operand Mismatch Error_
255+
> (a type of _Invalid Expression_ error)
256+
> because the literal `|horse|` does not match the production `number-literal`,
257+
> which is a requirement of the function `:number` for its operand:
258+
> ```
259+
> .local $horse = {horse :number}
260+
> {{You have a {$horse}.}}
261+
> ```
262+
> The following _message_ might produce an _Invalid Expression_ error if the
263+
> the function `:function` threw an exception or otherwise emitted an error
264+
> rather than returning a valid value:
265+
>```
266+
> {{This has an invalid expression {$var :function} because it has a bug in it.}}
267+
>```
268+
241269
### Unsupported Statement
242270
243271
An **_<dfn>Unsupported Statement</dfn>_** error occurs when a message includes a _reserved statement_.

spec/formatting.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,8 +236,17 @@ the following steps are taken:
236236
237237
5. If the call succeeds,
238238
resolve the value of the _expression_ as the result of that function call.
239+
239240
If the call fails or does not return a valid value,
240-
emit a _Resolution Error_ and use a _fallback value_ for the _expression_.
241+
emit a _Invalid Expression_ error.
242+
243+
Implementations MAY provide a mechanism for the _function_ to provide
244+
additional detail about internal failures.
245+
Specifically, if the cause of the failure was that the datatype, value, or format of the
246+
_operand_ did not match that expected by the _function_,
247+
the _function_ might cause an _Operand Mismatch Error_ to be emitted.
248+
249+
In all failure cases, use the _fallback value_ for the _expression_ as the resolved value.
241250
242251
#### Option Resolution
243252

0 commit comments

Comments
 (0)