diff --git a/sjsonnet/src/sjsonnet/Parser.scala b/sjsonnet/src/sjsonnet/Parser.scala index 7d75e255..3d549569 100644 --- a/sjsonnet/src/sjsonnet/Parser.scala +++ b/sjsonnet/src/sjsonnet/Parser.scala @@ -358,7 +358,7 @@ class Parser(val currentFile: Path) { Expr.ObjBody.ObjComp(pos, preLocals.toArray, lhs, rhs, plus, 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 50b2a70a..40100ea0 100644 --- a/sjsonnet/test/src/sjsonnet/EvaluatorTests.scala +++ b/sjsonnet/test/src/sjsonnet/EvaluatorTests.scala @@ -357,6 +357,12 @@ object EvaluatorTests extends TestSuite{ 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)) + } + } test("errorNonString") { assert(evalErr("""error {a: "b"}""").contains("""{"a": "b"}"""))