From 3eb48560e4d1e3217bf508b0006c82ec977496eb Mon Sep 17 00:00:00 2001 From: Laurence Morgan Date: Sun, 8 Oct 2023 23:07:35 +0100 Subject: [PATCH] improved $1 (et al) error message plus updated rosetta stone --- docs/parser/null-coalescing.md | 12 +++++------- docs/user-guide/rosetta-stone.md | 2 +- gen/parser/null_coalescing_op_doc.yaml | 12 +++++------- gen/user-guide/rosetta-stone.inc.md | 2 +- lang/variables.go | 2 +- 5 files changed, 13 insertions(+), 17 deletions(-) diff --git a/docs/parser/null-coalescing.md b/docs/parser/null-coalescing.md index 52d1e88ca..1032a60a2 100644 --- a/docs/parser/null-coalescing.md +++ b/docs/parser/null-coalescing.md @@ -41,13 +41,11 @@ The following extract was taken from [Wikipedia](https://en.wikipedia.org/wiki/N > The null coalescing operator (called the Logical Defined-Or operator in Perl) > is a binary operator that is part of the syntax for a basic conditional -> expression in several programming languages, including C#, PowerShell as of -> version 7.0.0, Perl as of version 5.10, Swift, and PHP 7.0.0. While its -> behavior differs between implementations, the null coalescing operator -> generally returns the result of its left-most operand if it exists and is not -> null, and otherwise returns the right-most operand. This behavior allows a -> default value to be defined for cases where a more specific value is not -> available. +> expression in several programming languages. While its behavior differs +> between implementations, the null coalescing operator generally returns the +> result of its left-most operand if it exists and is not null, and otherwise +> returns the right-most operand. This behavior allows a default value to be +> defined for cases where a more specific value is not available. > > In contrast to the ternary conditional if operator used as `x ? x : y`, but > like the binary Elvis operator used as `x ?: y`, the null coalescing operator diff --git a/docs/user-guide/rosetta-stone.md b/docs/user-guide/rosetta-stone.md index fe8504952..39a1fe9bc 100644 --- a/docs/user-guide/rosetta-stone.md +++ b/docs/user-guide/rosetta-stone.md @@ -92,7 +92,7 @@ if you want to learn more about shell scripting in Murex. | [Assign a local variable](../commands/set.md) | `local foo="bar"` | `$foo = "bar"` [[2]](#footnotes) [[6]](#footnotes)

`out "bar" \| set $foo` | | [Assign a global variable](../commands/global.md) | `foo="bar"` | `$GLOBAL.foo = "bar"` [[6]](#footnotes)

`out "bar" \| global $foo` | | [Assign an environmental variable](../commands/export.md) | `export foo="bar"` | `export foo = "bar"` [[1]](#footnotes) [[2]](#footnotes) [[3]](#footnotes)

`$ENV.foo = "bar"` [[6]](#footnotes)

`out "bar" \| export $foo` [[3]](#footnotes) | -| [Assign with a default value](../parser/null-coalescing.md) | `FOOBAR="${VARIABLE:-default}"` | `$foobar = $variable ?: "default"`

(the elvis operator can be used in any part of expressions and just for assignments) +| [Assign with a default value](../parser/null-coalescing.md) | `FOOBAR="${VARIABLE:-default}"` | `$foobar = $variable ?? "default"` | ### Arrays (eg arrays, lists) diff --git a/gen/parser/null_coalescing_op_doc.yaml b/gen/parser/null_coalescing_op_doc.yaml index 70c98bb05..0c487f27a 100644 --- a/gen/parser/null_coalescing_op_doc.yaml +++ b/gen/parser/null_coalescing_op_doc.yaml @@ -36,13 +36,11 @@ > The null coalescing operator (called the Logical Defined-Or operator in Perl) > is a binary operator that is part of the syntax for a basic conditional - > expression in several programming languages, including C#, PowerShell as of - > version 7.0.0, Perl as of version 5.10, Swift, and PHP 7.0.0. While its - > behavior differs between implementations, the null coalescing operator - > generally returns the result of its left-most operand if it exists and is not - > null, and otherwise returns the right-most operand. This behavior allows a - > default value to be defined for cases where a more specific value is not - > available. + > expression in several programming languages. While its behavior differs + > between implementations, the null coalescing operator generally returns the + > result of its left-most operand if it exists and is not null, and otherwise + > returns the right-most operand. This behavior allows a default value to be + > defined for cases where a more specific value is not available. > > In contrast to the ternary conditional if operator used as `x ? x : y`, but > like the binary Elvis operator used as `x ?: y`, the null coalescing operator diff --git a/gen/user-guide/rosetta-stone.inc.md b/gen/user-guide/rosetta-stone.inc.md index 291d1b2ab..b1c47cfbd 100644 --- a/gen/user-guide/rosetta-stone.inc.md +++ b/gen/user-guide/rosetta-stone.inc.md @@ -88,7 +88,7 @@ if you want to learn more about shell scripting in Murex. | [Assign a local variable](../commands/set.md) | `local foo="bar"` | `$foo = "bar"` [[2]](#footnotes) [[6]](#footnotes)

`out "bar" \| set $foo` | | [Assign a global variable](../commands/global.md) | `foo="bar"` | `$GLOBAL.foo = "bar"` [[6]](#footnotes)

`out "bar" \| global $foo` | | [Assign an environmental variable](../commands/export.md) | `export foo="bar"` | `export foo = "bar"` [[1]](#footnotes) [[2]](#footnotes) [[3]](#footnotes)

`$ENV.foo = "bar"` [[6]](#footnotes)

`out "bar" \| export $foo` [[3]](#footnotes) | -| [Assign with a default value](../parser/null-coalescing.md) | `FOOBAR="${VARIABLE:-default}"` | `$foobar = $variable ?: "default"`

(the elvis operator can be used in any part of expressions and just for assignments) +| [Assign with a default value](../parser/null-coalescing.md) | `FOOBAR="${VARIABLE:-default}"` | `$foobar = $variable ?? "default"` | ### Arrays (eg arrays, lists) diff --git a/lang/variables.go b/lang/variables.go index 182a38439..fb1e53530 100644 --- a/lang/variables.go +++ b/lang/variables.go @@ -36,7 +36,7 @@ func errVarCannotUpdateIndexOrElement(name string) error { } func errVarNoParam(i int, err error) error { - return fmt.Errorf("variable '%d' cannot be defined: %s", i, err.Error()) + return fmt.Errorf("variable '%d' is not set because the scope returned the following error when querying parameter %d: %s", i, i, err.Error()) } func errVarZeroLengthPath(name string) error {