lean4 icon indicating copy to clipboard operation
lean4 copied to clipboard

Unexpected and unnecessary grouping when referring to parsers directly

Open gebner opened this issue 3 years ago • 3 comments
trafficstars

Prerequisites

  • [x] Put an X between the brackets on this line if you have done all of the following:
    • Checked that your issue isn't already filed.
    • Reduced the issue to a self-contained, reproducible test case.

Description

import Lean
open Lean Elab Command

open Parser

elab "hmmm" arg:(ppSpace ident)+ : command =>
  -- arg has type `Option (TSyntax Name.anonymous)`
  logInfo (toString arg)

hmmm xyz

This prints #[(group `xyz)] when the Parser namespace is open. If you comment out the open Parser, then it prints #[`xyz].

I would expect it to always print #[`xyz].

Versions

Nightly from June 30.

gebner avatar Jun 30 '22 12:06 gebner

Hmm yes, this is https://github.com/leanprover/lean4/pull/1229#discussion_r900885634 :( . The best workaround I see is to make sure we always default to the alias.

Kha avatar Jun 30 '22 13:06 Kha

The best workaround I see is to make sure we always default to the alias.

@gebner What do you think? Is that satisfactory until we improve Parser?

Kha avatar Jul 05 '22 07:07 Kha

So resolve to the alias first, and only look it up as a declaration if that fails? That seems good to me.

gebner avatar Jul 05 '22 08:07 gebner