-
Notifications
You must be signed in to change notification settings - Fork 172
Open
Labels
ParserIssues or improvements related to parserIssues or improvements related to parser
Description
These are curious cases that LPython parses but CPython does not. These are artificial cases, but if we want to be 100% strict with regards to #1139, we should not allow it either, so that if things compile with LPython, they also work with CPython.
def f():
i: i32
a: i32 = 5; for i in range(10): print(i)
f()Which gives:
$ lpython --show-ast a.py
(Module [(FunctionDef f ([] [] [] [] [] [] []) [(AnnAssign (Name i Store) (Name i32 Load) () 1) (AnnAssign (Name a Store) (Name i32 Load) (ConstantInt 5 ()) 1) (For (Name i Store) (Call (Name range Load) [(ConstantInt 10 ())] []) [(Expr (Call (Name print Load) [(Name i Load)] []))] [] ())] [] () ()) (Expr (Call (Name f Load) [] []))] [])
$ python a.py
File "/Users/ondrej/repos/lpython/a.py", line 3
a: i32 = 5; for i in range(10): print(i)
^^^
SyntaxError: invalid syntaxThirumalai-Shaktivel
Metadata
Metadata
Assignees
Labels
ParserIssues or improvements related to parserIssues or improvements related to parser