coalesce operators '??' and '?=' now accepts function definitions too

This commit is contained in:
2024-04-20 09:40:07 +02:00
parent 6ae5ca34ed
commit d1122da566
2 changed files with 11 additions and 11 deletions
+1 -1
View File
@@ -134,7 +134,7 @@ func TestParser(t *testing.T) {
/* 113 */ {`import("test-funcs.expr"); (double(3+a) + 1) * two()`, int64(34), nil},
/* 114 */ {`x ?? "default"`, "default", nil},
/* 115 */ {`x="hello"; x ?? "default"`, "hello", nil},
/* 116 */ {`x ?? func(){}`, nil, errors.New(`[1:14] the right operand of a coalescing operation cannot be a function definition`)},
/* 116 */ {`y=x ?? func(){4}; y()`, int64(4), nil},
/* 117 */ {`x ?= "default"; x`, "default", nil},
/* 118 */ {`x="hello"; x ?= "default"; x`, "hello", nil},
/* 119 */ {`@x="hello"; @x`, nil, errors.New(`[1:3] variable references are not allowed in top level expressions: "@x"`)},