Quotation does not detect ambiguity
Nobody has claimed this yet.
- Dominant language
- Lean
- Stars
- 9.2k
- Forks
- 990
- Avg merge
- 1d 17h
- Merged PRs (30d)
- 175
Description
Prerequisites
Please put an X between the brackets as you perform the following steps:
- Check that your issue is not already filed:
https://github.com/leanprover/lean4/issues - Reduce the issue to a minimal, self-contained, reproducible test case.
Avoid dependencies to Mathlib or Batteries. - Test your test case against the latest nightly release, for example on
https://live.lean-lang.org/#project=lean-nightly
(You can also use the settings there to switch to “Lean nightly”)
Description
In the following example, the expr syntax category has two rules, which create an ambiguity: an ident can be directly an expression, or a nullary application. Ideally, this should trigger a warning or an error, but it doesn't, and, although just by looking at the source code, it looks like all the cases of the parse tree are handled, the expression f x reaches the catchall case.
import Lean
open Lean Meta Elab
open Lean.Elab.Command (liftTermElabM)
declare_syntax_cat expr
syntax "#demo " expr : command
syntax:60 ident expr:61* : expr
syntax:90 ident : expr
partial def elab_expr : Lean.TSyntax `expr → CoreM Unit
| `(expr| $_:ident) => return ()
| `(expr| $_:ident $args:expr*) => do
for arg in args do
elab_expr arg
| s => throwErrorAt s m!"{repr s}"
elab_rules : command
| `(command| #demo $expr) => liftTermElabM <| elab_expr expr
#demo f x
Context
See the zulip thread where this issue was first reported.
Versions
Tested on Lean 4.12.0 on a NixOS/nixpkgs unstable computer, and on Lean nightly on live.lean-lang.org.
Impact
Add 👍 to issues you consider important. If others are impacted by this issue, please ask them to add 👍 to it.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the minimal Lean example in the issue and reproduce it against Lean 4.12.0 or the nightly release on live.lean-lang.org. Read the syntax-category rules, parser priority behavior, and the elaboration patterns shown; done means the ambiguity is reported and the demonstrated parse no longer reaches the catchall case.
Written by the indexing model from the issue text.
Assessment
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100