effekt icon indicating copy to clipboard operation
effekt copied to clipboard

Unexpected parsing behavior with semicolons

Open marvinborner opened this issue 4 months ago • 2 comments

We have observed in #1074 that the parsed tree changes (modulo spans) depending on semicolons, which should not happen in these cases.

The cases giving different trees on parseProgram:

namespace list;
namespace internal;

val x = 4
val y = 5

vs.

namespace list
namespace internal

val x = 4
val y = 5

vs.

namespace list
namespace internal

val x = 4
val y = 5;

which can be reproduced by (progA.defs zip progB.defs).foreach(assertEqualModuloSpans)

marvinborner avatar Aug 11 '25 17:08 marvinborner

@phischu is right to question why there should be a semicolon on the toplevel at all. Does anybody see a single valid use case?

b-studios avatar Aug 11 '25 20:08 b-studios

Consistency: When I have definitions in a block (so not top-level), I can, and sometimes must add a semicolon, see https://github.com/effekt-lang/effekt/issues/1064#issuecomment-3023359028. So then I find myself writing things like val x = 4; with a semicolon reflexively even on the top-level.

Image

#595 is, in my eyes, somewhat related to this.

jiribenes avatar Aug 11 '25 21:08 jiribenes