erg-lang / erg

A statically typed language compatible with Python
http://erg-lang.org
Apache License 2.0
2.69k stars 55 forks source link

Declaration of invalid collections #305

Open GreasySlug opened 1 year ago

GreasySlug commented 1 year ago

Describe the bug?

The following collections allow elements to be declared by using whitespace Different error occurs instead of error due to delimitation

But these are syntax error

Reproducible code

[1 2 3] (1 2 3) {"a": 1 "b": 2 "c": 3} {1 2 3} {name = "John" age = 21}

Expected result

syntax error needs comma or semicolon

Actual result

Error[#0000]: File <stdin>, line 1, 

1 | [1 2 3]
  :       -

SyntaxError: invalid syntax

>>> (1 2 3)
Error[#0000]: File <stdin>, line 1, 

1 | (1 2 3)
  :       -

SyntaxError: invalid syntax

>>> {"a": 1 "b": 2}
Error[#3374]: File <stdin>, line 1, 

1 | {"a": 1 "b": 2}
  :              -

SyntaxError: invalid syntax

Error[#0000]: File <stdin>, line 1, 

1 | {"a": 1 "b": 2}
  :               -

SyntaxError: invalid syntax

>>> {name = "John" age = 21}
Record(name='John', age=21)

Additional context

When I look at how it is parsed using cargo dprs, we see that each syntax is parsed differently, and a patch is needed for each of them.

Erg version

Erg 0.6.0-beta.3

Python version

python3.10.8

OS

Windows 10