-
Notifications
You must be signed in to change notification settings - Fork 56
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
un-initialized constants report unresolved constant variable
while they should get their default value
#634
Comments
cmd1 & var2 need an initial value - the compiler message is really bad. We should improve the error message for this situation. Or do you think this code should work like this? the constants never get a value - or should they get default values? |
by the way - there is a typo I fixed so be careful when you test this again: I changed so the code would work like this: FUNCTION main : DINT
VAR CONSTANT
cmd1 : commands;
var2 : INT;
END_VAR
END_FUNCTION
TYPE commands :
STRUCT
ReInit : BOOL;
Reset : BOOL;
Stop : BOOL;
END_STRUCT
END_TYPE |
unresolved constant variable
Uninitialized constants should also get the default value. I've seen code that defines an uninitialized |
unresolved constant variable
unresolved constant variable
while they should get their default value
constants with no initializers used to cause validation errors, from this commit on they get thei'r datatypes default value. note that alias and range-types will inherit their default from their referenced types. fixes #634
* uninitialized consts fall back to default value constants with no initializers used to cause validation errors, from this commit on they get their datatypes default value. note that alias and range-types will inherit their default from their referenced types. added several test-szenarios * test that shows the transitivity for range types * test that covers enum default const evaluationF fixes #634
This is still not solved, the code in the example still fails on codegen (Struct init does not get an initial value) |
aggregate local constant variables (in functions) used to have problems if they were not properly initialized. Instead of forcing an initializer, we fallback to the type's default value or zeroinitializer. added regression test for a previously failing situation fixes #634
aggregate local constant variables (in functions) used to have problems if they were not properly initialized. Instead of forcing an initializer, we fallback to the type's default value or zeroinitializer. added regression test for a previously failing situation fixes #634
program example
error: Unresolved constant 'cmd1' variable
┌─ test.st:19:6
│
19 │ cmd1 : command;
│ ^^^^^
error: Unresolved constant 'var2' variable
┌─ test.st:20:6
│
20 │ var2 : int;
│ ^^^^^
The text was updated successfully, but these errors were encountered: