From ffa685e3a3c1bbc876765a8425b6393b82b921ef Mon Sep 17 00:00:00 2001 From: Li Haoyi Date: Tue, 30 May 2023 14:14:16 -0700 Subject: [PATCH] . --- sjsonnet/src/sjsonnet/Parser.scala | 2 +- sjsonnet/test/src/sjsonnet/EvaluatorTests.scala | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/sjsonnet/src/sjsonnet/Parser.scala b/sjsonnet/src/sjsonnet/Parser.scala index 9fc8933d..cf366b69 100644 --- a/sjsonnet/src/sjsonnet/Parser.scala +++ b/sjsonnet/src/sjsonnet/Parser.scala @@ -353,7 +353,7 @@ class Parser(val currentFile: Path) { Expr.ObjBody.ObjComp(pos, preLocals.toArray, lhs, rhs, postLocals.toArray, comps._1, comps._2.toList) } - def member[_: P]: P[Expr.Member] = P( objlocal | "assert" ~~ assertStmt | field ) + def member[_: P]: P[Expr.Member] = P( objlocal | "assert" ~~ break ~ assertStmt | field ) def field[_: P] = P( (Pos ~~ fieldname ~/ "+".!.? ~ ("(" ~ params ~ ")").? ~ fieldKeySep ~/ expr).map{ case (pos, name, plus, p, h2, e) => diff --git a/sjsonnet/test/src/sjsonnet/EvaluatorTests.scala b/sjsonnet/test/src/sjsonnet/EvaluatorTests.scala index 77bdeb32..bd088a82 100644 --- a/sjsonnet/test/src/sjsonnet/EvaluatorTests.scala +++ b/sjsonnet/test/src/sjsonnet/EvaluatorTests.scala @@ -355,5 +355,11 @@ object EvaluatorTests extends TestSuite{ eval("""local f(x)=null; f == null""") ==> ujson.False eval("""local f=null; f == null""") ==> ujson.True } + test("identifierStartsWithKeyword") { + for(keyword <- Parser.keywords){ + eval(s"""local ${keyword}Foo = 123; ${keyword}Foo""") ==> ujson.Num(123) + eval(s"""{${keyword}Foo: 123}""") ==> ujson.Obj(s"${keyword}Foo" -> ujson.Num(123)) + } + } } }