From 5f1d11fd15be9b4da65aa7bb9e19848906deb4ac Mon Sep 17 00:00:00 2001 From: Addison Phillips Date: Wed, 7 Feb 2024 13:40:57 -0800 Subject: [PATCH 1/3] Address #629: create invalid expression error --- spec/errors.md | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/spec/errors.md b/spec/errors.md index 5e49c1cd38..d78218d20e 100644 --- a/spec/errors.md +++ b/spec/errors.md @@ -238,6 +238,33 @@ 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. + +A **_Type 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 _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_. From ce4a5fe9c3767631b6e07cc7adb157f1d442fa08 Mon Sep 17 00:00:00 2001 From: Addison Phillips Date: Wed, 7 Feb 2024 15:19:28 -0800 Subject: [PATCH 2/3] Update formatting.md --- spec/formatting.md | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/spec/formatting.md b/spec/formatting.md index dd71c96a0f..62a385c230 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 a _Type Mismatch Error_ to be emitted. + + In all failure cases, use the _fallback value_ for the _expression_ as the resolved value. #### Option Resolution From ed13b3ec32d26c17a63b73d03aa3a8b8dbc1320a Mon Sep 17 00:00:00 2001 From: Addison Phillips Date: Mon, 12 Feb 2024 11:18:09 -0800 Subject: [PATCH 3/3] Change `type` to `operand` As discussed in 2024-02-12 teleconference --- spec/errors.md | 5 +++-- spec/formatting.md | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/spec/errors.md b/spec/errors.md index d78218d20e..71f72ec3fd 100644 --- a/spec/errors.md +++ b/spec/errors.md @@ -244,14 +244,15 @@ An **_Invalid Expression_** error occurs when a _message_ includes an 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. -A **_Type Mismatch Error_** is an _Invalid Expression_ error that occurs when +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 _Invalid Expression_ error +> 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: > ``` diff --git a/spec/formatting.md b/spec/formatting.md index 62a385c230..2379301cbb 100644 --- a/spec/formatting.md +++ b/spec/formatting.md @@ -245,7 +245,7 @@ the following steps are taken: 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 a _Type Mismatch Error_ to be emitted. + 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.