Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Bad error message for Optional[list[str] | str] #1953

Closed
@rebcabin

Description

@rebcabin

repro:

# from typing import Optional # uncomment for CPython; comment for LPython

NEWLINE      : str       = "\n"
WHITESPACE   : list[str] = [" ", ",", NEWLINE, "\r", "\t"]


def match(pat : str, string : str) -> Optional[list[str] | str]:
    return None

produces:

└─(06:39:53 on brian-lasr ✹ ✭)──> ~/CLionProjects/lpython/src/bin/lpython -I. lasr_lexer_optional_list.py                                             2 ↵ ──(Mon,Jun19)─┘
semantic error: Variable 'list' not declared
 --> lasr_lexer_optional_list.py:7:48
  |
7 | def match(pat : str, string : str) -> Optional[list[str] | str]:
  |                                                ^^^^ 

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions