Zulip Chat Archive

Stream: lean4

Topic: Unexpected difference between charLit and strLit parsers


François G. Dorais (Mar 10 2024 at 21:34):

Consider this mwe:

open Lean Parser

macro "strTest" s:strLit : term => if s.getString = "T" then `(true) else `(false)

macro "testChar" c:charLit : term => if c.getChar = 'T' then `(true) else `(false)

The first works because the strLit parser returns TSyntax `str but the charLit parser returns TSyntax `Lean.Parser.charLit instead of TSyntax `char.

Is there a reason for this difference?

Kyle Miller (Mar 10 2024 at 21:47):

It looks like strLit is special cased in docs#Lean.Elab.Command.expandMacroArg.mkAntiquotNode and charLit isn't

François G. Dorais (Mar 10 2024 at 21:53):

Thanks! I was having a really had a hard time figuring out where that was from!

I'm not sure that's a bug but I'll submit a report anyway...


Last updated: May 02 2025 at 03:31 UTC