rusty icon indicating copy to clipboard operation
rusty copied to clipboard

Panic on enum syntax error

Open volsa opened this issue 3 months ago • 2 comments

The compiler panics, when using an equal (=) instead of an assignment (:=) operator in an enum type definition. For example

TYPE State:
(
    Idle := 0,
    Running = 1, // This should be :=
);
END_TYPE

will panic in the pre-processor with the following message

thread 'main' panicked at compiler/plc_ast/src/pre_processor.rs:81:61:
expected assignment
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace                 

We should catch these as part of a syntax error in the parser.

volsa avatar Oct 07 '25 10:10 volsa

can i check this out?

BipulLamsal avatar Oct 07 '25 18:10 BipulLamsal

sure. I think the issue is somewhere here:

https://github.com/PLC-lang/rusty/blob/51efb1efb29147337bc29465f8761b9fdf053c87/src/parser.rs#L1157-L1176

Line 1164 allows a coma separated list of any expression. I think it should only expect a coma separated list of Identifiers and/or Assignments.

riederm avatar Oct 07 '25 18:10 riederm