PLC-lang/rusty

Improve `DataType` `SourceLocation`

Aperta

#1343 aperta il 18 ott 2024

 (0 commenti) (0 reazioni) (0 assegnatari)Rust (71 fork)auto 404
buggood first issuemedium-priorityvalidation

Metriche repository

Star
 (351 stelle)
Metriche merge PR
 (Metriche PR in attesa)

Descrizione

When parsing data-types, we include the initializer in the data-types source locations, leading to confusing error messages when converting the location to a slice:

FUNCTION main: DINT
VAR
    x: REF_TO STRING;
    y: REF_TO DINT := REF(x);
END_VAR
END_FUNCTION

error[E037]: Invalid assignment: cannot assign '__main_x' to 'REF_TO DINT := REF(x)'
  ┌─ target\demo.st:4:23
  │
4 │     y: REF_TO DINT := REF(x);
  │                       ^^^^^^ Invalid assignment: cannot assign '__main_x' to 'REF_TO DINT := REF(x)'

Guida contributor