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

array of struct - no type hint available for Assignment #659

Closed
rarris opened this issue Nov 21, 2022 · 3 comments · Fixed by #663 or #684
Closed

array of struct - no type hint available for Assignment #659

rarris opened this issue Nov 21, 2022 · 3 comments · Fixed by #663 or #684
Assignees
Labels
bug Something isn't working

Comments

@rarris
Copy link
Contributor

rarris commented Nov 21, 2022

PROGRAM mainProg
VAR
END_VAR

VAR CONSTANT
offset_check : INT := 1;
slots_nr : INT := 7;

config : ARRAY[offset_check..slots_nr] OF struct1 :=
(var1:=1, var2:=2, var3:=5),
(var1:=1, var2:=2, var3:=5),
(var1:=1, var2:=2, var3:=5),
(var1:=1, var2:=2, var3:=5),
(var1:=1, var2:=2, var3:=5),
(var1:=1, var2:=2, var3:=5),
(var1:=1, var2:=2, var3:=5, channel:=10(global_const));
END_VAR
;
END_PROGRAM
TYPE struct1 :
STRUCT
	var1				: DINT;
	var2			: DINT;
	var3				: DINT;
	channel		: ARRAY[1..16] OF DINT; 
END_STRUCT
END_TYPE
VAR_GLOBAL CONSTANT
global_const : DWORD;
END_VAR

error: Cannot generate literal initializer for 'mainProg.config': Value cannot be derived
Error: SyntaxError { message: "Some initial values were not generated", range: [SourceRange { range: 0..0 }], err_no: codegen__general }

@rarris rarris added the bug Something isn't working label Nov 21, 2022
@99NIMI 99NIMI self-assigned this Nov 23, 2022
99NIMI added a commit that referenced this issue Nov 24, 2022
@99NIMI 99NIMI linked a pull request Nov 24, 2022 that will close this issue
99NIMI added a commit that referenced this issue Nov 28, 2022
99NIMI added a commit that referenced this issue Nov 29, 2022
…ion-problem

#659 array of struct initialization
@rarris
Copy link
Contributor Author

rarris commented Nov 30, 2022

the error "Some initial values were not generated" was fixed, but now we have another error

Error: SyntaxError { message: "no type hint available for Assignment {\n
left: Reference {\n   name: \"var1\",\n    },\n
right: LiteralInteger {\n        value: 1,\n    },\n}"

same code example

@rarris rarris reopened this Nov 30, 2022
@rarris rarris changed the title array of struct initialization problem array of struct - no type hint available for Assignment Nov 30, 2022
@99NIMI
Copy link
Member

99NIMI commented Nov 30, 2022

the error "Some initial values were not generated" was fixed, but now we have another error

Error: SyntaxError { message: "no type hint available for Assignment {\n
left: Reference {\n   name: \"var1\",\n    },\n
right: LiteralInteger {\n        value: 1,\n    },\n}"

same code example

there was one little issue in the code example above, the ARRAY was defined with type of INT, should be struct1
now the code should be correct
i didn't get any issue trying to compile this example
the IR also seems correct to me

@rarris
Copy link
Contributor Author

rarris commented Dec 1, 2022

yes true ... my bad :)
but the issue is still reproducible - i've updated the code in the first post
if we write instead of global_const anything else, a dummy non declared var or so, we got the same error, no validation there

@99NIMI 99NIMI linked a pull request Dec 6, 2022 that will close this issue
@ghaith ghaith moved this to Done in Next Jan 9, 2023
@ghaith ghaith added this to Next Jan 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
No open projects
Status: Done
2 participants