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

Parse error: Infinite loop #134

Closed GreasySlug closed 2 years ago

GreasySlug commented 2 years ago

Describe the bug

I am currently working on #29 and implementing the exec() in parse.rs.

Unintended errors occur when running the parser with REPL and file input.

REPL will cause an infinite loop.

I checked and found that cfg::Input changed from REPL to Str in this assignment.

https://github.com/erg-lang/erg/blob/9783813ae08d872c6e2932f37bf74a41932f6ceb/compiler/erg_parser/parse.rs#L201-L206

It is not caused by the code I am implementing, but it processes strangely.

The instance in the trait.rs is converted from PEPL to Pipe at the following location

A file input(example/add.er or else) will result in an error with a trailing : inserted

Reproducible code

>>> a = 1

Infinite loop occurs.

OS Windows 10

mtshiba commented 2 years ago
self.cfg.input = Input::File(self.input().read());

This code is not correct. The input of Input::File is a file path. input.read() returns source code.

mtshiba commented 2 years ago
GreasySlug commented 2 years ago

I made a mistake in assigning the source code where I should have assigned the path.