Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix with precedence #299

Open
travisbrown opened this issue Jul 28, 2021 · 0 comments
Open

Fix with precedence #299

travisbrown opened this issue Jul 28, 2021 · 0 comments

Comments

@travisbrown
Copy link
Owner

The parser currently accepts some inputs it shouldn't:

scala> org.dhallj.parser.DhallParser.parse("foo { x = 0 } with x = 1")
val res0: org.dhallj.core.Expr.Parsed = (foo {x = 0}) with x = 1

scala> org.dhallj.parser.DhallParser.parse("{ x = 0 } with x = 1 : T")
val res1: org.dhallj.core.Expr.Parsed = ({x = 0} with x = 1) : T

Both of these should be parsing failures, but our handling of the precedence of with is currently somewhat awkward, and while I don't think it would be excessively hard to fix these cases, it's not trivial, and it would be much easier if we move to this approach, so I haven't done it yet.

Note that we're currently ignoring the WithPrecedence2 and WithPrecedence3 tests, which catch this bug.

In any case this bug should not affect most users, and it's unlikely to cause problems. As you can see in the printed code above, even when the parser does accept code it shouldn't, the parses it comes up with aren't unreasonable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant