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

Add validation for initializers #870

Open
mhasel opened this issue Jun 5, 2023 · 0 comments
Open

Add validation for initializers #870

mhasel opened this issue Jun 5, 2023 · 0 comments
Assignees
Labels
validation candidate for syntactic or semantic validation

Comments

@mhasel
Copy link
Member

mhasel commented Jun 5, 2023

Currently there is no validation in place for variables being initialized in variable blocks. Trying to initialize a variable with an invalid type will fail during codegen, but not be reported beforehand.
e.g.:

VAR_GLOBAL
      a : (red, yellow, green) := (1, 2, 3);
      b : INT := 'wrong type';
      c : STRING := 10(1000);
      d : ARRAY[0..1] OF WSTRING := 1000;
END_VAR

FUNCTION main : DINT
    VAR
        a : (red, yellow, green) := (1, 2, 3);
        b : INT := 'wrong type';
        c : STRING := 10(1000);
        d : ARRAY[0..1] OF WSTRING := 1000;
    END_VAR
END_FUNCTION
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
validation candidate for syntactic or semantic validation
Projects
None yet
Development

No branches or pull requests

2 participants