Skip to content

Add validation for initializers #870

Open
@mhasel

Description

@mhasel

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

Metadata

Metadata

Assignees

Labels

validationcandidate for syntactic or semantic validation

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions