Skip to content

Bogus error message from Pattern[str] #1945

@rebcabin

Description

@rebcabin

repro : https://github.com/rebcabin/lpython/tree/brian-lasr/lasr/lpython/Issue1945

The following works in ordinary CPython (after uncommenting the compatibility block at the top of the file)

hex_pat : Pattern[str] = fr'-?0[xX]{hexit}+'
oct_pat : Pattern[str] = fr'-?0{octit}+'
int_pat : Pattern[str] = fr'-?{digit}+'
dec_pat : Pattern[str] = fr'(-?{digit})M'
# Not kosher Clojure
sym_pat : Pattern[str] = fr'({alpha}{asr_alpha_mer}*)'

LPython produces the following misleading error message:

└─(15:13:05 on brian-lasr ✭)──> ~/CLionProjects/lpython/src/bin/lpython -I. lasr_lexer.py && ./lasr_lexer.out                                             ──(Sun,Jun18)─┘
semantic error: Variable 'str' not declared
   --> lasr_lexer.py:159:19
    |
159 | hex_pat : Pattern[str] = fr'-?0[xX]{hexit}+'
    |                   ^^^ 

The error message does not lead me to a fix.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions