Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The duplicate enum check returns false-positives #1156

Closed
volsa opened this issue Mar 14, 2024 · 0 comments · Fixed by #1175
Closed

The duplicate enum check returns false-positives #1156

volsa opened this issue Mar 14, 2024 · 0 comments · Fixed by #1175
Labels
bug Something isn't working high-priority validation candidate for syntactic or semantic validation

Comments

@volsa
Copy link
Member

volsa commented Mar 14, 2024

Describe the bug
These false-positives slipped in with commit e2e8fb3, take for example

TYPE
    State : (idle, running);
END_TYPE


FUNCTION main : DINT
    VAR
        stateA : State;
        stateB : State;
    END_VAR
END_FUNCTION

will report

error[E004]: State.idle: Duplicate symbol.
  ┌─ target/demo.st:2:14
  │
2 │     State : (idle, running);
  │              ^^^^ State.idle: Duplicate symbol.

error[E004]: State.idle: Duplicate symbol.
  ┌─ target/demo.st:2:14
  │
2 │     State : (idle, running);
  │              ^^^^ State.idle: Duplicate symbol.

error[E004]: State.running: Duplicate symbol.
  ┌─ target/demo.st:2:20
  │
2 │     State : (idle, running);
  │                    ^^^^^^^ State.running: Duplicate symbol.

error[E004]: State.running: Duplicate symbol.
  ┌─ target/demo.st:2:20
  │
2 │     State : (idle, running);
  │                    ^^^^^^^ State.running: Duplicate symbol.

which happens because get_enum_variants_in_pou will be called twice in the given example for the State enum, which should only happen once

Expected behavior
No duplicate error

Additional context
Will be much easier to implement once we refactor how enums are stored in the index

@volsa volsa added bug Something isn't working validation candidate for syntactic or semantic validation high-priority labels Mar 14, 2024
@volsa volsa linked a pull request Mar 26, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working high-priority validation candidate for syntactic or semantic validation
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant