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 in ARRAY initialization error #932

Closed
rarris opened this issue Aug 10, 2023 · 3 comments
Closed

ARRAY in ARRAY initialization error #932

rarris opened this issue Aug 10, 2023 · 3 comments
Labels
bug Something isn't working

Comments

@rarris
Copy link
Contributor

rarris commented Aug 10, 2023

PROGRAM mainProg
VAR
END_VAR
;
END_PROGRAM
TYPE STRUCT1 :
 STRUCT
  Node : ARRAY[0..15] OF 
   STRUCT2 := 
   [
   (
    var1_struct2 := 'text',
    enum_struct2 := enum_var1,
    arr_struct2 := 
    (
     var1 := 'Type',
     var2 := 3,
     var3 := 2
    )
   )
   ]
  ;
 END_STRUCT
END_TYPE
TYPE STRUCT2 :
	 	STRUCT
		var1_struct2 : STRING[31];
		enum_struct2 : ENUM1;
		var3_struct2 : UINT;
		arr_struct2 : ARRAY[0..19] OF STRUCT3;
	END_STRUCT
END_TYPE
TYPE ENUM1 :
		( 
		enum_var1,
		enum_var2,
		enum_var3,
		enum_var4 
	);
END_TYPE

err:
thread 'main' panicked at 'called Result::unwrap() on an Err value: CombinedDiagnostic { message: "Some initial values were not generated", inner_diagnostics: [SyntaxError { message: "Cannot generate literal initializer for 'STRUCT1.Node': Value cannot be derived", range: [SourceRange { range: 79..349, file: Some("...\src\STRUCT1.dt") }, SourceRange { range: 5..12, file: Some("...\src\STRUCT1.dt") }], err_no: codegen__general }], err_no: codegen__general }', compiler\plc_driver./src/main.rs:7:32
note: run with RUST_BACKTRACE=1 environment variable to display a backtrace

@rarris rarris added the bug Something isn't working label Aug 10, 2023
@volsa
Copy link
Member

volsa commented Aug 10, 2023

This looks somewhat similar to #707, let's re-check if solving it also solves this issue.

@volsa
Copy link
Member

volsa commented Aug 22, 2023

This will be fixed with #938 although validations seem to be missing to get a clear answer why the codegen failed here. Specifically this assignment arr_struct2 := (var1 := 'Type', var2 := 3, var3 := 2) has to start with a leading [ symbol, i.e. arr_struct2 := [(var1 := 'Type', var2 := 3, var3 := 2)]. Can you re-check this just to be sure @rarris ?

Edit: Validation doesn't happen because we never enter here

if let Some(v_entry) = context

Edit^2: Looks like we're already tracking non-existing validation of initializers here #870

@volsa
Copy link
Member

volsa commented Nov 21, 2023

I'm closing this in favor of #870 as the codegen issue seems to be fixed

@volsa volsa closed this as completed Nov 21, 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
None yet
Development

No branches or pull requests

2 participants