From 1817c8c0d2f545c02b9f228de7273248bb68a4ff Mon Sep 17 00:00:00 2001 From: Ghaith Hachem Date: Fri, 10 Nov 2023 15:51:43 +0100 Subject: [PATCH 01/33] fix: schema validation now uses binary location (#1011) Schema validation now happens from the current binary location. In tests, it still uses the source location. If no schema is found, validation is skipped. --- .github/workflows/rust.yml | 5 ++++ Cargo.toml | 3 +- book/src/using_rusty/build_configuration.md | 6 ++++ compiler/plc_project/Cargo.toml | 3 ++ compiler/plc_project/src/build_config.rs | 29 ++++++++++++++++++- src/parser/tests/expressions_parser_tests.rs | 5 +++- .../tests/resolve_expressions_tests.rs | 15 +++++++--- 7 files changed, 59 insertions(+), 7 deletions(-) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 9da5b4a9a6..80d18bee7e 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -55,6 +55,11 @@ jobs: name: plc path: target/release/plc + - uses: actions/upload-artifact@master + with: + name: schema + path: compiler/plc_project/schema + - uses: actions/upload-artifact@master with: name: stdlib diff --git a/Cargo.toml b/Cargo.toml index ed2974ca1d..ebaef5a49e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -45,13 +45,14 @@ num = "0.4" insta = "1.31.0" pretty_assertions = "1.3.0" driver = { path = "./compiler/plc_driver/", package = "plc_driver" } -project = { path = "./compiler/plc_project/", package = "plc_project" } +project = { path = "./compiler/plc_project/", package = "plc_project", features = ["integration"]} plc_xml = { path = "./compiler/plc_xml" } serial_test = "*" tempfile = "3" encoding_rs.workspace = true encoding_rs_io.workspace = true + [lib] name = "rusty" path = "src/lib.rs" diff --git a/book/src/using_rusty/build_configuration.md b/book/src/using_rusty/build_configuration.md index 7f1ebba927..c698c99dbd 100644 --- a/book/src/using_rusty/build_configuration.md +++ b/book/src/using_rusty/build_configuration.md @@ -168,3 +168,9 @@ To reference an environment variable in the description file, reference the vari ] } ``` + +## Validation + +The build description file uses a [Json Schema](https://json-schema.org/) file located at `compiler/plc_project/schema/plc-json.schema` to validate the build description before build. +In order for the schema to be used, it has to be either in that location for source builds or copied next to the build binaries. +If the schema is not found, the schema based validation will be skipped. diff --git a/compiler/plc_project/Cargo.toml b/compiler/plc_project/Cargo.toml index ad14786c05..5845fe8fba 100644 --- a/compiler/plc_project/Cargo.toml +++ b/compiler/plc_project/Cargo.toml @@ -19,3 +19,6 @@ glob = "*" [dev-dependencies] insta = "1.31.0" + +[features] +integration = [] diff --git a/compiler/plc_project/src/build_config.rs b/compiler/plc_project/src/build_config.rs index 3f1b469f7d..133325d4f7 100644 --- a/compiler/plc_project/src/build_config.rs +++ b/compiler/plc_project/src/build_config.rs @@ -86,8 +86,35 @@ impl ProjectConfig { Ok(project) } + fn get_schema() -> Result { + let current_exe_dir = + std::env::current_exe()?.parent().map(|it| it.to_path_buf()).unwrap_or_default(); + let schema_dir = current_exe_dir.join("schema"); + #[cfg(feature = "integration")] + //Fallback to the build location + let schema_dir = if !&schema_dir.exists() { + let project_dir: PathBuf = env!("CARGO_MANIFEST_DIR").into(); + project_dir.join("schema") + } else { + schema_dir + }; + let path = schema_dir.join("plc-json.schema"); + if !path.exists() { + Err(Diagnostic::io_read_error(&path.to_string_lossy(), "File not found")) + } else { + Ok(path) + } + } + fn validate(&self) -> Result<(), Diagnostic> { - let schema_path = Path::new(env!("CARGO_MANIFEST_DIR")).join(Path::new("schema/plc-json.schema")); + let schema_path = match Self::get_schema() { + Ok(path) => path, + Err(error) => { + eprintln!("Could not find schema, validation skipped. Original error: {error:?}"); + //Skip validation but do not fail + return Ok(()); + } + }; let schema = fs::read_to_string(schema_path).map_err(Diagnostic::from)?; let schema_obj = serde_json::from_str(&schema).expect("A valid schema"); let compiled = JSONSchema::compile(&schema_obj).expect("A valid schema"); diff --git a/src/parser/tests/expressions_parser_tests.rs b/src/parser/tests/expressions_parser_tests.rs index a2661d71ab..436c847aa2 100644 --- a/src/parser/tests/expressions_parser_tests.rs +++ b/src/parser/tests/expressions_parser_tests.rs @@ -1773,7 +1773,10 @@ fn parenthesized_expression_span() { let src = "PROGRAM prg [(1 + 2)] END_PROGRAM"; let (result, _) = parse(src); - let AstStatement::Literal(AstLiteral::Array(array)) = result.implementations[0].statements[0].get_stmt() else { panic!() }; + let AstStatement::Literal(AstLiteral::Array(array)) = result.implementations[0].statements[0].get_stmt() + else { + panic!() + }; let range = array.elements().unwrap().get_location().get_span().to_range().unwrap(); assert_eq!(&src[range.start..range.end], "(1 + 2)"); } diff --git a/src/resolver/tests/resolve_expressions_tests.rs b/src/resolver/tests/resolve_expressions_tests.rs index 06f7cb9fd1..4507024011 100644 --- a/src/resolver/tests/resolve_expressions_tests.rs +++ b/src/resolver/tests/resolve_expressions_tests.rs @@ -547,13 +547,13 @@ fn parenthesized_expression_assignment() { let (annotations, ..) = TypeAnnotator::visit_unit(&index, &unit, id_provider); let one = &unit.implementations[0].statements[0]; - let AstStatement::Assignment(Assignment {right, ..}) = &one.stmt else { panic!() }; + let AstStatement::Assignment(Assignment { right, .. }) = &one.stmt else { panic!() }; assert!(&right.is_paren()); assert_eq!(annotations.get_type(right, &index).unwrap().name, "DINT"); assert_eq!(annotations.get_type_hint(right, &index).unwrap().name, "DINT"); let two = &unit.implementations[0].statements[1]; - let AstStatement::Assignment(Assignment {right, ..}) = &two.stmt else { panic!() }; + let AstStatement::Assignment(Assignment { right, .. }) = &two.stmt else { panic!() }; assert!(&right.is_paren()); assert_eq!(annotations.get_type(right, &index).unwrap().name, "DINT"); assert_eq!(annotations.get_type_hint(right, &index).unwrap().name, "SINT"); @@ -4071,7 +4071,11 @@ fn array_with_parenthesized_expression() { let AstStatement::Literal(AstLiteral::Array(Array { elements })) = index .get_const_expressions() .maybe_get_constant_statement(&members[0].initial_value) - .map(AstNode::get_stmt).unwrap() else { panic!() }; + .map(AstNode::get_stmt) + .unwrap() + else { + panic!() + }; let AstStatement::ExpressionList(expressions) = elements.as_ref().unwrap().get_stmt() else { panic!() }; @@ -4120,7 +4124,10 @@ fn array_of_struct_with_initial_values_annotated_correctly() { .get_const_expressions() .maybe_get_constant_statement(&members[0].initial_value) .map(|it| it.get_stmt()) - .unwrap() else { panic!() }; + .unwrap() + else { + panic!() + }; let AstStatement::ExpressionList(expressions) = array.elements().unwrap().get_stmt() else { panic!() }; // we initialized the array with 2 structs From 5dac39d5a72a9aea551dd1b10793d63db357d7ea Mon Sep 17 00:00:00 2001 From: Volkan Date: Mon, 13 Nov 2023 12:48:56 +0100 Subject: [PATCH 02/33] feat(validation): Struct initializers within arrays (#996) Previously we accepted `arr := [foo := 0, bar := 1]` where `foo` and `bar` are struct fields. Doing so resulted in weird codegen issues documented in https://github.com/PLC-lang/rusty/issues/965. This commit disallows this behavior and instead forces users to use parentheses when initializing structs within arrays, e.g. `arr := [(foo := 0, bar := 1), (...)]`. --- compiler/plc_ast/src/ast.rs | 2 +- compiler/plc_ast/src/literals.rs | 12 +- compiler/plc_diagnostics/src/diagnostics.rs | 8 + .../generators/expression_generator.rs | 1 + ...ests__additon_of_two_variables_parsed.snap | 141 ------------------ ...ests__resolve_recursive_function_call.snap | 86 ----------- ...tests__resolve_recursive_program_call.snap | 63 -------- ...esolve_return_variable_in_nested_call.snap | 32 ---- src/validation/array.rs | 47 ++++-- src/validation/tests/array_validation_test.rs | 23 +++ .../tests/reference_resolve_tests.rs | 4 +- ...st__parenthesized_struct_initializers.snap | 53 +++++++ ...ble_source_to_variable_and_block_sink.snap | 50 ------- 13 files changed, 132 insertions(+), 390 deletions(-) delete mode 100644 src/parser/tests/snapshots/rusty__parser__tests__expressions_parser_tests__additon_of_two_variables_parsed.snap delete mode 100644 src/resolver/tests/snapshots/rusty__resolver__tests__resolve_expressions_tests__resolve_recursive_function_call.snap delete mode 100644 src/resolver/tests/snapshots/rusty__resolver__tests__resolve_expressions_tests__resolve_recursive_program_call.snap delete mode 100644 src/resolver/tests/snapshots/rusty__resolver__tests__resolve_expressions_tests__resolve_return_variable_in_nested_call.snap create mode 100644 src/validation/tests/snapshots/rusty__validation__tests__array_validation_test__parenthesized_struct_initializers.snap delete mode 100644 tests/integration/snapshots/tests__integration__cfc__codegen__variable_source_to_variable_and_block_sink.snap diff --git a/compiler/plc_ast/src/ast.rs b/compiler/plc_ast/src/ast.rs index 364c0e761c..bd498cf64a 100644 --- a/compiler/plc_ast/src/ast.rs +++ b/compiler/plc_ast/src/ast.rs @@ -553,7 +553,7 @@ fn replace_reference( Some(*old_data_type) } -#[derive(Clone, PartialEq, Debug)] +#[derive(Debug, Clone, PartialEq)] pub enum ReferenceAccess { /** * a, a.b diff --git a/compiler/plc_ast/src/literals.rs b/compiler/plc_ast/src/literals.rs index 3cc8942a5f..d5b1eb3bde 100644 --- a/compiler/plc_ast/src/literals.rs +++ b/compiler/plc_ast/src/literals.rs @@ -38,14 +38,14 @@ pub enum AstLiteral { Array(Array), } -#[derive(Clone, PartialEq)] +#[derive(Debug, Clone, PartialEq)] pub struct Date { year: i32, month: u32, day: u32, } -#[derive(Clone, PartialEq)] +#[derive(Debug, Clone, PartialEq)] pub struct DateAndTime { year: i32, month: u32, @@ -56,7 +56,7 @@ pub struct DateAndTime { nano: u32, } -#[derive(Clone, PartialEq)] +#[derive(Debug, Clone, PartialEq)] pub struct TimeOfDay { hour: u32, min: u32, @@ -64,7 +64,7 @@ pub struct TimeOfDay { nano: u32, } -#[derive(Clone, PartialEq)] +#[derive(Debug, Clone, PartialEq)] pub struct Time { pub day: f64, pub hour: f64, @@ -76,13 +76,13 @@ pub struct Time { pub negative: bool, } -#[derive(Clone, PartialEq)] +#[derive(Debug, Clone, PartialEq)] pub struct StringValue { pub value: String, pub is_wide: bool, } -#[derive(Clone, PartialEq)] +#[derive(Debug, Clone, PartialEq)] pub struct Array { pub elements: Option>, // expression-list } diff --git a/compiler/plc_diagnostics/src/diagnostics.rs b/compiler/plc_diagnostics/src/diagnostics.rs index 25783c20f3..7f0593819a 100644 --- a/compiler/plc_diagnostics/src/diagnostics.rs +++ b/compiler/plc_diagnostics/src/diagnostics.rs @@ -664,6 +664,14 @@ impl Diagnostic { } } + pub fn array_struct_assignment(range: SourceLocation) -> Diagnostic { + Diagnostic::SyntaxError { + message: "Struct initializers within arrays have to be wrapped by `()`".to_string(), + range: vec![range], + err_no: ErrNo::arr__invalid_array_assignment, + } + } + pub fn array_size(name: &str, len_lhs: usize, len_rhs: usize, range: SourceLocation) -> Diagnostic { Diagnostic::SemanticError { message: format!("Array {name} has a size of {len_lhs}, but {len_rhs} elements were provided"), diff --git a/src/codegen/generators/expression_generator.rs b/src/codegen/generators/expression_generator.rs index 5052bd97c2..5ab8f746ed 100644 --- a/src/codegen/generators/expression_generator.rs +++ b/src/codegen/generators/expression_generator.rs @@ -1774,6 +1774,7 @@ impl<'ink, 'b> ExpressionCodeGenerator<'ink, 'b> { AstStatement::MultipliedStatement { .. } => { self.generate_literal_array(literal_statement).map(ExpressionValue::RValue) } + AstStatement::ParenExpression(expr) => self.generate_literal(expr), // if there is an expression-list this might be a struct-initialization or array-initialization AstStatement::ExpressionList { .. } => { let type_hint = self.get_type_hint_info_for(literal_statement)?; diff --git a/src/parser/tests/snapshots/rusty__parser__tests__expressions_parser_tests__additon_of_two_variables_parsed.snap b/src/parser/tests/snapshots/rusty__parser__tests__expressions_parser_tests__additon_of_two_variables_parsed.snap deleted file mode 100644 index 5c250ad768..0000000000 --- a/src/parser/tests/snapshots/rusty__parser__tests__expressions_parser_tests__additon_of_two_variables_parsed.snap +++ /dev/null @@ -1,141 +0,0 @@ ---- -source: src/parser/tests/expressions_parser_tests.rs -expression: statement ---- -[ - BinaryExpression { - operator: Plus, - left: ReferenceExpr { - kind: Member( - Reference { - name: "x", - }, - ), - base: None, - }, - right: ReferenceExpr { - kind: Member( - Reference { - name: "y", - }, - ), - base: None, - }, - }, - BinaryExpression { - operator: Equal, - left: ReferenceExpr { - kind: Member( - Reference { - name: "y", - }, - ), - base: Some( - ReferenceExpr { - kind: Member( - Reference { - name: "x", - }, - ), - base: None, - }, - ), - }, - right: ReferenceExpr { - kind: Member( - Reference { - name: "z", - }, - ), - base: Some( - ReferenceExpr { - kind: Member( - Reference { - name: "y", - }, - ), - base: None, - }, - ), - }, - }, - BinaryExpression { - operator: Minus, - left: ReferenceExpr { - kind: Member( - Reference { - name: "y", - }, - ), - base: Some( - ReferenceExpr { - kind: Member( - Reference { - name: "x", - }, - ), - base: None, - }, - ), - }, - right: ReferenceExpr { - kind: Member( - Reference { - name: "z", - }, - ), - base: Some( - ReferenceExpr { - kind: Member( - Reference { - name: "y", - }, - ), - base: None, - }, - ), - }, - }, - BinaryExpression { - operator: Equal, - left: ReferenceExpr { - kind: Address, - base: Some( - ReferenceExpr { - kind: Member( - Reference { - name: "y", - }, - ), - base: Some( - ReferenceExpr { - kind: Member( - Reference { - name: "x", - }, - ), - base: None, - }, - ), - }, - ), - }, - right: ReferenceExpr { - kind: Member( - Reference { - name: "z", - }, - ), - base: Some( - ReferenceExpr { - kind: Member( - Reference { - name: "y", - }, - ), - base: None, - }, - ), - }, - }, -] diff --git a/src/resolver/tests/snapshots/rusty__resolver__tests__resolve_expressions_tests__resolve_recursive_function_call.snap b/src/resolver/tests/snapshots/rusty__resolver__tests__resolve_expressions_tests__resolve_recursive_function_call.snap deleted file mode 100644 index 73acc3ce37..0000000000 --- a/src/resolver/tests/snapshots/rusty__resolver__tests__resolve_expressions_tests__resolve_recursive_function_call.snap +++ /dev/null @@ -1,86 +0,0 @@ ---- -source: src/resolver/tests/resolve_expressions_tests.rs -expression: annotated_types ---- -{ - 1: Function { - return_type: "DINT", - qualified_name: "foo", - call_name: None, - }, - 3: Variable { - resulting_type: "DINT", - qualified_name: "foo.var1", - constant: false, - argument_type: ByVal( - Local, - ), - is_auto_deref: false, - }, - 2: Variable { - resulting_type: "DINT", - qualified_name: "foo.input1", - constant: false, - argument_type: ByVal( - Input, - ), - is_auto_deref: false, - }, - 6: Variable { - resulting_type: "DINT", - qualified_name: "foo.var2", - constant: false, - argument_type: ByVal( - Local, - ), - is_auto_deref: false, - }, - 5: Variable { - resulting_type: "DINT", - qualified_name: "foo.inout1", - constant: false, - argument_type: ByRef( - InOut, - ), - is_auto_deref: true, - }, - 8: Variable { - resulting_type: "DINT", - qualified_name: "foo.output1", - constant: false, - argument_type: ByRef( - Output, - ), - is_auto_deref: true, - }, - 9: Variable { - resulting_type: "DINT", - qualified_name: "foo.var3", - constant: false, - argument_type: ByVal( - Local, - ), - is_auto_deref: false, - }, - 12: Value { - resulting_type: "DINT", - }, - 14: Variable { - resulting_type: "DINT", - qualified_name: "foo.var1", - constant: false, - argument_type: ByVal( - Local, - ), - is_auto_deref: false, - }, - 13: Variable { - resulting_type: "DINT", - qualified_name: "foo.foo", - constant: false, - argument_type: ByVal( - Return, - ), - is_auto_deref: false, - }, -} diff --git a/src/resolver/tests/snapshots/rusty__resolver__tests__resolve_expressions_tests__resolve_recursive_program_call.snap b/src/resolver/tests/snapshots/rusty__resolver__tests__resolve_expressions_tests__resolve_recursive_program_call.snap deleted file mode 100644 index 520e48e507..0000000000 --- a/src/resolver/tests/snapshots/rusty__resolver__tests__resolve_expressions_tests__resolve_recursive_program_call.snap +++ /dev/null @@ -1,63 +0,0 @@ ---- -source: src/resolver/tests/resolve_expressions_tests.rs -expression: annotated_types ---- -{ - 1: Program { - qualified_name: "mainProg", - }, - 3: Variable { - resulting_type: "DINT", - qualified_name: "mainProg.var1", - constant: false, - argument_type: ByVal( - Local, - ), - is_auto_deref: false, - }, - 2: Variable { - resulting_type: "DINT", - qualified_name: "mainProg.input1", - constant: false, - argument_type: ByVal( - Input, - ), - is_auto_deref: false, - }, - 6: Variable { - resulting_type: "DINT", - qualified_name: "mainProg.var2", - constant: false, - argument_type: ByVal( - Local, - ), - is_auto_deref: false, - }, - 5: Variable { - resulting_type: "DINT", - qualified_name: "mainProg.inout1", - constant: false, - argument_type: ByRef( - InOut, - ), - is_auto_deref: true, - }, - 8: Variable { - resulting_type: "DINT", - qualified_name: "mainProg.output1", - constant: false, - argument_type: ByVal( - Output, - ), - is_auto_deref: false, - }, - 9: Variable { - resulting_type: "DINT", - qualified_name: "mainProg.var3", - constant: false, - argument_type: ByVal( - Local, - ), - is_auto_deref: false, - }, -} diff --git a/src/resolver/tests/snapshots/rusty__resolver__tests__resolve_expressions_tests__resolve_return_variable_in_nested_call.snap b/src/resolver/tests/snapshots/rusty__resolver__tests__resolve_expressions_tests__resolve_return_variable_in_nested_call.snap deleted file mode 100644 index 287e792b44..0000000000 --- a/src/resolver/tests/snapshots/rusty__resolver__tests__resolve_expressions_tests__resolve_return_variable_in_nested_call.snap +++ /dev/null @@ -1,32 +0,0 @@ ---- -source: src/resolver/tests/resolve_expressions_tests.rs -expression: codegen(src) ---- -; ModuleID = 'main' -source_filename = "main" - -define i32 @main() { -entry: - %main = alloca i32, align 4 - %x1 = alloca i32, align 4 - %x2 = alloca i32, align 4 - store i32 0, i32* %x1, align 4 - store i32 0, i32* %x2, align 4 - store i32 0, i32* %main, align 4 - %0 = ptrtoint i32* %main to i64 - %call = call i32 @SMC_Read(i64 %0) - store i32 %call, i32* %x1, align 4 - %main_ret = load i32, i32* %main, align 4 - ret i32 %main_ret -} - -define i32 @SMC_Read(i64 %0) { -entry: - %SMC_Read = alloca i32, align 4 - %ValAddr = alloca i64, align 8 - store i64 %0, i64* %ValAddr, align 4 - store i32 0, i32* %SMC_Read, align 4 - %SMC_Read_ret = load i32, i32* %SMC_Read, align 4 - ret i32 %SMC_Read_ret -} - diff --git a/src/validation/array.rs b/src/validation/array.rs index cfcdebea75..e5a484a670 100644 --- a/src/validation/array.rs +++ b/src/validation/array.rs @@ -26,41 +26,70 @@ pub(super) enum Wrapper<'a> { Variable(&'a Variable), } -pub(super) fn validate_array_assignment( +pub(super) fn validate_array_assignment( validator: &mut Validator, context: &ValidationContext, wrapper: Wrapper, -) where - T: AnnotationMap, -{ - let Some(dti_lhs) = wrapper.datatype_info_lhs(context) else { return }; - let Some(stmt_rhs) = wrapper.get_rhs() else { return }; +) { + let Some(lhs_type) = wrapper.datatype_info_lhs(context) else { return }; + let Some(rhs_stmt) = wrapper.get_rhs() else { return }; - if !dti_lhs.is_array() { + if !lhs_type.is_array() { return; } + validate_array(validator, context, lhs_type, rhs_stmt); + validate_array_of_structs(validator, context, lhs_type, rhs_stmt); +} + +fn validate_array( + validator: &mut Validator, + context: &ValidationContext, + lhs_type: &DataTypeInformation, + rhs_stmt: &AstNode, +) { + let stmt_rhs = peel(rhs_stmt); let stmt_rhs = peel(stmt_rhs); if !(stmt_rhs.is_literal_array() || stmt_rhs.is_reference()) { validator.push_diagnostic(Diagnostic::array_assignment(stmt_rhs.get_location())); return; // Return here, because array size validation is error-prone with incorrect assignments } - let len_lhs = dti_lhs.get_array_length(context.index).unwrap_or(0); + let len_lhs = lhs_type.get_array_length(context.index).unwrap_or(0); let len_rhs = statement_to_array_length(stmt_rhs); if len_lhs < len_rhs { - let name = dti_lhs.get_name(); + let name = lhs_type.get_name(); let location = stmt_rhs.get_location(); validator.push_diagnostic(Diagnostic::array_size(name, len_lhs, len_rhs, location)); } } +fn validate_array_of_structs( + validator: &mut Validator, + context: &ValidationContext, + lhs_type: &DataTypeInformation, + rhs_stmt: &AstNode, +) { + let Some(array_type_name) = lhs_type.get_inner_array_type_name() else { return }; + let Some(dti) = context.index.find_effective_type_by_name(array_type_name) else { return }; + + if dti.is_struct() { + let AstStatement::Literal(AstLiteral::Array(array)) = rhs_stmt.get_stmt() else { return }; + let Some(AstStatement::ExpressionList(expressions)) = array.elements().map(AstNode::get_stmt) else { return }; + + for invalid in expressions.iter().filter(|it| !it.is_paren()) { + validator.push_diagnostic(Diagnostic::array_struct_assignment(invalid.get_location())); + } + } +} + /// Takes an [`AstStatementKind`] and returns its length as if it was an array. For example calling this function /// on an expression-list such as `[(...), (...)]` would return 2. fn statement_to_array_length(statement: &AstNode) -> usize { match statement.get_stmt() { AstStatement::ExpressionList { .. } => 1, + AstStatement::ParenExpression(_) => 1, AstStatement::MultipliedStatement(data) => data.multiplier as usize, AstStatement::Literal(AstLiteral::Array(arr)) => match arr.elements() { Some(AstNode { stmt: AstStatement::ExpressionList(expressions), .. }) => { diff --git a/src/validation/tests/array_validation_test.rs b/src/validation/tests/array_validation_test.rs index 320fbfcf99..93700c4df9 100644 --- a/src/validation/tests/array_validation_test.rs +++ b/src/validation/tests/array_validation_test.rs @@ -296,3 +296,26 @@ fn assignment_multiplied_statement() { assert_snapshot!(diagnostics); } + +#[test] +fn parenthesized_struct_initializers() { + let diagnostics = parse_and_validate_buffered( + " + TYPE foo : STRUCT + idx : DINT; + val : DINT; + END_STRUCT END_TYPE + + FUNCTION main : DINT + VAR + foo_valid : ARRAY[1..2] OF foo := [(idx := 0, val := 0), (idx := 1, val := 1)]; + foo_invalid_a : ARRAY[1..2] OF foo := [idx := 0, val := 0, idx := 1, val := 1]; // Both initializers missing parens + foo_invalid_b : ARRAY[1..2] OF foo := [idx := 0, val := 0, (idx := 1, val := 1)]; // First initializer missing parens + foo_invalid_c : ARRAY[1..2] OF foo := [(idx := 0, val := 0), idx := 1, val := 1]; // Second initializer missing parens + END_VAR + END_FUNCTION + ", + ); + + assert_snapshot!(diagnostics); +} diff --git a/src/validation/tests/reference_resolve_tests.rs b/src/validation/tests/reference_resolve_tests.rs index dcd99911dc..b97c03aca4 100644 --- a/src/validation/tests/reference_resolve_tests.rs +++ b/src/validation/tests/reference_resolve_tests.rs @@ -305,7 +305,7 @@ fn resolve_array_of_struct_as_member_of_another_struct_initializer() { " PROGRAM mainProg VAR - var_str1 : STRUCT1 := (myArr := [x1 := FALSE, x2 := TRUE]); + var_str1 : STRUCT1 := (myArr := [(x1 := FALSE, x2 := TRUE)]); END_VAR END_PROGRAM @@ -359,5 +359,5 @@ fn array_of_struct_as_member_of_another_struct_and_variable_declaration_is_initi ", ); - assert_eq!(diagnostics, vec![]); + assert!(diagnostics.is_empty()); } diff --git a/src/validation/tests/snapshots/rusty__validation__tests__array_validation_test__parenthesized_struct_initializers.snap b/src/validation/tests/snapshots/rusty__validation__tests__array_validation_test__parenthesized_struct_initializers.snap new file mode 100644 index 0000000000..6ecd65b7f3 --- /dev/null +++ b/src/validation/tests/snapshots/rusty__validation__tests__array_validation_test__parenthesized_struct_initializers.snap @@ -0,0 +1,53 @@ +--- +source: src/validation/tests/array_validation_test.rs +expression: diagnostics +--- +error: Struct initializers within arrays have to be wrapped by `()` + ┌─ :10:56 + │ +10 │ foo_invalid_a : ARRAY[1..2] OF foo := [idx := 0, val := 0, idx := 1, val := 1]; // Both initializers missing parens + │ ^^^^^^^^ Struct initializers within arrays have to be wrapped by `()` + +error: Struct initializers within arrays have to be wrapped by `()` + ┌─ :10:66 + │ +10 │ foo_invalid_a : ARRAY[1..2] OF foo := [idx := 0, val := 0, idx := 1, val := 1]; // Both initializers missing parens + │ ^^^^^^^^ Struct initializers within arrays have to be wrapped by `()` + +error: Struct initializers within arrays have to be wrapped by `()` + ┌─ :10:76 + │ +10 │ foo_invalid_a : ARRAY[1..2] OF foo := [idx := 0, val := 0, idx := 1, val := 1]; // Both initializers missing parens + │ ^^^^^^^^ Struct initializers within arrays have to be wrapped by `()` + +error: Struct initializers within arrays have to be wrapped by `()` + ┌─ :10:86 + │ +10 │ foo_invalid_a : ARRAY[1..2] OF foo := [idx := 0, val := 0, idx := 1, val := 1]; // Both initializers missing parens + │ ^^^^^^^^ Struct initializers within arrays have to be wrapped by `()` + +error: Struct initializers within arrays have to be wrapped by `()` + ┌─ :11:56 + │ +11 │ foo_invalid_b : ARRAY[1..2] OF foo := [idx := 0, val := 0, (idx := 1, val := 1)]; // First initializer missing parens + │ ^^^^^^^^ Struct initializers within arrays have to be wrapped by `()` + +error: Struct initializers within arrays have to be wrapped by `()` + ┌─ :11:66 + │ +11 │ foo_invalid_b : ARRAY[1..2] OF foo := [idx := 0, val := 0, (idx := 1, val := 1)]; // First initializer missing parens + │ ^^^^^^^^ Struct initializers within arrays have to be wrapped by `()` + +error: Struct initializers within arrays have to be wrapped by `()` + ┌─ :12:78 + │ +12 │ foo_invalid_c : ARRAY[1..2] OF foo := [(idx := 0, val := 0), idx := 1, val := 1]; // Second initializer missing parens + │ ^^^^^^^^ Struct initializers within arrays have to be wrapped by `()` + +error: Struct initializers within arrays have to be wrapped by `()` + ┌─ :12:88 + │ +12 │ foo_invalid_c : ARRAY[1..2] OF foo := [(idx := 0, val := 0), idx := 1, val := 1]; // Second initializer missing parens + │ ^^^^^^^^ Struct initializers within arrays have to be wrapped by `()` + + diff --git a/tests/integration/snapshots/tests__integration__cfc__codegen__variable_source_to_variable_and_block_sink.snap b/tests/integration/snapshots/tests__integration__cfc__codegen__variable_source_to_variable_and_block_sink.snap deleted file mode 100644 index 3ad3d6af33..0000000000 --- a/tests/integration/snapshots/tests__integration__cfc__codegen__variable_source_to_variable_and_block_sink.snap +++ /dev/null @@ -1,50 +0,0 @@ ---- -source: tests/integration/cfc.rs -expression: output_file_content_without_headers.join(LINE_ENDING) ---- -define i32 @main() { -entry: - %main = alloca i32, align 4 - %value = alloca i32, align 4 - store i32 2, i32* %value, align 4 - store i32 0, i32* %main, align 4 - %load_value = load i32, i32* %value, align 4 - %call = call i32 @myConnection(i32 %load_value) - store i32 %call, i32* %main, align 4 - %main_ret = load i32, i32* %main, align 4 - ret i32 %main_ret -} - -define i32 @myAdd(i32 %0, i32 %1) { -entry: - %myAdd = alloca i32, align 4 - %a = alloca i32, align 4 - store i32 %0, i32* %a, align 4 - %b = alloca i32, align 4 - store i32 %1, i32* %b, align 4 - store i32 0, i32* %myAdd, align 4 - %load_a = load i32, i32* %a, align 4 - %load_b = load i32, i32* %b, align 4 - %tmpVar = add i32 %load_a, %load_b - store i32 %tmpVar, i32* %myAdd, align 4 - %myAdd_ret = load i32, i32* %myAdd, align 4 - ret i32 %myAdd_ret -} - -define i32 @myConnection(i32 %0) { -entry: - %myConnection = alloca i32, align 4 - %x = alloca i32, align 4 - store i32 %0, i32* %x, align 4 - %y = alloca i32, align 4 - store i32 0, i32* %y, align 4 - store i32 0, i32* %myConnection, align 4 - %load_x = load i32, i32* %x, align 4 - store i32 %load_x, i32* %y, align 4 - %load_y = load i32, i32* %y, align 4 - %load_x1 = load i32, i32* %x, align 4 - %call = call i32 @myAdd(i32 %load_y, i32 %load_x1) - store i32 %call, i32* %myConnection, align 4 - %myConnection_ret = load i32, i32* %myConnection, align 4 - ret i32 %myConnection_ret -} From 77cd41eb263d2699e11802d657bffb45d6954050 Mon Sep 17 00:00:00 2001 From: Volkan Date: Mon, 20 Nov 2023 10:47:44 +0100 Subject: [PATCH 03/33] test(cfc): Add codegen tests for CFC debugging (#999) --- compiler/plc_driver/src/lib.rs | 23 +++- compiler/plc_source/src/source_location.rs | 15 ++- compiler/plc_xml/src/lib.rs | 2 +- compiler/plc_xml/src/serializer.rs | 19 +++ src/codegen/debug.rs | 27 ++--- .../generators/expression_generator.rs | 2 +- src/codegen/generators/pou_generator.rs | 6 +- src/codegen/generators/statement_generator.rs | 15 ++- tests/integration/cfc.rs | 110 +++++++++++++++++- ...__integration__cfc__ir__actions_debug.snap | 76 ++++++++++++ ...on__cfc__ir__conditional_return_debug.snap | 42 +++++++ ...sts__integration__cfc__ir__jump_debug.snap | 51 ++++++++ ...tegration__cfc__ir__sink_source_debug.snap | 42 +++++++ 13 files changed, 401 insertions(+), 29 deletions(-) create mode 100644 tests/integration/snapshots/tests__integration__cfc__ir__actions_debug.snap create mode 100644 tests/integration/snapshots/tests__integration__cfc__ir__conditional_return_debug.snap create mode 100644 tests/integration/snapshots/tests__integration__cfc__ir__jump_debug.snap create mode 100644 tests/integration/snapshots/tests__integration__cfc__ir__sink_source_debug.snap diff --git a/compiler/plc_driver/src/lib.rs b/compiler/plc_driver/src/lib.rs index 54d8720b0a..201de68db0 100644 --- a/compiler/plc_driver/src/lib.rs +++ b/compiler/plc_driver/src/lib.rs @@ -215,13 +215,32 @@ pub fn parse_and_annotate( /// Generates an IR string from a list of sources. Useful for tests or api calls pub fn generate_to_string(name: &str, src: Vec) -> Result { + generate_to_string_internal(name, src, false) +} + +/// Generates an IR string from a list of sources with debug information enabled. Useful for tests or api calls +pub fn generate_to_string_debug(name: &str, src: Vec) -> Result { + generate_to_string_internal(name, src, true) +} + +fn generate_to_string_internal( + name: &str, + src: Vec, + debug: bool, +) -> Result { let mut diagnostician = Diagnostician::default(); let project = parse_and_annotate(name, src)?; - //Validate + + // Validate project.validate(&mut diagnostician)?; + // Generate let context = CodegenContext::create(); - let module = project.generate_single_module(&context, &CompileOptions::default())?; + let mut options = CompileOptions::default(); + if debug { + options.debug_level = DebugLevel::Full; + } + let module = project.generate_single_module(&context, &options)?; module.map(|it| it.persist_to_string()).ok_or_else(|| Diagnostic::GeneralError { message: "Cannot generate module".to_string(), diff --git a/compiler/plc_source/src/source_location.rs b/compiler/plc_source/src/source_location.rs index 5a552dd661..beafedd4d7 100644 --- a/compiler/plc_source/src/source_location.rs +++ b/compiler/plc_source/src/source_location.rs @@ -126,6 +126,14 @@ impl CodeSpan { } } + pub fn get_line_plus_one(&self) -> usize { + match self { + Self::Range(range) => range.start.line + 1, + Self::Block { local_id, .. } => *local_id, + _ => 0, + } + } + /// Gets the colmumn representation for a source location /// If the location does not represent a line, 0 is returned pub fn get_column(&self) -> usize { @@ -181,11 +189,16 @@ impl SourceLocation { /// Gets the line representation for a source location /// If the location does not represent a line, the closest equivalent is returned - // That is 0 for None and the ID for id/inner spans + /// That is 0 for None and the ID for id/inner spans pub fn get_line(&self) -> usize { self.span.get_line() } + /// Same as [`get_line`] but adds one to the line number if its of type [`CodeSpan::Range`]. + pub fn get_line_plus_one(&self) -> usize { + self.span.get_line_plus_one() + } + /// Gets the colmumn representation for a source location /// If the location does not represent a line, 0 is returned pub fn get_column(&self) -> usize { diff --git a/compiler/plc_xml/src/lib.rs b/compiler/plc_xml/src/lib.rs index 3823988b1b..df07567e42 100644 --- a/compiler/plc_xml/src/lib.rs +++ b/compiler/plc_xml/src/lib.rs @@ -17,4 +17,4 @@ pub(crate) mod model { pub mod variables; } mod reader; -pub(crate) mod serializer; +pub mod serializer; diff --git a/compiler/plc_xml/src/serializer.rs b/compiler/plc_xml/src/serializer.rs index 6085b33461..d5430e2227 100644 --- a/compiler/plc_xml/src/serializer.rs +++ b/compiler/plc_xml/src/serializer.rs @@ -1,3 +1,5 @@ +#![allow(clippy::new_without_default)] + use std::collections::HashMap; #[derive(Clone)] @@ -144,6 +146,7 @@ macro_rules! newtype_impl { }; } +// newtype_impl!(, , ) newtype_impl!(SInVariable, "inVariable", true); newtype_impl!(SOutVariable, "outVariable", true); newtype_impl!(SInOutVariable, "inOutVariable", true); @@ -173,6 +176,8 @@ newtype_impl!(SConnector, "connector", false); newtype_impl!(SContinuation, "continuation", false); newtype_impl!(SJump, "jump", false); newtype_impl!(SLabel, "label", false); +newtype_impl!(SAction, "action", false); +newtype_impl!(SActions, "actions", false); impl SInVariable { pub fn connect(mut self, ref_local_id: i32) -> Self { @@ -258,6 +263,10 @@ impl SPou { pub fn with_fbd(self, children: Vec<&dyn IntoNode>) -> Self { self.child(&SBody::new().child(&YFbd::new().children(children))) } + + pub fn with_actions(self, children: Vec<&dyn IntoNode>) -> Self { + self.child(&SActions::new().children(children)) + } } impl SBlock { @@ -363,3 +372,13 @@ impl SJump { ) } } + +impl SAction { + pub fn name(name: &'static str) -> Self { + Self::new().attribute("name", name) + } + + pub fn with_fbd(self, children: Vec<&dyn IntoNode>) -> Self { + self.child(&SBody::new().child(&YFbd::new().children(children))) + } +} diff --git a/src/codegen/debug.rs b/src/codegen/debug.rs index 8068a9b062..2eb056ba93 100644 --- a/src/codegen/debug.rs +++ b/src/codegen/debug.rs @@ -283,7 +283,7 @@ impl<'ink> DebugBuilder<'ink> { file.as_debug_info_scope(), member_name, file, - location.get_line().wrapping_add(1) as u32, + location.get_line_plus_one() as u32, size.bits().into(), alignment.bits(), running_offset.bits().into(), @@ -302,7 +302,7 @@ impl<'ink> DebugBuilder<'ink> { file.as_debug_info_scope(), name, file, - location.get_line().wrapping_add(1) as u32, + location.get_line_plus_one() as u32, running_offset.bits().into(), struct_dt.get_alignment(index).bits(), DIFlags::PUBLIC, @@ -429,7 +429,7 @@ impl<'ink> DebugBuilder<'ink> { inner_type.into(), name, file, - location.get_line().wrapping_add(1) as u32, + location.get_line_plus_one() as u32, file.as_debug_info_scope(), inner_dt.get_type_information().get_alignment(index).bits(), ); @@ -484,7 +484,7 @@ impl<'ink> DebugBuilder<'ink> { pou.get_name(), Some(pou.get_name()), // for generics e.g. NAME__TYPE file, - location.get_line().wrapping_add(1) as u32, + location.get_line_plus_one() as u32, // entry for the function ditype, false, // TODO: what is this @@ -562,7 +562,7 @@ impl<'ink> DebugBuilder<'ink> { .get_file_name() .map(|it| self.get_or_create_debug_file(it)) .unwrap_or_else(|| self.compile_unit.get_file()); - let line = location.get_line().wrapping_add(1) as u32; + let line = location.get_line_plus_one() as u32; let scope = scope .get_subprogram() .map(|it| it.as_debug_info_scope()) @@ -597,13 +597,8 @@ impl<'ink> Debug<'ink> for DebugBuilder<'ink> { .get_subprogram() .map(|it| it.as_debug_info_scope()) .unwrap_or_else(|| self.compile_unit.as_debug_info_scope()); - let location = self.debug_info.create_debug_location( - self.context, - (line + 1) as u32, - column as u32, - scope, - None, - ); + let location = + self.debug_info.create_debug_location(self.context, line as u32, column as u32, scope, None); llvm.builder.set_current_debug_location(location); } @@ -696,7 +691,7 @@ impl<'ink> Debug<'ink> for DebugBuilder<'ink> { name, "", file, - location.get_line().wrapping_add(1) as u32, + location.get_line_plus_one() as u32, debug_type.into(), false, None, @@ -722,7 +717,7 @@ impl<'ink> Debug<'ink> for DebugBuilder<'ink> { .get_file_name() .map(|it| self.get_or_create_debug_file(it)) .unwrap_or_else(|| self.compile_unit.get_file()); - let line = location.get_line().wrapping_add(1) as u32; + let line = location.get_line_plus_one() as u32; let scope = scope .get_subprogram() @@ -756,7 +751,7 @@ impl<'ink> Debug<'ink> for DebugBuilder<'ink> { .get_file_name() .map(|it| self.get_or_create_debug_file(it)) .unwrap_or_else(|| self.compile_unit.get_file()); - let line = location.get_line().wrapping_add(1) as u32; + let line = location.get_line_plus_one() as u32; let scope = scope .get_subprogram() .map(|it| it.as_debug_info_scope()) @@ -790,7 +785,7 @@ impl<'ink> Debug<'ink> for DebugBuilder<'ink> { .get_file_name() .map(|it| self.get_or_create_debug_file(it)) .unwrap_or_else(|| self.compile_unit.get_file()); - let line = pou.get_location().get_line().wrapping_add(1) as u32; + let line = pou.get_location().get_line_plus_one() as u32; let debug_variable = self.debug_info.create_parameter_variable( scope, pou.get_name(), diff --git a/src/codegen/generators/expression_generator.rs b/src/codegen/generators/expression_generator.rs index 5ab8f746ed..cdde8a8afa 100644 --- a/src/codegen/generators/expression_generator.rs +++ b/src/codegen/generators/expression_generator.rs @@ -184,7 +184,7 @@ impl<'ink, 'b> ExpressionCodeGenerator<'ink, 'b> { fn register_debug_location(&self, statement: &AstNode) { let function_context = self.function_context.expect("Cannot generate debug info without function context"); - let line = statement.get_location().get_line(); + let line = statement.get_location().get_line_plus_one(); let column = statement.get_location().get_column(); self.debug.set_debug_location(self.llvm, &function_context.function, line, column); } diff --git a/src/codegen/generators/pou_generator.rs b/src/codegen/generators/pou_generator.rs index 5c92187f05..e977f45ace 100644 --- a/src/codegen/generators/pou_generator.rs +++ b/src/codegen/generators/pou_generator.rs @@ -297,8 +297,10 @@ impl<'ink, 'cg> PouGenerator<'ink, 'cg> { let (line, column) = implementation .statements .first() - .map(|it| (it.get_location().get_line(), it.get_location().get_column())) - .or_else(|| Some((implementation.location.get_line(), implementation.location.get_column()))) + .map(|it| (it.get_location().get_line_plus_one(), it.get_location().get_column())) + .or_else(|| { + Some((implementation.location.get_line_plus_one(), implementation.location.get_column())) + }) // .or_else(|| Some(implementation.location.get_start())) .unwrap(); debug.set_debug_location(&self.llvm, ¤t_function, line, column); diff --git a/src/codegen/generators/statement_generator.rs b/src/codegen/generators/statement_generator.rs index 1075adaa43..0a65c636f7 100644 --- a/src/codegen/generators/statement_generator.rs +++ b/src/codegen/generators/statement_generator.rs @@ -129,8 +129,7 @@ impl<'a, 'b> StatementCodeGenerator<'a, 'b> { } AstStatement::ReturnStatement(ReturnStatement { condition }) => match condition { Some(condition) => { - self.register_debug_location(statement); - self.generate_conditional_return(condition)?; + self.generate_conditional_return(statement, condition)?; } None => { self.register_debug_location(statement); @@ -276,7 +275,7 @@ impl<'a, 'b> StatementCodeGenerator<'a, 'b> { } fn register_debug_location(&self, statement: &AstNode) { - let line = statement.get_location().get_line(); + let line = statement.get_location().get_line_plus_one(); let column = statement.get_location().get_column(); self.debug.set_debug_location(self.llvm, &self.function_context.function, line, column); } @@ -812,8 +811,14 @@ impl<'a, 'b> StatementCodeGenerator<'a, 'b> { /// Generates LLVM IR for conditional returns, which return if a given condition evaluates to true and /// does nothing otherwise. - pub fn generate_conditional_return(&'a self, condition: &AstNode) -> Result<(), Diagnostic> { + pub fn generate_conditional_return( + &'a self, + statement: &AstNode, + condition: &AstNode, + ) -> Result<(), Diagnostic> { let expression_generator = self.create_expr_generator(); + + self.register_debug_location(condition); let condition = expression_generator.generate_expression(condition)?; let then_block = self.llvm.context.append_basic_block(self.function_context.function, "then_block"); @@ -826,8 +831,8 @@ impl<'a, 'b> StatementCodeGenerator<'a, 'b> { ); self.llvm.builder.position_at_end(then_block); + self.register_debug_location(statement); self.generate_return_statement()?; - self.llvm.builder.position_at_end(else_block); Ok(()) diff --git a/tests/integration/cfc.rs b/tests/integration/cfc.rs index d465edf1f1..0caea6745d 100644 --- a/tests/integration/cfc.rs +++ b/tests/integration/cfc.rs @@ -202,8 +202,12 @@ fn actions_called_correctly() { // More specifically transform the following tests into simple codegen ones. #[cfg(test)] mod ir { - use driver::{compile, generate_to_string}; + use driver::{compile, generate_to_string, generate_to_string_debug}; use insta::assert_snapshot; + use plc_source::SourceCode; + use plc_xml::serializer::{ + SAction, SBlock, SConnector, SContinuation, SInVariable, SJump, SLabel, SOutVariable, SPou, SReturn, + }; use crate::get_test_file; @@ -299,4 +303,108 @@ mod ir { let output_file_content_without_headers = res.lines().skip(3).collect::>().join(NEWLINE); assert_snapshot!(output_file_content_without_headers); } + + #[test] + // TODO: Transfer this test to `codegen/tests/debug_tests/cfc.rs` once `test_utils.rs` has been refactored + fn conditional_return_debug() { + let declaration = "FUNCTION foo VAR_INPUT val : DINT; END_VAR"; + let content = SPou::init("foo", "function", declaration).with_fbd(vec![ + // IF val = 1 THEN RETURN + &SInVariable::id(2).with_expression("val = 5"), + &SReturn::id(3).with_execution_id(2).connect(2).negate(false), + // ELSE val := 10 + &SInVariable::id(4).with_expression("10"), + &SInVariable::id(5).with_execution_id(3).connect(4).with_expression("val"), + ]); + + let mut source = SourceCode::from(content.serialize()); + source.path = Some(".cfc".into()); + let res = generate_to_string_debug("plc", vec![source]).unwrap(); + + // We truncate the first 3 lines of the snapshot file because they contain file-metadata that changes + // with each run. This is due to working with temporary files (i.e. tempfile::NamedTempFile::new()) + let output_file_content_without_headers = res.lines().skip(3).collect::>().join(NEWLINE); + + // We expect two different !dbg statements for the return statement and its condition + assert_snapshot!(output_file_content_without_headers); + } + + #[test] + // TODO: Transfer this test to `codegen/tests/debug_tests/cfc.rs` once `test_utils.rs` has been refactored + fn jump_debug() { + let declaration = "PROGRAM foo VAR val : DINT := 0; END_VAR"; + let content = SPou::init("foo", "program", declaration).with_fbd(vec![ + // IF TRUE THEN GOTO lbl + &SInVariable::id(1).with_expression("val = 0"), // condition + &SLabel::id(2).with_name("lbl").with_execution_id(1), // label + &SJump::id(3).with_name("lbl").with_execution_id(2).connect(1), // statement + // ELSE x := FALSE + &SOutVariable::id(4).with_execution_id(3).with_expression("val").connect(5), // assignment + &SInVariable::id(5).with_expression("1"), + ]); + + let mut source = SourceCode::from(content.serialize()); + source.path = Some(".cfc".into()); + let res = generate_to_string_debug("plc", vec![source]).unwrap(); + + // We truncate the first 3 lines of the snapshot file because they contain file-metadata that changes + // with each run. This is due to working with temporary files (i.e. tempfile::NamedTempFile::new()) + let output_file_content_without_headers = res.lines().skip(3).collect::>().join(NEWLINE); + + // We expect four different !dbg statement for the condition, label, statement and the assignment + assert_snapshot!(output_file_content_without_headers); + } + + #[test] + // TODO: Transfer this test to `codegen/tests/debug_tests/cfc.rs` once `test_utils.rs` has been refactored + fn actions_debug() { + let content = SPou::init("main", "program", "PROGRAM main VAR a, b : DINT; END_VAR") + .with_actions(vec![ + &SAction::name("newAction").with_fbd(vec![ + &SOutVariable::id(1).with_expression("a").with_execution_id(0).connect(2), + &SInVariable::id(2).with_expression("a + 1"), + ]), + &SAction::name("newAction2").with_fbd(vec![ + &SInVariable::id(1).with_expression("b + 2"), + &SOutVariable::id(2).with_expression("b").with_execution_id(0).connect(1), + ]), + ]) + .with_fbd(vec![ + &SBlock::id(1).with_name("newAction").with_execution_id(1), + &SBlock::id(2).with_name("newAction2").with_execution_id(2), + &SInVariable::id(4).with_expression("0"), + &SOutVariable::id(3).with_expression("a").with_execution_id(0).connect(4), + ]); + + let mut source = SourceCode::from(content.serialize()); + source.path = Some(".cfc".into()); + let res = generate_to_string_debug("plc", vec![source]).unwrap(); + + // We truncate the first 3 lines of the snapshot file because they contain file-metadata that changes + // with each run. This is due to working with temporary files (i.e. tempfile::NamedTempFile::new()) + let output_file_content_without_headers = res.lines().skip(3).collect::>().join(NEWLINE); + + assert_snapshot!(output_file_content_without_headers); + } + + #[test] + // TODO: Transfer this test to `codegen/tests/debug_tests/cfc.rs` once `test_utils.rs` has been refactored + fn sink_source_debug() { + let content = SPou::init("main", "program", "PROGRAM main VAR x: DINT; END_VAR").with_fbd(vec![ + &SInVariable::id(1).with_expression("5"), + &SConnector::id(2).with_name("s1").connect(1), + &SContinuation::id(3).with_name("s1"), + &SOutVariable::id(4).with_expression("x").with_execution_id(1).connect(3), + ]); + + let mut source = SourceCode::from(content.serialize()); + source.path = Some(".cfc".into()); + let res = generate_to_string_debug("plc", vec![source]).unwrap(); + + // We truncate the first 3 lines of the snapshot file because they contain file-metadata that changes + // with each run. This is due to working with temporary files (i.e. tempfile::NamedTempFile::new()) + let output_file_content_without_headers = res.lines().skip(3).collect::>().join(NEWLINE); + + assert_snapshot!(output_file_content_without_headers); + } } diff --git a/tests/integration/snapshots/tests__integration__cfc__ir__actions_debug.snap b/tests/integration/snapshots/tests__integration__cfc__ir__actions_debug.snap new file mode 100644 index 0000000000..81edf2590d --- /dev/null +++ b/tests/integration/snapshots/tests__integration__cfc__ir__actions_debug.snap @@ -0,0 +1,76 @@ +--- +source: tests/integration/cfc.rs +expression: output_file_content_without_headers +--- +%main = type { i32, i32 } + +@main_instance = global %main zeroinitializer, !dbg !0 + +define void @main(%main* %0) !dbg !11 { +entry: + call void @llvm.dbg.declare(metadata %main* %0, metadata !15, metadata !DIExpression()), !dbg !16 + %a = getelementptr inbounds %main, %main* %0, i32 0, i32 0, !dbg !17 + %b = getelementptr inbounds %main, %main* %0, i32 0, i32 1, !dbg !17 + store i32 0, i32* %a, align 4, !dbg !18 + call void @main.newAction(%main* %0), !dbg !16 + call void @main.newAction2(%main* %0), !dbg !19 + ret void, !dbg !19 +} + +define void @main.newAction(%main* %0) !dbg !20 { +entry: + call void @llvm.dbg.declare(metadata %main* %0, metadata !15, metadata !DIExpression()), !dbg !21 + %a = getelementptr inbounds %main, %main* %0, i32 0, i32 0, !dbg !22 + %b = getelementptr inbounds %main, %main* %0, i32 0, i32 1, !dbg !22 + %load_a = load i32, i32* %a, align 4, !dbg !21 + %tmpVar = add i32 %load_a, 1, !dbg !21 + store i32 %tmpVar, i32* %a, align 4, !dbg !21 + ret void, !dbg !21 +} + +define void @main.newAction2(%main* %0) !dbg !23 { +entry: + call void @llvm.dbg.declare(metadata %main* %0, metadata !15, metadata !DIExpression()), !dbg !24 + %a = getelementptr inbounds %main, %main* %0, i32 0, i32 0, !dbg !25 + %b = getelementptr inbounds %main, %main* %0, i32 0, i32 1, !dbg !25 + %load_b = load i32, i32* %b, align 4, !dbg !26 + %tmpVar = add i32 %load_b, 2, !dbg !26 + store i32 %tmpVar, i32* %b, align 4, !dbg !26 + ret void, !dbg !26 +} + +; Function Attrs: nofree nosync nounwind readnone speculatable willreturn +declare void @llvm.dbg.declare(metadata, metadata, metadata) #0 + +attributes #0 = { nofree nosync nounwind readnone speculatable willreturn } + +!llvm.module.flags = !{!8} +!llvm.dbg.cu = !{!9} + +!0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression()) +!1 = distinct !DIGlobalVariable(name: "main", scope: !2, file: !2, line: 1, type: !3, isLocal: false, isDefinition: true) +!2 = !DIFile(filename: ".cfc", directory: "") +!3 = !DICompositeType(tag: DW_TAG_structure_type, name: "main", scope: !2, file: !2, line: 1, size: 64, align: 64, flags: DIFlagPublic, elements: !4, identifier: "main") +!4 = !{!5, !7} +!5 = !DIDerivedType(tag: DW_TAG_member, name: "a", scope: !2, file: !2, line: 1, baseType: !6, size: 32, align: 32, flags: DIFlagPublic) +!6 = !DIBasicType(name: "DINT", size: 32, encoding: DW_ATE_signed, flags: DIFlagPublic) +!7 = !DIDerivedType(tag: DW_TAG_member, name: "b", scope: !2, file: !2, line: 1, baseType: !6, size: 32, align: 32, offset: 32, flags: DIFlagPublic) +!8 = !{i32 2, !"Dwarf Version", i32 5} +!9 = distinct !DICompileUnit(language: DW_LANG_C, file: !2, producer: "RuSTy Structured text Compiler", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, globals: !10, splitDebugInlining: false) +!10 = !{!0} +!11 = distinct !DISubprogram(name: "main", linkageName: "main", scope: !2, file: !2, line: 1, type: !12, scopeLine: 1, flags: DIFlagPublic, spFlags: DISPFlagDefinition, unit: !9, retainedNodes: !14) +!12 = !DISubroutineType(flags: DIFlagPublic, types: !13) +!13 = !{null} +!14 = !{} +!15 = !DILocalVariable(name: "main", scope: !11, file: !2, line: 1, type: !3) +!16 = !DILocation(line: 1, scope: !11) +!17 = !DILocation(line: 0, scope: !11) +!18 = !DILocation(line: 3, scope: !11) +!19 = !DILocation(line: 2, scope: !11) +!20 = distinct !DISubprogram(name: "main.newAction", linkageName: "main.newAction", scope: !2, file: !2, type: !12, scopeLine: 1, flags: DIFlagPublic, spFlags: DISPFlagDefinition, unit: !9, retainedNodes: !14) +!21 = !DILocation(line: 1, scope: !20) +!22 = !DILocation(line: 0, scope: !20) +!23 = distinct !DISubprogram(name: "main.newAction2", linkageName: "main.newAction2", scope: !2, file: !2, type: !12, scopeLine: 1, flags: DIFlagPublic, spFlags: DISPFlagDefinition, unit: !9, retainedNodes: !14) +!24 = !DILocation(line: 1, scope: !23) +!25 = !DILocation(line: 0, scope: !23) +!26 = !DILocation(line: 2, scope: !23) diff --git a/tests/integration/snapshots/tests__integration__cfc__ir__conditional_return_debug.snap b/tests/integration/snapshots/tests__integration__cfc__ir__conditional_return_debug.snap new file mode 100644 index 0000000000..b3fe2cfa4c --- /dev/null +++ b/tests/integration/snapshots/tests__integration__cfc__ir__conditional_return_debug.snap @@ -0,0 +1,42 @@ +--- +source: tests/integration/cfc.rs +expression: output_file_content_without_headers +--- +define void @foo(i32 %0) !dbg !3 { +entry: + %val = alloca i32, align 4, !dbg !8 + call void @llvm.dbg.declare(metadata i32* %val, metadata !9, metadata !DIExpression()), !dbg !10 + store i32 %0, i32* %val, align 4, !dbg !8 + %load_val = load i32, i32* %val, align 4, !dbg !11 + %tmpVar = icmp eq i32 %load_val, 5, !dbg !11 + br i1 %tmpVar, label %then_block, label %else_block, !dbg !11 + +then_block: ; preds = %entry + ret void, !dbg !8 + +else_block: ; preds = %entry + store i32 10, i32* %val, align 4, !dbg !12 + ret void, !dbg !12 +} + +; Function Attrs: nofree nosync nounwind readnone speculatable willreturn +declare void @llvm.dbg.declare(metadata, metadata, metadata) #0 + +attributes #0 = { nofree nosync nounwind readnone speculatable willreturn } + +!llvm.module.flags = !{!0} +!llvm.dbg.cu = !{!1} + +!0 = !{i32 2, !"Dwarf Version", i32 5} +!1 = distinct !DICompileUnit(language: DW_LANG_C, file: !2, producer: "RuSTy Structured text Compiler", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, splitDebugInlining: false) +!2 = !DIFile(filename: ".cfc", directory: "") +!3 = distinct !DISubprogram(name: "foo", linkageName: "foo", scope: !2, file: !2, line: 1, type: !4, scopeLine: 4, flags: DIFlagPublic, spFlags: DISPFlagDefinition, unit: !1, retainedNodes: !7) +!4 = !DISubroutineType(flags: DIFlagPublic, types: !5) +!5 = !{null, !6} +!6 = !DIBasicType(name: "DINT", size: 32, encoding: DW_ATE_signed, flags: DIFlagPublic) +!7 = !{} +!8 = !DILocation(line: 3, scope: !3) +!9 = !DILocalVariable(name: "val", scope: !3, file: !2, line: 1, type: !6) +!10 = !DILocation(line: 1, column: 23, scope: !3) +!11 = !DILocation(line: 2, scope: !3) +!12 = !DILocation(line: 5, scope: !3) diff --git a/tests/integration/snapshots/tests__integration__cfc__ir__jump_debug.snap b/tests/integration/snapshots/tests__integration__cfc__ir__jump_debug.snap new file mode 100644 index 0000000000..06b43172da --- /dev/null +++ b/tests/integration/snapshots/tests__integration__cfc__ir__jump_debug.snap @@ -0,0 +1,51 @@ +--- +source: tests/integration/cfc.rs +expression: output_file_content_without_headers +--- +%foo = type { i32 } + +@foo_instance = global %foo zeroinitializer, !dbg !0 + +define void @foo(%foo* %0) !dbg !10 { +entry: + call void @llvm.dbg.declare(metadata %foo* %0, metadata !14, metadata !DIExpression()), !dbg !15 + %val = getelementptr inbounds %foo, %foo* %0, i32 0, i32 0, !dbg !16 + br label %lbl, !dbg !16 + +lbl: ; preds = %lbl, %entry + %load_val = load i32, i32* %val, align 4, !dbg !15 + %tmpVar = icmp eq i32 %load_val, 0, !dbg !15 + br i1 %tmpVar, label %lbl, label %else_block, !dbg !17 + +else_block: ; preds = %lbl + store i32 1, i32* %val, align 4, !dbg !18 + ret void, !dbg !18 +} + +; Function Attrs: nofree nosync nounwind readnone speculatable willreturn +declare void @llvm.dbg.declare(metadata, metadata, metadata) #0 + +attributes #0 = { nofree nosync nounwind readnone speculatable willreturn } + +!llvm.module.flags = !{!7} +!llvm.dbg.cu = !{!8} + +!0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression()) +!1 = distinct !DIGlobalVariable(name: "foo", scope: !2, file: !2, line: 1, type: !3, isLocal: false, isDefinition: true) +!2 = !DIFile(filename: ".cfc", directory: "") +!3 = !DICompositeType(tag: DW_TAG_structure_type, name: "foo", scope: !2, file: !2, line: 1, size: 32, align: 64, flags: DIFlagPublic, elements: !4, identifier: "foo") +!4 = !{!5} +!5 = !DIDerivedType(tag: DW_TAG_member, name: "val", scope: !2, file: !2, line: 1, baseType: !6, size: 32, align: 32, flags: DIFlagPublic) +!6 = !DIBasicType(name: "DINT", size: 32, encoding: DW_ATE_signed, flags: DIFlagPublic) +!7 = !{i32 2, !"Dwarf Version", i32 5} +!8 = distinct !DICompileUnit(language: DW_LANG_C, file: !2, producer: "RuSTy Structured text Compiler", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, globals: !9, splitDebugInlining: false) +!9 = !{!0} +!10 = distinct !DISubprogram(name: "foo", linkageName: "foo", scope: !2, file: !2, line: 1, type: !11, scopeLine: 3, flags: DIFlagPublic, spFlags: DISPFlagDefinition, unit: !8, retainedNodes: !13) +!11 = !DISubroutineType(flags: DIFlagPublic, types: !12) +!12 = !{null} +!13 = !{} +!14 = !DILocalVariable(name: "foo", scope: !10, file: !2, line: 1, type: !3) +!15 = !DILocation(line: 1, scope: !10) +!16 = !DILocation(line: 2, scope: !10) +!17 = !DILocation(line: 3, scope: !10) +!18 = !DILocation(line: 4, scope: !10) diff --git a/tests/integration/snapshots/tests__integration__cfc__ir__sink_source_debug.snap b/tests/integration/snapshots/tests__integration__cfc__ir__sink_source_debug.snap new file mode 100644 index 0000000000..51bd832702 --- /dev/null +++ b/tests/integration/snapshots/tests__integration__cfc__ir__sink_source_debug.snap @@ -0,0 +1,42 @@ +--- +source: tests/integration/cfc.rs +expression: output_file_content_without_headers +--- +%main = type { i32 } + +@main_instance = global %main zeroinitializer, !dbg !0 + +define void @main(%main* %0) !dbg !10 { +entry: + call void @llvm.dbg.declare(metadata %main* %0, metadata !14, metadata !DIExpression()), !dbg !15 + %x = getelementptr inbounds %main, %main* %0, i32 0, i32 0, !dbg !16 + store i32 5, i32* %x, align 4, !dbg !17 + ret void, !dbg !17 +} + +; Function Attrs: nofree nosync nounwind readnone speculatable willreturn +declare void @llvm.dbg.declare(metadata, metadata, metadata) #0 + +attributes #0 = { nofree nosync nounwind readnone speculatable willreturn } + +!llvm.module.flags = !{!7} +!llvm.dbg.cu = !{!8} + +!0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression()) +!1 = distinct !DIGlobalVariable(name: "main", scope: !2, file: !2, line: 1, type: !3, isLocal: false, isDefinition: true) +!2 = !DIFile(filename: ".cfc", directory: "") +!3 = !DICompositeType(tag: DW_TAG_structure_type, name: "main", scope: !2, file: !2, line: 1, size: 32, align: 64, flags: DIFlagPublic, elements: !4, identifier: "main") +!4 = !{!5} +!5 = !DIDerivedType(tag: DW_TAG_member, name: "x", scope: !2, file: !2, line: 1, baseType: !6, size: 32, align: 32, flags: DIFlagPublic) +!6 = !DIBasicType(name: "DINT", size: 32, encoding: DW_ATE_signed, flags: DIFlagPublic) +!7 = !{i32 2, !"Dwarf Version", i32 5} +!8 = distinct !DICompileUnit(language: DW_LANG_C, file: !2, producer: "RuSTy Structured text Compiler", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, globals: !9, splitDebugInlining: false) +!9 = !{!0} +!10 = distinct !DISubprogram(name: "main", linkageName: "main", scope: !2, file: !2, line: 1, type: !11, scopeLine: 1, flags: DIFlagPublic, spFlags: DISPFlagDefinition, unit: !8, retainedNodes: !13) +!11 = !DISubroutineType(flags: DIFlagPublic, types: !12) +!12 = !{null} +!13 = !{} +!14 = !DILocalVariable(name: "main", scope: !10, file: !2, line: 1, type: !3) +!15 = !DILocation(line: 1, scope: !10) +!16 = !DILocation(line: 0, scope: !10) +!17 = !DILocation(line: 4, scope: !10) From a26aa0b6a97b02c4231c36f2c0e2ad65bf1b5e2e Mon Sep 17 00:00:00 2001 From: Volkan Date: Mon, 20 Nov 2023 14:58:56 +0100 Subject: [PATCH 04/33] docs(cfc): Architecture (#1007) Rough architectural overview of the CFC implementation. Co-authored-by: Michael Co-authored-by: Michael <78988079+mhasel@users.noreply.github.com> --- book/src/SUMMARY.md | 2 + book/src/arch/architecture.md | 30 +++++++- book/src/cfc.md | 1 + book/src/cfc/cfc.md | 8 ++ book/src/cfc/m2m.md | 134 ++++++++++++++++++++++++++++++++++ book/src/using_rusty.md | 12 +-- compiler/plc_xml/README.md | 3 + 7 files changed, 180 insertions(+), 10 deletions(-) create mode 100644 book/src/cfc.md create mode 100644 book/src/cfc/cfc.md create mode 100644 book/src/cfc/m2m.md create mode 100644 compiler/plc_xml/README.md diff --git a/book/src/SUMMARY.md b/book/src/SUMMARY.md index aed93e61a5..92fbb4c6f9 100644 --- a/book/src/SUMMARY.md +++ b/book/src/SUMMARY.md @@ -19,3 +19,5 @@ - [Linker](./arch/linker.md) - [Validation](./arch/validation.md) - [Codegen](./arch/codegen.md) +- [CFC](./cfc/cfc.md) + - [Model-to-Model Conversion](./cfc/m2m.md) diff --git a/book/src/arch/architecture.md b/book/src/arch/architecture.md index 6a34454e3d..65db19fd61 100644 --- a/book/src/arch/architecture.md +++ b/book/src/arch/architecture.md @@ -2,9 +2,10 @@ ## Overview -RuSTy is a Compiler for Structured Text. -It utilizes the llvm compiler infrastructurue and contributes a [Structured Text](https://en.wikipedia.org/wiki/Structured_text) Frontend that translates Structured Text into llvm's language independent intermediate representation (IR). -The Further optimization and native code generation is performed by the existing LLVM infrastructure, namely llvm's common optimizer and the platform specific backend (see [here](https://www.aosabook.org/en/llvm.html)). +RuSTy is a compiler for IEC61131-3 languages. At the moment, ST and CFC ("FBD") are supported. +It utilizes the LLVM compiler infrastructurue and contributes a [Structured Text](https://en.wikipedia.org/wiki/Structured_text) frontend that translates Structured Text into LLVM's language independent intermediate representation (IR). +[CFC](../cfc/cfc.md) uses a M2M-transformation and reuses most of the ST frontend for compilation. +The further optimization and native code generation is performed by the existing LLVM infrastructure, namely LLVM's common optimizer and the platform specific backend (see [here](https://www.aosabook.org/en/llvm.html)). ```ignore ┌──────────────────┐ ┌───────────────┐ ┌────────────────┐ @@ -21,10 +22,12 @@ This means that this compiler can benefit from llvm's existing compiler-optimiza ## Rusty Frontend Architecture -Ultimately the goal of a compiler frontend, is to translate the original source code into the infrastructure's intermediate representation (in this case we're talking about [LLVM IR](https://llvm.org/docs/LangRef.html)). +Ultimately the goal of a compiler frontend is to translate the original source code into the infrastructure's intermediate representation (in this case we're talking about [LLVM IR](https://llvm.org/docs/LangRef.html)). RuSTy treats this task as a compilation step of its own. While a fully fledged compiler generates machine code as a last step, RuSTy generates LLVM IR assembly code. +## Structured Text + ```ignore ┌────────┐ ┌────────┐ │ Source │ │ LLVM │ @@ -41,3 +44,22 @@ While a fully fledged compiler generates machine code as a last step, RuSTy gene │ │ │ │ │ │ │ │ │ │ └────────────┘ └────────────┘ └────────────┘ └────────────┘ └────────────┘ ``` + +## CFC/FBD + +```ignore + ┌────────┐ ┌────────┐ + │ Source │ │ LLVM │ + │ │ │ IR │ + │ Files │ │ │ + └───┬────┘ └────────┘ + │ ▲ + ▼ │ + ┌────────────────┐ ┌────────────┐ ┌────────────┐ ┌────────────┐ ┌──────┴─────┐ + │ │ │ │ │ │ │ │ │ │ + │ Model-to-Model │ │ │ │ │ │ │ │ │ + │ Transformation ├───►│ Indexer ├──►│ Linker ├──►│ Validation ├──►│ Codegen │ + │ │ │ │ │ │ │ │ │ │ + │ │ │ │ │ │ │ │ │ │ + └────────────────┘ └────────────┘ └────────────┘ └────────────┘ └────────────┘ +``` diff --git a/book/src/cfc.md b/book/src/cfc.md new file mode 100644 index 0000000000..462d73e68b --- /dev/null +++ b/book/src/cfc.md @@ -0,0 +1 @@ +# CFC diff --git a/book/src/cfc/cfc.md b/book/src/cfc/cfc.md new file mode 100644 index 0000000000..6789ab7f65 --- /dev/null +++ b/book/src/cfc/cfc.md @@ -0,0 +1,8 @@ +# CFC (Continous Function Chart) + +RuSTy is compatible with CFC, as per the FBD part detailed in the [IEC61131-3 XML-exchange format](https://www.plcopen.org/system/files/downloads/tc6_xml_v201_technical_doc.pdf). +The CFC implementation borrows extensively from the [ST compiler-pipeline](../arch/architecture.md), with the exception that the lexical analysis and parsing phases are replaced by a model-to-model conversion process. +This involves converting the XML into a structured model, which is then converted into ST AST statements. + + +The next chapter will walk you through the CFC implementation, giving you a better understanding of underlying [code](https://github.com/PLC-lang/rusty/tree/master/compiler/plc_xml). \ No newline at end of file diff --git a/book/src/cfc/m2m.md b/book/src/cfc/m2m.md new file mode 100644 index 0000000000..08e52fd0c5 --- /dev/null +++ b/book/src/cfc/m2m.md @@ -0,0 +1,134 @@ +# Model-to-Model Conversion + +As previously mentioned, the lexical and parsing phases are replaced by a model-to-model conversion process which consists of two steps: +1. Transform the input file (XML) into a data-model +2. Transform the data-model into an AST + +## XML to Data-Model + +Consider the heavily minified CFC file [`MyProgram.cfc`](m2m.md#myprogramcfc), which translates to the CFC chart below. +```ignore + x MyAdd + ┌─────────────┐ ┌─────────────────┐ + │ │ │ exec_id:0 │ + │ ├───────►│ a │ z + │ local_id: 0 │ │ ref_local_id: 0 │ ┌──────────────┐ + └─────────────┘ │ │ │ exec_id: 1 │ + y │ ├─────────►│ │ + ┌─────────────┐ │ │ │ref_local_id:2│ + │ │ │ │ └──────────────┘ + │ ├───────►│ b │ local_id: 3 + │ local_id:1 │ │ ref_local_id: 1 │ + └─────────────┘ └─────────────────┘ + local_id: 2 +``` + +The initial phase of the transformation process involves streaming the entire input file. +During the streaming process, whenever important keywords such as `block` are encountered, they are directly mapped into a corresponding model structure. +For example, when reaching the line `` within the XML file, we generate a model that can be represented as follows: +```rust,ignore +struct Block { + localId: 2, + type_name: "MyAdd", + instance_name: None, + execution_order_id: 0, + variables: [ + InputVariable { ... }, // x, with localId = 0 + InputVariable { ... }, // y, with localId = 1 + OutputVariable { ... }, // MyAdd eventually becoming `z := MyAdd`, with z having a localId = 2 + ] +} +``` + +This process is repeated for every element in the input file which has a corresponding model implementation. For more information on implementation details, see the [model](https://github.com/PLC-lang/rusty/tree/master/compiler/plc_xml/src/model) folder. + +Since the CFC programming language utilizes blocks and their interconnections to establish the program's logic flow, +with the sequencing of block execution and inter-block links represented through corresponding `localId`, `refLocalId` and `excutionOrderId`, +we have to order each element by their execution ID before proceeding to the next phase. +Otherwise the generated AST statements would be out of order and hence semantically incorrect. + +## Data-Model to AST +The final part of the model-to-model transformation takes the input from the previous step and transforms it into an AST which the compiler pipeline understands and can generate code from. +Consider the previous `block` example - the transformer first encounters the element with the `executionOrderId` of 0, which is a call to `myAdd`. +We then check and transform each parameter, input `a` and `b` corresponding to the variables `x` and `y` respectively. The result of this transformation looks as follows: + +```rust,ignore +CallStatement { + operator: myAdd, + parameters: [x, y] +} +``` + + Next, we process the element with an `executionOrderId` of 1, which corresponds to an assignment of the previous call's result to z. This update modifies the generated AST as follows: + +```rust,ignore +AssignmentStatement { + left: z, + right: CallStatement { + operator: myAdd, + parameters: [x, y] + } +} +``` + +While this explanation covers the handling of blocks and variables, there are other elements (e.g. control-flow), that are not discussed here. For more information on implementation details, see [`plc_xml/src/xml_parser`](https://github.com/PLC-lang/rusty/tree/master/compiler/plc_xml/src/xml_parser). + +Finally, after transforming all elements into their respective AST statements, the result is passed to the indexer and subsequently enters the next stages of the compiler pipeline, as described in the [architecture documentation](../arch/architecture.md#rusty-frontend-architecture)). + +## Appendix +### MyAdd.st +```st,ignore +FUNCTION MyAdd : DINT + VAR_INPUT + x, y : DINT; + END_VAR + + MyAdd := x + y; +END_FUNCTION +``` + +### MyProgram.cfc +```xml,ignore + + + PROGRAM myProgram + VAR + x, y, z : DINT; + END_VAR + + + + + x + + + y + + + + + + + + + + + + + + + + + + + + + + + + z + + + + +``` diff --git a/book/src/using_rusty.md b/book/src/using_rusty.md index 4b52a72a6f..4699d1130b 100644 --- a/book/src/using_rusty.md +++ b/book/src/using_rusty.md @@ -2,7 +2,7 @@ > The RuSTy compiler binary is called `plc` -`plc` offers a comprehensive help via the -h (--help) option. +`plc` offers a comprehensive help via the `-h` (`--help`) option. `plc` takes one output-format parameter and any number of input-files. The input files can also be written as [glob patterns](https://en.wikipedia.org/wiki/Glob_(programming)). @@ -16,13 +16,13 @@ the output filename will consist of the first input filename, but with an approp file extension depending on the output file format. A minimal invocation looks like this: -`plc input.st` ... this will take in the file input.st and compile it into a static object that will be written to a file named input.o. +`plc input.st` this will take in the file `input.st` and compile it into a static object that will be written to a file named `input.o`. More examples: - - `plc --ir file1.st file2.st` will compile file1.st and file2.st. -- `plc --ir src/*.st` will compile all st files in the src-folder. -- `plc --ir "**/*.st"` will compile all st-files in the current folder and its subfolders recursively. +- `plc --ir file1.cfc file2.st` will compile file1.cfc and file2.st. +- `plc --ir src/*.st` will compile all ST files in the src-folder. +- `plc --ir "**/*.st"` will compile all ST-files in the current folder and its subfolders recursively. ## Example: Building a hello world program @@ -33,7 +33,7 @@ This example is available under `examples/hello_world.st` in the main RuSTy repo - `main` is our entry point to the program. - To link the program, we are going to use the system's linker using the `--linker=cc` argument. -- On windows, replace this with --linker=clang as cc is usually not available. +- On Windows and MacOS, replace this with `--linker=clang` as cc is usually not available. ```iecst {external} diff --git a/compiler/plc_xml/README.md b/compiler/plc_xml/README.md new file mode 100644 index 0000000000..e89baa6bcc --- /dev/null +++ b/compiler/plc_xml/README.md @@ -0,0 +1,3 @@ +# plc_xml + +This crate contains the CFC implementation of RuSTy, for more information refer to the [book](https://plc-lang.github.io/rusty/cfc/cfc.html). \ No newline at end of file From 477598f48bdc6bacca5cc980815121f64a11497d Mon Sep 17 00:00:00 2001 From: Volkan Date: Tue, 21 Nov 2023 16:25:35 +0100 Subject: [PATCH 05/33] fix(resolver): Annotate assignments with a hint when dealing with structs (#1020) Fixes https://github.com/PLC-lang/rusty/issues/1019 This commit adds a type-hint on struct field assignments when dealing with array of structs. For example given structs - `STRUCT1 { idx: DINT, arr: ARRAY[...] OF STRUCT2 }` and - `STRUCT2 { x: DINT, y: DINT }` The following snippet `ARRAY[1..3] OF STRUCT1 := [(idx := 0, arr := [(x := 1)])];` will result in `idx := 0` having a type-hint on `STRUCT1` and `x := 1` on `STRUCT2` --- compiler/plc_driver/src/pipelines.rs | 2 +- ...array_of_structs_are_zero_initialized.snap | 22 ++++++++ .../initialization_test/type_initializers.rs | 30 ++++++++++ src/resolver.rs | 49 ++++++++--------- src/resolver/tests/resolve_literals_tests.rs | 55 +++++++++++++++++++ 5 files changed, 132 insertions(+), 26 deletions(-) create mode 100644 src/codegen/tests/initialization_test/snapshots/rusty__codegen__tests__initialization_test__type_initializers__skipped_field_members_for_array_of_structs_are_zero_initialized.snap diff --git a/compiler/plc_driver/src/pipelines.rs b/compiler/plc_driver/src/pipelines.rs index 2606a50067..05008c1930 100644 --- a/compiler/plc_driver/src/pipelines.rs +++ b/compiler/plc_driver/src/pipelines.rs @@ -40,7 +40,7 @@ pub struct ParsedProject(Vec); impl ParsedProject { /// Parses a giving project, transforming it to a `ParsedProject` - /// Reprots parsing diagnostics such as Syntax error on the fly + /// Reports parsing diagnostics such as Syntax error on the fly pub fn parse( project: &Project, encoding: Option<&'static Encoding>, diff --git a/src/codegen/tests/initialization_test/snapshots/rusty__codegen__tests__initialization_test__type_initializers__skipped_field_members_for_array_of_structs_are_zero_initialized.snap b/src/codegen/tests/initialization_test/snapshots/rusty__codegen__tests__initialization_test__type_initializers__skipped_field_members_for_array_of_structs_are_zero_initialized.snap new file mode 100644 index 0000000000..8e1d26f2ea --- /dev/null +++ b/src/codegen/tests/initialization_test/snapshots/rusty__codegen__tests__initialization_test__type_initializers__skipped_field_members_for_array_of_structs_are_zero_initialized.snap @@ -0,0 +1,22 @@ +--- +source: src/codegen/tests/initialization_test/type_initializers.rs +expression: res +--- +; ModuleID = 'main' +source_filename = "main" + +%main = type { [3 x %STRUCT1] } +%STRUCT1 = type { i32, [2 x %STRUCT2] } +%STRUCT2 = type { i32, i32 } + +@main_instance = global %main { [3 x %STRUCT1] [%STRUCT1 { i32 0, [2 x %STRUCT2] [%STRUCT2 { i32 1, i32 0 }, %STRUCT2 zeroinitializer] }, %STRUCT1 { i32 2, [2 x %STRUCT2] [%STRUCT2 { i32 1, i32 1 }, %STRUCT2 zeroinitializer] }, %STRUCT1 { i32 1, [2 x %STRUCT2] [%STRUCT2 { i32 1, i32 0 }, %STRUCT2 { i32 0, i32 2 }] }] } +@__STRUCT1__init = unnamed_addr constant %STRUCT1 zeroinitializer +@__STRUCT2__init = unnamed_addr constant %STRUCT2 zeroinitializer +@__main.var_init1__init = unnamed_addr constant [3 x %STRUCT1] [%STRUCT1 { i32 0, [2 x %STRUCT2] [%STRUCT2 { i32 1, i32 0 }, %STRUCT2 zeroinitializer] }, %STRUCT1 { i32 2, [2 x %STRUCT2] [%STRUCT2 { i32 1, i32 1 }, %STRUCT2 zeroinitializer] }, %STRUCT1 { i32 1, [2 x %STRUCT2] [%STRUCT2 { i32 1, i32 0 }, %STRUCT2 { i32 0, i32 2 }] }] + +define void @main(%main* %0) { +entry: + %var_init1 = getelementptr inbounds %main, %main* %0, i32 0, i32 0 + ret void +} + diff --git a/src/codegen/tests/initialization_test/type_initializers.rs b/src/codegen/tests/initialization_test/type_initializers.rs index 9610712a87..beffef7d12 100644 --- a/src/codegen/tests/initialization_test/type_initializers.rs +++ b/src/codegen/tests/initialization_test/type_initializers.rs @@ -604,5 +604,35 @@ fn enums_with_inline_initializer_are_initialized() { END_FUNCTION "#, ); + + insta::assert_snapshot!(res); +} + +#[test] +fn skipped_field_members_for_array_of_structs_are_zero_initialized() { + let res = codegen( + r#" + TYPE STRUCT1 : STRUCT + idx: DINT; + arr: ARRAY[1..2] OF STRUCT2; + END_STRUCT END_TYPE + + TYPE STRUCT2 : STRUCT + x: DINT; + y: DINT; + END_STRUCT END_TYPE + + PROGRAM main + VAR + var_init1 : ARRAY[1..3] OF STRUCT1 := [ + (idx := 0, arr := [(x := 1)]), + (idx := 2, arr := [(x := 1, y := 1)]), + (idx := 1, arr := [(x := 1), (y := 2)]) + ]; + END_VAR + END_PROGRAM + "#, + ); + insta::assert_snapshot!(res); } diff --git a/src/resolver.rs b/src/resolver.rs index b4a61d3137..f2f8bcd980 100644 --- a/src/resolver.rs +++ b/src/resolver.rs @@ -330,15 +330,9 @@ pub enum StatementAnnotation { } impl StatementAnnotation { - /// constructs a new StatementAnnotation::Value with the given type_name - /// this is a convinience method to take a &str and clones it itself - pub fn value(type_name: &str) -> Self { - StatementAnnotation::new_value(type_name.to_string()) - } - - /// constructs a new StatementAnnotation::Value with the given type_name - pub fn new_value(type_name: String) -> Self { - StatementAnnotation::Value { resulting_type: type_name } + /// Constructs a new [`StatementAnnotation::Value`] with the given type name + pub fn value(type_name: impl Into) -> Self { + StatementAnnotation::Value { resulting_type: type_name.into() } } pub fn is_const(&self) -> bool { @@ -979,8 +973,8 @@ impl<'i> TypeAnnotator<'i> { } AstStatement::ExpressionList(expressions) => { - let name = inner_data_type.get_name().to_string(); - let hint = StatementAnnotation::Value { resulting_type: name }; + let name = inner_data_type.get_name(); + let hint = StatementAnnotation::value(name); for expression in expressions { self.annotation_map.annotate_type_hint(expression, hint.clone()); @@ -994,14 +988,19 @@ impl<'i> TypeAnnotator<'i> { } AstStatement::Assignment(Assignment { left, right, .. }) if left.is_reference() => { - let AstStatement::Literal(AstLiteral::Array(array)) = right.as_ref().get_stmt() - else { - return; - }; - let Some(elements) = array.elements() else { return }; + if let AstStatement::Literal(AstLiteral::Array(array)) = right.as_ref().get_stmt() { + let Some(elements) = array.elements() else { return }; + + if let Some(datatype) = self.annotation_map.get_type(left, self.index).cloned() { + self.type_hint_for_array_of_structs(&datatype, elements, &ctx); + } + } - if let Some(datatype) = self.annotation_map.get_type(left, self.index).cloned() { - self.type_hint_for_array_of_structs(&datatype, elements, &ctx); + // https://github.com/PLC-lang/rusty/issues/1019 + if inner_data_type.information.is_struct() { + let name = inner_data_type.get_name(); + let hint = StatementAnnotation::value(name); + self.annotation_map.annotate_type_hint(statement, hint); } } @@ -1189,11 +1188,11 @@ impl<'i> TypeAnnotator<'i> { let ctx = VisitorContext { qualifier: None, ..ctx.clone() }; visit_all_statements!(self, &ctx, &data.index); let access_type = get_direct_access_type(&data.access); - self.annotate(statement, StatementAnnotation::Value { resulting_type: access_type.into() }); + self.annotate(statement, StatementAnnotation::value(access_type)); } AstStatement::HardwareAccess(data, ..) => { let access_type = get_direct_access_type(&data.access); - self.annotate(statement, StatementAnnotation::Value { resulting_type: access_type.into() }); + self.annotate(statement, StatementAnnotation::value(access_type)); } AstStatement::BinaryExpression(data, ..) => { visit_all_statements!(self, ctx, &data.left, &data.right); @@ -1286,7 +1285,7 @@ impl<'i> TypeAnnotator<'i> { }; if let Some(statement_type) = statement_type { - self.annotate(statement, StatementAnnotation::new_value(statement_type)); + self.annotate(statement, StatementAnnotation::value(statement_type)); } } AstStatement::UnaryExpression(data, ..) => { @@ -1310,7 +1309,7 @@ impl<'i> TypeAnnotator<'i> { }; if let Some(statement_type) = statement_type { - self.annotate(statement, StatementAnnotation::new_value(statement_type)); + self.annotate(statement, StatementAnnotation::value(statement_type)); } } @@ -1394,7 +1393,7 @@ impl<'i> TypeAnnotator<'i> { vec![] }; for (stmt, annotation) in statement_to_annotation { - self.annotate(stmt, StatementAnnotation::new_value(annotation)); + self.annotate(stmt, StatementAnnotation::value(annotation)); } } AstStatement::ReferenceExpr(data, ..) => { @@ -1514,7 +1513,7 @@ impl<'i> TypeAnnotator<'i> { .map(|base| self.annotation_map.get_type_or_void(base, self.index).get_name().to_string()) { let ptr_type = add_pointer_type(&mut self.annotation_map.new_index, inner_type); - self.annotate(stmt, StatementAnnotation::new_value(ptr_type)) + self.annotate(stmt, StatementAnnotation::value(ptr_type)) } } _ => {} @@ -1816,7 +1815,7 @@ impl<'i> TypeAnnotator<'i> { AstLiteral::String(StringValue { is_wide, value, .. }) => { let string_type_name = register_string_type(&mut self.annotation_map.new_index, *is_wide, value.len()); - self.annotate(statement, StatementAnnotation::new_value(string_type_name)); + self.annotate(statement, StatementAnnotation::value(string_type_name)); //collect literals so we can generate global constants later if ctx.is_in_a_body() { diff --git a/src/resolver/tests/resolve_literals_tests.rs b/src/resolver/tests/resolve_literals_tests.rs index 557533ed07..18868548fa 100644 --- a/src/resolver/tests/resolve_literals_tests.rs +++ b/src/resolver/tests/resolve_literals_tests.rs @@ -1,3 +1,4 @@ +use plc_ast::literals::AstLiteral; use plc_ast::{ ast::{AstStatement, ReferenceAccess, ReferenceExpr, TypeNature}, provider::IdProvider, @@ -507,3 +508,57 @@ fn expression_list_as_array_initilization_is_annotated_correctly() { unreachable!(); } } + +#[test] +fn struct_field_members_assignments_are_annotated_correctly_in_array_of_structs() { + let id_provider = IdProvider::default(); + let (unit, mut index) = index_with_ids( + " + TYPE STRUCT1 : STRUCT + x : DINT; + arr : ARRAY[0..1] OF STRUCT2; + END_STRUCT END_TYPE + + TYPE STRUCT2 : STRUCT + y : INT; + z : INT; + END_STRUCT END_TYPE + + PROGRAM main + VAR + var_init1 : ARRAY[0..1] OF STRUCT1 := [ + (x := 0, arr := [(y := 0), (z := 0)]) + ]; + END_VAR + END_PROGRAM + ", + id_provider.clone(), + ); + + let annotations = annotate_with_ids(&unit, &mut index, id_provider); + let var = unit.units[0].variable_blocks[0].variables[0].initializer.clone().unwrap(); + + // (x := 0, arr := [(y := 0), (z := 0)]) + let AstStatement::Literal(AstLiteral::Array(arr)) = &var.stmt else { panic!() }; + let AstStatement::ParenExpression(expr) = &arr.elements().unwrap().stmt else { panic!() }; + let AstStatement::ExpressionList(elements) = &expr.stmt else { panic!() }; + + // x := 0 + let x = &elements[0]; + assert_eq!(&annotations.get_type_hint(&x, &index).unwrap().name, "STRUCT1"); + + // arr := [(y := 0), (z := 0)] + let AstStatement::Assignment(assignment) = &elements[1].stmt else { panic!() }; + + // [(y := 0), (z := 0)] + let AstStatement::Literal(AstLiteral::Array(arr)) = &assignment.right.stmt else { panic!() }; + let AstStatement::ExpressionList(elements) = &arr.elements.as_ref().unwrap().stmt else { panic!() }; + + // y := 0 + let AstStatement::ParenExpression(y) = &elements[0].stmt else { panic!() }; + assert_eq!(&annotations.get_type_hint(&y, &index).unwrap().name, "STRUCT2"); + + // z := 0 + let AstStatement::ParenExpression(z) = &elements[1].stmt else { panic!() }; + assert_eq!(&annotations.get_type_hint(&z, &index).unwrap().name, "STRUCT2"); +} From 5c729d8632d8c60ca28f65f2eabe5a5901174706 Mon Sep 17 00:00:00 2001 From: Volkan Date: Thu, 23 Nov 2023 13:55:48 +0100 Subject: [PATCH 06/33] Force parentheses for single assignment statements (#1025) Add a validation for single assignment statements in array of struct initializer, e.g. foo : ARRAY[...] OF MyStruct := [myField := 0] returns a codegen error ("Some initial values were not generated") with no validation error. This PR introduces a validation for that edge-case. --- src/validation/array.rs | 33 +++++++++++++------ src/validation/tests/array_validation_test.rs | 1 + ...st__parenthesized_struct_initializers.snap | 6 ++++ 3 files changed, 30 insertions(+), 10 deletions(-) diff --git a/src/validation/array.rs b/src/validation/array.rs index e5a484a670..8e591c6871 100644 --- a/src/validation/array.rs +++ b/src/validation/array.rs @@ -31,8 +31,8 @@ pub(super) fn validate_array_assignment( context: &ValidationContext, wrapper: Wrapper, ) { - let Some(lhs_type) = wrapper.datatype_info_lhs(context) else { return }; - let Some(rhs_stmt) = wrapper.get_rhs() else { return }; + let Some(lhs_type) = wrapper.datatype_info_lhs(context) else { return; }; + let Some(rhs_stmt) = wrapper.get_rhs() else { return; }; if !lhs_type.is_array() { return; @@ -71,16 +71,29 @@ fn validate_array_of_structs( lhs_type: &DataTypeInformation, rhs_stmt: &AstNode, ) { - let Some(array_type_name) = lhs_type.get_inner_array_type_name() else { return }; - let Some(dti) = context.index.find_effective_type_by_name(array_type_name) else { return }; + let Some(array_type_name) = lhs_type.get_inner_array_type_name() else { return; }; + let Some(dti) = context.index.find_effective_type_by_name(array_type_name) else { return; }; - if dti.is_struct() { - let AstStatement::Literal(AstLiteral::Array(array)) = rhs_stmt.get_stmt() else { return }; - let Some(AstStatement::ExpressionList(expressions)) = array.elements().map(AstNode::get_stmt) else { return }; + if !dti.is_struct() { + return; + } - for invalid in expressions.iter().filter(|it| !it.is_paren()) { - validator.push_diagnostic(Diagnostic::array_struct_assignment(invalid.get_location())); + let AstStatement::Literal(AstLiteral::Array(array)) = rhs_stmt.get_stmt() else { return; }; + let Some(elements) = array.elements().map(AstNode::get_stmt) else { return; }; + + match elements { + AstStatement::ExpressionList(expressions) => { + for invalid in expressions.iter().filter(|it| !it.is_paren()) { + validator.push_diagnostic(Diagnostic::array_struct_assignment(invalid.get_location())); + } } + + // arr := [foo := 0] + AstStatement::Assignment(..) => { + validator.push_diagnostic(Diagnostic::array_struct_assignment(rhs_stmt.get_location())); + } + + _ => (), } } @@ -126,7 +139,7 @@ impl<'a> Wrapper<'a> { { match self { Wrapper::Statement(statement) => { - let AstNode { stmt: AstStatement::Assignment(data), .. } = statement else { return None }; + let AstNode { stmt: AstStatement::Assignment(data), .. } = statement else { return None; }; context.annotations.get_type(&data.left, context.index).map(|it| it.get_type_information()) } diff --git a/src/validation/tests/array_validation_test.rs b/src/validation/tests/array_validation_test.rs index 93700c4df9..e541b62237 100644 --- a/src/validation/tests/array_validation_test.rs +++ b/src/validation/tests/array_validation_test.rs @@ -312,6 +312,7 @@ fn parenthesized_struct_initializers() { foo_invalid_a : ARRAY[1..2] OF foo := [idx := 0, val := 0, idx := 1, val := 1]; // Both initializers missing parens foo_invalid_b : ARRAY[1..2] OF foo := [idx := 0, val := 0, (idx := 1, val := 1)]; // First initializer missing parens foo_invalid_c : ARRAY[1..2] OF foo := [(idx := 0, val := 0), idx := 1, val := 1]; // Second initializer missing parens + foo_invalid_d : ARRAY[1..2] OF foo := [idx := 0]; END_VAR END_FUNCTION ", diff --git a/src/validation/tests/snapshots/rusty__validation__tests__array_validation_test__parenthesized_struct_initializers.snap b/src/validation/tests/snapshots/rusty__validation__tests__array_validation_test__parenthesized_struct_initializers.snap index 6ecd65b7f3..8041c5ec8f 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__array_validation_test__parenthesized_struct_initializers.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__array_validation_test__parenthesized_struct_initializers.snap @@ -50,4 +50,10 @@ error: Struct initializers within arrays have to be wrapped by `()` 12 │ foo_invalid_c : ARRAY[1..2] OF foo := [(idx := 0, val := 0), idx := 1, val := 1]; // Second initializer missing parens │ ^^^^^^^^ Struct initializers within arrays have to be wrapped by `()` +error: Struct initializers within arrays have to be wrapped by `()` + ┌─ :13:55 + │ +13 │ foo_invalid_d : ARRAY[1..2] OF foo := [idx := 0]; + │ ^^^^^^^^^^ Struct initializers within arrays have to be wrapped by `()` + From ea718d297786019f5c37181365d5419e9555e62a Mon Sep 17 00:00:00 2001 From: Kari Argillander Date: Fri, 24 Nov 2023 10:07:25 +0200 Subject: [PATCH 07/33] Remove unnecessary unsafe blocks (#1028) * Remove unneeded unsafe markers in counters.rs This file where refactored in commit 986522e6447e (fixes flanks, timers. changes impl Default to #derived where applicable.) It removes use of raw pointers. However that commit did not remove unsafe markers. We can remove those so people do not get confuse why there is unsafe code as there is none anymore. * Remove unneeded unsafe markers in bistable_functionblocks --------- Co-authored-by: Kari Argillander --- libs/stdlib/src/bistable_functionblocks.rs | 10 +- libs/stdlib/src/counters.rs | 120 ++++++--------------- 2 files changed, 35 insertions(+), 95 deletions(-) diff --git a/libs/stdlib/src/bistable_functionblocks.rs b/libs/stdlib/src/bistable_functionblocks.rs index 7dc4a79001..14c6f7d2bb 100644 --- a/libs/stdlib/src/bistable_functionblocks.rs +++ b/libs/stdlib/src/bistable_functionblocks.rs @@ -15,23 +15,17 @@ impl SetResetParams { ///. /// Bistable function, set dominant /// -/// # Safety -/// Working with raw pointers -/// #[allow(non_snake_case)] #[no_mangle] -pub unsafe extern "C" fn SR(params: &mut SetResetParams) { +pub extern "C" fn SR(params: &mut SetResetParams) { params.set_output(params.set | (!params.reset & params.output)); } ///. /// Bistable function, reset dominant /// -/// # Safety -/// Working with raw pointers -/// #[allow(non_snake_case)] #[no_mangle] -pub unsafe extern "C" fn RS(params: &mut SetResetParams) { +pub extern "C" fn RS(params: &mut SetResetParams) { params.set_output(!params.reset & (params.set | params.output)); } diff --git a/libs/stdlib/src/counters.rs b/libs/stdlib/src/counters.rs index 05f95de4fd..78e91d6a48 100644 --- a/libs/stdlib/src/counters.rs +++ b/libs/stdlib/src/counters.rs @@ -17,15 +17,15 @@ impl CTUParams where T: Integer + Copy, { - unsafe fn update_q(&mut self) { + fn update_q(&mut self) { self.q = self.cv >= self.pv } - unsafe fn reset(&mut self) { + fn reset(&mut self) { self.cv = Zero::zero() } - unsafe fn inc(&mut self) { + fn inc(&mut self) { self.cv = self.cv + One::one(); } @@ -34,7 +34,7 @@ where } } -unsafe fn ctu(params: &mut CTUParams) +fn ctu(params: &mut CTUParams) where T: Integer + Copy + Bounded, { @@ -49,72 +49,54 @@ where ///. /// Counter up for INT /// -/// # Safety -/// Working with raw pointers -/// #[allow(non_snake_case)] #[no_mangle] -pub unsafe extern "C" fn CTU(params: &mut CTUParams) { +pub extern "C" fn CTU(params: &mut CTUParams) { ctu(params); } ///. /// Counter up for INT /// -/// # Safety -/// Working with raw pointers -/// #[allow(non_snake_case)] #[no_mangle] -pub unsafe extern "C" fn CTU_INT(params: &mut CTUParams) { +pub extern "C" fn CTU_INT(params: &mut CTUParams) { ctu(params); } ///. /// Counter up for DINT /// -/// # Safety -/// Working with raw pointers -/// #[allow(non_snake_case)] #[no_mangle] -pub unsafe extern "C" fn CTU_DINT(params: &mut CTUParams) { +pub extern "C" fn CTU_DINT(params: &mut CTUParams) { ctu(params); } ///. /// Counter up for DINT /// -/// # Safety -/// Working with raw pointers -/// #[allow(non_snake_case)] #[no_mangle] -pub unsafe extern "C" fn CTU_UDINT(params: &mut CTUParams) { +pub extern "C" fn CTU_UDINT(params: &mut CTUParams) { ctu(params); } ///. /// Counter up for LINT /// -/// # Safety -/// Working with raw pointers -/// #[allow(non_snake_case)] #[no_mangle] -pub unsafe extern "C" fn CTU_LINT(params: &mut CTUParams) { +pub extern "C" fn CTU_LINT(params: &mut CTUParams) { ctu(params); } ///. /// Counter up for ULINT /// -/// # Safety -/// Working with raw pointers -/// #[allow(non_snake_case)] #[no_mangle] -pub unsafe extern "C" fn CTU_ULINT(params: &mut CTUParams) { +pub extern "C" fn CTU_ULINT(params: &mut CTUParams) { ctu(params); } @@ -133,15 +115,15 @@ impl CTDParams where T: Integer + Copy, { - unsafe fn update_q(&mut self) { + fn update_q(&mut self) { self.q = self.cv <= Zero::zero() } - unsafe fn load(&mut self) { + fn load(&mut self) { self.cv = self.pv } - unsafe fn dec(&mut self) { + fn dec(&mut self) { self.cv = self.cv - One::one(); } @@ -150,7 +132,7 @@ where } } -unsafe fn ctd(params: &mut CTDParams) +fn ctd(params: &mut CTDParams) where T: Integer + Copy + Bounded, { @@ -165,72 +147,54 @@ where ///. /// Counter down for INT /// -/// # Safety -/// Working with raw pointers -/// #[allow(non_snake_case)] #[no_mangle] -pub unsafe extern "C" fn CTD(params: &mut CTDParams) { +pub extern "C" fn CTD(params: &mut CTDParams) { ctd(params); } ///. /// Counter down for INT /// -/// # Safety -/// Working with raw pointers -/// #[allow(non_snake_case)] #[no_mangle] -pub unsafe extern "C" fn CTD_INT(params: &mut CTDParams) { +pub extern "C" fn CTD_INT(params: &mut CTDParams) { ctd(params); } ///. /// Counter down for DINT /// -/// # Safety -/// Working with raw pointers -/// #[allow(non_snake_case)] #[no_mangle] -pub unsafe extern "C" fn CTD_DINT(params: &mut CTDParams) { +pub extern "C" fn CTD_DINT(params: &mut CTDParams) { ctd(params); } ///. /// Counter down for UDINT /// -/// # Safety -/// Working with raw pointers -/// #[allow(non_snake_case)] #[no_mangle] -pub unsafe extern "C" fn CTD_UDINT(params: &mut CTDParams) { +pub extern "C" fn CTD_UDINT(params: &mut CTDParams) { ctd(params); } ///. /// Counter down for LINT /// -/// # Safety -/// Working with raw pointers -/// #[allow(non_snake_case)] #[no_mangle] -pub unsafe extern "C" fn CTD_LINT(params: &mut CTDParams) { +pub extern "C" fn CTD_LINT(params: &mut CTDParams) { ctd(params); } ///. /// Counter down for ULINT /// -/// # Safety -/// Working with raw pointers -/// #[allow(non_snake_case)] #[no_mangle] -pub unsafe extern "C" fn CTD_ULINT(params: &mut CTDParams) { +pub extern "C" fn CTD_ULINT(params: &mut CTDParams) { ctd(params); } @@ -253,27 +217,27 @@ impl CTUDParams where T: Integer + Copy, { - unsafe fn update_qu(&mut self) { + fn update_qu(&mut self) { self.qu = self.cv >= self.pv } - unsafe fn update_qd(&mut self) { + fn update_qd(&mut self) { self.qd = self.cv <= Zero::zero() } - unsafe fn reset(&mut self) { + fn reset(&mut self) { self.cv = Zero::zero() } - unsafe fn load(&mut self) { + fn load(&mut self) { self.cv = self.pv } - unsafe fn inc(&mut self) { + fn inc(&mut self) { self.cv = self.cv + One::one(); } - unsafe fn dec(&mut self) { + fn dec(&mut self) { self.cv = self.cv - One::one(); } @@ -286,7 +250,7 @@ where } } -unsafe fn ctud(params: &mut CTUDParams) +fn ctud(params: &mut CTUDParams) where T: Integer + Copy + Bounded, { @@ -312,71 +276,53 @@ where ///. /// Counter up and down for INT /// -/// # Safety -/// Working with raw pointers -/// #[allow(non_snake_case)] #[no_mangle] -pub unsafe extern "C" fn CTUD(params: &mut CTUDParams) { +pub extern "C" fn CTUD(params: &mut CTUDParams) { ctud(params); } ///. /// Counter up and down for INT /// -/// # Safety -/// Working with raw pointers -/// #[allow(non_snake_case)] #[no_mangle] -pub unsafe extern "C" fn CTUD_INT(params: &mut CTUDParams) { +pub extern "C" fn CTUD_INT(params: &mut CTUDParams) { ctud(params); } ///. /// Counter up and down for DINT /// -/// # Safety -/// Working with raw pointers -/// #[allow(non_snake_case)] #[no_mangle] -pub unsafe extern "C" fn CTUD_DINT(params: &mut CTUDParams) { +pub extern "C" fn CTUD_DINT(params: &mut CTUDParams) { ctud(params); } ///. /// Counter up and down for UDINT /// -/// # Safety -/// Working with raw pointers -/// #[allow(non_snake_case)] #[no_mangle] -pub unsafe extern "C" fn CTUD_UDINT(params: &mut CTUDParams) { +pub extern "C" fn CTUD_UDINT(params: &mut CTUDParams) { ctud(params); } ///. /// Counter up and down for LINT /// -/// # Safety -/// Working with raw pointers -/// #[allow(non_snake_case)] #[no_mangle] -pub unsafe extern "C" fn CTUD_LINT(params: &mut CTUDParams) { +pub extern "C" fn CTUD_LINT(params: &mut CTUDParams) { ctud(params); } ///. /// Counter up and down for ULINT /// -/// # Safety -/// Working with raw pointers -/// #[allow(non_snake_case)] #[no_mangle] -pub unsafe extern "C" fn CTUD_ULINT(params: &mut CTUDParams) { +pub extern "C" fn CTUD_ULINT(params: &mut CTUDParams) { ctud(params); } From 2da66ec5c90a2c24897af9f814d64fe393edb0a1 Mon Sep 17 00:00:00 2001 From: Kari Argillander Date: Fri, 24 Nov 2023 12:25:47 +0200 Subject: [PATCH 08/33] fix(stdlib): Endian conversion functions (#1029) Currently endian conversion functions work mostly very wrong. Also most of the test would also break in BE system. Only TO_*_ENDIAN() for other than float types does what they should. FROM_*_ENDIAN() for other than float types does conversion totally wrong. Normally we would do in IEC something like this (PSEUDO): address := FROM_LITTLE_ENDIAN(READ_MODBUS_ADDRESS_DWORD()); Now we would get big endian address even if we just wanted to document that we have checked that address should be little endian. In companies it is happit that every time they read/write to/from fieldbus they use FROM_*_ENDIAN/TO_*_ENDIAN conversion functions so it is obvious that it has been taken to account. Also floating points did not do any conversions as they first convert to x endian and then convert back to native. I also improve unittests so it is now obvious that when we do not touch res we should do same conversion for the some value. Co-authored-by: Kari Argillander Co-authored-by: Michael <78988079+mhasel@users.noreply.github.com> --- .../endianness_conversion_functions.st | 44 ++--- .../src/endianness_conversion_functions.rs | 48 +++--- .../endianness_conversion_functions_tests.rs | 152 ++++++++++-------- 3 files changed, 132 insertions(+), 112 deletions(-) diff --git a/libs/stdlib/iec61131-st/endianness_conversion_functions.st b/libs/stdlib/iec61131-st/endianness_conversion_functions.st index 4203d17ffc..34bfa01acf 100644 --- a/libs/stdlib/iec61131-st/endianness_conversion_functions.st +++ b/libs/stdlib/iec61131-st/endianness_conversion_functions.st @@ -1,8 +1,9 @@ -(******************** -* -* Converts little endian data format to big endian data format -* -*********************) +(****************************************************************************** +Description: Converts data to big endian format from native endian format. +Input: + - in: The input value in native endian format. +Return: The value converted to big endian format. +******************************************************************************) {external} FUNCTION TO_BIG_ENDIAN : T VAR_INPUT @@ -10,11 +11,12 @@ VAR_INPUT END_VAR END_FUNCTION -(******************** -* -* Converts big endian data format to little endian data format -* -*********************) +(****************************************************************************** +Description: Converts data to little endian format from big endian format. +Input: + - in: The input value in native endian format. +Return: The value converted to little endian format. +******************************************************************************) {external} FUNCTION TO_LITTLE_ENDIAN : T VAR_INPUT @@ -22,11 +24,12 @@ VAR_INPUT END_VAR END_FUNCTION -(******************** -* -* Converts to little endian data format from big endian data format -* -*********************) +(****************************************************************************** +Description: Converts data from big endian format to native endian format. +Input: + - in: The input value in big endian format. +Return: The value converted to native endian format. +******************************************************************************) {external} FUNCTION FROM_BIG_ENDIAN : T VAR_INPUT @@ -34,11 +37,12 @@ VAR_INPUT END_VAR END_FUNCTION -(******************** -* -* Converts to big endian data format from little endian data format -* -*********************) +(****************************************************************************** +Description: Converts data from little endian format to native endian format. +Input: + - in: The input value in little endian format. +Return: The value converted to native endian format. +******************************************************************************) {external} FUNCTION FROM_LITTLE_ENDIAN : T VAR_INPUT diff --git a/libs/stdlib/src/endianness_conversion_functions.rs b/libs/stdlib/src/endianness_conversion_functions.rs index 336c4536fc..9c5b716546 100644 --- a/libs/stdlib/src/endianness_conversion_functions.rs +++ b/libs/stdlib/src/endianness_conversion_functions.rs @@ -3,39 +3,39 @@ macro_rules! define_endianness_for_int_types { ( $st_type:tt, $t:ty ) => { paste! { /// . - /// Converts given integer type from little endian data format to big endian data format + /// Converts given integer type from native endian data format to big endian data format /// #[allow(non_snake_case)] #[no_mangle] pub fn [](input: $t) -> $t { - return input.to_be(); + input.to_be() } /// . - /// Converts given integer type from big endian data format to little endian data format + /// Converts given integer type from native endian data format to little endian data format /// #[allow(non_snake_case)] #[no_mangle] pub fn [](input: $t) -> $t { - return input.to_le(); + input.to_le() } /// . - /// Converts given integer type from big endian data format to little endian data format + /// Converts given integer type from big endian data format to native endian data format /// #[allow(non_snake_case)] #[no_mangle] pub fn [](input: $t) -> $t { - return input.to_le(); + <$t>::from_be(input) } /// . - /// Converts given integer type from little endian data format to big endian data format + /// Converts given integer type from little endian data format to native endian data format /// #[allow(non_snake_case)] #[no_mangle] pub fn [](input: $t) -> $t { - return input.to_be(); + <$t>::from_le(input) } } }; @@ -57,73 +57,73 @@ define_endianness_for_int_types!(TIME_OF_DAY, i64); define_endianness_for_int_types!(DATE_AND_TIME, i64); /// . -/// Converts given f32 from little endian data format to big endian data format +/// Converts given f32 from native endian data format to big endian data format /// #[allow(non_snake_case)] #[no_mangle] pub fn TO_BIG_ENDIAN__REAL(input: f32) -> f32 { - f32::from_be_bytes(input.to_be_bytes()) + f32::from_ne_bytes(input.to_be_bytes()) } /// . -/// Converts given f32 from big endian data format to little endian data format +/// Converts given f32 from native endian data format to little endian data format /// #[allow(non_snake_case)] #[no_mangle] pub fn TO_LITTLE_ENDIAN__REAL(input: f32) -> f32 { - f32::from_le_bytes(input.to_le_bytes()) + f32::from_ne_bytes(input.to_le_bytes()) } /// . -/// Converts given f32 from big endian data format to little endian data format +/// Converts given f32 from big endian data format to native endian data format /// #[allow(non_snake_case)] #[no_mangle] pub fn FROM_BIG_ENDIAN__REAL(input: f32) -> f32 { - f32::from_le_bytes(input.to_le_bytes()) + f32::from_be_bytes(input.to_ne_bytes()) } /// . -/// Converts given f32 from little endian data format to big endian data format +/// Converts given f32 from little endian data format to native endian data format /// #[allow(non_snake_case)] #[no_mangle] pub fn FROM_LITTLE_ENDIAN__REAL(input: f32) -> f32 { - f32::from_be_bytes(input.to_be_bytes()) + f32::from_le_bytes(input.to_ne_bytes()) } /// . -/// Converts given f64 from little endian data format to big endian data format +/// Converts given f64 from native endian data format to big endian data format /// #[allow(non_snake_case)] #[no_mangle] pub fn TO_BIG_ENDIAN__LREAL(input: f64) -> f64 { - f64::from_be_bytes(input.to_be_bytes()) + f64::from_ne_bytes(input.to_be_bytes()) } /// . -/// Converts given f64 from big endian data format to little endian data format +/// Converts given f64 from native endian data format to little endian data format /// #[allow(non_snake_case)] #[no_mangle] pub fn TO_LITTLE_ENDIAN__LREAL(input: f64) -> f64 { - f64::from_le_bytes(input.to_le_bytes()) + f64::from_ne_bytes(input.to_le_bytes()) } /// . -/// Converts given f64 from big endian data format to little endian data format +/// Converts given f64 from big endian data format to native endian data format /// #[allow(non_snake_case)] #[no_mangle] pub fn FROM_BIG_ENDIAN__LREAL(input: f64) -> f64 { - f64::from_le_bytes(input.to_le_bytes()) + f64::from_be_bytes(input.to_ne_bytes()) } /// . -/// Converts given f64 from little endian data format to big endian data format +/// Converts given f64 from little endian data format to native endian data format /// #[allow(non_snake_case)] #[no_mangle] pub fn FROM_LITTLE_ENDIAN__LREAL(input: f64) -> f64 { - f64::from_be_bytes(input.to_be_bytes()) + f64::from_le_bytes(input.to_ne_bytes()) } diff --git a/libs/stdlib/tests/endianness_conversion_functions_tests.rs b/libs/stdlib/tests/endianness_conversion_functions_tests.rs index 28a0c8aac1..27521fc701 100644 --- a/libs/stdlib/tests/endianness_conversion_functions_tests.rs +++ b/libs/stdlib/tests/endianness_conversion_functions_tests.rs @@ -17,7 +17,7 @@ fn test_to_big_endian_int() { let src = add_std!(src, "endianness_conversion_functions.st"); let res: i16 = compile_and_run_no_params(src); - assert_eq!(res, 0x0110) + assert_eq!(res, i16::to_be(0x1001)) } #[test] @@ -29,7 +29,7 @@ fn test_to_little_endian_int() { let src = add_std!(src, "endianness_conversion_functions.st"); let res: i16 = compile_and_run_no_params(src); - assert_eq!(res, 0x1001) + assert_eq!(res, i16::to_le(0x1001)) } #[test] @@ -41,7 +41,7 @@ fn test_from_big_endian_int() { let src = add_std!(src, "endianness_conversion_functions.st"); let res: i16 = compile_and_run_no_params(src); - assert_eq!(res, 0x1001) + assert_eq!(res, i16::from_be(0x1001)) } #[test] @@ -53,7 +53,7 @@ fn test_from_little_endian_int() { let src = add_std!(src, "endianness_conversion_functions.st"); let res: i16 = compile_and_run_no_params(src); - assert_eq!(res, 0x0110) + assert_eq!(res, i16::from_le(0x1001)) } ///-------------------------------DINT @@ -66,7 +66,7 @@ fn test_to_big_endian_dint() { let src = add_std!(src, "endianness_conversion_functions.st"); let res: i32 = compile_and_run_no_params(src); - assert_eq!(res, 0x0B0A0110) + assert_eq!(res, i32::to_be(0x10010A0B)) } #[test] @@ -78,7 +78,7 @@ fn test_to_little_endian_dint() { let src = add_std!(src, "endianness_conversion_functions.st"); let res: i32 = compile_and_run_no_params(src); - assert_eq!(res, 0x10010A0B) + assert_eq!(res, i32::to_le(0x10010A0B)) } #[test] @@ -90,7 +90,7 @@ fn test_from_big_endian_dint() { let src = add_std!(src, "endianness_conversion_functions.st"); let res: i32 = compile_and_run_no_params(src); - assert_eq!(res, 0x10010A0B) + assert_eq!(res, i32::from_be(0x10010A0B)) } #[test] @@ -102,7 +102,7 @@ fn test_from_little_endian_dint() { let src = add_std!(src, "endianness_conversion_functions.st"); let res: i32 = compile_and_run_no_params(src); - assert_eq!(res, 0x0B0A0110) + assert_eq!(res, i32::from_le(0x10010A0B)) } ///-------------------------------LINT @@ -115,7 +115,7 @@ fn test_to_big_endian_lint() { let src = add_std!(src, "endianness_conversion_functions.st"); let res: i64 = compile_and_run_no_params(src); - assert_eq!(res, 0x0B0A01100B0A0110) + assert_eq!(res, i64::to_be(0x10010A0B10010A0B)) } #[test] @@ -127,7 +127,7 @@ fn test_to_little_endian_lint() { let src = add_std!(src, "endianness_conversion_functions.st"); let res: i64 = compile_and_run_no_params(src); - assert_eq!(res, 0x10010A0B10010A0B) + assert_eq!(res, i64::to_le(0x10010A0B10010A0B)) } #[test] @@ -139,7 +139,7 @@ fn test_from_big_endian_lint() { let src = add_std!(src, "endianness_conversion_functions.st"); let res: i64 = compile_and_run_no_params(src); - assert_eq!(res, 0x10010A0B10010A0B) + assert_eq!(res, i64::from_be(0x10010A0B10010A0B)) } #[test] @@ -151,7 +151,7 @@ fn test_from_little_endian_lint() { let src = add_std!(src, "endianness_conversion_functions.st"); let res: i64 = compile_and_run_no_params(src); - assert_eq!(res, 0x0B0A01100B0A0110) + assert_eq!(res, i64::from_le(0x10010A0B10010A0B)) } ///-------------------------------UINT @@ -164,7 +164,7 @@ fn test_to_big_endian_uint() { let src = add_std!(src, "endianness_conversion_functions.st"); let res: u16 = compile_and_run_no_params(src); - assert_eq!(res, 0xBAAB) + assert_eq!(res, u16::to_be(0xABBA)) } #[test] @@ -176,7 +176,7 @@ fn test_to_little_endian_uint() { let src = add_std!(src, "endianness_conversion_functions.st"); let res: u16 = compile_and_run_no_params(src); - assert_eq!(res, 0x1001) + assert_eq!(res, u16::to_le(0x1001)) } #[test] @@ -188,7 +188,7 @@ fn test_from_big_endian_uint() { let src = add_std!(src, "endianness_conversion_functions.st"); let res: u16 = compile_and_run_no_params(src); - assert_eq!(res, 0x1001) + assert_eq!(res, u16::from_be(0x1001)) } #[test] @@ -200,7 +200,7 @@ fn test_from_little_endian_uint() { let src = add_std!(src, "endianness_conversion_functions.st"); let res: u16 = compile_and_run_no_params(src); - assert_eq!(res, 0xBAAB) + assert_eq!(res, u16::from_le(0xABBA)) } ///-------------------------------UDINT @@ -213,7 +213,7 @@ fn test_to_big_endian_udint() { let src = add_std!(src, "endianness_conversion_functions.st"); let res: u32 = compile_and_run_no_params(src); - assert_eq!(res, 0x0B0A0110) + assert_eq!(res, u32::to_be(0x10010A0B)) } #[test] @@ -225,7 +225,7 @@ fn test_to_little_endian_udint() { let src = add_std!(src, "endianness_conversion_functions.st"); let res: u32 = compile_and_run_no_params(src); - assert_eq!(res, 0x10010A0B) + assert_eq!(res, u32::to_le(0x10010A0B)) } #[test] @@ -237,7 +237,7 @@ fn test_from_big_endian_udint() { let src = add_std!(src, "endianness_conversion_functions.st"); let res: u32 = compile_and_run_no_params(src); - assert_eq!(res, 0x10010A0B) + assert_eq!(res, u32::from_be(0x10010A0B)) } #[test] @@ -249,7 +249,7 @@ fn test_from_little_endian_udint() { let src = add_std!(src, "endianness_conversion_functions.st"); let res: u32 = compile_and_run_no_params(src); - assert_eq!(res, 0x0B0A0110) + assert_eq!(res, u32::from_le(0x10010A0B)) } ///-------------------------------ULINT @@ -262,7 +262,7 @@ fn test_to_big_endian_ulint() { let src = add_std!(src, "endianness_conversion_functions.st"); let res: u64 = compile_and_run_no_params(src); - assert_eq!(res, 0x0B0A01100B0A0110) + assert_eq!(res, u64::to_be(0x10010A0B10010A0B)) } #[test] @@ -274,7 +274,7 @@ fn test_to_little_endian_ulint() { let src = add_std!(src, "endianness_conversion_functions.st"); let res: u64 = compile_and_run_no_params(src); - assert_eq!(res, 0x10010A0B10010A0B) + assert_eq!(res, u64::to_le(0x10010A0B10010A0B)) } #[test] @@ -286,7 +286,7 @@ fn test_from_big_endian_ulint() { let src = add_std!(src, "endianness_conversion_functions.st"); let res: u64 = compile_and_run_no_params(src); - assert_eq!(res, 0x10010A0B10010A0B) + assert_eq!(res, u64::from_be(0x10010A0B10010A0B)) } #[test] @@ -298,7 +298,7 @@ fn test_from_little_endian_ulint() { let src = add_std!(src, "endianness_conversion_functions.st"); let res: u64 = compile_and_run_no_params(src); - assert_eq!(res, 0x0B0A01100B0A0110) + assert_eq!(res, u64::from_le(0x10010A0B10010A0B)) } ///-------------------------------REAL @@ -311,19 +311,19 @@ fn test_to_big_endian_f32() { let src = add_std!(src, "endianness_conversion_functions.st"); let res: f32 = compile_and_run_no_params(src); - assert_eq!(res, f32::from_be_bytes(12.5_f32.to_be_bytes())) + assert_eq!(res, f32::from_ne_bytes(12.5_f32.to_be_bytes())) } #[test] fn test_to_little_endian_f32() { let src = r#"FUNCTION main : REAL - main := TO_BIG_ENDIAN(REAL#12.5); + main := TO_LITTLE_ENDIAN(REAL#12.5); END_FUNCTION "#; let src = add_std!(src, "endianness_conversion_functions.st"); let res: f32 = compile_and_run_no_params(src); - assert_eq!(res, 12.5_f32) + assert_eq!(res, f32::from_ne_bytes(12.5_f32.to_le_bytes())) } #[test] @@ -335,7 +335,7 @@ fn test_from_big_endian_f32() { let src = add_std!(src, "endianness_conversion_functions.st"); let res: f32 = compile_and_run_no_params(src); - assert_eq!(res, 12.5_f32) + assert_eq!(res, f32::from_be_bytes(12.5_f32.to_ne_bytes())) } #[test] @@ -347,7 +347,7 @@ fn test_from_little_endian_f32() { let src = add_std!(src, "endianness_conversion_functions.st"); let res: f32 = compile_and_run_no_params(src); - assert_eq!(res, f32::from_be_bytes(12.5_f32.to_be_bytes())) + assert_eq!(res, f32::from_le_bytes(12.5_f32.to_ne_bytes())) } ///-------------------------------LREAL @@ -360,19 +360,19 @@ fn test_to_big_endian_f64() { let src = add_std!(src, "endianness_conversion_functions.st"); let res: f64 = compile_and_run_no_params(src); - assert_eq!(res, f64::from_be_bytes(12.5_f64.to_be_bytes())) + assert_eq!(res, f64::from_ne_bytes(12.5_f64.to_be_bytes())) } #[test] fn test_to_little_endian_f64() { let src = r#"FUNCTION main : LREAL - main := TO_BIG_ENDIAN(LREAL#12.5); + main := TO_LITTLE_ENDIAN(LREAL#12.5); END_FUNCTION "#; let src = add_std!(src, "endianness_conversion_functions.st"); let res: f64 = compile_and_run_no_params(src); - assert_eq!(res, 12.5_f64) + assert_eq!(res, f64::from_ne_bytes(12.5_f64.to_le_bytes())) } #[test] @@ -384,7 +384,7 @@ fn test_from_big_endian_f64() { let src = add_std!(src, "endianness_conversion_functions.st"); let res: f64 = compile_and_run_no_params(src); - assert_eq!(res, 12.5_f64) + assert_eq!(res, f64::from_be_bytes(12.5_f64.to_ne_bytes())) } #[test] @@ -396,7 +396,7 @@ fn test_from_little_endian_f64() { let src = add_std!(src, "endianness_conversion_functions.st"); let res: f64 = compile_and_run_no_params(src); - assert_eq!(res, f64::from_be_bytes(12.5f64.to_be_bytes())) + assert_eq!(res, f64::from_le_bytes(12.5_f64.to_ne_bytes())) } ///-------------------------------WORD @@ -409,7 +409,7 @@ fn test_to_big_endian_word() { let src = add_std!(src, "endianness_conversion_functions.st"); let res: u16 = compile_and_run_no_params(src); - assert_eq!(res, 0xBAAB) + assert_eq!(res, u16::to_be(0xABBA)) } #[test] @@ -421,7 +421,7 @@ fn test_to_little_endian_word() { let src = add_std!(src, "endianness_conversion_functions.st"); let res: u16 = compile_and_run_no_params(src); - assert_eq!(res, 0x1001) + assert_eq!(res, u16::to_le(0x1001)) } #[test] @@ -433,7 +433,7 @@ fn test_from_big_endian_word() { let src = add_std!(src, "endianness_conversion_functions.st"); let res: u16 = compile_and_run_no_params(src); - assert_eq!(res, 0x1001) + assert_eq!(res, u16::from_be(0x1001)) } #[test] @@ -445,7 +445,7 @@ fn test_from_little_endian_word() { let src = add_std!(src, "endianness_conversion_functions.st"); let res: u16 = compile_and_run_no_params(src); - assert_eq!(res, 0xBAAB) + assert_eq!(res, u16::from_le(0xABBA)) } ///-------------------------------DWORD @@ -458,7 +458,7 @@ fn test_to_big_endian_dword() { let src = add_std!(src, "endianness_conversion_functions.st"); let res: u32 = compile_and_run_no_params(src); - assert_eq!(res, 0x0B0A0110) + assert_eq!(res, u32::to_be(0x10010A0B)) } #[test] @@ -470,7 +470,7 @@ fn test_to_little_endian_dword() { let src = add_std!(src, "endianness_conversion_functions.st"); let res: u32 = compile_and_run_no_params(src); - assert_eq!(res, 0x10010A0B) + assert_eq!(res, u32::to_le(0x10010A0B)) } #[test] @@ -482,7 +482,7 @@ fn test_from_big_endian_dword() { let src = add_std!(src, "endianness_conversion_functions.st"); let res: u32 = compile_and_run_no_params(src); - assert_eq!(res, 0x10010A0B) + assert_eq!(res, u32::from_be(0x10010A0B)) } #[test] @@ -494,7 +494,7 @@ fn test_from_little_endian_dword() { let src = add_std!(src, "endianness_conversion_functions.st"); let res: u32 = compile_and_run_no_params(src); - assert_eq!(res, 0x0B0A0110) + assert_eq!(res, u32::from_le(0x10010A0B)) } ///-------------------------------LWORD @@ -507,7 +507,7 @@ fn test_to_big_endian_lword() { let src = add_std!(src, "endianness_conversion_functions.st"); let res: u64 = compile_and_run_no_params(src); - assert_eq!(res, 0x0B0A01100B0A0110) + assert_eq!(res, u64::to_be(0x10010A0B10010A0B)) } #[test] @@ -519,7 +519,7 @@ fn test_to_little_endian_lword() { let src = add_std!(src, "endianness_conversion_functions.st"); let res: u64 = compile_and_run_no_params(src); - assert_eq!(res, 0x10010A0B10010A0B) + assert_eq!(res, u64::to_le(0x10010A0B10010A0B)) } #[test] @@ -531,7 +531,7 @@ fn test_from_big_endian_lword() { let src = add_std!(src, "endianness_conversion_functions.st"); let res: u64 = compile_and_run_no_params(src); - assert_eq!(res, 0x10010A0B10010A0B) + assert_eq!(res, u64::from_be(0x10010A0B10010A0B)) } #[test] @@ -543,7 +543,7 @@ fn test_from_little_endian_lword() { let src = add_std!(src, "endianness_conversion_functions.st"); let res: u64 = compile_and_run_no_params(src); - assert_eq!(res, 0x0B0A01100B0A0110) + assert_eq!(res, u64::from_le(0x10010A0B10010A0B)) } ///-------------------------------WCHAR @@ -556,7 +556,7 @@ fn test_to_big_endian_wchar() { let src = add_std!(src, "endianness_conversion_functions.st"); let res: u16 = compile_and_run_no_params(src); - assert_eq!(res, 0x4300) + assert_eq!(res, u16::to_be('C' as u16)) } #[test] @@ -568,7 +568,7 @@ fn test_to_little_endian_wchar() { let src = add_std!(src, "endianness_conversion_functions.st"); let res: u16 = compile_and_run_no_params(src); - assert_eq!(res, 0x0043) + assert_eq!(res, u16::to_le('C' as u16)) } #[test] @@ -580,7 +580,7 @@ fn test_from_big_endian_wchar() { let src = add_std!(src, "endianness_conversion_functions.st"); let res: u16 = compile_and_run_no_params(src); - assert_eq!(res, 0x0043) + assert_eq!(res, u16::from_be('C' as u16)) } #[test] @@ -592,7 +592,7 @@ fn test_from_little_endian_wchar() { let src = add_std!(src, "endianness_conversion_functions.st"); let res: u16 = compile_and_run_no_params(src); - assert_eq!(res, 0x4300) + assert_eq!(res, u16::from_le('C' as u16)) } ///-------------------------------DATE @@ -620,7 +620,7 @@ fn test_to_little_endian_date() { let res: i64 = compile_and_run_no_params(src); assert_eq!( res, - NaiveDate::from_ymd_opt(1984, 6, 25).unwrap().and_hms_opt(0, 0, 0).unwrap().timestamp_nanos() + NaiveDate::from_ymd_opt(1984, 6, 25).unwrap().and_hms_opt(0, 0, 0).unwrap().timestamp_nanos().to_le() ) } @@ -634,7 +634,9 @@ fn test_from_big_endian_date() { let res: i64 = compile_and_run_no_params(src); assert_eq!( res, - NaiveDate::from_ymd_opt(1984, 6, 25).unwrap().and_hms_opt(0, 0, 0).unwrap().timestamp_nanos() + i64::from_be( + NaiveDate::from_ymd_opt(1984, 6, 25).unwrap().and_hms_opt(0, 0, 0).unwrap().timestamp_nanos() + ) ) } @@ -648,7 +650,9 @@ fn test_from_little_endian_date() { let res: i64 = compile_and_run_no_params(src); assert_eq!( res, - NaiveDate::from_ymd_opt(1984, 6, 25).unwrap().and_hms_opt(0, 0, 0).unwrap().timestamp_nanos().to_be() + i64::from_le( + NaiveDate::from_ymd_opt(1984, 6, 25).unwrap().and_hms_opt(0, 0, 0).unwrap().timestamp_nanos() + ) ) } @@ -674,7 +678,7 @@ fn test_to_little_endian_tod() { let src = add_std!(src, "endianness_conversion_functions.st"); let res: i64 = compile_and_run_no_params(src); - assert_eq!(res, DURATION_NANOS) + assert_eq!(res, DURATION_NANOS.to_le()) } #[test] @@ -686,7 +690,7 @@ fn test_from_big_endian_tod() { let src = add_std!(src, "endianness_conversion_functions.st"); let res: i64 = compile_and_run_no_params(src); - assert_eq!(res, DURATION_NANOS) + assert_eq!(res, i64::from_be(DURATION_NANOS)) } #[test] @@ -698,7 +702,7 @@ fn test_from_little_endian_tod() { let src = add_std!(src, "endianness_conversion_functions.st"); let res: i64 = compile_and_run_no_params(src); - assert_eq!(res, DURATION_NANOS.to_be()) + assert_eq!(res, i64::from_le(DURATION_NANOS)) } ///-------------------------------DT @@ -728,7 +732,7 @@ fn test_to_little_endian_dt() { let res: i64 = compile_and_run_no_params(src); assert_eq!( res, - NaiveDate::from_ymd_opt(1984, 6, 25).unwrap().and_hms_opt(0, 0, 0).unwrap().timestamp_nanos() + NaiveDate::from_ymd_opt(1984, 6, 25).unwrap().and_hms_opt(0, 0, 0).unwrap().timestamp_nanos().to_le() ) } @@ -743,7 +747,9 @@ fn test_from_big_endian_dt() { let res: i64 = compile_and_run_no_params(src); assert_eq!( res, - NaiveDate::from_ymd_opt(1984, 6, 25).unwrap().and_hms_opt(0, 0, 0).unwrap().timestamp_nanos() + i64::from_be( + NaiveDate::from_ymd_opt(1984, 6, 25).unwrap().and_hms_opt(0, 0, 0).unwrap().timestamp_nanos() + ) ) } @@ -758,7 +764,9 @@ fn test_from_little_endian_dt() { let res: i64 = compile_and_run_no_params(src); assert_eq!( res, - NaiveDate::from_ymd_opt(1984, 6, 25).unwrap().and_hms_opt(0, 0, 0).unwrap().timestamp_nanos().to_be() + i64::from_le( + NaiveDate::from_ymd_opt(1984, 6, 25).unwrap().and_hms_opt(0, 0, 0).unwrap().timestamp_nanos() + ) ) } @@ -790,7 +798,7 @@ fn test_to_little_endian_ldate_nanos() { let res: i64 = compile_and_run_no_params(src); assert_eq!( res, - NaiveDate::from_ymd_opt(1984, 6, 25).unwrap().and_hms_opt(0, 0, 0).unwrap().timestamp_nanos() + NaiveDate::from_ymd_opt(1984, 6, 25).unwrap().and_hms_opt(0, 0, 0).unwrap().timestamp_nanos().to_le() ) } @@ -805,7 +813,9 @@ fn test_from_big_endian_ldate_nanos() { let res: i64 = compile_and_run_no_params(src); assert_eq!( res, - NaiveDate::from_ymd_opt(1984, 6, 25).unwrap().and_hms_opt(0, 0, 0).unwrap().timestamp_nanos() + i64::from_be( + NaiveDate::from_ymd_opt(1984, 6, 25).unwrap().and_hms_opt(0, 0, 0).unwrap().timestamp_nanos() + ) ) } @@ -820,7 +830,9 @@ fn test_from_little_endian_ldate_nanos() { let res: i64 = compile_and_run_no_params(src); assert_eq!( res, - NaiveDate::from_ymd_opt(1984, 6, 25).unwrap().and_hms_opt(0, 0, 0).unwrap().timestamp_nanos().to_be() + i64::from_le( + NaiveDate::from_ymd_opt(1984, 6, 25).unwrap().and_hms_opt(0, 0, 0).unwrap().timestamp_nanos() + ) ) } @@ -857,7 +869,7 @@ fn test_to_little_endian_ldt_nanos() { let res: i64 = compile_and_run_no_params(src); assert_eq!( res, - NaiveDate::from_ymd_opt(1984, 6, 25).unwrap().and_hms_opt(0, 0, 0).unwrap().timestamp_nanos() + NaiveDate::from_ymd_opt(1984, 6, 25).unwrap().and_hms_opt(0, 0, 0).unwrap().timestamp_nanos().to_le() ) } @@ -872,7 +884,9 @@ fn test_from_big_endian_nanos() { let res: i64 = compile_and_run_no_params(src); assert_eq!( res, - NaiveDate::from_ymd_opt(1984, 6, 25).unwrap().and_hms_opt(0, 0, 0).unwrap().timestamp_nanos() + i64::from_be( + NaiveDate::from_ymd_opt(1984, 6, 25).unwrap().and_hms_opt(0, 0, 0).unwrap().timestamp_nanos() + ) ) } @@ -887,7 +901,9 @@ fn test_from_little_endian_nanos() { let res: i64 = compile_and_run_no_params(src); assert_eq!( res, - NaiveDate::from_ymd_opt(1984, 6, 25).unwrap().and_hms_opt(0, 0, 0).unwrap().timestamp_nanos().to_be() + i64::from_le( + NaiveDate::from_ymd_opt(1984, 6, 25).unwrap().and_hms_opt(0, 0, 0).unwrap().timestamp_nanos() + ) ) } @@ -913,7 +929,7 @@ fn test_to_little_endian_ltod_nanos() { let src = add_std!(src, "endianness_conversion_functions.st"); let res: i64 = compile_and_run_no_params(src); - assert_eq!(res, DURATION_NANOS) + assert_eq!(res, DURATION_NANOS.to_le()) } #[test] @@ -925,7 +941,7 @@ fn test_from_big_endian_ltod_nanos() { let src = add_std!(src, "endianness_conversion_functions.st"); let res: i64 = compile_and_run_no_params(src); - assert_eq!(res, DURATION_NANOS) + assert_eq!(res, i64::from_be(DURATION_NANOS)) } #[test] @@ -937,5 +953,5 @@ fn test_from_little_endian_ltod_nanos() { let src = add_std!(src, "endianness_conversion_functions.st"); let res: i64 = compile_and_run_no_params(src); - assert_eq!(res, DURATION_NANOS.to_be()) + assert_eq!(res, i64::from_le(DURATION_NANOS)) } From ff4027c0523775a8604aff936f13ca2c3d56c65b Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 29 Nov 2023 06:42:15 +0100 Subject: [PATCH 09/33] chore: Bump openssl from 0.10.57 to 0.10.60 (#1042) Bumps [openssl](https://github.com/sfackler/rust-openssl) from 0.10.57 to 0.10.60. - [Release notes](https://github.com/sfackler/rust-openssl/releases) - [Commits](https://github.com/sfackler/rust-openssl/compare/openssl-v0.10.57...openssl-v0.10.60) --- updated-dependencies: - dependency-name: openssl dependency-type: indirect ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- Cargo.lock | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 5e5cbeda91..8e252c885d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1725,9 +1725,9 @@ checksum = "dd8b5dd2ae5ed71462c540258bedcb51965123ad7e7ccf4b9a8cafaa4a63576d" [[package]] name = "openssl" -version = "0.10.57" +version = "0.10.60" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bac25ee399abb46215765b1cb35bc0212377e58a061560d8b29b024fd0430e7c" +checksum = "79a4c6c3a2b158f7f8f2a2fc5a969fa3a068df6fc9dbb4a43845436e3af7c800" dependencies = [ "bitflags 2.4.0", "cfg-if", @@ -1757,9 +1757,9 @@ checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" [[package]] name = "openssl-sys" -version = "0.9.93" +version = "0.9.96" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "db4d56a4c0478783083cfafcc42493dd4a981d41669da64b4572a2a089b51b1d" +checksum = "3812c071ba60da8b5677cc12bcb1d42989a65553772897a7e0355545a819838f" dependencies = [ "cc", "libc", From 23e6139e5415a8fd143a937921a85af1e419259a Mon Sep 17 00:00:00 2001 From: Volkan Date: Wed, 29 Nov 2023 14:16:40 +0100 Subject: [PATCH 10/33] feat(validation): Initializers of struct fields (#1032) This commit validates the initializers of struct fields --- src/typesystem.rs | 4 ++++ src/validation.rs | 9 +++++++++ src/validation/array.rs | 4 ++++ ...initializers_in_structs_are_validated.snap | 17 ++++++++++++++++ .../tests/variable_validation_tests.rs | 20 +++++++++++++++++++ src/validation/types.rs | 1 + src/validation/variable.rs | 1 - 7 files changed, 55 insertions(+), 1 deletion(-) create mode 100644 src/validation/tests/snapshots/rusty__validation__tests__variable_validation_tests__type_initializers_in_structs_are_validated.snap diff --git a/src/typesystem.rs b/src/typesystem.rs index 0464632cb4..2a9bd3f4e4 100644 --- a/src/typesystem.rs +++ b/src/typesystem.rs @@ -701,6 +701,10 @@ impl DataTypeInformation { let inner_type_size = inner_type_info.get_size_in_bits(index); let arr_size = self.get_size_in_bits(index); + if inner_type_size == 0 { + return None; + } + Some((arr_size / inner_type_size) as usize) } } diff --git a/src/validation.rs b/src/validation.rs index d42f7ca71c..ec948f745b 100644 --- a/src/validation.rs +++ b/src/validation.rs @@ -48,6 +48,15 @@ impl<'s, T: AnnotationMap> ValidationContext<'s, T> { } } + fn with_optional_qualifier(&self, qualifier: Option<&'s str>) -> Self { + ValidationContext { + annotations: self.annotations, + index: self.index, + qualifier, + is_call: self.is_call, + } + } + fn find_pou(&self, stmt: &AstNode) -> Option<&PouIndexEntry> { self.annotations.get_call_name(stmt).and_then(|pou_name| { self.index diff --git a/src/validation/array.rs b/src/validation/array.rs index 8e591c6871..d96bf767c2 100644 --- a/src/validation/array.rs +++ b/src/validation/array.rs @@ -58,6 +58,10 @@ fn validate_array( let len_lhs = lhs_type.get_array_length(context.index).unwrap_or(0); let len_rhs = statement_to_array_length(stmt_rhs); + if len_lhs == 0 { + return; + } + if len_lhs < len_rhs { let name = lhs_type.get_name(); let location = stmt_rhs.get_location(); diff --git a/src/validation/tests/snapshots/rusty__validation__tests__variable_validation_tests__type_initializers_in_structs_are_validated.snap b/src/validation/tests/snapshots/rusty__validation__tests__variable_validation_tests__type_initializers_in_structs_are_validated.snap new file mode 100644 index 0000000000..e5529788e5 --- /dev/null +++ b/src/validation/tests/snapshots/rusty__validation__tests__variable_validation_tests__type_initializers_in_structs_are_validated.snap @@ -0,0 +1,17 @@ +--- +source: src/validation/tests/variable_validation_tests.rs +expression: diagnostics +--- +error: Could not resolve reference to xxx + ┌─ :7:41 + │ +7 │ unknown_reference : foo := (xxx := 1); + │ ^^^ Could not resolve reference to xxx + +error: Array assignments must be surrounded with `[]` + ┌─ :8:62 + │ +8 │ invalid_array_assignment : ARRAY[0..1] OF INT := 0; + │ ^ Array assignments must be surrounded with `[]` + + diff --git a/src/validation/tests/variable_validation_tests.rs b/src/validation/tests/variable_validation_tests.rs index 1317ac49a3..27a3c4af7a 100644 --- a/src/validation/tests/variable_validation_tests.rs +++ b/src/validation/tests/variable_validation_tests.rs @@ -1,4 +1,6 @@ +use crate::test_utils::tests::parse_and_validate_buffered; use crate::{assert_validation_snapshot, test_utils::tests::parse_and_validate}; +use insta::assert_snapshot; #[test] fn uninitialized_constants_fall_back_to_the_default() { @@ -360,3 +362,21 @@ mod overflows { assert_validation_snapshot!(diagnostics); } } + +#[test] +fn type_initializers_in_structs_are_validated() { + let diagnostics = parse_and_validate_buffered( + " + TYPE foo : STRUCT + x : DINT; + END_STRUCT END_TYPE + + TYPE MyStruct: STRUCT + unknown_reference : foo := (xxx := 1); + invalid_array_assignment : ARRAY[0..1] OF INT := 0; + END_STRUCT END_TYPE + ", + ); + + assert_snapshot!(diagnostics); +} diff --git a/src/validation/types.rs b/src/validation/types.rs index b85ad9a60b..af27651df1 100644 --- a/src/validation/types.rs +++ b/src/validation/types.rs @@ -28,6 +28,7 @@ pub fn visit_data_type( ) { validate_data_type(validator, data_type, location); + let context = &context.with_optional_qualifier(data_type.get_name()); match data_type { DataType::StructType { variables, .. } => { variables.iter().for_each(|v| visit_variable(validator, v, context)) diff --git a/src/validation/variable.rs b/src/validation/variable.rs index 234f95f74f..75723101a4 100644 --- a/src/validation/variable.rs +++ b/src/validation/variable.rs @@ -43,7 +43,6 @@ pub fn visit_variable( context: &ValidationContext, ) { validate_variable(validator, variable, context); - visit_data_type_declaration(validator, &variable.data_type_declaration, context); } From 5615d80b4a45be2d72613e8ccdd09726ac46aaff Mon Sep 17 00:00:00 2001 From: Kari Argillander Date: Fri, 1 Dec 2023 08:23:23 +0200 Subject: [PATCH 11/33] refactor: add Pre-commit + editorconfig + gitattributes (#1034) * Fix indentation levels cause by tabs In many places indentation level is little of because tabs where used. Probably someone might have example tabs size 2. Let's fix these by hand as automatic tools cannot fix these for us. They can prevent them from happening but fixing is not easy. * Fix unicode replacement chars These seems like accidents so remove those so we can start verify whole repo against those. In combined.st I changed language to english as it seems it should be. * Change all line-endings to LF in whole project There where not many files which where with CRLF. So it looks like we should always use LF. Let's fix couple files and then make sure this does not happen again. I also have some other problems with some of these files as I get strange douple newlines. * Add .gitattributes to force line-ending LF Force line-endings to LF. It could probably also be auto, but unless someone complain let's keep it LF. This will help that we have unified way for line-endings so we do not get those accidental commits where whole file is just big diff because line-ending change. * Add .pre-commit-config.yaml and .editorconfig With these we can automate lot of formatting issues with all files. We also get cleaner commits as every commit will be check with various small checkers. * Add editorconfig extension to devcontainer Now that we have editorconfig file it make sense to add it also to VScode as it does not support it out of the box. * ci: Remove submodules checks as we do not have any We do not have submodules so we do not need to check those. * format: Strip trailing whitespaces We want to get rid of trailing whitespaces completly as they make just git noice. Much better to start using automated tools to get rid of them once and not getting them back again. This way git history will be cleaner and review easyer. Commit was generated with: pre-commit run --all-files trailing-whitespace * format: File should have exacly one new line end of them It is good practice that every file has one new line. It is not now days so mandatory but it also is not nice if file has lot of newlines end of it. We will use pre-commit which takes automatically care about this so let's fix all. Commit was generated with: pre-commit run --all-files end-of-file-fixer * format: Run Black for whole repo Currently we only have one python file but is is nice if we have same formatting for all files. We will use Black for this. Commit was generated with: pre-commit run --all-files black * format: Convert tabs to spaces Project mostly use spaces over tabs. When mixing tabs and spaces this usually makes formatting issues and also when changing those in commits it will make lot of git noise. We will force spaces so just convert everything to tabs already. We did also have some users who tab wide was 2 and some 4. This is very common in projects to happen. Using pre-commit for these we can basically prevent this. Commit was generated with: pre-commit run --all-files remove-tabs * Regenerate test snapshots As we have changed style and example removed whitespaces we need to regenerate all test snapshots. Commit was generated with: ./pre-py/snap-pre.sh; cargo test --all; ./pre-py/snap-rework.sh; cargo test --all; ./pre-py/snap-rework.sh --------- Co-authored-by: Kari Argillander --- .cargo/config.toml | 2 +- .devcontainer/Dockerfile | 2 +- .devcontainer/devcontainer.json | 71 +- .editorconfig | 12 + .gitattributes | 2 + .github/workflows/doc.yml | 2 - .github/workflows/metrics.yml | 2 +- .github/workflows/rust.yml | 14 +- .pre-commit-config.yaml | 75 + .vscode/launch.json | 2 +- Cargo.toml | 24 +- book/iecst.min.js | 2 +- book/llvm.min.js | 2 +- book/src/arch/architecture.md | 2 +- book/src/arch/codegen.md | 16 +- book/src/arch/linker.md | 17 +- book/src/arch/parser.md | 2 +- book/src/build_and_install.md | 8 +- book/src/cfc/cfc.md | 8 +- book/src/cfc/m2m.md | 14 +- book/src/direct_variables.md | 158 +- book/src/libraries.md | 2 +- book/src/libraries/external_functions.md | 2 +- book/src/pous.md | 4 +- book/src/using_rusty.md | 4 +- compiler/plc_driver/src/cli.rs | 2 +- .../plc_driver/src/tests/external_files.rs | 12 +- compiler/plc_project/schema/plc-json.schema | 4 +- compiler/plc_xml/README.md | 2 +- compiler/plc_xml/src/model/action.rs | 4 +- ...ests__list_of_actions_parsed_to_model.snap | 2 +- compiler/plc_xml/src/xml_parser/tests.rs | 2 +- examples/ExternalFunctions.st | 4 +- examples/actions.st | 14 +- examples/class_method.st | 2 +- examples/function_with_return.st | 16 +- examples/hello_world.st | 4 +- examples/lt.st | 2 +- examples/math_st.c | 5 - examples/plc.json | 2 +- examples/pointer.st | 12 +- examples/program_with_references.st | 2 +- .../program_with_variable_and_operation.st | 6 +- examples/simple_program.st | 9 +- libs/stdlib/.gitignore | 2 +- .../iec61131-st/arithmetic_functions.st | 168 +- .../iec61131-st/bistable_functionblocks.st | 14 +- libs/stdlib/iec61131-st/bit_conversion.st | 158 +- libs/stdlib/iec61131-st/bit_num_conversion.st | 298 +- .../stdlib/iec61131-st/bit_shift_functions.st | 55 +- libs/stdlib/iec61131-st/counters.st | 266 +- .../iec61131-st/date_time_conversion.st | 54 +- .../iec61131-st/date_time_extra_functions.st | 780 ++--- .../date_time_numeric_functions.st | 178 +- .../endianness_conversion_functions.st | 9 +- libs/stdlib/iec61131-st/extra_functions.st | 2 +- libs/stdlib/iec61131-st/flanks.st | 26 +- libs/stdlib/iec61131-st/num_conversion.st | 362 +- .../stdlib/iec61131-st/numerical_functions.st | 58 +- libs/stdlib/iec61131-st/selectors.st | 20 +- libs/stdlib/iec61131-st/string_conversion.st | 56 +- libs/stdlib/iec61131-st/string_functions.st | 108 +- libs/stdlib/iec61131-st/timers.st | 122 +- .../iec61131-st/validation_functions.st | 6 +- .../tests/arithmetic_functions_tests.rs | 32 +- .../tests/bistable_functionblocks_tests.rs | 60 +- libs/stdlib/tests/bit_conversion_tests.rs | 712 ++-- libs/stdlib/tests/bit_num_conversion_tests.rs | 1384 ++++---- libs/stdlib/tests/counters_tests.rs | 768 ++--- .../tests/date_time_conversion_tests.rs | 72 +- .../tests/date_time_extra_functions_tests.rs | 848 ++--- .../date_time_numeric_functions_tests.rs | 754 ++-- .../endianness_conversion_functions_tests.rs | 144 +- libs/stdlib/tests/extra_function_tests.rs | 32 +- libs/stdlib/tests/num_conversion_tests.rs | 3048 ++++++++--------- libs/stdlib/tests/string_conversion_tests.rs | 148 +- libs/stdlib/tests/string_function_tests.rs | 242 +- .../tests/validation_functions_tests.rs | 204 +- libs/stdlib/utils/code_gen.py | 18 +- scripts/build.sh | 722 ++-- scripts/cargo_watch.sh | 4 +- scripts/common.sh | 128 +- src/codegen/generators/llvm.rs | 2 +- src/codegen/generators/pou_generator.rs | 4 +- src/codegen/tests/code_gen_tests.rs | 556 +-- .../tests/codegen_error_messages_tests.rs | 128 +- .../tests/compare_instructions_tests.rs | 152 +- src/codegen/tests/constants_tests.rs | 54 +- src/codegen/tests/debug_tests.rs | 14 +- .../tests/debug_tests/expression_debugging.rs | 4 +- src/codegen/tests/expression_tests.rs | 130 +- src/codegen/tests/function_tests.rs | 18 +- src/codegen/tests/generics_test.rs | 76 +- .../global_initializers.rs | 30 +- .../initialization_test/pou_initializers.rs | 76 +- ...lizers__unresolvable_types_validation.snap | 4 +- .../initialization_test/type_initializers.rs | 174 +- src/codegen/tests/parameters_tests.rs | 800 ++--- ...ring_literal_to_char_results_in_error.snap | 6 +- ...literal_to_wide_char_results_in_error.snap | 6 +- ...int_variable_results_in_casting_error.snap | 6 +- ...binary_expression_adding_two_pointers.snap | 6 +- ...s__pointer_binary_expression_division.snap | 6 +- ...sts__pointer_binary_expression_modulo.snap | 6 +- ...nter_binary_expression_multiplication.snap | 6 +- ...with_invalid_casted_string_assignment.snap | 2 +- ...ialization_of_multi_dim_string_arrays.snap | 4 +- src/codegen/tests/string_tests.rs | 58 +- src/codegen/tests/switch_case_tests.rs | 164 +- src/codegen/tests/typesystem_test.rs | 6 +- src/index.rs | 2 +- src/index/tests/index_tests.rs | 170 +- src/index/tests/instance_resolver_tests.rs | 16 +- ...ex_tests__fb_parameters_variable_type.snap | 24 +- ...ts__function_parameters_variable_type.snap | 32 +- ...sts__program_parameters_variable_type.snap | 24 +- ...r_tests__array_instances_are_repeated.snap | 32 +- ...ray_with_const_instances_are_repeated.snap | 20 +- ...ests__filter_on_variables_are_applied.snap | 20 +- ...ts__global_fb_variables_are_retrieved.snap | 28 +- ...global_struct_variables_are_retrieved.snap | 28 +- ...global_struct_variables_are_retrieved.snap | 60 +- ...__pointer_variables_are_not_retrieved.snap | 8 +- src/lexer/tests/lexer_tests.rs | 46 +- src/parser/tests/class_parser_tests.rs | 4 +- src/parser/tests/control_parser_tests.rs | 56 +- src/parser/tests/expressions_parser_tests.rs | 126 +- src/parser/tests/function_parser_tests.rs | 4 +- src/parser/tests/misc_parser_tests.rs | 2 +- .../parse_error_containers_tests.rs | 4 +- .../parse_error_literals_tests.rs | 8 +- .../parse_errors/parse_error_messages_test.rs | 10 +- .../parse_error_statements_tests.rs | 34 +- src/parser/tests/parse_generics.rs | 12 +- ...rameter_assignments_in_call_statement.snap | 24 +- ...parser_tests__global_var_with_address.snap | 2 +- ...le_parser_tests__pou_var_with_address.snap | 2 +- ...ble_parser_tests__struct_with_address.snap | 2 +- src/parser/tests/statement_parser_tests.rs | 32 +- src/parser/tests/type_parser_tests.rs | 24 +- src/parser/tests/variable_parser_tests.rs | 48 +- src/resolver/generics.rs | 2 +- src/resolver/tests/const_resolver_tests.rs | 52 +- .../tests/resolve_control_statments.rs | 2 +- .../tests/resolve_expressions_tests.rs | 180 +- src/resolver/tests/resolve_generic_calls.rs | 32 +- src/resolver/tests/resolve_literals_tests.rs | 32 +- .../tests/resolver_dependency_resolution.rs | 26 +- src/tests/adr/annotated_ast_adr.rs | 40 +- src/tests/adr/arrays_adr.rs | 2 +- src/tests/adr/enum_adr.rs | 2 +- src/tests/adr/pou_adr.rs | 44 +- src/tests/adr/vla_adr.rs | 22 +- src/validation/statement.rs | 2 +- src/validation/tests/array_validation_test.rs | 422 +-- .../tests/assignment_validation_tests.rs | 216 +- .../tests/bitaccess_validation_test.rs | 18 +- .../tests/duplicates_validation_test.rs | 8 +- .../tests/generic_validation_tests.rs | 340 +- .../tests/literals_validation_tests.rs | 26 +- src/validation/tests/pou_validation_tests.rs | 18 +- .../tests/recursive_validation_tests.rs | 46 +- .../tests/reference_resolve_tests.rs | 26 +- ...test__array_access_dimension_mismatch.snap | 24 +- ...idation_test__array_access_validation.snap | 48 +- ...test__array_initialization_validation.snap | 60 +- ..._array_validation_test__assignment_1d.snap | 78 +- ..._array_validation_test__assignment_2d.snap | 60 +- ..._array_validation_test__assignment_3d.snap | 54 +- ...test__assignment_multiplied_statement.snap | 60 +- ...y_validation_test__assignment_structs.snap | 36 +- ...on_tests__array_assignment_validation.snap | 34 +- ...tion_tests__bit_assignment_validation.snap | 14 +- ...ion_tests__char_assignment_validation.snap | 50 +- ...tests__constant_assignment_validation.snap | 2 +- ...ion_tests__date_assignment_validation.snap | 14 +- ...tests__duration_assignment_validation.snap | 14 +- ...idation_tests__enum_variants_mismatch.snap | 8 +- ...plicit_action_downcasts_are_validated.snap | 2 +- ...action_call_assignments_are_validated.snap | 4 +- ...tion_tests__int_assignment_validation.snap | 28 +- ...tion_block_instantiation_is_validated.snap | 8 +- ...method_call_assignments_are_validated.snap | 4 +- ..._tests__pointer_assignment_validation.snap | 18 +- ...ion_tests__real_assignment_validation.snap | 14 +- ...n_tests__string_assignment_validation.snap | 38 +- ...n_tests__struct_assignment_validation.snap | 22 +- ...ion_test__bitaccess_only_on_bit_types.snap | 6 +- ...validation_test__bitaccess_range_test.snap | 8 +- ...test__byteaccess_only_on_bigger_sizes.snap | 6 +- ...alidation_test__byteaccess_range_test.snap | 6 +- ...est__dwordaccess_only_on_bigger_sizes.snap | 6 +- ...lidation_test__dwordaccess_range_test.snap | 2 +- ...eference_direct_access_only_with_ints.snap | 4 +- ...test__wordaccess_only_on_bigger_sizes.snap | 6 +- ...alidation_test__wordaccess_range_test.snap | 4 +- ..._duplicate_action_should_be_a_problem.snap | 4 +- ...n_tests__any_bit_does_not_allow_chars.snap | 4 +- ...on_tests__any_bit_does_not_allow_date.snap | 8 +- ...on_tests__any_bit_does_not_allow_ints.snap | 16 +- ...on_tests__any_bit_does_not_allow_time.snap | 2 +- ...n_tests__any_char_does_not_allow_bits.snap | 16 +- ...n_tests__any_char_does_not_allow_date.snap | 16 +- ...n_tests__any_char_does_not_allow_ints.snap | 32 +- ...n_tests__any_char_does_not_allow_time.snap | 4 +- ..._tests__any_chars_does_not_allow_bits.snap | 16 +- ..._tests__any_chars_does_not_allow_date.snap | 16 +- ..._tests__any_chars_does_not_allow_ints.snap | 32 +- ..._tests__any_chars_does_not_allow_time.snap | 4 +- ...n_tests__any_date_does_not_allow_bits.snap | 8 +- ..._tests__any_date_does_not_allow_chars.snap | 4 +- ...n_tests__any_date_does_not_allow_ints.snap | 16 +- ...n_tests__any_date_does_not_allow_time.snap | 2 +- ...sts__any_duration_does_not_allow_bits.snap | 8 +- ...ts__any_duration_does_not_allow_chars.snap | 4 +- ...sts__any_duration_does_not_allow_date.snap | 8 +- ...sts__any_duration_does_not_allow_ints.snap | 16 +- ...on_tests__any_int_does_not_allow_bits.snap | 8 +- ...n_tests__any_int_does_not_allow_chars.snap | 4 +- ...on_tests__any_int_does_not_allow_date.snap | 8 +- ...on_tests__any_int_does_not_allow_time.snap | 2 +- ...ts__any_magnitude_does_not_allow_bits.snap | 6 +- ...ts__any_magnitude_does_not_allow_date.snap | 6 +- ...on_tests__any_num_does_not_allow_bits.snap | 6 +- ...on_tests__any_num_does_not_allow_date.snap | 6 +- ...n_tests__any_real_does_not_allow_bits.snap | 8 +- ..._tests__any_real_does_not_allow_chars.snap | 4 +- ...n_tests__any_real_does_not_allow_date.snap | 8 +- ...n_tests__any_real_does_not_allow_time.snap | 2 +- ...tests__any_signed_does_not_allow_bits.snap | 8 +- ...ests__any_signed_does_not_allow_chars.snap | 4 +- ...tests__any_signed_does_not_allow_date.snap | 8 +- ...tests__any_signed_does_not_allow_time.snap | 2 +- ...y_signed_does_not_allow_unsigned_ints.snap | 8 +- ...tests__any_string_does_not_allow_bits.snap | 16 +- ...ests__any_string_does_not_allow_chars.snap | 4 +- ...tests__any_string_does_not_allow_date.snap | 16 +- ...tests__any_string_does_not_allow_ints.snap | 32 +- ...tests__any_string_does_not_allow_time.snap | 4 +- ...sts__any_unsigned_does_not_allow_bits.snap | 8 +- ...ts__any_unsigned_does_not_allow_chars.snap | 4 +- ...sts__any_unsigned_does_not_allow_date.snap | 8 +- ...y_unsigned_does_not_allow_signed_ints.snap | 8 +- ...sts__any_unsigned_does_not_allow_time.snap | 2 +- ..._validation_tests__char_cast_validate.snap | 4 +- ..._tests__literal_cast_with_non_literal.snap | 2 +- ...sts__real_literal_casts_are_validated.snap | 4 +- ...s__string_literal_casts_are_validated.snap | 12 +- ...ation_tests__class_has_implementation.snap | 2 +- ...lidation_tests__arrays__one_cycle_bcb.snap | 2 +- ...e_with_multiple_identical_members_aba.snap | 2 +- ..._tests__arrays__two_cycles_aa_and_aba.snap | 2 +- ..._arrays__two_cycles_with_branch_input.snap | 4 +- ...nblocks__two_cycles_with_branch_input.snap | 4 +- ...nblocks__two_cycles_with_branch_input.snap | 4 +- ...idation_tests__structs__one_cycle_bcb.snap | 2 +- ...e_with_multiple_identical_members_aba.snap | 2 +- ...tests__structs__two_cycles_aa_and_aba.snap | 2 +- ...structs__two_cycles_branch_cc_and_cec.snap | 4 +- ...o_private_variable_in_intermediate_fb.snap | 2 +- ...erence_to_private_variable_is_illegal.snap | 2 +- ...ve_tests__resole_struct_member_access.snap | 12 +- ...ock_calls_in_structs_and_field_access.snap | 12 +- ...esolve_function_members_via_qualifier.snap | 6 +- ..._to_too_small_type_result_in_an_error.snap | 4 +- ...ll_type_to_pointer_result_in_an_error.snap | 4 +- ...validation_tests__assigning_to_rvalue.snap | 6 +- ...ent_to_enum_literals_results_in_error.snap | 6 +- ...condition_used_outside_case_statement.snap | 4 +- ...s__function_call_parameter_validation.snap | 16 +- ...ation_tests__invalid_char_assignments.snap | 24 +- ...ts__program_call_parameter_validation.snap | 16 +- ...sts__program_missing_inout_assignment.snap | 8 +- ..._function_reports_invalid_param_count.snap | 2 +- ...nce_assignments_in_function_arguments.snap | 6 +- ..._tests__switch_case_duplicate_integer.snap | 8 +- ...icate_integer_non_const_var_reference.snap | 8 +- ...__switch_case_invalid_case_conditions.snap | 6 +- ...__validate_arrays_passed_to_functions.snap | 16 +- ...alidation_tests__validate_call_by_ref.snap | 16 +- ..._tests__validate_call_by_ref_explicit.snap | 10 +- ...s__builtins_called_with_invalid_index.snap | 12 +- ...ts__constant_fb_instances_are_illegal.snap | 4 +- ...__unresolvable_variables_are_reported.snap | 6 +- .../tests/statement_validation_tests.rs | 466 +-- .../tests/variable_length_array_test.rs | 6 +- .../tests/variable_validation_tests.rs | 16 +- src/validation/variable.rs | 6 +- tests/correctness/arrays.rs | 62 +- tests/correctness/bitaccess.rs | 12 +- tests/correctness/classes.rs | 6 +- tests/correctness/constants.rs | 64 +- tests/correctness/control_flow.rs | 18 +- tests/correctness/custom_datatypes.rs | 34 +- tests/correctness/datatypes.rs | 12 +- tests/correctness/expressions.rs | 14 +- tests/correctness/functions.rs | 330 +- tests/correctness/generic_functions.rs | 32 +- tests/correctness/initial_values.rs | 264 +- tests/correctness/math_operators/addition.rs | 2 +- tests/correctness/methods.rs | 10 +- tests/correctness/pointers.rs | 180 +- tests/correctness/pointers/references.rs | 50 +- tests/correctness/strings.rs | 144 +- tests/correctness/sub_range_types.rs | 2 +- tests/correctness/vla.rs | 84 +- tests/integration/data/cfc/actions.cfc | 32 +- tests/integration/data/cfc/assigning.st | 2 +- tests/integration/data/cfc/chained_calls.cfc | 4 +- tests/integration/data/cfc/chained_calls.st | 4 +- .../data/cfc/chained_calls_galore.cfc | 2 +- .../data/cfc/chained_calls_galore.st | 4 +- .../data/cfc/conditional_return.cfc | 2 +- .../data/cfc/conditional_return_block.cfc | 2 +- ...nditional_return_block_evaluating_false.st | 18 +- ...onditional_return_block_evaluating_true.st | 18 +- .../conditional_return_evaluating_false.st | 2 +- .../cfc/conditional_return_evaluating_true.st | 2 +- ...ditional_return_evaluating_true_negated.st | 2 +- .../data/cfc/conditional_return_negated.cfc | 2 +- tests/integration/data/cfc/connection.st | 10 +- .../connection_block_source_multi_sink.cfc | 6 +- .../cfc/connection_var_source_multi_sink.cfc | 2 +- .../integration/data/cfc/duplicate_label.cfc | 240 +- .../data/cfc/function_block_call_fb.cfc | 2 +- .../data/cfc/function_block_call_main.cfc | 2 +- .../integration/data/cfc/function_returns.cfc | 2 +- .../integration/data/cfc/function_returns.st | 2 +- tests/integration/data/cfc/jump_false.cfc | 234 +- .../data/cfc/jump_missing_label.cfc | 234 +- tests/integration/data/cfc/jump_no_label.cfc | 226 +- tests/integration/data/cfc/jump_true.cfc | 234 +- tests/integration/data/cfc/multi_labels.cfc | 240 +- tests/integration/data/cfc/my_add.cfc | 4 +- tests/integration/data/cfc/my_add.st | 4 +- tests/integration/data/cfc/select.cfc | 6 +- tests/integration/data/cfc/select.st | 2 +- .../data/cfc/variable_assignment.cfc | 2 +- .../data/cfc/variable_assignment.st | 2 +- tests/integration/data/command_line.st | 2 +- tests/integration/data/io.st | 2 +- .../data/json/build_cc_linker.json | 2 +- .../data/json/build_clang_windows.json | 2 +- .../integration/data/json/build_to_temp.json | 2 +- .../data/json/build_without_sysroot.json | 2 +- .../data/json/multi_target_and_sysroot.json | 2 +- .../data/json/separate_build_and_lib.json | 2 +- tests/integration/data/json/simple_program.st | 8 +- tests/integration/data/linking/consts.st | 3 +- tests/integration/data/linking/file1.st | 3 +- tests/integration/data/linking/file2.st | 3 +- .../integration/data/linking/folder1/vars.st | 3 +- .../integration/data/linking/folder2/vars.st | 3 +- tests/integration/data/linking/init.st | 6 +- tests/integration/data/linking/init2.st | 6 +- tests/integration/data/linking/init3.st | 6 +- tests/integration/data/multi/concat_date.st | 8 +- .../data/multi/concat_date_prg1.st | 2 +- .../data/multi/concat_date_prg2.st | 2 +- tests/integration/data/multi/prog.st | 2 +- xtask/.gitignore | 2 +- xtask/README.md | 2 +- .../migrations/20230620132156_benchmarks.sql | 12 +- xtask/res/ARCH.drawio | 2 +- xtask/res/ARCH.svg | 2 +- xtask/res/combined.st | 2580 +++++++------- xtask/res/sieve.st | 2 +- xtask/src/task/lexer.rs | 2 +- 368 files changed, 12573 insertions(+), 12489 deletions(-) create mode 100644 .editorconfig create mode 100644 .gitattributes create mode 100644 .pre-commit-config.yaml diff --git a/.cargo/config.toml b/.cargo/config.toml index e6e5441c60..61e413fce5 100644 --- a/.cargo/config.toml +++ b/.cargo/config.toml @@ -14,4 +14,4 @@ rustflags = [ "-C", "link-arg=--target=aarch64-linux-gnu", ] -linker = "clang" \ No newline at end of file +linker = "clang" diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index eee449832f..d10a96e1c0 100755 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -18,7 +18,7 @@ ENV DEBIAN_FRONTEND=noninteractive # # [Optional] Add sudo support for the non-root user # && apt-get install -y sudo \ # && echo $USERNAME ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/$USERNAME\ -# && chmod 0440 /etc/sudoers.d/$USERNAME +# && chmod 0440 /etc/sudoers.d/$USERNAME RUN apt-get -y update RUN apt-get -y install git diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 2afc92f8b8..d2fb67b58f 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -1,43 +1,44 @@ { - "name": "Rust", - "build": { - "dockerfile": "./Dockerfile" - }, - // "image": "ghcr.io/plc-lang/rust-llvm:latest", - "features": { - "ghcr.io/devcontainers/features/common-utils:2": { + "name": "Rust", + "build": { + "dockerfile": "./Dockerfile" + }, + // "image": "ghcr.io/plc-lang/rust-llvm:latest", + "features": { + "ghcr.io/devcontainers/features/common-utils:2": { "installZsh": "true", "username": "vscode", "userUid": "1000", "userGid": "1000", "upgradePackages": "true" } - }, - // Set *default* container specific settings.json values on container create. - "customizations": { - "vscode": { - "settings": { - "lldb.executable": "/usr/bin/lldb", - // VS Code don't watch files under ./target - "files.watcherExclude": { - "**/target/**": true - }, - "rust-analyzer.checkOnSave.command": "clippy" - }, - // Add the IDs of extensions you want installed when the container is created. - "extensions": [ - "bungcip.better-toml", - "vadimcn.vscode-lldb", - "mutantdino.resourcemonitor", - "rust-lang.rust-analyzer" - ] - } - }, - // Use 'forwardPorts' to make a list of ports inside the container available locally. - // "forwardPorts": [], - // Use 'postCreateCommand' to run commands after the container is created. - // "postCreateCommand": "rustc --version", - // Comment out connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root. - "remoteUser": "vscode", - "containerUser": "vscode" + }, + // Set *default* container specific settings.json values on container create. + "customizations": { + "vscode": { + "settings": { + "lldb.executable": "/usr/bin/lldb", + // VS Code don't watch files under ./target + "files.watcherExclude": { + "**/target/**": true + }, + "rust-analyzer.checkOnSave.command": "clippy" + }, + // Add the IDs of extensions you want installed when the container is created. + "extensions": [ + "bungcip.better-toml", + "editorconfig.editorconfig", + "vadimcn.vscode-lldb", + "mutantdino.resourcemonitor", + "rust-lang.rust-analyzer" + ] + } + }, + // Use 'forwardPorts' to make a list of ports inside the container available locally. + // "forwardPorts": [], + // Use 'postCreateCommand' to run commands after the container is created. + // "postCreateCommand": "rustc --version", + // Comment out connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root. + "remoteUser": "vscode", + "containerUser": "vscode" } diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000000..305b1aa050 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,12 @@ +root = true + +[*] +end_of_line = lf +charset = utf-8 +insert_final_newline = true +trim_trailing_whitespace = true +indent_style = space +indent_size = 4 + +[*.{yaml,yml}] +indent_size = 2 diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000000..76c689bf24 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,2 @@ +# Set default behaviour to force line endings to LF. +* text=auto eol=lf diff --git a/.github/workflows/doc.yml b/.github/workflows/doc.yml index 5c0e2f6476..e8e3c8e901 100644 --- a/.github/workflows/doc.yml +++ b/.github/workflows/doc.yml @@ -15,8 +15,6 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 - with: - submodules: true - name: Run Documentation Build run: | diff --git a/.github/workflows/metrics.yml b/.github/workflows/metrics.yml index 88bcbac5bb..a4f340e6bb 100644 --- a/.github/workflows/metrics.yml +++ b/.github/workflows/metrics.yml @@ -21,7 +21,7 @@ jobs: steps: - uses: actions/checkout@v3 - + - name: Update git permissions run: | git config --global --add safe.directory /__w/rusty/rusty diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 80d18bee7e..8f15c55c0c 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -10,14 +10,12 @@ on: workflow_dispatch: jobs: - check: + check: name: Check runs-on: ubuntu-latest container: ghcr.io/plc-lang/rust-llvm:latest steps: - uses: actions/checkout@v3 - with: - submodules: true - name: Run Check run: | @@ -49,7 +47,7 @@ jobs: echo "Build command : ./scripts/build.sh --build --release" ./scripts/build.sh --build --release --package \ --target x86_64-unknown-linux-gnu,aarch64-unknown-linux-gnu - + - uses: actions/upload-artifact@master with: name: plc @@ -85,7 +83,7 @@ jobs: with: version: ${{ env.llvm-version }} directory: "./llvm" - + - name: Cargo test (Unit) uses: actions-rs/cargo@v1 with: @@ -109,7 +107,7 @@ jobs: with: command: build args: --release - + - uses: actions/upload-artifact@master with: name: plc.exe @@ -127,7 +125,7 @@ jobs: ./scripts/build.sh --check-style coverage: - name: Run Coverage + name: Run Coverage runs-on: ubuntu-latest container: ghcr.io/plc-lang/rust-llvm:latest steps: @@ -140,7 +138,7 @@ jobs: - name: Upload to codecov.io uses: codecov/codecov-action@v3 with: - files: lcov.info + files: lcov.info - name: Archive code coverage results uses: actions/upload-artifact@v1 diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000000..fb5b5e0737 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,75 @@ +# Pre-commit is currently in testing phase for this repo. It is not yet forced +# in CI or mandatory to use. Pre-commit will run various checks and mostly fix +# those when you do commiting. You can use it locally by installing it with +# +# pip install pre-commit +# +# and running +# +# pre-commit install +# +# in the root of the repository. This will install git hook which will run +# checks before every commit. If you want to run checks manually for whole repo, +# you can run +# +# pre-commit run --all-files +# +# You can always commit without running checks by adding --no-verify flag to git +# commit command. + +exclude: target/|\.git/|.*\.snap + +repos: + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: c4a0b883114b00d8d76b479c820ce7950211c99b # v4.5.0 + hooks: + - id: check-merge-conflict + args: [--assume-in-merge] + # Editorconfig-checker does not care if file contains multiple newlines. + - id: end-of-file-fixer + - id: check-yaml + - id: check-case-conflict + - id: trailing-whitespace + - id: fix-byte-order-marker + + - repo: https://github.com/Lucas-C/pre-commit-hooks + rev: 762c66ea96843b54b936fc680162ea67f85ec2d7 # v1.5.4 + hooks: + - id: remove-tabs + name: Remove tabs (4 spaces) + args: ['--whitespaces-count', '4'] + exclude: \.(yaml|yml)$ + - id: remove-tabs + name: Remove tabs (2 spaces) + args: ['--whitespaces-count', '2'] + files: \.(yaml|yml)$ + + - repo: https://github.com/pre-commit/pygrep-hooks + rev: 3a6eb0fadf60b3cccfd80bad9dbb6fae7e47b316 # v1.10.0 + hooks: + - id: text-unicode-replacement-char + exclude: ".*test_fdx_utf8.cpp$" + + # Formatting Python code. We have not so many files so no example flake8 yet. + - repo: https://github.com/psf/black + rev: 2a1c67e0b2f81df602ec1f6e7aeb030b9709dc7c #23.11.0 + hooks: + - id: black + language_version: python3 + + - repo: https://github.com/doublify/pre-commit-rust + rev: eeee35a89e69d5772bdee97db1a6a898467b686e #v1.0 + hooks: + - id: fmt + - id: cargo-check + - id: clippy + args: ["--", "-D", "warnings"] + + - repo: https://github.com/editorconfig-checker/editorconfig-checker.python + rev: 2b74735540f79457a50369e5c17a2c35d52c3298 # 2.7.3 + hooks: + - id: editorconfig-checker + args: [ + # Saddly we have to disable this, but it just won't work. Maybe some day. + -disable-indent-size, + ] diff --git a/.vscode/launch.json b/.vscode/launch.json index be9b1159d8..bf585bf031 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -46,4 +46,4 @@ "cwd": "${workspaceFolder}" }, ] -} \ No newline at end of file +} diff --git a/Cargo.toml b/Cargo.toml index ebaef5a49e..825edd9492 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -2,8 +2,8 @@ name = "rusty" version = "0.2.0" authors = [ - "Ghaith Hachem ", - "Mathias Rieder ", + "Ghaith Hachem ", + "Mathias Rieder ", ] edition = "2021" readme = "README.md" @@ -59,16 +59,16 @@ path = "src/lib.rs" [workspace] members = [ - "xtask", - "libs/stdlib", - "compiler/plc_driver", - "compiler/plc_ast", - "compiler/plc_diagnostics", - "compiler/plc_project", - "compiler/plc_source", - "compiler/plc_util", - "compiler/plc_xml", - "compiler/plc_derive", + "xtask", + "libs/stdlib", + "compiler/plc_driver", + "compiler/plc_ast", + "compiler/plc_diagnostics", + "compiler/plc_project", + "compiler/plc_source", + "compiler/plc_util", + "compiler/plc_xml", + "compiler/plc_derive", ] default-members = [".", "compiler/plc_driver", "compiler/plc_xml"] diff --git a/book/iecst.min.js b/book/iecst.min.js index d9a3e36c93..63c0253663 100644 --- a/book/iecst.min.js +++ b/book/iecst.min.js @@ -20,4 +20,4 @@ begin:"[a-zA-Z_]+#\\-?[0-9_]*",relevance:0},{className:"symbol", begin:"%(I|Q|M)(X|B|W|D|L)[0-9\\.]*"},{className:"symbol", begin:"%(I|Q|M)[0-9.]*" },e.C_NUMBER_MODE,e.COMMENT("//","$"),e.C_BLOCK_COMMENT_MODE,e.COMMENT("\\(\\*","\\*\\)")] -})})()); \ No newline at end of file +})})()); diff --git a/book/llvm.min.js b/book/llvm.min.js index d9a279c4c3..280843d531 100644 --- a/book/llvm.min.js +++ b/book/llvm.min.js @@ -16,4 +16,4 @@ variants:[{begin:/"/,end:/[^\\]"/}]},i,{className:"punctuation",relevance:0, begin:/,/},{className:"operator",relevance:0,begin:/=/},t,{className:"symbol", variants:[{begin:/^\s*[a-z]+:/}],relevance:0},{className:"number",variants:[{ begin:/0[xX][a-fA-F0-9]+/},{begin:/-?\d+(?:[.]\d+)?(?:[eE][-+]?\d+(?:[.]\d+)?)?/ -}],relevance:0}]}}})();hljs.registerLanguage("llvm",e)})(); \ No newline at end of file +}],relevance:0}]}}})();hljs.registerLanguage("llvm",e)})(); diff --git a/book/src/arch/architecture.md b/book/src/arch/architecture.md index 65db19fd61..225eebda1a 100644 --- a/book/src/arch/architecture.md +++ b/book/src/arch/architecture.md @@ -62,4 +62,4 @@ While a fully fledged compiler generates machine code as a last step, RuSTy gene │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ └────────────────┘ └────────────┘ └────────────┘ └────────────┘ └────────────┘ -``` +``` diff --git a/book/src/arch/codegen.md b/book/src/arch/codegen.md index 3315f2e335..56129b3cd4 100644 --- a/book/src/arch/codegen.md +++ b/book/src/arch/codegen.md @@ -126,7 +126,7 @@ Struct types translate direclty to llvm struct datatypes. We generate a new datatype with the user-type's name for the struct. ```iecst -TYPE MyStruct: +TYPE MyStruct: STRUCT a: DINT; b: INT; @@ -162,7 +162,7 @@ For every enum's element we generate a global variable with the element's value. Array types are generated as fixed sized llvm vector types - note that Array types must be fixed sized in *ST* : ```iecst -TYPE MyArray: ARRAY[0..9] OF INT; +TYPE MyArray: ARRAY[0..9] OF INT; END_TYPE VAR_GLOBAL @@ -208,9 +208,9 @@ This means that such a multidimensional array must be initialized like a single- ```iecst VAR_GLOBAL - wrong_array : ARRAY[1..2, 0..3] OF INT := [ [10, 11, 12], - [20, 21, 22], - [30, 31, 32]]; + wrong_array : ARRAY[1..2, 0..3] OF INT := [ [10, 11, 12], + [20, 21, 22], + [30, 31, 32]]; END_VAR ``` @@ -218,9 +218,9 @@ END_VAR ```iecst VAR_GLOBAL - correct_array : ARRAY[1..2, 0..3] OF INT := [ 10, 11, 12, - 20, 21, 22, - 30, 31, 32]; + correct_array : ARRAY[1..2, 0..3] OF INT := [ 10, 11, 12, + 20, 21, 22, + 30, 31, 32]; END_VAR ``` diff --git a/book/src/arch/linker.md b/book/src/arch/linker.md index a9b049066d..c583ca3882 100644 --- a/book/src/arch/linker.md +++ b/book/src/arch/linker.md @@ -3,13 +3,13 @@ The linker's task is to decide where all references in the source code point to. There are different references in Structured Text: -- variable references -`x := 4` where *x* is a reference to the variable x. -- type references +- variable references +`x := 4` where *x* is a reference to the variable x. +- type references `i : MyFunctionBlock` where *MyFunctionBlock* is a reference to the declared FunctionBlock. -- Program references +- Program references `PLC_PRG.x := 4` where *PLC_PRG* is a reference to a Program-POU called *PLC_PRG*. -- Function references +- Function references `max(a, b)` where *max* is a reference to a Function-POU called *max*. So the linker decides where a reference points to. A reference has a corresponding declaration that matches the reference's name: @@ -20,7 +20,7 @@ So the linker decides where a reference points to. A reference has a correspondi ┌──────► x : INT; │ - │ END_VAR + │ END_VAR │ └────┐ │ @@ -58,7 +58,7 @@ So the expression `a + 3` now looks like this: │ ID: 1 │ └──────┬──┬───────┘ │ │ - left │ │ right + left │ │ right ┌───────────┘ └──────────┐ │ │ │ │ @@ -73,7 +73,7 @@ So the expression `a + 3` now looks like this: The AnnotationMap stores 5 different types of annotation: -- `Value` +- `Value` The Value-annotation indicates that this AST-Element resolves to a value with the given resulting datatype. So for Example the LiteralInteger(3) node gets a Value-Annotation with a resulting type of `DINT`. @@ -321,4 +321,3 @@ The code-generation steps can easily decide when to generate casts, by simply co When generating multiple units, the Linker will keep track of a dependency-tree for the unit. This means that every datatype or global variable referenced directly or indirectly by the module will be marked as a dependency. This information can then be used during the [codegen](./codegen.md) period to only generated types and variables that are relevant to the unit. - diff --git a/book/src/arch/parser.md b/book/src/arch/parser.md index aa245a091c..c1da7b5047 100644 --- a/book/src/arch/parser.md +++ b/book/src/arch/parser.md @@ -95,7 +95,7 @@ As the parser reads the token stream `Reference`, `KeywordEquals`, `Number`, `Se ┌─────────────────┐ │ Assignment │ └──────┬──┬───────┘ - left │ │ right + left │ │ right ┌───────────┘ └──────────┐ ▼ ▼ ┌──────────────────┐ ┌──────────────────┐ diff --git a/book/src/build_and_install.md b/book/src/build_and_install.md index 7f3e15cfa7..bafef5823c 100644 --- a/book/src/build_and_install.md +++ b/book/src/build_and_install.md @@ -1,7 +1,7 @@ # Build & Install RuSTys code can be found on [GitHub](https://github.com/PLC-lang/rusty). -By default a `Dockerfile` and a `devcontainer.json` file are provided. If you wish to develop natively +By default a `Dockerfile` and a `devcontainer.json` file are provided. If you wish to develop natively however, you will need some additional dependencies namely: - [Rust](https://www.rust-lang.org/tools/install) @@ -12,7 +12,7 @@ however, you will need some additional dependencies namely: The next sections cover how to install these dependencies on different platforms, if you already have them however, RuSTy can be build using the `cargo` command. For debug builds this can be accomplished by executing -`cargo build` and for release builds (smaller & faster) you would execute `cargo build --release`. The +`cargo build` and for release builds (smaller & faster) you would execute `cargo build --release`. The resulting binaries can be found at `target/debug/plc` and `target/release/plc` respectively. ## Ubuntu @@ -24,7 +24,7 @@ sudo apt install \ build-essential \ llvm-14-dev liblld-14-dev \ libz-dev \ - libclang-common-14-dev + libclang-common-14-dev ``` Additionally you _might_ need `libffi7`, which can be installed with `sudo apt install libffi7`. @@ -73,4 +73,4 @@ major version of the `llvm-sys` crate.Currently you will need to install LLVM 14 - To avoid installation conflicts on Linux/Ubuntu, make sure you don't have a default installation available (like you get by just installing `llvm-dev`), which may break things. If you do, make sure you have set the appropriate environment variable (`LLVM_SYS_140_PREFIX=/usr/lib/llvm-14` for LLVM 14), so -the build of the `llvm-sys` crate knows what files to grab. \ No newline at end of file +the build of the `llvm-sys` crate knows what files to grab. diff --git a/book/src/cfc/cfc.md b/book/src/cfc/cfc.md index 6789ab7f65..6540888c72 100644 --- a/book/src/cfc/cfc.md +++ b/book/src/cfc/cfc.md @@ -1,8 +1,8 @@ # CFC (Continous Function Chart) -RuSTy is compatible with CFC, as per the FBD part detailed in the [IEC61131-3 XML-exchange format](https://www.plcopen.org/system/files/downloads/tc6_xml_v201_technical_doc.pdf). -The CFC implementation borrows extensively from the [ST compiler-pipeline](../arch/architecture.md), with the exception that the lexical analysis and parsing phases are replaced by a model-to-model conversion process. -This involves converting the XML into a structured model, which is then converted into ST AST statements. +RuSTy is compatible with CFC, as per the FBD part detailed in the [IEC61131-3 XML-exchange format](https://www.plcopen.org/system/files/downloads/tc6_xml_v201_technical_doc.pdf). +The CFC implementation borrows extensively from the [ST compiler-pipeline](../arch/architecture.md), with the exception that the lexical analysis and parsing phases are replaced by a model-to-model conversion process. +This involves converting the XML into a structured model, which is then converted into ST AST statements. -The next chapter will walk you through the CFC implementation, giving you a better understanding of underlying [code](https://github.com/PLC-lang/rusty/tree/master/compiler/plc_xml). \ No newline at end of file +The next chapter will walk you through the CFC implementation, giving you a better understanding of underlying [code](https://github.com/PLC-lang/rusty/tree/master/compiler/plc_xml). diff --git a/book/src/cfc/m2m.md b/book/src/cfc/m2m.md index 08e52fd0c5..47ad549b6b 100644 --- a/book/src/cfc/m2m.md +++ b/book/src/cfc/m2m.md @@ -21,10 +21,10 @@ Consider the heavily minified CFC file [`MyProgram.cfc`](m2m.md#myprogramcfc), w │ local_id:1 │ │ ref_local_id: 1 │ └─────────────┘ └─────────────────┘ local_id: 2 -``` +``` The initial phase of the transformation process involves streaming the entire input file. -During the streaming process, whenever important keywords such as `block` are encountered, they are directly mapped into a corresponding model structure. +During the streaming process, whenever important keywords such as `block` are encountered, they are directly mapped into a corresponding model structure. For example, when reaching the line `` within the XML file, we generate a model that can be represented as follows: ```rust,ignore struct Block { @@ -44,7 +44,7 @@ This process is repeated for every element in the input file which has a corresp Since the CFC programming language utilizes blocks and their interconnections to establish the program's logic flow, with the sequencing of block execution and inter-block links represented through corresponding `localId`, `refLocalId` and `excutionOrderId`, -we have to order each element by their execution ID before proceeding to the next phase. +we have to order each element by their execution ID before proceeding to the next phase. Otherwise the generated AST statements would be out of order and hence semantically incorrect. ## Data-Model to AST @@ -53,9 +53,9 @@ Consider the previous `block` example - the transformer first encounters the ele We then check and transform each parameter, input `a` and `b` corresponding to the variables `x` and `y` respectively. The result of this transformation looks as follows: ```rust,ignore -CallStatement { - operator: myAdd, - parameters: [x, y] +CallStatement { + operator: myAdd, + parameters: [x, y] } ``` @@ -63,7 +63,7 @@ CallStatement { ```rust,ignore AssignmentStatement { - left: z, + left: z, right: CallStatement { operator: myAdd, parameters: [x, y] diff --git a/book/src/direct_variables.md b/book/src/direct_variables.md index d140e81314..b2027fce59 100644 --- a/book/src/direct_variables.md +++ b/book/src/direct_variables.md @@ -1,79 +1,79 @@ -# Direct (Bit) Access on Variables - -The IEC61131-3 Standard allows reading specific `Bits`, `Bytes`, `Words` or `DWords` from an `ANY_BIT` type. -RuSTy supports this functionalty and extends it to support all `INT` types. - -## Constant based Direct Access - -To access a bit sequence in a variable, a direct access instruction `%` is used. - -`Type` is the bit sequence size required and is described as follows: - -| Type | Size | Example | -| ---- | ---- | ------- | -| X | 1 | `%X1 | -| B | 8 | `%B1 | -| W | 16 | `%W1 | -| D | 32 | `%D1 | - -> _For `Bit` access, the `%X` is optional._ - -### Example - -```st -FUNCTION main : DINT -VAR - variable : LWORD; - bitTarget : BOOL; - bitTarget2 : BOOL; - byteTarget : BYTE; - wordTarget : WORD; - dwordTarget : DWORD; -END_VAR - -variable := 16#AB_CD_EF_12_34_56_78_90; -bitTarget := variable.%X63; (*Access last bit*) -byteTarget := variable.%B7; (*Access last byte*) -wordTarget := variable.%W3; (*Access last word*) -dwordTarget := variable.%D1; (*Access last dword*) -(*Chaining an access is also allowed *) -bitTarget2 := variable.%D1.%W1.%B1.%X1; - -END_FUNCTION -``` - -## Varirable based Direct Access - -While the IEC61131-3 Standard only defines variable access using constant int literals, -RuSTy additionally supports access using Variables. -The Syntax for a variable based access is `%`. -The provided varibale has to be a direct Reference variable (non Qualified). - -> _Short hand access for Bit (Without the `%X` modifier) is not allowed._ - -### Example - -```st -FUNCTION main : DINT -VAR - variable : LWORD; - access_var : INT; - bitTarget : BOOL; - bitTarget2 : BOOL; - byteTarget : BYTE; - wordTarget : WORD; - dwordTarget : DWORD; -END_VAR -variable := 16#AB_CD_EF_12_34_56_78_90; -access_var := 63; -bitTarget := variable.%Xaccess_var; (*Access last bit*) -access_var := 7; -byteTarget := variable.%Baccess_var; (*Access last byte*) -access_var := 3; -wordTarget := variable.%Waccess_var; (*Access last word*) -access_var := 1; -dwordTarget := variable.%Daccess_var; (*Access last dword*) -(*Chaining an access is also allowed *) -bitTarget2 := variable.%Daccess_var.%Waccess_var.%Baccess_var.%Xaccess_var; -END_FUNCTION -``` +# Direct (Bit) Access on Variables + +The IEC61131-3 Standard allows reading specific `Bits`, `Bytes`, `Words` or `DWords` from an `ANY_BIT` type. +RuSTy supports this functionalty and extends it to support all `INT` types. + +## Constant based Direct Access + +To access a bit sequence in a variable, a direct access instruction `%` is used. + +`Type` is the bit sequence size required and is described as follows: + +| Type | Size | Example | +| ---- | ---- | ------- | +| X | 1 | `%X1 | +| B | 8 | `%B1 | +| W | 16 | `%W1 | +| D | 32 | `%D1 | + +> _For `Bit` access, the `%X` is optional._ + +### Example + +```st +FUNCTION main : DINT +VAR + variable : LWORD; + bitTarget : BOOL; + bitTarget2 : BOOL; + byteTarget : BYTE; + wordTarget : WORD; + dwordTarget : DWORD; +END_VAR + +variable := 16#AB_CD_EF_12_34_56_78_90; +bitTarget := variable.%X63; (*Access last bit*) +byteTarget := variable.%B7; (*Access last byte*) +wordTarget := variable.%W3; (*Access last word*) +dwordTarget := variable.%D1; (*Access last dword*) +(*Chaining an access is also allowed *) +bitTarget2 := variable.%D1.%W1.%B1.%X1; + +END_FUNCTION +``` + +## Varirable based Direct Access + +While the IEC61131-3 Standard only defines variable access using constant int literals, +RuSTy additionally supports access using Variables. +The Syntax for a variable based access is `%`. +The provided varibale has to be a direct Reference variable (non Qualified). + +> _Short hand access for Bit (Without the `%X` modifier) is not allowed._ + +### Example + +```st +FUNCTION main : DINT +VAR + variable : LWORD; + access_var : INT; + bitTarget : BOOL; + bitTarget2 : BOOL; + byteTarget : BYTE; + wordTarget : WORD; + dwordTarget : DWORD; +END_VAR +variable := 16#AB_CD_EF_12_34_56_78_90; +access_var := 63; +bitTarget := variable.%Xaccess_var; (*Access last bit*) +access_var := 7; +byteTarget := variable.%Baccess_var; (*Access last byte*) +access_var := 3; +wordTarget := variable.%Waccess_var; (*Access last word*) +access_var := 1; +dwordTarget := variable.%Daccess_var; (*Access last dword*) +(*Chaining an access is also allowed *) +bitTarget2 := variable.%Daccess_var.%Waccess_var.%Baccess_var.%Xaccess_var; +END_FUNCTION +``` diff --git a/book/src/libraries.md b/book/src/libraries.md index 8c2b686df0..285c1ce3bb 100644 --- a/book/src/libraries.md +++ b/book/src/libraries.md @@ -21,7 +21,7 @@ A library is defined by: > PROGRAM example > VAR_INPUT > a,b,c : DINT - > END_VAR + > END_VAR > (* End of interface *) > > (* Implementation *) diff --git a/book/src/libraries/external_functions.md b/book/src/libraries/external_functions.md index 1d7b61c42d..e989d9fbaa 100644 --- a/book/src/libraries/external_functions.md +++ b/book/src/libraries/external_functions.md @@ -96,7 +96,7 @@ An `ST` program called `ExternalFunctions.st` with the following code can be dec (*ExternalFunctions.st*) (** - * The printf function's interface, marked as external since + * The printf function's interface, marked as external since * it is defined directly along other ST functions *) {external} diff --git a/book/src/pous.md b/book/src/pous.md index aa9bd8436c..d923d74fe0 100644 --- a/book/src/pous.md +++ b/book/src/pous.md @@ -10,7 +10,7 @@ It can be defined as either a Program, a Function, a Function Block, or an Actio A POU is defined as: ```iecst - name + name (* parameters *) (* code *) @@ -106,7 +106,7 @@ A program does not support passing input parameters by reference. Example: ```iecst -PROGRAM prg +PROGRAM prg (* parameters *) VAR_INPUT x : INT; diff --git a/book/src/using_rusty.md b/book/src/using_rusty.md index 4699d1130b..7ea9ca0b9a 100644 --- a/book/src/using_rusty.md +++ b/book/src/using_rusty.md @@ -36,7 +36,7 @@ This example is available under `examples/hello_world.st` in the main RuSTy repo - On Windows and MacOS, replace this with `--linker=clang` as cc is usually not available. ```iecst -{external} +{external} FUNCTION puts : DINT VAR_INPUT {ref} text : STRING; @@ -121,4 +121,4 @@ This is determined by the underlying parallelisation library [Rayon](https://cra With the introducton of parallel compilation, every unit is compiled into an object file independently and then linked together in a single module. This behaviour might not always be desired and could be disabled using the `--single-module` flag. -> Note that the single module flag is currently much slower to produce as it requires first generating all modules and then merging them together. \ No newline at end of file +> Note that the single module flag is currently much slower to produce as it requires first generating all modules and then merging them together. diff --git a/compiler/plc_driver/src/cli.rs b/compiler/plc_driver/src/cli.rs index 0a3befef98..9c6676bf68 100644 --- a/compiler/plc_driver/src/cli.rs +++ b/compiler/plc_driver/src/cli.rs @@ -90,7 +90,7 @@ pub struct CompileParameters { name = "hardware-conf", long, global = true, - help = "Generate Hardware configuration files to the given location. + help = "Generate Hardware configuration files to the given location. Format is detected by extenstion. Supported formats : json, toml", parse(try_from_str = validate_config) diff --git a/compiler/plc_driver/src/tests/external_files.rs b/compiler/plc_driver/src/tests/external_files.rs index 5e11eb04d5..82634939ee 100644 --- a/compiler/plc_driver/src/tests/external_files.rs +++ b/compiler/plc_driver/src/tests/external_files.rs @@ -10,7 +10,7 @@ fn external_file_function_call() { let prog = SourceCode::new( " FUNCTION main : INT - external(); + external(); END_FUNCTION ", "main.st", @@ -19,7 +19,7 @@ fn external_file_function_call() { let ext = SourceCode::new( " FUNCTION external : INT - END_FUNCTION + END_FUNCTION ", "external.st", ); @@ -37,7 +37,7 @@ fn external_file_global_var() { FUNCTION main : INT x := 2; y := 2; - external(); + external(); END_FUNCTION ", "main.st", @@ -49,7 +49,7 @@ fn external_file_global_var() { x : INT; END_VAR FUNCTION external : INT - END_FUNCTION + END_FUNCTION VAR_GLOBAL y : INT; END_VAR @@ -68,7 +68,7 @@ fn calling_external_file_function_without_including_file_results_in_error() { let prog = SourceCode::new( " FUNCTION main : INT - external(); + external(); END_FUNCTION ", "external_file.st", @@ -81,7 +81,7 @@ fn calling_external_file_function_without_including_file_results_in_error() { assert_eq!( Diagnostic::codegen_error( r#"cannot generate call statement for "ReferenceExpr { kind: Member(Identifier { name: \"external\" }), base: None }""#, - source_location_factory.create_range(30..38) + source_location_factory.create_range(33..41) ), msg ) diff --git a/compiler/plc_project/schema/plc-json.schema b/compiler/plc_project/schema/plc-json.schema index a4f4ceb791..19dc9d9335 100644 --- a/compiler/plc_project/schema/plc-json.schema +++ b/compiler/plc_project/schema/plc-json.schema @@ -68,10 +68,10 @@ } } }, - "additionalProperties": false, + "additionalProperties": false, "required": [ "name", "files", "compile_type" ] - } \ No newline at end of file + } diff --git a/compiler/plc_xml/README.md b/compiler/plc_xml/README.md index e89baa6bcc..b43da59d3a 100644 --- a/compiler/plc_xml/README.md +++ b/compiler/plc_xml/README.md @@ -1,3 +1,3 @@ # plc_xml -This crate contains the CFC implementation of RuSTy, for more information refer to the [book](https://plc-lang.github.io/rusty/cfc/cfc.html). \ No newline at end of file +This crate contains the CFC implementation of RuSTy, for more information refer to the [book](https://plc-lang.github.io/rusty/cfc/cfc.html). diff --git a/compiler/plc_xml/src/model/action.rs b/compiler/plc_xml/src/model/action.rs index 224bf725d9..85887efb28 100644 --- a/compiler/plc_xml/src/model/action.rs +++ b/compiler/plc_xml/src/model/action.rs @@ -88,9 +88,9 @@ mod tests { PROGRAM program_0 VAR - a : DINT; + a : DINT; END_VAR - + diff --git a/compiler/plc_xml/src/model/snapshots/plc_xml__model__action__tests__list_of_actions_parsed_to_model.snap b/compiler/plc_xml/src/model/snapshots/plc_xml__model__action__tests__list_of_actions_parsed_to_model.snap index 8544471df2..40e525f614 100644 --- a/compiler/plc_xml/src/model/snapshots/plc_xml__model__action__tests__list_of_actions_parsed_to_model.snap +++ b/compiler/plc_xml/src/model/snapshots/plc_xml__model__action__tests__list_of_actions_parsed_to_model.snap @@ -76,7 +76,7 @@ Project { Interface { add_data: Some( Data { - content: "PROGRAM program_0\nVAR\n\ta : DINT;\nEND_VAR\nEND_PROGRAM", + content: "PROGRAM program_0\nVAR\n a : DINT;\nEND_VAR\nEND_PROGRAM", handle: Implementation, }, ), diff --git a/compiler/plc_xml/src/xml_parser/tests.rs b/compiler/plc_xml/src/xml_parser/tests.rs index a142359318..dbeda9ea1d 100644 --- a/compiler/plc_xml/src/xml_parser/tests.rs +++ b/compiler/plc_xml/src/xml_parser/tests.rs @@ -518,7 +518,7 @@ mod content { PROGRAM program_0 VAR - a,b : DINT; + a,b : DINT; END_VAR diff --git a/examples/ExternalFunctions.st b/examples/ExternalFunctions.st index d9675433a8..505d5b4b7a 100644 --- a/examples/ExternalFunctions.st +++ b/examples/ExternalFunctions.st @@ -13,6 +13,6 @@ END_FUNCTION FUNCTION main : DINT - main := LOG(100); - PRINTF('Log value %d\n', main); + main := LOG(100); + PRINTF('Log value %d\n', main); END_FUNCTION diff --git a/examples/actions.st b/examples/actions.st index f7236f3f2d..c5e9fa9b97 100644 --- a/examples/actions.st +++ b/examples/actions.st @@ -1,6 +1,6 @@ PROGRAM main VAR - a,b : DINT; + a,b : DINT; END_VAr action1(); @@ -9,10 +9,10 @@ action2(); END_PROGRAM ACTIONS - ACTION action1 - a := a + 1; - END_ACTION - ACTION action2 - b := b + 2; - END_ACTION + ACTION action1 + a := a + 1; + END_ACTION + ACTION action2 + b := b + 2; + END_ACTION END_ACTIONS diff --git a/examples/class_method.st b/examples/class_method.st index f89d2e6fa3..1e54f7b646 100644 --- a/examples/class_method.st +++ b/examples/class_method.st @@ -9,4 +9,4 @@ CLASS MyClass x := myMethodArg; END_METHOD -END_CLASS \ No newline at end of file +END_CLASS diff --git a/examples/function_with_return.st b/examples/function_with_return.st index e1304b1500..704c3df57b 100644 --- a/examples/function_with_return.st +++ b/examples/function_with_return.st @@ -1,11 +1,11 @@ FUNCTION smaller_than_ten: BOOL - VAR_INPUT - n : INT; - END_VAR + VAR_INPUT + n : INT; + END_VAR - IF n < 10 THEN - smaller_than_ten := TRUE; - RETURN; - END_IF; - smaller_than_ten := FALSE; + IF n < 10 THEN + smaller_than_ten := TRUE; + RETURN; + END_IF; + smaller_than_ten := FALSE; END_FUNCTION diff --git a/examples/hello_world.st b/examples/hello_world.st index 3ca0c54829..499254ab4e 100644 --- a/examples/hello_world.st +++ b/examples/hello_world.st @@ -1,4 +1,4 @@ -{external} +{external} FUNCTION puts : DINT VAR_INPUT {ref} text : STRING; @@ -6,5 +6,5 @@ END_VAR END_FUNCTION FUNCTION main : DINT - puts('hello, world!$N'); + puts('hello, world!$N'); END_FUNCTION diff --git a/examples/lt.st b/examples/lt.st index edd139c6d3..702a439481 100644 --- a/examples/lt.st +++ b/examples/lt.st @@ -10,5 +10,5 @@ FUNCTION a : DINT END_FUNCTION y^.1 := 3; z^[0] := 4; z^[1].1 := 5; - a() := 5; + a() := 5; END_PROGRAM diff --git a/examples/math_st.c b/examples/math_st.c index 967d6c7ebc..33da8d37e5 100644 --- a/examples/math_st.c +++ b/examples/math_st.c @@ -20,8 +20,3 @@ int LOG(LOG_interface* param) { int PRINTF(PRINT_interface* param) { return printf(param->text, param->value); } - - - - - diff --git a/examples/plc.json b/examples/plc.json index 1e51738091..d0bc582014 100644 --- a/examples/plc.json +++ b/examples/plc.json @@ -1,5 +1,5 @@ { - "name": "ProjectName", + "name": "ProjectName", "files" : [ "examples/hw.st", "examples/hello_world.st", diff --git a/examples/pointer.st b/examples/pointer.st index 32de0b1583..731b599b9e 100644 --- a/examples/pointer.st +++ b/examples/pointer.st @@ -1,17 +1,17 @@ TYPE MyStruct: STRUCT x: DINT; y: DINT; END_STRUCT END_TYPE FUNCTION main : DINT - main := foo(); + main := foo(); END_FUNCTION FUNCTION foo : DINT VAR - x : DINT; - s : MyStruct; - u,y : REF_TO DINT; - z : REF_TO REF_TO DINT; - + x : DINT; + s : MyStruct; + u,y : REF_TO DINT; + z : REF_TO REF_TO DINT; END_VAR + u := NULL; u := &s.x; y := u; diff --git a/examples/program_with_references.st b/examples/program_with_references.st index d7a250fcfc..13b1048df5 100644 --- a/examples/program_with_references.st +++ b/examples/program_with_references.st @@ -1 +1 @@ -PROGRAM exp a AND NOT b OR c XOR d; END_PROGRAM \ No newline at end of file +PROGRAM exp a AND NOT b OR c XOR d; END_PROGRAM diff --git a/examples/program_with_variable_and_operation.st b/examples/program_with_variable_and_operation.st index 3b9c4b9a8e..6583eaa24e 100644 --- a/examples/program_with_variable_and_operation.st +++ b/examples/program_with_variable_and_operation.st @@ -7,9 +7,9 @@ END_VAR IF Condition THEN - -ELSIF - + +ELSIF + END_IF; 1 + 2 + 3 + 4; diff --git a/examples/simple_program.st b/examples/simple_program.st index 3f89442478..0514e1ae3a 100644 --- a/examples/simple_program.st +++ b/examples/simple_program.st @@ -1,8 +1,9 @@ PROGRAM prg VAR - a : INT; - b : REAL; + a : INT; + b : REAL; END_VAR - b := 1.5; - a := b; + + b := 1.5; + a := b; END_PROGRAM diff --git a/libs/stdlib/.gitignore b/libs/stdlib/.gitignore index d11b59f723..a9fe45999f 100644 --- a/libs/stdlib/.gitignore +++ b/libs/stdlib/.gitignore @@ -8,4 +8,4 @@ *.o *.bc *.a -*.elf \ No newline at end of file +*.elf diff --git a/libs/stdlib/iec61131-st/arithmetic_functions.st b/libs/stdlib/iec61131-st/arithmetic_functions.st index 2df8690586..10a512bce6 100644 --- a/libs/stdlib/iec61131-st/arithmetic_functions.st +++ b/libs/stdlib/iec61131-st/arithmetic_functions.st @@ -2,21 +2,21 @@ {external} VAR_GLOBAL - PI_REAL : REAL; - PI_LREAL : LREAL; - FRAC_PI_2_REAL : REAL; - FRAC_PI_2_LREAL : LREAL; - FRAC_PI_4_REAL : REAL; - FRAC_PI_4_LREAL : LREAL; - E_REAL : REAL; - E_LREAL : LREAL; + PI_REAL : REAL; + PI_LREAL : LREAL; + FRAC_PI_2_REAL : REAL; + FRAC_PI_2_LREAL : LREAL; + FRAC_PI_4_REAL : REAL; + FRAC_PI_4_LREAL : LREAL; + E_REAL : REAL; + E_LREAL : LREAL; END_VAR (* Calculates the square root of a given value *) {external} FUNCTION SQRT : T VAR_INPUT - in : T; + in : T; END_VAR END_FUNCTION @@ -27,7 +27,7 @@ END_FUNCTION {external} FUNCTION LN : T VAR_INPUT - in : T; + in : T; END_VAR END_FUNCTION @@ -36,7 +36,7 @@ END_FUNCTION {external} FUNCTION LOG : T VAR_INPUT - in : T; + in : T; END_VAR END_FUNCTION @@ -44,7 +44,7 @@ END_FUNCTION {external} FUNCTION EXP : T VAR_INPUT - in : T; + in : T; END_VAR END_FUNCTION @@ -55,7 +55,7 @@ END_FUNCTION {external} FUNCTION SIN : T VAR_INPUT - rad : T; + rad : T; END_VAR END_FUNCTION @@ -63,7 +63,7 @@ END_FUNCTION {external} FUNCTION COS : T VAR_INPUT - rad : T; + rad : T; END_VAR END_FUNCTION @@ -71,7 +71,7 @@ END_FUNCTION {external} FUNCTION TAN : T VAR_INPUT - rad : T; + rad : T; END_VAR END_FUNCTION @@ -79,7 +79,7 @@ END_FUNCTION {external} FUNCTION ASIN : T VAR_INPUT - in : T; + in : T; END_VAR END_FUNCTION @@ -87,7 +87,7 @@ END_FUNCTION {external} FUNCTION ACOS : T VAR_INPUT - in : T; + in : T; END_VAR END_FUNCTION @@ -95,7 +95,7 @@ END_FUNCTION {external} FUNCTION ATAN : T VAR_INPUT - in : T; + in : T; END_VAR END_FUNCTION @@ -103,32 +103,32 @@ END_FUNCTION {external} FUNCTION ATAN2 : T VAR_INPUT - y : T; - x : T; + y : T; + x : T; END_VAR END_FUNCTION {external} FUNCTION EXPT : T -VAR_INPUT - in1 : T; - in2 : U; -END_VAR +VAR_INPUT + in1 : T; + in2 : U; +END_VAR END_FUNCTION {external} FUNCTION EXPT__REAL__DINT : REAL -VAR_INPUT - in1 : REAL; - in2 : DINT; +VAR_INPUT + in1 : REAL; + in2 : DINT; END_VAR END_FUNCTION {external} FUNCTION EXPT__REAL__REAL : REAL -VAR_INPUT - in1 : REAL; - in2 : REAL; +VAR_INPUT + in1 : REAL; + in2 : REAL; END_VAR END_FUNCTION @@ -137,144 +137,144 @@ END_FUNCTION On overflow, infinity of the same sign as the input is produced *) {external} FUNCTION EXPT__REAL__LREAL : REAL -VAR_INPUT - in1 : REAL; - in2 : LREAL; +VAR_INPUT + in1 : REAL; + in2 : LREAL; END_VAR END_FUNCTION {external} FUNCTION EXPT__LREAL__DINT : LREAL -VAR_INPUT - in1 : LREAL; - in2 : DINT; +VAR_INPUT + in1 : LREAL; + in2 : DINT; END_VAR END_FUNCTION {external} FUNCTION EXPT__LREAL__REAL : LREAL -VAR_INPUT - in1 : LREAL; - in2 : REAL; +VAR_INPUT + in1 : LREAL; + in2 : REAL; END_VAR END_FUNCTION {external} FUNCTION EXPT__LREAL__LREAL : LREAL -VAR_INPUT - in1 : LREAL; - in2 : LREAL; +VAR_INPUT + in1 : LREAL; + in2 : LREAL; END_VAR END_FUNCTION FUNCTION EXPT__REAL__USINT : REAL -VAR_INPUT - in1 : REAL; - in2 : USINT; +VAR_INPUT + in1 : REAL; + in2 : USINT; END_VAR EXPT__REAL__USINT := EXPT__REAL__DINT(in1, in2); END_FUNCTION FUNCTION EXPT__REAL__UINT : REAL -VAR_INPUT - in1 : REAL; - in2 : UINT; +VAR_INPUT + in1 : REAL; + in2 : UINT; END_VAR EXPT__REAL__UINT := EXPT__REAL__DINT(in1, in2); END_FUNCTION FUNCTION EXPT__REAL__UDINT : REAL -VAR_INPUT - in1 : REAL; - in2 : UDINT; +VAR_INPUT + in1 : REAL; + in2 : UDINT; END_VAR EXPT__REAL__UDINT := EXPT__REAL__DINT(in1, in2); END_FUNCTION FUNCTION EXPT__REAL__ULINT : REAL -VAR_INPUT - in1 : REAL; - in2 : ULINT; +VAR_INPUT + in1 : REAL; + in2 : ULINT; END_VAR EXPT__REAL__ULINT := EXPT__REAL__DINT(in1, in2); END_FUNCTION FUNCTION EXPT__REAL__SINT : REAL -VAR_INPUT - in1 : REAL; - in2 : SINT; +VAR_INPUT + in1 : REAL; + in2 : SINT; END_VAR EXPT__REAL__SINT := EXPT__REAL__DINT(in1, in2); END_FUNCTION FUNCTION EXPT__REAL__INT : REAL -VAR_INPUT - in1 : REAL; - in2 : INT; +VAR_INPUT + in1 : REAL; + in2 : INT; END_VAR EXPT__REAL__INT := EXPT__REAL__DINT(in1, in2); END_FUNCTION FUNCTION EXPT__REAL__LINT : REAL -VAR_INPUT - in1 : REAL; - in2 : LINT; +VAR_INPUT + in1 : REAL; + in2 : LINT; END_VAR EXPT__REAL__LINT := EXPT__REAL__DINT(in1, in2); END_FUNCTION FUNCTION EXPT__LREAL__USINT : LREAL -VAR_INPUT - in1 : LREAL; - in2 : USINT; +VAR_INPUT + in1 : LREAL; + in2 : USINT; END_VAR EXPT__LREAL__USINT := EXPT__LREAL__DINT(in1, in2); END_FUNCTION FUNCTION EXPT__LREAL__UINT : LREAL -VAR_INPUT - in1 : LREAL; - in2 : UINT; +VAR_INPUT + in1 : LREAL; + in2 : UINT; END_VAR EXPT__LREAL__UINT := EXPT__LREAL__DINT(in1, in2); END_FUNCTION FUNCTION EXPT__LREAL__UDINT : LREAL -VAR_INPUT - in1 : LREAL; - in2 : UDINT; +VAR_INPUT + in1 : LREAL; + in2 : UDINT; END_VAR EXPT__LREAL__UDINT := EXPT__LREAL__DINT(in1, in2); END_FUNCTION FUNCTION EXPT__LREAL__ULINT : LREAL -VAR_INPUT - in1 : LREAL; - in2 : ULINT; +VAR_INPUT + in1 : LREAL; + in2 : ULINT; END_VAR EXPT__LREAL__ULINT := EXPT__LREAL__DINT(in1, in2); END_FUNCTION FUNCTION EXPT__LREAL__SINT : LREAL -VAR_INPUT - in1 : LREAL; - in2 : SINT; +VAR_INPUT + in1 : LREAL; + in2 : SINT; END_VAR EXPT__LREAL__SINT := EXPT__LREAL__DINT(in1, in2); END_FUNCTION FUNCTION EXPT__LREAL__INT : LREAL -VAR_INPUT - in1 : LREAL; - in2 : INT; +VAR_INPUT + in1 : LREAL; + in2 : INT; END_VAR EXPT__LREAL__INT := EXPT__LREAL__DINT(in1, in2); END_FUNCTION FUNCTION EXPT__LREAL__LINT : LREAL -VAR_INPUT - in1 : LREAL; - in2 : LINT; +VAR_INPUT + in1 : LREAL; + in2 : LINT; END_VAR EXPT__LREAL__LINT := EXPT__LREAL__DINT(in1, in2); END_FUNCTION diff --git a/libs/stdlib/iec61131-st/bistable_functionblocks.st b/libs/stdlib/iec61131-st/bistable_functionblocks.st index aabb68bb3e..b4c6983431 100644 --- a/libs/stdlib/iec61131-st/bistable_functionblocks.st +++ b/libs/stdlib/iec61131-st/bistable_functionblocks.st @@ -10,11 +10,11 @@ Return: Output is used as return {external} FUNCTION_BLOCK SR VAR_INPUT - SET1: BOOL; - RESET: BOOL; + SET1: BOOL; + RESET: BOOL; END_VAR VAR_OUTPUT - Q1: BOOL; + Q1: BOOL; END_VAR END_FUNCTION_BLOCK @@ -30,10 +30,10 @@ Return: Output is used as return {external} FUNCTION_BLOCK RS VAR_INPUT - SET: BOOL; - RESET1: BOOL; + SET: BOOL; + RESET1: BOOL; END_VAR VAR_OUTPUT - Q1: BOOL; + Q1: BOOL; END_VAR -END_FUNCTION_BLOCK \ No newline at end of file +END_FUNCTION_BLOCK diff --git a/libs/stdlib/iec61131-st/bit_conversion.st b/libs/stdlib/iec61131-st/bit_conversion.st index 52fd86cd3d..4a3a9ee1f9 100644 --- a/libs/stdlib/iec61131-st/bit_conversion.st +++ b/libs/stdlib/iec61131-st/bit_conversion.st @@ -5,9 +5,9 @@ *********************) FUNCTION LWORD_TO_DWORD : DWORD VAR_INPUT - in : LWORD; + in : LWORD; END_VAR - LWORD_TO_DWORD := in; + LWORD_TO_DWORD := in; END_FUNCTION (******************** @@ -17,9 +17,9 @@ END_FUNCTION *********************) FUNCTION LWORD_TO_WORD : WORD VAR_INPUT - in : LWORD; + in : LWORD; END_VAR - LWORD_TO_WORD := in; + LWORD_TO_WORD := in; END_FUNCTION (******************** @@ -29,9 +29,9 @@ END_FUNCTION *********************) FUNCTION LWORD_TO_BYTE : BYTE VAR_INPUT - in : LWORD; + in : LWORD; END_VAR - LWORD_TO_BYTE := in; + LWORD_TO_BYTE := in; END_FUNCTION (******************** @@ -41,9 +41,9 @@ END_FUNCTION *********************) FUNCTION LWORD_TO_BOOL : BOOL VAR_INPUT - in : LWORD; + in : LWORD; END_VAR - LWORD_TO_BOOL := in.0; + LWORD_TO_BOOL := in.0; END_FUNCTION (******************** @@ -53,9 +53,9 @@ END_FUNCTION *********************) FUNCTION DWORD_TO_LWORD : LWORD VAR_INPUT - in : DWORD; + in : DWORD; END_VAR - DWORD_TO_LWORD := in; + DWORD_TO_LWORD := in; END_FUNCTION (******************** @@ -65,9 +65,9 @@ END_FUNCTION *********************) FUNCTION DWORD_TO_WORD : WORD VAR_INPUT - in : DWORD; + in : DWORD; END_VAR - DWORD_TO_WORD := in; + DWORD_TO_WORD := in; END_FUNCTION (******************** @@ -77,9 +77,9 @@ END_FUNCTION *********************) FUNCTION DWORD_TO_BYTE : BYTE VAR_INPUT - in : DWORD; + in : DWORD; END_VAR - DWORD_TO_BYTE := in; + DWORD_TO_BYTE := in; END_FUNCTION (******************** @@ -89,9 +89,9 @@ END_FUNCTION *********************) FUNCTION DWORD_TO_BOOL : BOOL VAR_INPUT - in : DWORD; + in : DWORD; END_VAR - DWORD_TO_BOOL := in.0; + DWORD_TO_BOOL := in.0; END_FUNCTION (******************** @@ -101,9 +101,9 @@ END_FUNCTION *********************) FUNCTION WORD_TO_LWORD : LWORD VAR_INPUT - in : WORD; + in : WORD; END_VAR - WORD_TO_LWORD := in; + WORD_TO_LWORD := in; END_FUNCTION (******************** @@ -113,9 +113,9 @@ END_FUNCTION *********************) FUNCTION WORD_TO_DWORD : DWORD VAR_INPUT - in : WORD; + in : WORD; END_VAR - WORD_TO_DWORD := in; + WORD_TO_DWORD := in; END_FUNCTION (******************** @@ -125,9 +125,9 @@ END_FUNCTION *********************) FUNCTION WORD_TO_BYTE : BYTE VAR_INPUT - in : WORD; + in : WORD; END_VAR - WORD_TO_BYTE := in; + WORD_TO_BYTE := in; END_FUNCTION (******************** @@ -137,9 +137,9 @@ END_FUNCTION *********************) FUNCTION WORD_TO_BOOL : BOOL VAR_INPUT - in : WORD; + in : WORD; END_VAR - WORD_TO_BOOL := in.0; + WORD_TO_BOOL := in.0; END_FUNCTION (******************** @@ -149,9 +149,9 @@ END_FUNCTION *********************) FUNCTION BYTE_TO_LWORD : LWORD VAR_INPUT - in : BYTE; + in : BYTE; END_VAR - BYTE_TO_LWORD := in; + BYTE_TO_LWORD := in; END_FUNCTION (******************** @@ -161,9 +161,9 @@ END_FUNCTION *********************) FUNCTION BYTE_TO_DWORD : DWORD VAR_INPUT - in : BYTE; + in : BYTE; END_VAR - BYTE_TO_DWORD := in; + BYTE_TO_DWORD := in; END_FUNCTION (******************** @@ -173,9 +173,9 @@ END_FUNCTION *********************) FUNCTION BYTE_TO_WORD : WORD VAR_INPUT - in : BYTE; + in : BYTE; END_VAR - BYTE_TO_WORD := in; + BYTE_TO_WORD := in; END_FUNCTION (******************** @@ -185,9 +185,9 @@ END_FUNCTION *********************) FUNCTION BYTE_TO_BOOL : BOOL VAR_INPUT - in : BYTE; + in : BYTE; END_VAR - BYTE_TO_BOOL := in.0; + BYTE_TO_BOOL := in.0; END_FUNCTION (******************** @@ -197,13 +197,13 @@ END_FUNCTION *********************) FUNCTION BYTE_TO_CHAR : CHAR VAR_INPUT - in : BYTE; + in : BYTE; END_VAR VAR - ptr : REF_TO CHAR; + ptr : REF_TO CHAR; END_VAR - ptr := ∈ - BYTE_TO_CHAR := ptr^; + ptr := ∈ + BYTE_TO_CHAR := ptr^; END_FUNCTION (******************** @@ -213,13 +213,13 @@ END_FUNCTION *********************) FUNCTION BOOL_TO_LWORD : LWORD VAR_INPUT - in : BOOL; + in : BOOL; END_VAR - IF in <> 0 THEN - BOOL_TO_LWORD := 1; - ELSE - BOOL_TO_LWORD := 0; - END_IF; + IF in <> 0 THEN + BOOL_TO_LWORD := 1; + ELSE + BOOL_TO_LWORD := 0; + END_IF; END_FUNCTION (******************** @@ -229,13 +229,13 @@ END_FUNCTION *********************) FUNCTION BOOL_TO_DWORD : DWORD VAR_INPUT - in : BOOL; + in : BOOL; END_VAR - IF in <> 0 THEN - BOOL_TO_DWORD := 1; - ELSE - BOOL_TO_DWORD := 0; - END_IF; + IF in <> 0 THEN + BOOL_TO_DWORD := 1; + ELSE + BOOL_TO_DWORD := 0; + END_IF; END_FUNCTION (******************** @@ -245,13 +245,13 @@ END_FUNCTION *********************) FUNCTION BOOL_TO_WORD : WORD VAR_INPUT - in : BOOL; + in : BOOL; END_VAR - IF in <> 0 THEN - BOOL_TO_WORD := 1; - ELSE - BOOL_TO_WORD := 0; - END_IF; + IF in <> 0 THEN + BOOL_TO_WORD := 1; + ELSE + BOOL_TO_WORD := 0; + END_IF; END_FUNCTION (******************** @@ -261,13 +261,13 @@ END_FUNCTION *********************) FUNCTION BOOL_TO_BYTE : BYTE VAR_INPUT - in : BOOL; + in : BOOL; END_VAR - IF in <> 0 THEN - BOOL_TO_BYTE := 1; - ELSE - BOOL_TO_BYTE := 0; - END_IF; + IF in <> 0 THEN + BOOL_TO_BYTE := 1; + ELSE + BOOL_TO_BYTE := 0; + END_IF; END_FUNCTION (******************** @@ -277,13 +277,13 @@ END_FUNCTION *********************) FUNCTION CHAR_TO_BYTE : BYTE VAR_INPUT - in : CHAR; + in : CHAR; END_VAR VAR - ptr : REF_TO BYTE; + ptr : REF_TO BYTE; END_VAR - ptr := ∈ - CHAR_TO_BYTE := ptr^; + ptr := ∈ + CHAR_TO_BYTE := ptr^; END_FUNCTION (******************** @@ -293,9 +293,9 @@ END_FUNCTION *********************) FUNCTION CHAR_TO_WORD : WORD VAR_INPUT - in : CHAR; + in : CHAR; END_VAR - CHAR_TO_WORD := CHAR_TO_BYTE(in); + CHAR_TO_WORD := CHAR_TO_BYTE(in); END_FUNCTION (******************** @@ -305,9 +305,9 @@ END_FUNCTION *********************) FUNCTION CHAR_TO_DWORD : DWORD VAR_INPUT - in : CHAR; + in : CHAR; END_VAR - CHAR_TO_DWORD := CHAR_TO_BYTE(in); + CHAR_TO_DWORD := CHAR_TO_BYTE(in); END_FUNCTION (******************** @@ -317,9 +317,9 @@ END_FUNCTION *********************) FUNCTION CHAR_TO_LWORD : LWORD VAR_INPUT - in : CHAR; + in : CHAR; END_VAR - CHAR_TO_LWORD := CHAR_TO_BYTE(in); + CHAR_TO_LWORD := CHAR_TO_BYTE(in); END_FUNCTION (******************** @@ -329,13 +329,13 @@ END_FUNCTION *********************) FUNCTION WCHAR_TO_WORD : WORD VAR_INPUT - in : WCHAR; + in : WCHAR; END_VAR VAR - ptr : REF_TO WORD; + ptr : REF_TO WORD; END_VAR - ptr := ∈ - WCHAR_TO_WORD := ptr^; + ptr := ∈ + WCHAR_TO_WORD := ptr^; END_FUNCTION (******************** @@ -345,9 +345,9 @@ END_FUNCTION *********************) FUNCTION WCHAR_TO_DWORD : DWORD VAR_INPUT - in : WCHAR; + in : WCHAR; END_VAR - WCHAR_TO_DWORD := WCHAR_TO_WORD(in); + WCHAR_TO_DWORD := WCHAR_TO_WORD(in); END_FUNCTION (******************** @@ -357,7 +357,7 @@ END_FUNCTION *********************) FUNCTION WCHAR_TO_LWORD : LWORD VAR_INPUT - in : WCHAR; + in : WCHAR; END_VAR - WCHAR_TO_LWORD := WCHAR_TO_WORD(in); -END_FUNCTION \ No newline at end of file + WCHAR_TO_LWORD := WCHAR_TO_WORD(in); +END_FUNCTION diff --git a/libs/stdlib/iec61131-st/bit_num_conversion.st b/libs/stdlib/iec61131-st/bit_num_conversion.st index 922c38ca9c..ff0f83ceee 100644 --- a/libs/stdlib/iec61131-st/bit_num_conversion.st +++ b/libs/stdlib/iec61131-st/bit_num_conversion.st @@ -6,7 +6,7 @@ {external} FUNCTION LWORD_TO_LREAL : LREAL VAR_INPUT - in : LWORD; + in : LWORD; END_VAR END_FUNCTION @@ -17,9 +17,9 @@ END_FUNCTION *********************) FUNCTION LWORD_TO_LINT : LINT VAR_INPUT - in : LWORD; + in : LWORD; END_VAR - LWORD_TO_LINT := in; + LWORD_TO_LINT := in; END_FUNCTION (******************** @@ -29,9 +29,9 @@ END_FUNCTION *********************) FUNCTION LWORD_TO_DINT : DINT VAR_INPUT - in : LWORD; + in : LWORD; END_VAR - LWORD_TO_DINT := in; + LWORD_TO_DINT := in; END_FUNCTION (******************** @@ -41,9 +41,9 @@ END_FUNCTION *********************) FUNCTION LWORD_TO_INT : INT VAR_INPUT - in : LWORD; + in : LWORD; END_VAR - LWORD_TO_INT := in; + LWORD_TO_INT := in; END_FUNCTION (******************** @@ -53,9 +53,9 @@ END_FUNCTION *********************) FUNCTION LWORD_TO_SINT : SINT VAR_INPUT - in : LWORD; + in : LWORD; END_VAR - LWORD_TO_SINT := in; + LWORD_TO_SINT := in; END_FUNCTION (******************** @@ -65,9 +65,9 @@ END_FUNCTION *********************) FUNCTION LWORD_TO_ULINT : ULINT VAR_INPUT - in : LWORD; + in : LWORD; END_VAR - LWORD_TO_ULINT := in; + LWORD_TO_ULINT := in; END_FUNCTION (******************** @@ -77,9 +77,9 @@ END_FUNCTION *********************) FUNCTION LWORD_TO_UDINT : UDINT VAR_INPUT - in : LWORD; + in : LWORD; END_VAR - LWORD_TO_UDINT := in; + LWORD_TO_UDINT := in; END_FUNCTION (******************** @@ -89,9 +89,9 @@ END_FUNCTION *********************) FUNCTION LWORD_TO_UINT : UINT VAR_INPUT - in : LWORD; + in : LWORD; END_VAR - LWORD_TO_UINT := in; + LWORD_TO_UINT := in; END_FUNCTION (******************** @@ -101,9 +101,9 @@ END_FUNCTION *********************) FUNCTION LWORD_TO_USINT : USINT VAR_INPUT - in : LWORD; + in : LWORD; END_VAR - LWORD_TO_USINT := in; + LWORD_TO_USINT := in; END_FUNCTION (******************** @@ -114,7 +114,7 @@ END_FUNCTION {external} FUNCTION DWORD_TO_REAL : REAL VAR_INPUT - in : DWORD; + in : DWORD; END_VAR END_FUNCTION @@ -125,9 +125,9 @@ END_FUNCTION *********************) FUNCTION DWORD_TO_LINT : LINT VAR_INPUT - in : DWORD; + in : DWORD; END_VAR - DWORD_TO_LINT := in; + DWORD_TO_LINT := in; END_FUNCTION (******************** @@ -137,9 +137,9 @@ END_FUNCTION *********************) FUNCTION DWORD_TO_DINT : DINT VAR_INPUT - in : DWORD; + in : DWORD; END_VAR - DWORD_TO_DINT := in; + DWORD_TO_DINT := in; END_FUNCTION (******************** @@ -149,9 +149,9 @@ END_FUNCTION *********************) FUNCTION DWORD_TO_INT : INT VAR_INPUT - in : DWORD; + in : DWORD; END_VAR - DWORD_TO_INT := in; + DWORD_TO_INT := in; END_FUNCTION (******************** @@ -161,9 +161,9 @@ END_FUNCTION *********************) FUNCTION DWORD_TO_SINT : SINT VAR_INPUT - in : DWORD; + in : DWORD; END_VAR - DWORD_TO_SINT := in; + DWORD_TO_SINT := in; END_FUNCTION (******************** @@ -173,9 +173,9 @@ END_FUNCTION *********************) FUNCTION DWORD_TO_ULINT : ULINT VAR_INPUT - in : DWORD; + in : DWORD; END_VAR - DWORD_TO_ULINT := in; + DWORD_TO_ULINT := in; END_FUNCTION (******************** @@ -185,9 +185,9 @@ END_FUNCTION *********************) FUNCTION DWORD_TO_UDINT : UDINT VAR_INPUT - in : DWORD; + in : DWORD; END_VAR - DWORD_TO_UDINT := in; + DWORD_TO_UDINT := in; END_FUNCTION (******************** @@ -197,9 +197,9 @@ END_FUNCTION *********************) FUNCTION DWORD_TO_UINT : UINT VAR_INPUT - in : DWORD; + in : DWORD; END_VAR - DWORD_TO_UINT := in; + DWORD_TO_UINT := in; END_FUNCTION (******************** @@ -209,9 +209,9 @@ END_FUNCTION *********************) FUNCTION DWORD_TO_USINT : USINT VAR_INPUT - in : DWORD; + in : DWORD; END_VAR - DWORD_TO_USINT := in; + DWORD_TO_USINT := in; END_FUNCTION (******************** @@ -221,9 +221,9 @@ END_FUNCTION *********************) FUNCTION WORD_TO_LINT : LINT VAR_INPUT - in : WORD; + in : WORD; END_VAR - WORD_TO_LINT := in; + WORD_TO_LINT := in; END_FUNCTION (******************** @@ -233,9 +233,9 @@ END_FUNCTION *********************) FUNCTION WORD_TO_DINT : DINT VAR_INPUT - in : WORD; + in : WORD; END_VAR - WORD_TO_DINT := in; + WORD_TO_DINT := in; END_FUNCTION (******************** @@ -245,9 +245,9 @@ END_FUNCTION *********************) FUNCTION WORD_TO_INT : INT VAR_INPUT - in : WORD; + in : WORD; END_VAR - WORD_TO_INT := in; + WORD_TO_INT := in; END_FUNCTION (******************** @@ -257,9 +257,9 @@ END_FUNCTION *********************) FUNCTION WORD_TO_SINT : SINT VAR_INPUT - in : WORD; + in : WORD; END_VAR - WORD_TO_SINT := in; + WORD_TO_SINT := in; END_FUNCTION (******************** @@ -269,9 +269,9 @@ END_FUNCTION *********************) FUNCTION WORD_TO_ULINT : ULINT VAR_INPUT - in : WORD; + in : WORD; END_VAR - WORD_TO_ULINT := in; + WORD_TO_ULINT := in; END_FUNCTION (******************** @@ -281,9 +281,9 @@ END_FUNCTION *********************) FUNCTION WORD_TO_UDINT : UDINT VAR_INPUT - in : WORD; + in : WORD; END_VAR - WORD_TO_UDINT := in; + WORD_TO_UDINT := in; END_FUNCTION (******************** @@ -293,9 +293,9 @@ END_FUNCTION *********************) FUNCTION WORD_TO_UINT : UINT VAR_INPUT - in : WORD; + in : WORD; END_VAR - WORD_TO_UINT := in; + WORD_TO_UINT := in; END_FUNCTION (******************** @@ -305,9 +305,9 @@ END_FUNCTION *********************) FUNCTION WORD_TO_USINT : USINT VAR_INPUT - in : WORD; + in : WORD; END_VAR - WORD_TO_USINT := in; + WORD_TO_USINT := in; END_FUNCTION (******************** @@ -317,9 +317,9 @@ END_FUNCTION *********************) FUNCTION BYTE_TO_LINT : LINT VAR_INPUT - in : BYTE; + in : BYTE; END_VAR - BYTE_TO_LINT := in; + BYTE_TO_LINT := in; END_FUNCTION (******************** @@ -329,9 +329,9 @@ END_FUNCTION *********************) FUNCTION BYTE_TO_DINT : DINT VAR_INPUT - in : BYTE; + in : BYTE; END_VAR - BYTE_TO_DINT := in; + BYTE_TO_DINT := in; END_FUNCTION (******************** @@ -341,9 +341,9 @@ END_FUNCTION *********************) FUNCTION BYTE_TO_INT : INT VAR_INPUT - in : BYTE; + in : BYTE; END_VAR - BYTE_TO_INT := in; + BYTE_TO_INT := in; END_FUNCTION (******************** @@ -353,9 +353,9 @@ END_FUNCTION *********************) FUNCTION BYTE_TO_SINT : SINT VAR_INPUT - in : BYTE; + in : BYTE; END_VAR - BYTE_TO_SINT := in; + BYTE_TO_SINT := in; END_FUNCTION (******************** @@ -365,9 +365,9 @@ END_FUNCTION *********************) FUNCTION BYTE_TO_ULINT : ULINT VAR_INPUT - in : BYTE; + in : BYTE; END_VAR - BYTE_TO_ULINT := in; + BYTE_TO_ULINT := in; END_FUNCTION (******************** @@ -377,9 +377,9 @@ END_FUNCTION *********************) FUNCTION BYTE_TO_UDINT : UDINT VAR_INPUT - in : BYTE; + in : BYTE; END_VAR - BYTE_TO_UDINT := in; + BYTE_TO_UDINT := in; END_FUNCTION (******************** @@ -389,9 +389,9 @@ END_FUNCTION *********************) FUNCTION BYTE_TO_UINT : UINT VAR_INPUT - in : BYTE; + in : BYTE; END_VAR - BYTE_TO_UINT := in; + BYTE_TO_UINT := in; END_FUNCTION (******************** @@ -401,9 +401,9 @@ END_FUNCTION *********************) FUNCTION BYTE_TO_USINT : USINT VAR_INPUT - in : BYTE; + in : BYTE; END_VAR - BYTE_TO_USINT := in; + BYTE_TO_USINT := in; END_FUNCTION (******************** @@ -413,9 +413,9 @@ END_FUNCTION *********************) FUNCTION BOOL_TO_LINT : LINT VAR_INPUT - in : BOOL; + in : BOOL; END_VAR - BOOL_TO_LINT := in; + BOOL_TO_LINT := in; END_FUNCTION (******************** @@ -425,9 +425,9 @@ END_FUNCTION *********************) FUNCTION BOOL_TO_DINT : DINT VAR_INPUT - in : BOOL; + in : BOOL; END_VAR - BOOL_TO_DINT := in; + BOOL_TO_DINT := in; END_FUNCTION (******************** @@ -437,9 +437,9 @@ END_FUNCTION *********************) FUNCTION BOOL_TO_INT : INT VAR_INPUT - in : BOOL; + in : BOOL; END_VAR - BOOL_TO_INT := in; + BOOL_TO_INT := in; END_FUNCTION (******************** @@ -449,9 +449,9 @@ END_FUNCTION *********************) FUNCTION BOOL_TO_SINT : SINT VAR_INPUT - in : BOOL; + in : BOOL; END_VAR - BOOL_TO_SINT := in; + BOOL_TO_SINT := in; END_FUNCTION (******************** @@ -461,9 +461,9 @@ END_FUNCTION *********************) FUNCTION BOOL_TO_ULINT : ULINT VAR_INPUT - in : BOOL; + in : BOOL; END_VAR - BOOL_TO_ULINT := in; + BOOL_TO_ULINT := in; END_FUNCTION (******************** @@ -473,9 +473,9 @@ END_FUNCTION *********************) FUNCTION BOOL_TO_UDINT : UDINT VAR_INPUT - in : BOOL; + in : BOOL; END_VAR - BOOL_TO_UDINT := in; + BOOL_TO_UDINT := in; END_FUNCTION (******************** @@ -485,9 +485,9 @@ END_FUNCTION *********************) FUNCTION BOOL_TO_UINT : UINT VAR_INPUT - in : BOOL; + in : BOOL; END_VAR - BOOL_TO_UINT := in; + BOOL_TO_UINT := in; END_FUNCTION (******************** @@ -497,9 +497,9 @@ END_FUNCTION *********************) FUNCTION BOOL_TO_USINT : USINT VAR_INPUT - in : BOOL; + in : BOOL; END_VAR - BOOL_TO_USINT := in; + BOOL_TO_USINT := in; END_FUNCTION (******************** @@ -510,7 +510,7 @@ END_FUNCTION {external} FUNCTION LREAL_TO_LWORD : LWORD VAR_INPUT - in : LREAL; + in : LREAL; END_VAR END_FUNCTION @@ -522,7 +522,7 @@ END_FUNCTION {external} FUNCTION REAL_TO_DWORD : DWORD VAR_INPUT - in : REAL; + in : REAL; END_VAR END_FUNCTION @@ -533,9 +533,9 @@ END_FUNCTION *********************) FUNCTION LINT_TO_LWORD : LWORD VAR_INPUT - in : LINT; + in : LINT; END_VAR - LINT_TO_LWORD := in; + LINT_TO_LWORD := in; END_FUNCTION (******************** @@ -545,9 +545,9 @@ END_FUNCTION *********************) FUNCTION LINT_TO_DWORD : DWORD VAR_INPUT - in : LINT; + in : LINT; END_VAR - LINT_TO_DWORD := in; + LINT_TO_DWORD := in; END_FUNCTION (******************** @@ -557,9 +557,9 @@ END_FUNCTION *********************) FUNCTION LINT_TO_WORD : WORD VAR_INPUT - in : LINT; + in : LINT; END_VAR - LINT_TO_WORD := in; + LINT_TO_WORD := in; END_FUNCTION (******************** @@ -569,9 +569,9 @@ END_FUNCTION *********************) FUNCTION LINT_TO_BYTE : BYTE VAR_INPUT - in : LINT; + in : LINT; END_VAR - LINT_TO_BYTE := in; + LINT_TO_BYTE := in; END_FUNCTION (******************** @@ -581,9 +581,9 @@ END_FUNCTION *********************) FUNCTION DINT_TO_LWORD : LWORD VAR_INPUT - in : DINT; + in : DINT; END_VAR - DINT_TO_LWORD := in; + DINT_TO_LWORD := in; END_FUNCTION (******************** @@ -593,9 +593,9 @@ END_FUNCTION *********************) FUNCTION DINT_TO_DWORD : DWORD VAR_INPUT - in : DINT; + in : DINT; END_VAR - DINT_TO_DWORD := in; + DINT_TO_DWORD := in; END_FUNCTION (******************** @@ -605,9 +605,9 @@ END_FUNCTION *********************) FUNCTION DINT_TO_WORD : WORD VAR_INPUT - in : DINT; + in : DINT; END_VAR - DINT_TO_WORD := in; + DINT_TO_WORD := in; END_FUNCTION (******************** @@ -617,9 +617,9 @@ END_FUNCTION *********************) FUNCTION DINT_TO_BYTE : BYTE VAR_INPUT - in : DINT; + in : DINT; END_VAR - DINT_TO_BYTE := in; + DINT_TO_BYTE := in; END_FUNCTION (******************** @@ -629,9 +629,9 @@ END_FUNCTION *********************) FUNCTION INT_TO_LWORD : LWORD VAR_INPUT - in : INT; + in : INT; END_VAR - INT_TO_LWORD := in; + INT_TO_LWORD := in; END_FUNCTION (******************** @@ -641,9 +641,9 @@ END_FUNCTION *********************) FUNCTION INT_TO_DWORD : DWORD VAR_INPUT - in : INT; + in : INT; END_VAR - INT_TO_DWORD := in; + INT_TO_DWORD := in; END_FUNCTION (******************** @@ -653,9 +653,9 @@ END_FUNCTION *********************) FUNCTION INT_TO_WORD : WORD VAR_INPUT - in : INT; + in : INT; END_VAR - INT_TO_WORD := in; + INT_TO_WORD := in; END_FUNCTION (******************** @@ -665,9 +665,9 @@ END_FUNCTION *********************) FUNCTION INT_TO_BYTE : BYTE VAR_INPUT - in : INT; + in : INT; END_VAR - INT_TO_BYTE := in; + INT_TO_BYTE := in; END_FUNCTION (******************** @@ -677,9 +677,9 @@ END_FUNCTION *********************) FUNCTION SINT_TO_LWORD : LWORD VAR_INPUT - in : SINT; + in : SINT; END_VAR - SINT_TO_LWORD := in; + SINT_TO_LWORD := in; END_FUNCTION (******************** @@ -689,9 +689,9 @@ END_FUNCTION *********************) FUNCTION SINT_TO_DWORD : DWORD VAR_INPUT - in : SINT; + in : SINT; END_VAR - SINT_TO_DWORD := in; + SINT_TO_DWORD := in; END_FUNCTION (******************** @@ -701,9 +701,9 @@ END_FUNCTION *********************) FUNCTION SINT_TO_WORD : WORD VAR_INPUT - in : SINT; + in : SINT; END_VAR - SINT_TO_WORD := in; + SINT_TO_WORD := in; END_FUNCTION (******************** @@ -713,9 +713,9 @@ END_FUNCTION *********************) FUNCTION SINT_TO_BYTE : BYTE VAR_INPUT - in : SINT; + in : SINT; END_VAR - SINT_TO_BYTE := in; + SINT_TO_BYTE := in; END_FUNCTION (******************** @@ -725,9 +725,9 @@ END_FUNCTION *********************) FUNCTION ULINT_TO_LWORD : LWORD VAR_INPUT - in : ULINT; + in : ULINT; END_VAR - ULINT_TO_LWORD := in; + ULINT_TO_LWORD := in; END_FUNCTION (******************** @@ -737,9 +737,9 @@ END_FUNCTION *********************) FUNCTION ULINT_TO_DWORD : DWORD VAR_INPUT - in : ULINT; + in : ULINT; END_VAR - ULINT_TO_DWORD := in; + ULINT_TO_DWORD := in; END_FUNCTION (******************** @@ -749,9 +749,9 @@ END_FUNCTION *********************) FUNCTION ULINT_TO_WORD : WORD VAR_INPUT - in : ULINT; + in : ULINT; END_VAR - ULINT_TO_WORD := in; + ULINT_TO_WORD := in; END_FUNCTION (******************** @@ -761,9 +761,9 @@ END_FUNCTION *********************) FUNCTION ULINT_TO_BYTE : BYTE VAR_INPUT - in : ULINT; + in : ULINT; END_VAR - ULINT_TO_BYTE := in; + ULINT_TO_BYTE := in; END_FUNCTION (******************** @@ -773,9 +773,9 @@ END_FUNCTION *********************) FUNCTION UDINT_TO_LWORD : LWORD VAR_INPUT - in : UDINT; + in : UDINT; END_VAR - UDINT_TO_LWORD := in; + UDINT_TO_LWORD := in; END_FUNCTION (******************** @@ -785,9 +785,9 @@ END_FUNCTION *********************) FUNCTION UDINT_TO_DWORD : DWORD VAR_INPUT - in : UDINT; + in : UDINT; END_VAR - UDINT_TO_DWORD := in; + UDINT_TO_DWORD := in; END_FUNCTION (******************** @@ -797,9 +797,9 @@ END_FUNCTION *********************) FUNCTION UDINT_TO_WORD : WORD VAR_INPUT - in : UDINT; + in : UDINT; END_VAR - UDINT_TO_WORD := in; + UDINT_TO_WORD := in; END_FUNCTION (******************** @@ -809,9 +809,9 @@ END_FUNCTION *********************) FUNCTION UDINT_TO_BYTE : BYTE VAR_INPUT - in : UDINT; + in : UDINT; END_VAR - UDINT_TO_BYTE := in; + UDINT_TO_BYTE := in; END_FUNCTION (******************** @@ -821,9 +821,9 @@ END_FUNCTION *********************) FUNCTION UINT_TO_LWORD : LWORD VAR_INPUT - in : UINT; + in : UINT; END_VAR - UINT_TO_LWORD := in; + UINT_TO_LWORD := in; END_FUNCTION (******************** @@ -833,9 +833,9 @@ END_FUNCTION *********************) FUNCTION UINT_TO_DWORD : DWORD VAR_INPUT - in : UINT; + in : UINT; END_VAR - UINT_TO_DWORD := in; + UINT_TO_DWORD := in; END_FUNCTION (******************** @@ -845,9 +845,9 @@ END_FUNCTION *********************) FUNCTION UINT_TO_WORD : WORD VAR_INPUT - in : UINT; + in : UINT; END_VAR - UINT_TO_WORD := in; + UINT_TO_WORD := in; END_FUNCTION (******************** @@ -857,9 +857,9 @@ END_FUNCTION *********************) FUNCTION UINT_TO_BYTE : BYTE VAR_INPUT - in : UINT; + in : UINT; END_VAR - UINT_TO_BYTE := in; + UINT_TO_BYTE := in; END_FUNCTION (******************** @@ -869,9 +869,9 @@ END_FUNCTION *********************) FUNCTION USINT_TO_LWORD : LWORD VAR_INPUT - in : USINT; + in : USINT; END_VAR - USINT_TO_LWORD := in; + USINT_TO_LWORD := in; END_FUNCTION (******************** @@ -881,9 +881,9 @@ END_FUNCTION *********************) FUNCTION USINT_TO_DWORD : DWORD VAR_INPUT - in : USINT; + in : USINT; END_VAR - USINT_TO_DWORD := in; + USINT_TO_DWORD := in; END_FUNCTION (******************** @@ -893,9 +893,9 @@ END_FUNCTION *********************) FUNCTION USINT_TO_WORD : WORD VAR_INPUT - in : USINT; + in : USINT; END_VAR - USINT_TO_WORD := in; + USINT_TO_WORD := in; END_FUNCTION (******************** @@ -905,7 +905,7 @@ END_FUNCTION *********************) FUNCTION USINT_TO_BYTE : BYTE VAR_INPUT - in : USINT; + in : USINT; END_VAR - USINT_TO_BYTE := in; -END_FUNCTION \ No newline at end of file + USINT_TO_BYTE := in; +END_FUNCTION diff --git a/libs/stdlib/iec61131-st/bit_shift_functions.st b/libs/stdlib/iec61131-st/bit_shift_functions.st index d6e6ef3624..74676fef60 100644 --- a/libs/stdlib/iec61131-st/bit_shift_functions.st +++ b/libs/stdlib/iec61131-st/bit_shift_functions.st @@ -1,69 +1,68 @@ (************************** - * + * * SHL(IN, n) - * + * * This operator implements a bitwise shift of an operand to the left. * IN is shifted by n bit to the left and is filled from the right with zeros. - * + * *************************) {external} FUNCTION SHL : T VAR_INPUT - IN : T; - n : UDINT; + IN : T; + n : UDINT; END_VAR END_FUNCTION (************************** - * + * * SHR(IN, n) - * + * * This operator implements a bitwise shift of an operand to the right. - * IN is shifted by n bit to the right. - * If an unsigned data type is used, filling from the left with zeros ensues. - * In the case of signed data types, an arithmetic shifting is implemented, + * IN is shifted by n bit to the right. + * If an unsigned data type is used, filling from the left with zeros ensues. + * In the case of signed data types, an arithmetic shifting is implemented, * i.e. it is filled with the value of the highest bit. - * + * *************************) {external} FUNCTION SHR : T VAR_INPUT - IN : T; - n : UDINT; + IN : T; + n : UDINT; END_VAR END_FUNCTION (************************** - * + * * ROL(IN, n) - * + * * This operator implements a bitwise rotation of an operand to the left. - * IN is shifted n-times to the left, + * IN is shifted n-times to the left, * whereby the highest bit from the right is again inserted. - * + * *************************) {external} -FUNCTION ROL : T +FUNCTION ROL : T VAR_INPUT - IN : T; - n : UDINT; + IN : T; + n : UDINT; END_VAR END_FUNCTION (************************** - * + * * ROR(IN, n) - * + * * This operator implements a bitwise rotation of an operand to the right. - * IN is shifted n-times to the right, + * IN is shifted n-times to the right, * whereby the lowest bit from the left is again inserted. - * + * *************************) {external} -FUNCTION ROR : T +FUNCTION ROR : T VAR_INPUT - IN : T; - n : UDINT; + IN : T; + n : UDINT; END_VAR END_FUNCTION - diff --git a/libs/stdlib/iec61131-st/counters.st b/libs/stdlib/iec61131-st/counters.st index 1b6b72a12b..b83a6330ea 100644 --- a/libs/stdlib/iec61131-st/counters.st +++ b/libs/stdlib/iec61131-st/counters.st @@ -12,16 +12,16 @@ Return: Output is used as return value {external} FUNCTION_BLOCK CTU VAR_INPUT - CU : BOOL; - R : BOOL; - PV : INT; + CU : BOOL; + R : BOOL; + PV : INT; END_VAR VAR_OUTPUT - Q : BOOL; - CV : INT; + Q : BOOL; + CV : INT; END_VAR VAR - M : BOOL; + M : BOOL; END_VAR END_FUNCTION_BLOCK @@ -39,16 +39,16 @@ Return: Output is used as return value {external} FUNCTION_BLOCK CTU_INT VAR_INPUT - CU : BOOL; - R : BOOL; - PV : INT; + CU : BOOL; + R : BOOL; + PV : INT; END_VAR VAR_OUTPUT - Q : BOOL; - CV : INT; + Q : BOOL; + CV : INT; END_VAR VAR - M : BOOL; + M : BOOL; END_VAR END_FUNCTION_BLOCK @@ -66,16 +66,16 @@ Return: Output is used as return value {external} FUNCTION_BLOCK CTU_DINT VAR_INPUT - CU : BOOL; - R : BOOL; - PV : DINT; + CU : BOOL; + R : BOOL; + PV : DINT; END_VAR VAR_OUTPUT - Q : BOOL; - CV : DINT; + Q : BOOL; + CV : DINT; END_VAR VAR - M : BOOL; + M : BOOL; END_VAR END_FUNCTION_BLOCK @@ -93,16 +93,16 @@ Return: Output is used as return value {external} FUNCTION_BLOCK CTU_UDINT VAR_INPUT - CU : BOOL; - R : BOOL; - PV : UDINT; + CU : BOOL; + R : BOOL; + PV : UDINT; END_VAR VAR_OUTPUT - Q : BOOL; - CV : UDINT; + Q : BOOL; + CV : UDINT; END_VAR VAR - M : BOOL; + M : BOOL; END_VAR END_FUNCTION_BLOCK @@ -120,16 +120,16 @@ Return: Output is used as return value {external} FUNCTION_BLOCK CTU_LINT VAR_INPUT - CU : BOOL; - R : BOOL; - PV : LINT; + CU : BOOL; + R : BOOL; + PV : LINT; END_VAR VAR_OUTPUT - Q : BOOL; - CV : LINT; + Q : BOOL; + CV : LINT; END_VAR VAR - M : BOOL; + M : BOOL; END_VAR END_FUNCTION_BLOCK @@ -147,16 +147,16 @@ Return: Output is used as return value {external} FUNCTION_BLOCK CTU_ULINT VAR_INPUT - CU : BOOL; - R : BOOL; - PV : ULINT; + CU : BOOL; + R : BOOL; + PV : ULINT; END_VAR VAR_OUTPUT - Q : BOOL; - CV : ULINT; + Q : BOOL; + CV : ULINT; END_VAR VAR - M : BOOL; + M : BOOL; END_VAR END_FUNCTION_BLOCK @@ -174,16 +174,16 @@ Return: Output is used as return value {external} FUNCTION_BLOCK CTD VAR_INPUT - CD : BOOL; - LD : BOOL; - PV : INT; + CD : BOOL; + LD : BOOL; + PV : INT; END_VAR VAR_OUTPUT - Q : BOOL; - CV : INT; + Q : BOOL; + CV : INT; END_VAR VAR - M : BOOL; + M : BOOL; END_VAR END_FUNCTION_BLOCK @@ -201,16 +201,16 @@ Return: Output is used as return value {external} FUNCTION_BLOCK CTD_INT VAR_INPUT - CD : BOOL; - LD : BOOL; - PV : INT; + CD : BOOL; + LD : BOOL; + PV : INT; END_VAR VAR_OUTPUT - Q : BOOL; - CV : INT; + Q : BOOL; + CV : INT; END_VAR VAR - M : BOOL; + M : BOOL; END_VAR END_FUNCTION_BLOCK @@ -228,16 +228,16 @@ Return: Output is used as return value {external} FUNCTION_BLOCK CTD_DINT VAR_INPUT - CD : BOOL; - LD : BOOL; - PV : DINT; + CD : BOOL; + LD : BOOL; + PV : DINT; END_VAR VAR_OUTPUT - Q : BOOL; - CV : DINT; + Q : BOOL; + CV : DINT; END_VAR VAR - M : BOOL; + M : BOOL; END_VAR END_FUNCTION_BLOCK @@ -255,16 +255,16 @@ Return: Output is used as return value {external} FUNCTION_BLOCK CTD_UDINT VAR_INPUT - CD : BOOL; - LD : BOOL; - PV : UDINT; + CD : BOOL; + LD : BOOL; + PV : UDINT; END_VAR VAR_OUTPUT - Q : BOOL; - CV : UDINT; + Q : BOOL; + CV : UDINT; END_VAR VAR - M : BOOL; + M : BOOL; END_VAR END_FUNCTION_BLOCK @@ -282,16 +282,16 @@ Return: Output is used as return value {external} FUNCTION_BLOCK CTD_LINT VAR_INPUT - CD : BOOL; - LD : BOOL; - PV : LINT; + CD : BOOL; + LD : BOOL; + PV : LINT; END_VAR VAR_OUTPUT - Q : BOOL; - CV : LINT; + Q : BOOL; + CV : LINT; END_VAR VAR - M : BOOL; + M : BOOL; END_VAR END_FUNCTION_BLOCK @@ -309,16 +309,16 @@ Return: Output is used as return value {external} FUNCTION_BLOCK CTD_ULINT VAR_INPUT - CD : BOOL; - LD : BOOL; - PV : ULINT; + CD : BOOL; + LD : BOOL; + PV : ULINT; END_VAR VAR_OUTPUT - Q : BOOL; - CV : ULINT; + Q : BOOL; + CV : ULINT; END_VAR VAR - M : BOOL; + M : BOOL; END_VAR END_FUNCTION_BLOCK @@ -339,20 +339,20 @@ Return: Output is used as return value {external} FUNCTION_BLOCK CTUD VAR_INPUT - CU : BOOL; - CD : BOOL; - R : BOOL; - LD : BOOL; - PV : INT; + CU : BOOL; + CD : BOOL; + R : BOOL; + LD : BOOL; + PV : INT; END_VAR VAR_OUTPUT - QU : BOOL; - QD : BOOL; - CV : INT; + QU : BOOL; + QD : BOOL; + CV : INT; END_VAR VAR - MU : BOOL; - MD : BOOL; + MU : BOOL; + MD : BOOL; END_VAR END_FUNCTION_BLOCK @@ -373,20 +373,20 @@ Return: Output is used as return value {external} FUNCTION_BLOCK CTUD_INT VAR_INPUT - CU : BOOL; - CD : BOOL; - R : BOOL; - LD : BOOL; - PV : INT; + CU : BOOL; + CD : BOOL; + R : BOOL; + LD : BOOL; + PV : INT; END_VAR VAR_OUTPUT - QU : BOOL; - QD : BOOL; - CV : INT; + QU : BOOL; + QD : BOOL; + CV : INT; END_VAR VAR - MU : BOOL; - MD : BOOL; + MU : BOOL; + MD : BOOL; END_VAR END_FUNCTION_BLOCK @@ -407,20 +407,20 @@ Return: Output is used as return value {external} FUNCTION_BLOCK CTUD_DINT VAR_INPUT - CU : BOOL; - CD : BOOL; - R : BOOL; - LD : BOOL; - PV : DINT; + CU : BOOL; + CD : BOOL; + R : BOOL; + LD : BOOL; + PV : DINT; END_VAR VAR_OUTPUT - QU : BOOL; - QD : BOOL; - CV : DINT; + QU : BOOL; + QD : BOOL; + CV : DINT; END_VAR VAR - MU : BOOL; - MD : BOOL; + MU : BOOL; + MD : BOOL; END_VAR END_FUNCTION_BLOCK @@ -441,20 +441,20 @@ Return: Output is used as return value {external} FUNCTION_BLOCK CTUD_UDINT VAR_INPUT - CU : BOOL; - CD : BOOL; - R : BOOL; - LD : BOOL; - PV : UDINT; + CU : BOOL; + CD : BOOL; + R : BOOL; + LD : BOOL; + PV : UDINT; END_VAR VAR_OUTPUT - QU : BOOL; - QD : BOOL; - CV : UDINT; + QU : BOOL; + QD : BOOL; + CV : UDINT; END_VAR VAR - MU : BOOL; - MD : BOOL; + MU : BOOL; + MD : BOOL; END_VAR END_FUNCTION_BLOCK @@ -475,20 +475,20 @@ Return: Output is used as return value {external} FUNCTION_BLOCK CTUD_LINT VAR_INPUT - CU : BOOL; - CD : BOOL; - R : BOOL; - LD : BOOL; - PV : LINT; + CU : BOOL; + CD : BOOL; + R : BOOL; + LD : BOOL; + PV : LINT; END_VAR VAR_OUTPUT - QU : BOOL; - QD : BOOL; - CV : LINT; + QU : BOOL; + QD : BOOL; + CV : LINT; END_VAR VAR - MU : BOOL; - MD : BOOL; + MU : BOOL; + MD : BOOL; END_VAR END_FUNCTION_BLOCK @@ -509,19 +509,19 @@ Return: Output is used as return value {external} FUNCTION_BLOCK CTUD_ULINT VAR_INPUT - CU : BOOL; - CD : BOOL; - R : BOOL; - LD : BOOL; - PV : ULINT; + CU : BOOL; + CD : BOOL; + R : BOOL; + LD : BOOL; + PV : ULINT; END_VAR VAR_OUTPUT - QU : BOOL; - QD : BOOL; - CV : ULINT; + QU : BOOL; + QD : BOOL; + CV : ULINT; END_VAR VAR - MU : BOOL; - MD : BOOL; + MU : BOOL; + MD : BOOL; END_VAR -END_FUNCTION_BLOCK \ No newline at end of file +END_FUNCTION_BLOCK diff --git a/libs/stdlib/iec61131-st/date_time_conversion.st b/libs/stdlib/iec61131-st/date_time_conversion.st index 0615f61332..91bae5d3dc 100644 --- a/libs/stdlib/iec61131-st/date_time_conversion.st +++ b/libs/stdlib/iec61131-st/date_time_conversion.st @@ -6,7 +6,7 @@ {external} FUNCTION DATE_AND_TIME_TO_DATE : DATE VAR_INPUT - in : DT; + in : DT; END_VAR END_FUNCTION @@ -18,7 +18,7 @@ END_FUNCTION {external} FUNCTION DATE_AND_TIME_TO_TIME_OF_DAY : TOD VAR_INPUT - in : DT; + in : DT; END_VAR END_FUNCTION @@ -29,9 +29,9 @@ END_FUNCTION *********************) FUNCTION LTIME_TO_TIME : TIME VAR_INPUT - in : LTIME; + in : LTIME; END_VAR - LTIME_TO_TIME := in; + LTIME_TO_TIME := in; END_FUNCTION (******************** @@ -41,9 +41,9 @@ END_FUNCTION *********************) FUNCTION TIME_TO_LTIME : LTIME VAR_INPUT - in : TIME; + in : TIME; END_VAR - TIME_TO_LTIME := in; + TIME_TO_LTIME := in; END_FUNCTION (******************** @@ -53,9 +53,9 @@ END_FUNCTION *********************) FUNCTION LDT_TO_DT : DT VAR_INPUT - in : LDT; + in : LDT; END_VAR - LDT_TO_DT := in; + LDT_TO_DT := in; END_FUNCTION (******************** @@ -65,9 +65,9 @@ END_FUNCTION *********************) FUNCTION LDT_TO_DATE : DATE VAR_INPUT - in : LDT; + in : LDT; END_VAR - LDT_TO_DATE := DATE_AND_TIME_TO_DATE(in); + LDT_TO_DATE := DATE_AND_TIME_TO_DATE(in); END_FUNCTION (******************** @@ -77,9 +77,9 @@ END_FUNCTION *********************) FUNCTION LDT_TO_LTOD : LTOD VAR_INPUT - in : LDT; + in : LDT; END_VAR - LDT_TO_LTOD := DATE_AND_TIME_TO_TIME_OF_DAY(in); + LDT_TO_LTOD := DATE_AND_TIME_TO_TIME_OF_DAY(in); END_FUNCTION (******************** @@ -89,9 +89,9 @@ END_FUNCTION *********************) FUNCTION LDT_TO_TOD : TOD VAR_INPUT - in : LDT; + in : LDT; END_VAR - LDT_TO_TOD := DATE_AND_TIME_TO_TIME_OF_DAY(in); + LDT_TO_TOD := DATE_AND_TIME_TO_TIME_OF_DAY(in); END_FUNCTION (******************** @@ -101,9 +101,9 @@ END_FUNCTION *********************) FUNCTION DT_TO_LDT : LDT VAR_INPUT - in : DT; + in : DT; END_VAR - DT_TO_LDT := in; + DT_TO_LDT := in; END_FUNCTION (******************** @@ -113,9 +113,9 @@ END_FUNCTION *********************) FUNCTION DT_TO_DATE : DATE VAR_INPUT - in : DT; + in : DT; END_VAR - DT_TO_DATE := DATE_AND_TIME_TO_DATE(in); + DT_TO_DATE := DATE_AND_TIME_TO_DATE(in); END_FUNCTION (******************** @@ -125,9 +125,9 @@ END_FUNCTION *********************) FUNCTION DT_TO_LTOD : LTOD VAR_INPUT - in : DT; + in : DT; END_VAR - DT_TO_LTOD := DATE_AND_TIME_TO_TIME_OF_DAY(in); + DT_TO_LTOD := DATE_AND_TIME_TO_TIME_OF_DAY(in); END_FUNCTION (******************** @@ -137,9 +137,9 @@ END_FUNCTION *********************) FUNCTION DT_TO_TOD : TOD VAR_INPUT - in : DT; + in : DT; END_VAR - DT_TO_TOD := DATE_AND_TIME_TO_TIME_OF_DAY(in); + DT_TO_TOD := DATE_AND_TIME_TO_TIME_OF_DAY(in); END_FUNCTION (******************** @@ -149,9 +149,9 @@ END_FUNCTION *********************) FUNCTION LTOD_TO_TOD : TOD VAR_INPUT - in : LTOD; + in : LTOD; END_VAR - LTOD_TO_TOD := in; + LTOD_TO_TOD := in; END_FUNCTION (******************** @@ -161,7 +161,7 @@ END_FUNCTION *********************) FUNCTION TOD_TO_LTOD : LTOD VAR_INPUT - in : TOD; + in : TOD; END_VAR - TOD_TO_LTOD := in; -END_FUNCTION \ No newline at end of file + TOD_TO_LTOD := in; +END_FUNCTION diff --git a/libs/stdlib/iec61131-st/date_time_extra_functions.st b/libs/stdlib/iec61131-st/date_time_extra_functions.st index bc28622c51..42d630308a 100644 --- a/libs/stdlib/iec61131-st/date_time_extra_functions.st +++ b/libs/stdlib/iec61131-st/date_time_extra_functions.st @@ -6,8 +6,8 @@ {external} FUNCTION CONCAT_DATE_TOD : DT VAR_INPUT - date_input : DATE; - tod_input : TOD; + date_input : DATE; + tod_input : TOD; END_VAR END_FUNCTION @@ -18,10 +18,10 @@ END_FUNCTION *********************) FUNCTION CONCAT_DATE_LTOD : DT VAR_INPUT - date_input : DATE; - tod_input : LTOD; + date_input : DATE; + tod_input : LTOD; END_VAR - CONCAT_DATE_LTOD := CONCAT_DATE_TOD(date_input, tod_input); + CONCAT_DATE_LTOD := CONCAT_DATE_TOD(date_input, tod_input); END_FUNCTION (******************** @@ -32,9 +32,9 @@ END_FUNCTION {external} FUNCTION CONCAT_DATE : DATE VAR_INPUT - year : T; - month : T; - day : T; + year : T; + month : T; + day : T; END_VAR END_FUNCTION @@ -46,10 +46,10 @@ END_FUNCTION {external} FUNCTION CONCAT_TOD : TOD VAR_INPUT - hour : T; - minute : T; - second : T; - millisecond : T; + hour : T; + minute : T; + second : T; + millisecond : T; END_VAR END_FUNCTION @@ -60,99 +60,99 @@ END_FUNCTION *********************) FUNCTION CONCAT_LTOD : LTOD VAR_INPUT - hour : T; - minute : T; - second : T; - millisecond : T; + hour : T; + minute : T; + second : T; + millisecond : T; END_VAR END_FUNCTION (* Specialized implementation of CONCAT_LTOD for SINT *) FUNCTION CONCAT_LTOD__SINT : LTOD VAR_INPUT - hour : SINT; - minute : SINT; - second : SINT; - millisecond : SINT; + hour : SINT; + minute : SINT; + second : SINT; + millisecond : SINT; END_VAR - CONCAT_LTOD__SINT := CONCAT_TOD(hour, minute, second, millisecond); + CONCAT_LTOD__SINT := CONCAT_TOD(hour, minute, second, millisecond); END_FUNCTION (* Specialized implementation of CONCAT_LTOD for USINT *) FUNCTION CONCAT_LTOD__USINT : LTOD VAR_INPUT - hour : USINT; - minute : USINT; - second : USINT; - millisecond : USINT; + hour : USINT; + minute : USINT; + second : USINT; + millisecond : USINT; END_VAR - CONCAT_LTOD__USINT := CONCAT_TOD(hour, minute, second, millisecond); + CONCAT_LTOD__USINT := CONCAT_TOD(hour, minute, second, millisecond); END_FUNCTION (* Specialized implementation of CONCAT_LTOD for INT *) FUNCTION CONCAT_LTOD__INT : LTOD VAR_INPUT - hour : INT; - minute : INT; - second : INT; - millisecond : INT; + hour : INT; + minute : INT; + second : INT; + millisecond : INT; END_VAR - CONCAT_LTOD__INT := CONCAT_TOD(hour, minute, second, millisecond); + CONCAT_LTOD__INT := CONCAT_TOD(hour, minute, second, millisecond); END_FUNCTION (* Specialized implementation of CONCAT_LTOD for UINT *) FUNCTION CONCAT_LTOD__UINT : LTOD VAR_INPUT - hour : UINT; - minute : UINT; - second : UINT; - millisecond : UINT; + hour : UINT; + minute : UINT; + second : UINT; + millisecond : UINT; END_VAR - CONCAT_LTOD__UINT := CONCAT_TOD(hour, minute, second, millisecond); + CONCAT_LTOD__UINT := CONCAT_TOD(hour, minute, second, millisecond); END_FUNCTION (* Specialized implementation of CONCAT_LTOD for DINT *) FUNCTION CONCAT_LTOD__DINT : LTOD VAR_INPUT - hour : DINT; - minute : DINT; - second : DINT; - millisecond : DINT; + hour : DINT; + minute : DINT; + second : DINT; + millisecond : DINT; END_VAR - CONCAT_LTOD__DINT := CONCAT_TOD(hour, minute, second, millisecond); + CONCAT_LTOD__DINT := CONCAT_TOD(hour, minute, second, millisecond); END_FUNCTION (* Specialized implementation of CONCAT_LTOD for UDINT *) FUNCTION CONCAT_LTOD__UDINT : LTOD VAR_INPUT - hour : UDINT; - minute : UDINT; - second : UDINT; - millisecond : UDINT; + hour : UDINT; + minute : UDINT; + second : UDINT; + millisecond : UDINT; END_VAR - CONCAT_LTOD__UDINT := CONCAT_TOD(hour, minute, second, millisecond); + CONCAT_LTOD__UDINT := CONCAT_TOD(hour, minute, second, millisecond); END_FUNCTION (* Specialized implementation of CONCAT_LTOD for LINT *) FUNCTION CONCAT_LTOD__LINT : LTOD VAR_INPUT - hour : LINT; - minute : LINT; - second : LINT; - millisecond : LINT; + hour : LINT; + minute : LINT; + second : LINT; + millisecond : LINT; END_VAR - CONCAT_LTOD__LINT := CONCAT_TOD(hour, minute, second, millisecond); + CONCAT_LTOD__LINT := CONCAT_TOD(hour, minute, second, millisecond); END_FUNCTION (* Specialized implementation of CONCAT_LTOD for ULINT *) FUNCTION CONCAT_LTOD__ULINT : LTOD VAR_INPUT - hour : ULINT; - minute : ULINT; - second : ULINT; - millisecond : ULINT; + hour : ULINT; + minute : ULINT; + second : ULINT; + millisecond : ULINT; END_VAR - CONCAT_LTOD__ULINT := CONCAT_TOD(hour, minute, second, millisecond); + CONCAT_LTOD__ULINT := CONCAT_TOD(hour, minute, second, millisecond); END_FUNCTION (******************** @@ -162,98 +162,98 @@ END_FUNCTION *********************) FUNCTION CONCAT_DT : DT VAR_INPUT - year : T; - month : T; - day : T; - hour : T; - minute : T; - second : T; - millisecond : T; + year : T; + month : T; + day : T; + hour : T; + minute : T; + second : T; + millisecond : T; END_VAR END_FUNCTION (* Specialized implementation of CONCAT_DT for INT *) FUNCTION CONCAT_DT__INT : DT VAR_INPUT - year : INT; - month : INT; - day : INT; - hour : INT; - minute : INT; - second : INT; - millisecond : INT; + year : INT; + month : INT; + day : INT; + hour : INT; + minute : INT; + second : INT; + millisecond : INT; END_VAR - CONCAT_DT__INT := CONCAT_DATE_TOD(CONCAT_DATE(year, month, day), CONCAT_TOD(hour, minute, second, millisecond)); + CONCAT_DT__INT := CONCAT_DATE_TOD(CONCAT_DATE(year, month, day), CONCAT_TOD(hour, minute, second, millisecond)); END_FUNCTION (* Specialized implementation of CONCAT_DT for UINT *) FUNCTION CONCAT_DT__UINT : DT VAR_INPUT - year : UINT; - month : UINT; - day : UINT; - hour : UINT; - minute : UINT; - second : UINT; - millisecond : UINT; + year : UINT; + month : UINT; + day : UINT; + hour : UINT; + minute : UINT; + second : UINT; + millisecond : UINT; END_VAR - CONCAT_DT__UINT := CONCAT_DATE_TOD(CONCAT_DATE(year, month, day), CONCAT_TOD(hour, minute, second, millisecond)); + CONCAT_DT__UINT := CONCAT_DATE_TOD(CONCAT_DATE(year, month, day), CONCAT_TOD(hour, minute, second, millisecond)); END_FUNCTION (* Specialized implementation of CONCAT_DT for DINT *) FUNCTION CONCAT_DT__DINT : DT VAR_INPUT - year : DINT; - month : DINT; - day : DINT; - hour : DINT; - minute : DINT; - second : DINT; - millisecond : DINT; + year : DINT; + month : DINT; + day : DINT; + hour : DINT; + minute : DINT; + second : DINT; + millisecond : DINT; END_VAR - CONCAT_DT__DINT := CONCAT_DATE_TOD(CONCAT_DATE(year, month, day), CONCAT_TOD(hour, minute, second, millisecond)); + CONCAT_DT__DINT := CONCAT_DATE_TOD(CONCAT_DATE(year, month, day), CONCAT_TOD(hour, minute, second, millisecond)); END_FUNCTION (* Specialized implementation of CONCAT_DT for UDINT *) FUNCTION CONCAT_DT__UDINT : DT VAR_INPUT - year : UDINT; - month : UDINT; - day : UDINT; - hour : UDINT; - minute : UDINT; - second : UDINT; - millisecond : UDINT; + year : UDINT; + month : UDINT; + day : UDINT; + hour : UDINT; + minute : UDINT; + second : UDINT; + millisecond : UDINT; END_VAR - CONCAT_DT__UDINT := CONCAT_DATE_TOD(CONCAT_DATE(year, month, day), CONCAT_TOD(hour, minute, second, millisecond)); + CONCAT_DT__UDINT := CONCAT_DATE_TOD(CONCAT_DATE(year, month, day), CONCAT_TOD(hour, minute, second, millisecond)); END_FUNCTION (* Specialized implementation of CONCAT_DT for LINT *) FUNCTION CONCAT_DT__LINT : DT VAR_INPUT - year : LINT; - month : LINT; - day : LINT; - hour : LINT; - minute : LINT; - second : LINT; - millisecond : LINT; + year : LINT; + month : LINT; + day : LINT; + hour : LINT; + minute : LINT; + second : LINT; + millisecond : LINT; END_VAR - CONCAT_DT__LINT := CONCAT_DATE_TOD(CONCAT_DATE(year, month, day), CONCAT_TOD(hour, minute, second, millisecond)); + CONCAT_DT__LINT := CONCAT_DATE_TOD(CONCAT_DATE(year, month, day), CONCAT_TOD(hour, minute, second, millisecond)); END_FUNCTION (* Specialized implementation of CONCAT_DT for ULINT *) FUNCTION CONCAT_DT__ULINT : DT VAR_INPUT - year : ULINT; - month : ULINT; - day : ULINT; - hour : ULINT; - minute : ULINT; - second : ULINT; - millisecond : ULINT; + year : ULINT; + month : ULINT; + day : ULINT; + hour : ULINT; + minute : ULINT; + second : ULINT; + millisecond : ULINT; END_VAR - CONCAT_DT__ULINT := CONCAT_DATE_TOD(CONCAT_DATE(year, month, day), CONCAT_TOD(hour, minute, second, millisecond)); + CONCAT_DT__ULINT := CONCAT_DATE_TOD(CONCAT_DATE(year, month, day), CONCAT_TOD(hour, minute, second, millisecond)); END_FUNCTION (******************** @@ -263,98 +263,98 @@ END_FUNCTION *********************) FUNCTION CONCAT_LDT : LDT VAR_INPUT - year : T; - month : T; - day : T; - hour : T; - minute : T; - second : T; - millisecond : T; + year : T; + month : T; + day : T; + hour : T; + minute : T; + second : T; + millisecond : T; END_VAR END_FUNCTION (* Specialized implementation of CONCAT_LDT for INT *) FUNCTION CONCAT_LDT__INT : LDT VAR_INPUT - year : INT; - month : INT; - day : INT; - hour : INT; - minute : INT; - second : INT; - millisecond : INT; + year : INT; + month : INT; + day : INT; + hour : INT; + minute : INT; + second : INT; + millisecond : INT; END_VAR - CONCAT_LDT__INT := CONCAT_DATE_LTOD(CONCAT_DATE(year, month, day), CONCAT_LTOD(hour, minute, second, millisecond)); + CONCAT_LDT__INT := CONCAT_DATE_LTOD(CONCAT_DATE(year, month, day), CONCAT_LTOD(hour, minute, second, millisecond)); END_FUNCTION (* Specialized implementation of CONCAT_LDT for UINT *) FUNCTION CONCAT_LDT__UINT : LDT VAR_INPUT - year : UINT; - month : UINT; - day : UINT; - hour : UINT; - minute : UINT; - second : UINT; - millisecond : UINT; + year : UINT; + month : UINT; + day : UINT; + hour : UINT; + minute : UINT; + second : UINT; + millisecond : UINT; END_VAR - CONCAT_LDT__UINT := CONCAT_DATE_LTOD(CONCAT_DATE(year, month, day), CONCAT_LTOD(hour, minute, second, millisecond)); + CONCAT_LDT__UINT := CONCAT_DATE_LTOD(CONCAT_DATE(year, month, day), CONCAT_LTOD(hour, minute, second, millisecond)); END_FUNCTION (* Specialized implementation of CONCAT_LDT for DINT *) FUNCTION CONCAT_LDT__DINT : LDT VAR_INPUT - year : DINT; - month : DINT; - day : DINT; - hour : DINT; - minute : DINT; - second : DINT; - millisecond : DINT; + year : DINT; + month : DINT; + day : DINT; + hour : DINT; + minute : DINT; + second : DINT; + millisecond : DINT; END_VAR - CONCAT_LDT__DINT := CONCAT_DATE_LTOD(CONCAT_DATE(year, month, day), CONCAT_LTOD(hour, minute, second, millisecond)); + CONCAT_LDT__DINT := CONCAT_DATE_LTOD(CONCAT_DATE(year, month, day), CONCAT_LTOD(hour, minute, second, millisecond)); END_FUNCTION (* Specialized implementation of CONCAT_LDT for UDINT *) FUNCTION CONCAT_LDT__UDINT : LDT VAR_INPUT - year : UDINT; - month : UDINT; - day : UDINT; - hour : UDINT; - minute : UDINT; - second : UDINT; - millisecond : UDINT; + year : UDINT; + month : UDINT; + day : UDINT; + hour : UDINT; + minute : UDINT; + second : UDINT; + millisecond : UDINT; END_VAR - CONCAT_LDT__UDINT := CONCAT_DATE_LTOD(CONCAT_DATE(year, month, day), CONCAT_LTOD(hour, minute, second, millisecond)); + CONCAT_LDT__UDINT := CONCAT_DATE_LTOD(CONCAT_DATE(year, month, day), CONCAT_LTOD(hour, minute, second, millisecond)); END_FUNCTION (* Specialized implementation of CONCAT_LDT for LINT *) FUNCTION CONCAT_LDT__LINT : LDT VAR_INPUT - year : LINT; - month : LINT; - day : LINT; - hour : LINT; - minute : LINT; - second : LINT; - millisecond : LINT; + year : LINT; + month : LINT; + day : LINT; + hour : LINT; + minute : LINT; + second : LINT; + millisecond : LINT; END_VAR - CONCAT_LDT__LINT := CONCAT_DATE_LTOD(CONCAT_DATE(year, month, day), CONCAT_LTOD(hour, minute, second, millisecond)); + CONCAT_LDT__LINT := CONCAT_DATE_LTOD(CONCAT_DATE(year, month, day), CONCAT_LTOD(hour, minute, second, millisecond)); END_FUNCTION (* Specialized implementation of CONCAT_LDT for ULINT *) FUNCTION CONCAT_LDT__ULINT : LDT VAR_INPUT - year : ULINT; - month : ULINT; - day : ULINT; - hour : ULINT; - minute : ULINT; - second : ULINT; - millisecond : ULINT; + year : ULINT; + month : ULINT; + day : ULINT; + hour : ULINT; + minute : ULINT; + second : ULINT; + millisecond : ULINT; END_VAR - CONCAT_LDT__ULINT := CONCAT_DATE_LTOD(CONCAT_DATE(year, month, day), CONCAT_LTOD(hour, minute, second, millisecond)); + CONCAT_LDT__ULINT := CONCAT_DATE_LTOD(CONCAT_DATE(year, month, day), CONCAT_LTOD(hour, minute, second, millisecond)); END_FUNCTION (******************** @@ -364,12 +364,12 @@ END_FUNCTION *********************) FUNCTION SPLIT_DATE : INT VAR_INPUT - in : DATE; + in : DATE; END_VAR VAR_OUTPUT - year : T; - month : T; - day : T; + year : T; + month : T; + day : T; END_VAR END_FUNCTION @@ -377,12 +377,12 @@ END_FUNCTION {external} FUNCTION SPLIT_DATE__INT : INT VAR_INPUT - in : DATE; + in : DATE; END_VAR VAR_OUTPUT - year : INT; - month : INT; - day : INT; + year : INT; + month : INT; + day : INT; END_VAR END_FUNCTION @@ -390,12 +390,12 @@ END_FUNCTION {external} FUNCTION SPLIT_DATE__UINT : INT VAR_INPUT - in : DATE; + in : DATE; END_VAR VAR_OUTPUT - year : UINT; - month : UINT; - day : UINT; + year : UINT; + month : UINT; + day : UINT; END_VAR END_FUNCTION @@ -403,12 +403,12 @@ END_FUNCTION {external} FUNCTION SPLIT_DATE__DINT : INT VAR_INPUT - in : DATE; + in : DATE; END_VAR VAR_OUTPUT - year : DINT; - month : DINT; - day : DINT; + year : DINT; + month : DINT; + day : DINT; END_VAR END_FUNCTION @@ -416,12 +416,12 @@ END_FUNCTION {external} FUNCTION SPLIT_DATE__UDINT : INT VAR_INPUT - in : DATE; + in : DATE; END_VAR VAR_OUTPUT - year : UDINT; - month : UDINT; - day : UDINT; + year : UDINT; + month : UDINT; + day : UDINT; END_VAR END_FUNCTION @@ -429,12 +429,12 @@ END_FUNCTION {external} FUNCTION SPLIT_DATE__LINT : INT VAR_INPUT - in : DATE; + in : DATE; END_VAR VAR_OUTPUT - year : LINT; - month : LINT; - day : LINT; + year : LINT; + month : LINT; + day : LINT; END_VAR END_FUNCTION @@ -442,12 +442,12 @@ END_FUNCTION {external} FUNCTION SPLIT_DATE__ULINT : INT VAR_INPUT - in : DATE; + in : DATE; END_VAR VAR_OUTPUT - year : ULINT; - month : ULINT; - day : ULINT; + year : ULINT; + month : ULINT; + day : ULINT; END_VAR END_FUNCTION @@ -458,13 +458,13 @@ END_FUNCTION *********************) FUNCTION SPLIT_TOD : INT VAR_INPUT - in : TOD; + in : TOD; END_VAR VAR_OUTPUT - hour : T; - minute : T; - second : T; - millisecond : T; + hour : T; + minute : T; + second : T; + millisecond : T; END_VAR END_FUNCTION @@ -472,13 +472,13 @@ END_FUNCTION {external} FUNCTION SPLIT_TOD__INT : INT VAR_INPUT - in : TOD; + in : TOD; END_VAR VAR_OUTPUT - hour : INT; - minute : INT; - second : INT; - millisecond : INT; + hour : INT; + minute : INT; + second : INT; + millisecond : INT; END_VAR END_FUNCTION @@ -486,13 +486,13 @@ END_FUNCTION {external} FUNCTION SPLIT_TOD__UINT : INT VAR_INPUT - in : TOD; + in : TOD; END_VAR VAR_OUTPUT - hour : UINT; - minute : UINT; - second : UINT; - millisecond : UINT; + hour : UINT; + minute : UINT; + second : UINT; + millisecond : UINT; END_VAR END_FUNCTION @@ -500,13 +500,13 @@ END_FUNCTION {external} FUNCTION SPLIT_TOD__DINT : INT VAR_INPUT - in : TOD; + in : TOD; END_VAR VAR_OUTPUT - hour : DINT; - minute : DINT; - second : DINT; - millisecond : DINT; + hour : DINT; + minute : DINT; + second : DINT; + millisecond : DINT; END_VAR END_FUNCTION @@ -514,13 +514,13 @@ END_FUNCTION {external} FUNCTION SPLIT_TOD__UDINT : INT VAR_INPUT - in : TOD; + in : TOD; END_VAR VAR_OUTPUT - hour : UDINT; - minute : UDINT; - second : UDINT; - millisecond : UDINT; + hour : UDINT; + minute : UDINT; + second : UDINT; + millisecond : UDINT; END_VAR END_FUNCTION @@ -528,13 +528,13 @@ END_FUNCTION {external} FUNCTION SPLIT_TOD__LINT : INT VAR_INPUT - in : TOD; + in : TOD; END_VAR VAR_OUTPUT - hour : LINT; - minute : LINT; - second : LINT; - millisecond : LINT; + hour : LINT; + minute : LINT; + second : LINT; + millisecond : LINT; END_VAR END_FUNCTION @@ -542,13 +542,13 @@ END_FUNCTION {external} FUNCTION SPLIT_TOD__ULINT : INT VAR_INPUT - in : TOD; + in : TOD; END_VAR VAR_OUTPUT - hour : ULINT; - minute : ULINT; - second : ULINT; - millisecond : ULINT; + hour : ULINT; + minute : ULINT; + second : ULINT; + millisecond : ULINT; END_VAR END_FUNCTION @@ -559,98 +559,98 @@ END_FUNCTION *********************) FUNCTION SPLIT_LTOD : INT VAR_INPUT - in : LTOD; + in : LTOD; END_VAR VAR_OUTPUT - hour : T; - minute : T; - second : T; - millisecond : T; + hour : T; + minute : T; + second : T; + millisecond : T; END_VAR END_FUNCTION (* Specialized implementation of SPLIT_LTOD for INT *) FUNCTION SPLIT_LTOD__INT : INT VAR_INPUT - in : LTOD; + in : LTOD; END_VAR VAR_OUTPUT - hour : INT; - minute : INT; - second : INT; - millisecond : INT; + hour : INT; + minute : INT; + second : INT; + millisecond : INT; END_VAR - SPLIT_LTOD__INT := SPLIT_TOD__INT(in, hour, minute, second, millisecond); + SPLIT_LTOD__INT := SPLIT_TOD__INT(in, hour, minute, second, millisecond); END_FUNCTION (* Specialized implementation of SPLIT_LTOD for UINT *) FUNCTION SPLIT_LTOD__UINT : INT VAR_INPUT - in : LTOD; + in : LTOD; END_VAR VAR_OUTPUT - hour : UINT; - minute : UINT; - second : UINT; - millisecond : UINT; + hour : UINT; + minute : UINT; + second : UINT; + millisecond : UINT; END_VAR - SPLIT_LTOD__UINT := SPLIT_TOD__UINT(in, hour, minute, second, millisecond); + SPLIT_LTOD__UINT := SPLIT_TOD__UINT(in, hour, minute, second, millisecond); END_FUNCTION (* Specialized implementation of SPLIT_LTOD for DINT *) FUNCTION SPLIT_LTOD__DINT : INT VAR_INPUT - in : LTOD; + in : LTOD; END_VAR VAR_OUTPUT - hour : DINT; - minute : DINT; - second : DINT; - millisecond : DINT; + hour : DINT; + minute : DINT; + second : DINT; + millisecond : DINT; END_VAR - SPLIT_LTOD__DINT := SPLIT_TOD__DINT(in, hour, minute, second, millisecond); + SPLIT_LTOD__DINT := SPLIT_TOD__DINT(in, hour, minute, second, millisecond); END_FUNCTION (* Specialized implementation of SPLIT_LTOD for UDINT *) FUNCTION SPLIT_LTOD__UDINT : INT VAR_INPUT - in : LTOD; + in : LTOD; END_VAR VAR_OUTPUT - hour : UDINT; - minute : UDINT; - second : UDINT; - millisecond : UDINT; + hour : UDINT; + minute : UDINT; + second : UDINT; + millisecond : UDINT; END_VAR - SPLIT_LTOD__UDINT := SPLIT_TOD__UDINT(in, hour, minute, second, millisecond); + SPLIT_LTOD__UDINT := SPLIT_TOD__UDINT(in, hour, minute, second, millisecond); END_FUNCTION (* Specialized implementation of SPLIT_LTOD for LINT *) FUNCTION SPLIT_LTOD__LINT : INT VAR_INPUT - in : LTOD; + in : LTOD; END_VAR VAR_OUTPUT - hour : LINT; - minute : LINT; - second : LINT; - millisecond : LINT; + hour : LINT; + minute : LINT; + second : LINT; + millisecond : LINT; END_VAR - SPLIT_LTOD__LINT := SPLIT_TOD__LINT(in, hour, minute, second, millisecond); + SPLIT_LTOD__LINT := SPLIT_TOD__LINT(in, hour, minute, second, millisecond); END_FUNCTION (* Specialized implementation of SPLIT_LTOD for ULINT *) FUNCTION SPLIT_LTOD__ULINT : INT VAR_INPUT - in : LTOD; + in : LTOD; END_VAR VAR_OUTPUT - hour : ULINT; - minute : ULINT; - second : ULINT; - millisecond : ULINT; + hour : ULINT; + minute : ULINT; + second : ULINT; + millisecond : ULINT; END_VAR - SPLIT_LTOD__ULINT := SPLIT_TOD__ULINT(in, hour, minute, second, millisecond); + SPLIT_LTOD__ULINT := SPLIT_TOD__ULINT(in, hour, minute, second, millisecond); END_FUNCTION (******************** @@ -660,16 +660,16 @@ END_FUNCTION *********************) FUNCTION SPLIT_DT : INT VAR_INPUT - in : DT; + in : DT; END_VAR VAR_OUTPUT - year : T; - month : T; - day : T; - hour : T; - minute : T; - second : T; - millisecond : T; + year : T; + month : T; + day : T; + hour : T; + minute : T; + second : T; + millisecond : T; END_VAR END_FUNCTION @@ -677,16 +677,16 @@ END_FUNCTION {external} FUNCTION SPLIT_DT__INT : INT VAR_INPUT - in : DT; + in : DT; END_VAR VAR_OUTPUT - year : INT; - month : INT; - day : INT; - hour : INT; - minute : INT; - second : INT; - millisecond : INT; + year : INT; + month : INT; + day : INT; + hour : INT; + minute : INT; + second : INT; + millisecond : INT; END_VAR END_FUNCTION @@ -694,16 +694,16 @@ END_FUNCTION {external} FUNCTION SPLIT_DT__UINT : INT VAR_INPUT - in : DT; + in : DT; END_VAR VAR_OUTPUT - year : UINT; - month : UINT; - day : UINT; - hour : UINT; - minute : UINT; - second : UINT; - millisecond : UINT; + year : UINT; + month : UINT; + day : UINT; + hour : UINT; + minute : UINT; + second : UINT; + millisecond : UINT; END_VAR END_FUNCTION @@ -711,16 +711,16 @@ END_FUNCTION {external} FUNCTION SPLIT_DT__DINT : INT VAR_INPUT - in : DT; + in : DT; END_VAR VAR_OUTPUT - year : DINT; - month : DINT; - day : DINT; - hour : DINT; - minute : DINT; - second : DINT; - millisecond : DINT; + year : DINT; + month : DINT; + day : DINT; + hour : DINT; + minute : DINT; + second : DINT; + millisecond : DINT; END_VAR END_FUNCTION @@ -728,16 +728,16 @@ END_FUNCTION {external} FUNCTION SPLIT_DT__UDINT : INT VAR_INPUT - in : DT; + in : DT; END_VAR VAR_OUTPUT - year : UDINT; - month : UDINT; - day : UDINT; - hour : UDINT; - minute : UDINT; - second : UDINT; - millisecond : UDINT; + year : UDINT; + month : UDINT; + day : UDINT; + hour : UDINT; + minute : UDINT; + second : UDINT; + millisecond : UDINT; END_VAR END_FUNCTION @@ -745,16 +745,16 @@ END_FUNCTION {external} FUNCTION SPLIT_DT__LINT : INT VAR_INPUT - in : DT; + in : DT; END_VAR VAR_OUTPUT - year : LINT; - month : LINT; - day : LINT; - hour : LINT; - minute : LINT; - second : LINT; - millisecond : LINT; + year : LINT; + month : LINT; + day : LINT; + hour : LINT; + minute : LINT; + second : LINT; + millisecond : LINT; END_VAR END_FUNCTION @@ -762,16 +762,16 @@ END_FUNCTION {external} FUNCTION SPLIT_DT__ULINT : INT VAR_INPUT - in : DT; + in : DT; END_VAR VAR_OUTPUT - year : ULINT; - month : ULINT; - day : ULINT; - hour : ULINT; - minute : ULINT; - second : ULINT; - millisecond : ULINT; + year : ULINT; + month : ULINT; + day : ULINT; + hour : ULINT; + minute : ULINT; + second : ULINT; + millisecond : ULINT; END_VAR END_FUNCTION @@ -782,16 +782,16 @@ END_FUNCTION *********************) FUNCTION SPLIT_LDT : INT VAR_INPUT - in : LDT; + in : LDT; END_VAR VAR_OUTPUT - year : T; - month : T; - day : T; - hour : T; - minute : T; - second : T; - millisecond : T; + year : T; + month : T; + day : T; + hour : T; + minute : T; + second : T; + millisecond : T; END_VAR END_FUNCTION @@ -799,108 +799,108 @@ END_FUNCTION {external} FUNCTION SPLIT_LDT__INT : INT VAR_INPUT - in : LDT; + in : LDT; END_VAR VAR_OUTPUT - year : INT; - month : INT; - day : INT; - hour : INT; - minute : INT; - second : INT; - millisecond : INT; + year : INT; + month : INT; + day : INT; + hour : INT; + minute : INT; + second : INT; + millisecond : INT; END_VAR - SPLIT_LDT__INT := SPLIT_DT__INT(in, year, month, day, hour, minute, second, millisecond); + SPLIT_LDT__INT := SPLIT_DT__INT(in, year, month, day, hour, minute, second, millisecond); END_FUNCTION (* Specialized implementation of SPLIT_LDT for UINT *) {external} FUNCTION SPLIT_LDT__UINT : INT VAR_INPUT - in : LDT; + in : LDT; END_VAR VAR_OUTPUT - year : UINT; - month : UINT; - day : UINT; - hour : UINT; - minute : UINT; - second : UINT; - millisecond : UINT; + year : UINT; + month : UINT; + day : UINT; + hour : UINT; + minute : UINT; + second : UINT; + millisecond : UINT; END_VAR - SPLIT_LDT__UINT := SPLIT_DT__UINT(in, year, month, day, hour, minute, second, millisecond); + SPLIT_LDT__UINT := SPLIT_DT__UINT(in, year, month, day, hour, minute, second, millisecond); END_FUNCTION (* Specialized implementation of SPLIT_LDT for DINT *) {external} FUNCTION SPLIT_LDT__DINT : INT VAR_INPUT - in : LDT; + in : LDT; END_VAR VAR_OUTPUT - year : DINT; - month : DINT; - day : DINT; - hour : DINT; - minute : DINT; - second : DINT; - millisecond : DINT; + year : DINT; + month : DINT; + day : DINT; + hour : DINT; + minute : DINT; + second : DINT; + millisecond : DINT; END_VAR - SPLIT_LDT__DINT := SPLIT_DT__DINT(in, year, month, day, hour, minute, second, millisecond); + SPLIT_LDT__DINT := SPLIT_DT__DINT(in, year, month, day, hour, minute, second, millisecond); END_FUNCTION (* Specialized implementation of SPLIT_LDT for UDINT *) {external} FUNCTION SPLIT_LDT__UDINT : INT VAR_INPUT - in : LDT; + in : LDT; END_VAR VAR_OUTPUT - year : UDINT; - month : UDINT; - day : UDINT; - hour : UDINT; - minute : UDINT; - second : UDINT; - millisecond : UDINT; + year : UDINT; + month : UDINT; + day : UDINT; + hour : UDINT; + minute : UDINT; + second : UDINT; + millisecond : UDINT; END_VAR - SPLIT_LDT__UDINT := SPLIT_DT__UDINT(in, year, month, day, hour, minute, second, millisecond); + SPLIT_LDT__UDINT := SPLIT_DT__UDINT(in, year, month, day, hour, minute, second, millisecond); END_FUNCTION (* Specialized implementation of SPLIT_LDT for LINT *) {external} FUNCTION SPLIT_LDT__LINT : INT VAR_INPUT - in : LDT; + in : LDT; END_VAR VAR_OUTPUT - year : LINT; - month : LINT; - day : LINT; - hour : LINT; - minute : LINT; - second : LINT; - millisecond : LINT; + year : LINT; + month : LINT; + day : LINT; + hour : LINT; + minute : LINT; + second : LINT; + millisecond : LINT; END_VAR - SPLIT_LDT__LINT := SPLIT_DT__LINT(in, year, month, day, hour, minute, second, millisecond); + SPLIT_LDT__LINT := SPLIT_DT__LINT(in, year, month, day, hour, minute, second, millisecond); END_FUNCTION (* Specialized implementation of SPLIT_LDT for ULINT *) {external} FUNCTION SPLIT_LDT__ULINT : INT VAR_INPUT - in : LDT; + in : LDT; END_VAR VAR_OUTPUT - year : ULINT; - month : ULINT; - day : ULINT; - hour : ULINT; - minute : ULINT; - second : ULINT; - millisecond : ULINT; + year : ULINT; + month : ULINT; + day : ULINT; + hour : ULINT; + minute : ULINT; + second : ULINT; + millisecond : ULINT; END_VAR - SPLIT_LDT__ULINT := SPLIT_DT__ULINT(in, year, month, day, hour, minute, second, millisecond); + SPLIT_LDT__ULINT := SPLIT_DT__ULINT(in, year, month, day, hour, minute, second, millisecond); END_FUNCTION (******************** @@ -912,6 +912,6 @@ END_FUNCTION {external} FUNCTION DAY_OF_WEEK : SINT VAR_INPUT - in : DATE; + in : DATE; END_VAR -END_FUNCTION \ No newline at end of file +END_FUNCTION diff --git a/libs/stdlib/iec61131-st/date_time_numeric_functions.st b/libs/stdlib/iec61131-st/date_time_numeric_functions.st index 4c9c167123..9dc5586280 100644 --- a/libs/stdlib/iec61131-st/date_time_numeric_functions.st +++ b/libs/stdlib/iec61131-st/date_time_numeric_functions.st @@ -5,18 +5,18 @@ *********************) FUNCTION ADD : T1 VAR_INPUT - IN1 : T1; - IN2 : T2; + IN1 : T1; + IN2 : T2; END_VAR END_FUNCTION (* Specialized implementation of ADD for TIME *) FUNCTION ADD__TIME__TIME : TIME VAR_INPUT - IN1 : TIME; - IN2 : TIME; + IN1 : TIME; + IN2 : TIME; END_VAR - ADD__TIME__TIME := ADD_TIME(IN1, IN2); + ADD__TIME__TIME := ADD_TIME(IN1, IN2); END_FUNCTION (******************** @@ -27,8 +27,8 @@ END_FUNCTION {external} FUNCTION ADD_TIME : TIME VAR_INPUT - IN1 : TIME; - IN2 : TIME; + IN1 : TIME; + IN2 : TIME; END_VAR END_FUNCTION @@ -39,19 +39,19 @@ END_FUNCTION *********************) FUNCTION ADD_LTIME : LTIME VAR_INPUT - IN1 : LTIME; - IN2 : LTIME; + IN1 : LTIME; + IN2 : LTIME; END_VAR - ADD_LTIME := ADD_TIME(IN1, IN2); + ADD_LTIME := ADD_TIME(IN1, IN2); END_FUNCTION (* Specialized implementation of ADD for TOD *) FUNCTION ADD__TIME_OF_DAY__TIME : TOD VAR_INPUT - IN1 : TOD; - IN2 : TIME; + IN1 : TOD; + IN2 : TIME; END_VAR - ADD__TIME_OF_DAY__TIME := ADD_TOD_TIME(IN1, IN2); + ADD__TIME_OF_DAY__TIME := ADD_TOD_TIME(IN1, IN2); END_FUNCTION (******************** @@ -63,8 +63,8 @@ END_FUNCTION {external} FUNCTION ADD_TOD_TIME : TOD VAR_INPUT - IN1 : TOD; - IN2 : TIME; + IN1 : TOD; + IN2 : TIME; END_VAR END_FUNCTION @@ -76,19 +76,19 @@ END_FUNCTION *********************) FUNCTION ADD_LTOD_LTIME : LTOD VAR_INPUT - IN1 : LTOD; - IN2 : LTIME; + IN1 : LTOD; + IN2 : LTIME; END_VAR - ADD_LTOD_LTIME := ADD_TOD_TIME(IN1, IN2); + ADD_LTOD_LTIME := ADD_TOD_TIME(IN1, IN2); END_FUNCTION (* Specialized implementation of ADD for DT *) FUNCTION ADD__DATE_AND_TIME__TIME : DT VAR_INPUT - IN1 : DT; - IN2 : TIME; + IN1 : DT; + IN2 : TIME; END_VAR - ADD__DATE_AND_TIME__TIME := ADD_DT_TIME(IN1, IN2); + ADD__DATE_AND_TIME__TIME := ADD_DT_TIME(IN1, IN2); END_FUNCTION (******************** @@ -100,8 +100,8 @@ END_FUNCTION {external} FUNCTION ADD_DT_TIME : DT VAR_INPUT - IN1 : DT; - IN2 : TIME; + IN1 : DT; + IN2 : TIME; END_VAR END_FUNCTION @@ -113,10 +113,10 @@ END_FUNCTION *********************) FUNCTION ADD_LDT_LTIME : LDT VAR_INPUT - IN1 : LDT; - IN2 : LTIME; + IN1 : LDT; + IN2 : LTIME; END_VAR - ADD_LDT_LTIME := ADD_DT_TIME(IN1, IN2); + ADD_LDT_LTIME := ADD_DT_TIME(IN1, IN2); END_FUNCTION (******************** @@ -126,18 +126,18 @@ END_FUNCTION *********************) FUNCTION SUB : T1 VAR_INPUT - IN1 : T1; - IN2 : T2; + IN1 : T1; + IN2 : T2; END_VAR END_FUNCTION (* Specialized implementation of SUB for TIME *) FUNCTION SUB__TIME__TIME : TIME VAR_INPUT - IN1 : TIME; - IN2 : TIME; + IN1 : TIME; + IN2 : TIME; END_VAR - SUB__TIME__TIME := SUB_TIME(IN1, IN2); + SUB__TIME__TIME := SUB_TIME(IN1, IN2); END_FUNCTION (******************** @@ -148,8 +148,8 @@ END_FUNCTION {external} FUNCTION SUB_TIME : TIME VAR_INPUT - IN1 : TIME; - IN2 : TIME; + IN1 : TIME; + IN2 : TIME; END_VAR END_FUNCTION @@ -160,19 +160,19 @@ END_FUNCTION *********************) FUNCTION SUB_LTIME : LTIME VAR_INPUT - IN1 : LTIME; - IN2 : LTIME; + IN1 : LTIME; + IN2 : LTIME; END_VAR - SUB_LTIME := SUB_TIME(IN1, IN2); + SUB_LTIME := SUB_TIME(IN1, IN2); END_FUNCTION (* Specialized implementation of SUB for DATE *) FUNCTION SUB__DATE__DATE : TIME VAR_INPUT - IN1 : DATE; - IN2 : DATE; + IN1 : DATE; + IN2 : DATE; END_VAR - SUB__DATE__DATE := SUB_DATE_DATE(IN1, IN2); + SUB__DATE__DATE := SUB_DATE_DATE(IN1, IN2); END_FUNCTION (******************** @@ -184,8 +184,8 @@ END_FUNCTION {external} FUNCTION SUB_DATE_DATE : TIME VAR_INPUT - IN1 : DATE; - IN2 : DATE; + IN1 : DATE; + IN2 : DATE; END_VAR END_FUNCTION @@ -197,19 +197,19 @@ END_FUNCTION *********************) FUNCTION SUB_LDATE_LDATE : LTIME VAR_INPUT - IN1 : LDATE; - IN2 : LDATE; + IN1 : LDATE; + IN2 : LDATE; END_VAR - SUB_LDATE_LDATE := SUB_DATE_DATE(IN1, IN2); + SUB_LDATE_LDATE := SUB_DATE_DATE(IN1, IN2); END_FUNCTION (* Specialized implementation of SUB for TOD and TIME *) FUNCTION SUB__TIME_OF_DAY__TIME : TOD VAR_INPUT - IN1 : TOD; - IN2 : TIME; + IN1 : TOD; + IN2 : TIME; END_VAR - SUB__TIME_OF_DAY__TIME := SUB_TOD_TIME(IN1, IN2); + SUB__TIME_OF_DAY__TIME := SUB_TOD_TIME(IN1, IN2); END_FUNCTION (******************** @@ -221,8 +221,8 @@ END_FUNCTION {external} FUNCTION SUB_TOD_TIME : TOD VAR_INPUT - IN1 : TOD; - IN2 : TIME; + IN1 : TOD; + IN2 : TIME; END_VAR END_FUNCTION @@ -234,19 +234,19 @@ END_FUNCTION *********************) FUNCTION SUB_LTOD_LTIME : LTOD VAR_INPUT - IN1 : LTOD; - IN2 : LTIME; + IN1 : LTOD; + IN2 : LTIME; END_VAR - SUB_LTOD_LTIME := SUB_TOD_TIME(IN1, IN2); + SUB_LTOD_LTIME := SUB_TOD_TIME(IN1, IN2); END_FUNCTION (* Specialized implementation of SUB for TOD *) FUNCTION SUB__TIME_OF_DAY__TIME_OF_DAY : TIME VAR_INPUT - IN1 : TOD; - IN2 : TOD; + IN1 : TOD; + IN2 : TOD; END_VAR - SUB__TIME_OF_DAY__TIME_OF_DAY := SUB_TOD_TOD(IN1, IN2); + SUB__TIME_OF_DAY__TIME_OF_DAY := SUB_TOD_TOD(IN1, IN2); END_FUNCTION (******************** @@ -258,8 +258,8 @@ END_FUNCTION {external} FUNCTION SUB_TOD_TOD : TIME VAR_INPUT - IN1 : TOD; - IN2 : TOD; + IN1 : TOD; + IN2 : TOD; END_VAR END_FUNCTION @@ -271,19 +271,19 @@ END_FUNCTION *********************) FUNCTION SUB_LTOD_LTOD : LTIME VAR_INPUT - IN1 : LTOD; - IN2 : LTOD; + IN1 : LTOD; + IN2 : LTOD; END_VAR - SUB_LTOD_LTOD := SUB_TOD_TOD(IN1, IN2); + SUB_LTOD_LTOD := SUB_TOD_TOD(IN1, IN2); END_FUNCTION (* Specialized implementation of SUB for DT and TIME *) FUNCTION SUB__DATE_AND_TIME__TIME : DT VAR_INPUT - IN1 : DT; - IN2 : TIME; + IN1 : DT; + IN2 : TIME; END_VAR - SUB__DATE_AND_TIME__TIME := SUB_DT_TIME(IN1, IN2); + SUB__DATE_AND_TIME__TIME := SUB_DT_TIME(IN1, IN2); END_FUNCTION (******************** @@ -295,8 +295,8 @@ END_FUNCTION {external} FUNCTION SUB_DT_TIME : DT VAR_INPUT - IN1 : DT; - IN2 : TIME; + IN1 : DT; + IN2 : TIME; END_VAR END_FUNCTION @@ -308,19 +308,19 @@ END_FUNCTION *********************) FUNCTION SUB_LDT_LTIME : LDT VAR_INPUT - IN1 : LDT; - IN2 : LTIME; + IN1 : LDT; + IN2 : LTIME; END_VAR - SUB_LDT_LTIME := SUB_DT_TIME(IN1, IN2); + SUB_LDT_LTIME := SUB_DT_TIME(IN1, IN2); END_FUNCTION (* Specialized implementation of SUB for DT *) FUNCTION SUB__DATE_AND_TIME__DATE_AND_TIME : TIME VAR_INPUT - IN1 : DT; - IN2 : DT; + IN1 : DT; + IN2 : DT; END_VAR - SUB__DATE_AND_TIME__DATE_AND_TIME := SUB_DT_DT(IN1, IN2); + SUB__DATE_AND_TIME__DATE_AND_TIME := SUB_DT_DT(IN1, IN2); END_FUNCTION (******************** @@ -332,8 +332,8 @@ END_FUNCTION {external} FUNCTION SUB_DT_DT : TIME VAR_INPUT - IN1 : DT; - IN2 : DT; + IN1 : DT; + IN2 : DT; END_VAR END_FUNCTION @@ -345,10 +345,10 @@ END_FUNCTION *********************) FUNCTION SUB_LDT_LDT : LTIME VAR_INPUT - IN1 : LDT; - IN2 : LDT; + IN1 : LDT; + IN2 : LDT; END_VAR - SUB_LDT_LDT := SUB_DT_DT(IN1, IN2); + SUB_LDT_LDT := SUB_DT_DT(IN1, IN2); END_FUNCTION (******************** @@ -358,8 +358,8 @@ END_FUNCTION *********************) FUNCTION MUL : T1 VAR_INPUT - IN1 : T1; - IN2 : T2; + IN1 : T1; + IN2 : T2; END_VAR END_FUNCTION @@ -370,8 +370,8 @@ END_FUNCTION *********************) FUNCTION MUL_TIME : TIME VAR_INPUT - IN1 : TIME; - IN2 : T; + IN1 : TIME; + IN2 : T; END_VAR END_FUNCTION @@ -382,8 +382,8 @@ END_FUNCTION *********************) FUNCTION MUL_LTIME : LTIME VAR_INPUT - IN1 : LTIME; - IN2 : T; + IN1 : LTIME; + IN2 : T; END_VAR END_FUNCTION @@ -394,8 +394,8 @@ END_FUNCTION *********************) FUNCTION DIV : T1 VAR_INPUT - IN1 : T1; - IN2 : T2; + IN1 : T1; + IN2 : T2; END_VAR END_FUNCTION @@ -406,8 +406,8 @@ END_FUNCTION *********************) FUNCTION DIV_TIME : TIME VAR_INPUT - IN1 : TIME; - IN2 : T; + IN1 : TIME; + IN2 : T; END_VAR END_FUNCTION @@ -418,7 +418,7 @@ END_FUNCTION *********************) FUNCTION DIV_LTIME : LTIME VAR_INPUT - IN1 : LTIME; - IN2 : T; + IN1 : LTIME; + IN2 : T; END_VAR -END_FUNCTION \ No newline at end of file +END_FUNCTION diff --git a/libs/stdlib/iec61131-st/endianness_conversion_functions.st b/libs/stdlib/iec61131-st/endianness_conversion_functions.st index 34bfa01acf..51dba16612 100644 --- a/libs/stdlib/iec61131-st/endianness_conversion_functions.st +++ b/libs/stdlib/iec61131-st/endianness_conversion_functions.st @@ -7,7 +7,7 @@ Return: The value converted to big endian format. {external} FUNCTION TO_BIG_ENDIAN : T VAR_INPUT - in : T; + in : T; END_VAR END_FUNCTION @@ -20,7 +20,7 @@ Return: The value converted to little endian format. {external} FUNCTION TO_LITTLE_ENDIAN : T VAR_INPUT - in : T; + in : T; END_VAR END_FUNCTION @@ -33,7 +33,7 @@ Return: The value converted to native endian format. {external} FUNCTION FROM_BIG_ENDIAN : T VAR_INPUT - in : T; + in : T; END_VAR END_FUNCTION @@ -46,7 +46,6 @@ Return: The value converted to native endian format. {external} FUNCTION FROM_LITTLE_ENDIAN : T VAR_INPUT - in : T; + in : T; END_VAR END_FUNCTION - diff --git a/libs/stdlib/iec61131-st/extra_functions.st b/libs/stdlib/iec61131-st/extra_functions.st index 7f784d6665..c8b0f6796c 100644 --- a/libs/stdlib/iec61131-st/extra_functions.st +++ b/libs/stdlib/iec61131-st/extra_functions.st @@ -1095,4 +1095,4 @@ VAR_INPUT IN : ULINT; END_VAR LWORD_TO_STRING_EXT(IN, ULINT_TO_STRING); -END_FUNCTION \ No newline at end of file +END_FUNCTION diff --git a/libs/stdlib/iec61131-st/flanks.st b/libs/stdlib/iec61131-st/flanks.st index cfa610318b..43abd0ea43 100644 --- a/libs/stdlib/iec61131-st/flanks.st +++ b/libs/stdlib/iec61131-st/flanks.st @@ -1,41 +1,41 @@ (****************************************************************************** Description: Rising Edge detection Input: - - CLK: Signal to detect + - CLK: Signal to detect Output: - - Q: Edge detected + - Q: Edge detected Return: Output variable are used for return. ******************************************************************************) -{external} +{external} FUNCTION_BLOCK R_TRIG VAR_INPUT - CLK: BOOL; + CLK: BOOL; END_VAR VAR_OUTPUT - Q: BOOL; + Q: BOOL; END_VAR VAR - M: BOOL; + M: BOOL; END_VAR END_FUNCTION_BLOCK (****************************************************************************** Description: Falling Edge detection Input: - - CLK: Signal to detect + - CLK: Signal to detect Output: - - Q: Edge detected + - Q: Edge detected Return: Output variable is used for return. ******************************************************************************) -{external} +{external} FUNCTION_BLOCK F_TRIG VAR_INPUT - CLK: BOOL; + CLK: BOOL; END_VAR VAR_OUTPUT - Q: BOOL; + Q: BOOL; END_VAR VAR - M: BOOL; + M: BOOL; END_VAR -END_FUNCTION_BLOCK \ No newline at end of file +END_FUNCTION_BLOCK diff --git a/libs/stdlib/iec61131-st/num_conversion.st b/libs/stdlib/iec61131-st/num_conversion.st index c8479daec6..71dba70843 100644 --- a/libs/stdlib/iec61131-st/num_conversion.st +++ b/libs/stdlib/iec61131-st/num_conversion.st @@ -5,9 +5,9 @@ *********************) FUNCTION LREAL_TO_REAL : REAL VAR_INPUT - in : LREAL; + in : LREAL; END_VAR - LREAL_TO_REAL := in; + LREAL_TO_REAL := in; END_FUNCTION (******************** @@ -17,9 +17,9 @@ END_FUNCTION *********************) FUNCTION LREAL_TO_LINT : LINT VAR_INPUT - in : LREAL; + in : LREAL; END_VAR - LREAL_TO_LINT := ROUND(in); + LREAL_TO_LINT := ROUND(in); END_FUNCTION (******************** @@ -29,9 +29,9 @@ END_FUNCTION *********************) FUNCTION LREAL_TO_DINT : DINT VAR_INPUT - in : LREAL; + in : LREAL; END_VAR - LREAL_TO_DINT := ROUND(in); + LREAL_TO_DINT := ROUND(in); END_FUNCTION (******************** @@ -41,9 +41,9 @@ END_FUNCTION *********************) FUNCTION LREAL_TO_INT : INT VAR_INPUT - in : LREAL; + in : LREAL; END_VAR - LREAL_TO_INT := ROUND(in); + LREAL_TO_INT := ROUND(in); END_FUNCTION (******************** @@ -53,9 +53,9 @@ END_FUNCTION *********************) FUNCTION LREAL_TO_SINT : SINT VAR_INPUT - in : LREAL; + in : LREAL; END_VAR - LREAL_TO_SINT := ROUND(in); + LREAL_TO_SINT := ROUND(in); END_FUNCTION (******************** @@ -65,9 +65,9 @@ END_FUNCTION *********************) FUNCTION LREAL_TO_ULINT : ULINT VAR_INPUT - in : LREAL; + in : LREAL; END_VAR - LREAL_TO_ULINT := ROUND(in); + LREAL_TO_ULINT := ROUND(in); END_FUNCTION (******************** @@ -77,9 +77,9 @@ END_FUNCTION *********************) FUNCTION LREAL_TO_UDINT : UDINT VAR_INPUT - in : LREAL; + in : LREAL; END_VAR - LREAL_TO_UDINT := ROUND(in); + LREAL_TO_UDINT := ROUND(in); END_FUNCTION (******************** @@ -89,9 +89,9 @@ END_FUNCTION *********************) FUNCTION LREAL_TO_UINT : UINT VAR_INPUT - in : LREAL; + in : LREAL; END_VAR - LREAL_TO_UINT := ROUND(in); + LREAL_TO_UINT := ROUND(in); END_FUNCTION (******************** @@ -101,9 +101,9 @@ END_FUNCTION *********************) FUNCTION LREAL_TO_USINT : USINT VAR_INPUT - in : LREAL; + in : LREAL; END_VAR - LREAL_TO_USINT := ROUND(in); + LREAL_TO_USINT := ROUND(in); END_FUNCTION (******************** @@ -113,9 +113,9 @@ END_FUNCTION *********************) FUNCTION REAL_TO_LREAL : LREAL VAR_INPUT - in : REAL; + in : REAL; END_VAR - REAL_TO_LREAL := in; + REAL_TO_LREAL := in; END_FUNCTION (******************** @@ -125,9 +125,9 @@ END_FUNCTION *********************) FUNCTION REAL_TO_LINT : LINT VAR_INPUT - in : REAL; + in : REAL; END_VAR - REAL_TO_LINT := ROUND(in); + REAL_TO_LINT := ROUND(in); END_FUNCTION (******************** @@ -137,9 +137,9 @@ END_FUNCTION *********************) FUNCTION REAL_TO_DINT : DINT VAR_INPUT - in : REAL; + in : REAL; END_VAR - REAL_TO_DINT := ROUND(in); + REAL_TO_DINT := ROUND(in); END_FUNCTION (******************** @@ -149,9 +149,9 @@ END_FUNCTION *********************) FUNCTION REAL_TO_INT : INT VAR_INPUT - in : REAL; + in : REAL; END_VAR - REAL_TO_INT := ROUND(in); + REAL_TO_INT := ROUND(in); END_FUNCTION (******************** @@ -161,9 +161,9 @@ END_FUNCTION *********************) FUNCTION REAL_TO_SINT : SINT VAR_INPUT - in : REAL; + in : REAL; END_VAR - REAL_TO_SINT := ROUND(in); + REAL_TO_SINT := ROUND(in); END_FUNCTION (******************** @@ -173,9 +173,9 @@ END_FUNCTION *********************) FUNCTION REAL_TO_ULINT : ULINT VAR_INPUT - in : REAL; + in : REAL; END_VAR - REAL_TO_ULINT := ROUND(in); + REAL_TO_ULINT := ROUND(in); END_FUNCTION (******************** @@ -185,9 +185,9 @@ END_FUNCTION *********************) FUNCTION REAL_TO_UDINT : UDINT VAR_INPUT - in : REAL; + in : REAL; END_VAR - REAL_TO_UDINT := ROUND(in); + REAL_TO_UDINT := ROUND(in); END_FUNCTION (******************** @@ -197,9 +197,9 @@ END_FUNCTION *********************) FUNCTION REAL_TO_UINT : UINT VAR_INPUT - in : REAL; + in : REAL; END_VAR - REAL_TO_UINT := ROUND(in); + REAL_TO_UINT := ROUND(in); END_FUNCTION (******************** @@ -209,9 +209,9 @@ END_FUNCTION *********************) FUNCTION REAL_TO_USINT : USINT VAR_INPUT - in : REAL; + in : REAL; END_VAR - REAL_TO_USINT := ROUND(in); + REAL_TO_USINT := ROUND(in); END_FUNCTION (******************** @@ -221,9 +221,9 @@ END_FUNCTION *********************) FUNCTION LINT_TO_LREAL : LREAL VAR_INPUT - in : LINT; + in : LINT; END_VAR - LINT_TO_LREAL := in; + LINT_TO_LREAL := in; END_FUNCTION (******************** @@ -233,9 +233,9 @@ END_FUNCTION *********************) FUNCTION LINT_TO_REAL : REAL VAR_INPUT - in : LINT; + in : LINT; END_VAR - LINT_TO_REAL := in; + LINT_TO_REAL := in; END_FUNCTION (******************** @@ -245,9 +245,9 @@ END_FUNCTION *********************) FUNCTION LINT_TO_DINT : DINT VAR_INPUT - in : LINT; + in : LINT; END_VAR - LINT_TO_DINT := in; + LINT_TO_DINT := in; END_FUNCTION (******************** @@ -257,9 +257,9 @@ END_FUNCTION *********************) FUNCTION LINT_TO_INT : INT VAR_INPUT - in : LINT; + in : LINT; END_VAR - LINT_TO_INT := in; + LINT_TO_INT := in; END_FUNCTION (******************** @@ -269,9 +269,9 @@ END_FUNCTION *********************) FUNCTION LINT_TO_SINT : SINT VAR_INPUT - in : LINT; + in : LINT; END_VAR - LINT_TO_SINT := in; + LINT_TO_SINT := in; END_FUNCTION (******************** @@ -281,9 +281,9 @@ END_FUNCTION *********************) FUNCTION LINT_TO_ULINT : ULINT VAR_INPUT - in : LINT; + in : LINT; END_VAR - LINT_TO_ULINT := in; + LINT_TO_ULINT := in; END_FUNCTION (******************** @@ -293,9 +293,9 @@ END_FUNCTION *********************) FUNCTION LINT_TO_UDINT : UDINT VAR_INPUT - in : LINT; + in : LINT; END_VAR - LINT_TO_UDINT := in; + LINT_TO_UDINT := in; END_FUNCTION (******************** @@ -305,9 +305,9 @@ END_FUNCTION *********************) FUNCTION LINT_TO_UINT : UINT VAR_INPUT - in : LINT; + in : LINT; END_VAR - LINT_TO_UINT := in; + LINT_TO_UINT := in; END_FUNCTION (******************** @@ -317,9 +317,9 @@ END_FUNCTION *********************) FUNCTION LINT_TO_USINT : USINT VAR_INPUT - in : LINT; + in : LINT; END_VAR - LINT_TO_USINT := in; + LINT_TO_USINT := in; END_FUNCTION (******************** @@ -329,9 +329,9 @@ END_FUNCTION *********************) FUNCTION DINT_TO_LREAL : LREAL VAR_INPUT - in : DINT; + in : DINT; END_VAR - DINT_TO_LREAL := in; + DINT_TO_LREAL := in; END_FUNCTION (******************** @@ -341,9 +341,9 @@ END_FUNCTION *********************) FUNCTION DINT_TO_REAL : REAL VAR_INPUT - in : DINT; + in : DINT; END_VAR - DINT_TO_REAL := in; + DINT_TO_REAL := in; END_FUNCTION (******************** @@ -353,9 +353,9 @@ END_FUNCTION *********************) FUNCTION DINT_TO_LINT : LINT VAR_INPUT - in : DINT; + in : DINT; END_VAR - DINT_TO_LINT := in; + DINT_TO_LINT := in; END_FUNCTION (******************** @@ -365,9 +365,9 @@ END_FUNCTION *********************) FUNCTION DINT_TO_INT : INT VAR_INPUT - in : DINT; + in : DINT; END_VAR - DINT_TO_INT := in; + DINT_TO_INT := in; END_FUNCTION (******************** @@ -377,9 +377,9 @@ END_FUNCTION *********************) FUNCTION DINT_TO_SINT : SINT VAR_INPUT - in : DINT; + in : DINT; END_VAR - DINT_TO_SINT := in; + DINT_TO_SINT := in; END_FUNCTION (******************** @@ -389,9 +389,9 @@ END_FUNCTION *********************) FUNCTION DINT_TO_ULINT : ULINT VAR_INPUT - in : DINT; + in : DINT; END_VAR - DINT_TO_ULINT := in; + DINT_TO_ULINT := in; END_FUNCTION (******************** @@ -401,9 +401,9 @@ END_FUNCTION *********************) FUNCTION DINT_TO_UDINT : UDINT VAR_INPUT - in : DINT; + in : DINT; END_VAR - DINT_TO_UDINT := in; + DINT_TO_UDINT := in; END_FUNCTION (******************** @@ -413,9 +413,9 @@ END_FUNCTION *********************) FUNCTION DINT_TO_UINT : UINT VAR_INPUT - in : DINT; + in : DINT; END_VAR - DINT_TO_UINT := in; + DINT_TO_UINT := in; END_FUNCTION (******************** @@ -425,9 +425,9 @@ END_FUNCTION *********************) FUNCTION DINT_TO_USINT : USINT VAR_INPUT - in : DINT; + in : DINT; END_VAR - DINT_TO_USINT := in; + DINT_TO_USINT := in; END_FUNCTION (******************** @@ -437,9 +437,9 @@ END_FUNCTION *********************) FUNCTION INT_TO_LREAL : LREAL VAR_INPUT - in : INT; + in : INT; END_VAR - INT_TO_LREAL := in; + INT_TO_LREAL := in; END_FUNCTION (******************** @@ -449,9 +449,9 @@ END_FUNCTION *********************) FUNCTION INT_TO_REAL : REAL VAR_INPUT - in : INT; + in : INT; END_VAR - INT_TO_REAL := in; + INT_TO_REAL := in; END_FUNCTION (******************** @@ -461,9 +461,9 @@ END_FUNCTION *********************) FUNCTION INT_TO_LINT : LINT VAR_INPUT - in : INT; + in : INT; END_VAR - INT_TO_LINT := in; + INT_TO_LINT := in; END_FUNCTION (******************** @@ -473,9 +473,9 @@ END_FUNCTION *********************) FUNCTION INT_TO_DINT : DINT VAR_INPUT - in : INT; + in : INT; END_VAR - INT_TO_DINT := in; + INT_TO_DINT := in; END_FUNCTION (******************** @@ -485,9 +485,9 @@ END_FUNCTION *********************) FUNCTION INT_TO_SINT : SINT VAR_INPUT - in : INT; + in : INT; END_VAR - INT_TO_SINT := in; + INT_TO_SINT := in; END_FUNCTION (******************** @@ -497,9 +497,9 @@ END_FUNCTION *********************) FUNCTION INT_TO_ULINT : ULINT VAR_INPUT - in : INT; + in : INT; END_VAR - INT_TO_ULINT := in; + INT_TO_ULINT := in; END_FUNCTION (******************** @@ -509,9 +509,9 @@ END_FUNCTION *********************) FUNCTION INT_TO_UDINT : UDINT VAR_INPUT - in : INT; + in : INT; END_VAR - INT_TO_UDINT := in; + INT_TO_UDINT := in; END_FUNCTION (******************** @@ -521,9 +521,9 @@ END_FUNCTION *********************) FUNCTION INT_TO_UINT : UINT VAR_INPUT - in : INT; + in : INT; END_VAR - INT_TO_UINT := in; + INT_TO_UINT := in; END_FUNCTION (******************** @@ -533,9 +533,9 @@ END_FUNCTION *********************) FUNCTION INT_TO_USINT : USINT VAR_INPUT - in : INT; + in : INT; END_VAR - INT_TO_USINT := in; + INT_TO_USINT := in; END_FUNCTION (******************** @@ -545,9 +545,9 @@ END_FUNCTION *********************) FUNCTION SINT_TO_LREAL : LREAL VAR_INPUT - in : SINT; + in : SINT; END_VAR - SINT_TO_LREAL := in; + SINT_TO_LREAL := in; END_FUNCTION (******************** @@ -557,9 +557,9 @@ END_FUNCTION *********************) FUNCTION SINT_TO_REAL : REAL VAR_INPUT - in : SINT; + in : SINT; END_VAR - SINT_TO_REAL := in; + SINT_TO_REAL := in; END_FUNCTION (******************** @@ -569,9 +569,9 @@ END_FUNCTION *********************) FUNCTION SINT_TO_LINT : LINT VAR_INPUT - in : SINT; + in : SINT; END_VAR - SINT_TO_LINT := in; + SINT_TO_LINT := in; END_FUNCTION (******************** @@ -581,9 +581,9 @@ END_FUNCTION *********************) FUNCTION SINT_TO_DINT : DINT VAR_INPUT - in : SINT; + in : SINT; END_VAR - SINT_TO_DINT := in; + SINT_TO_DINT := in; END_FUNCTION (******************** @@ -593,9 +593,9 @@ END_FUNCTION *********************) FUNCTION SINT_TO_INT : INT VAR_INPUT - in : SINT; + in : SINT; END_VAR - SINT_TO_INT := in; + SINT_TO_INT := in; END_FUNCTION (******************** @@ -605,9 +605,9 @@ END_FUNCTION *********************) FUNCTION SINT_TO_ULINT : ULINT VAR_INPUT - in : SINT; + in : SINT; END_VAR - SINT_TO_ULINT := in; + SINT_TO_ULINT := in; END_FUNCTION (******************** @@ -617,9 +617,9 @@ END_FUNCTION *********************) FUNCTION SINT_TO_UDINT : UDINT VAR_INPUT - in : SINT; + in : SINT; END_VAR - SINT_TO_UDINT := in; + SINT_TO_UDINT := in; END_FUNCTION (******************** @@ -629,9 +629,9 @@ END_FUNCTION *********************) FUNCTION SINT_TO_UINT : UINT VAR_INPUT - in : SINT; + in : SINT; END_VAR - SINT_TO_UINT := in; + SINT_TO_UINT := in; END_FUNCTION (******************** @@ -641,9 +641,9 @@ END_FUNCTION *********************) FUNCTION SINT_TO_USINT : USINT VAR_INPUT - in : SINT; + in : SINT; END_VAR - SINT_TO_USINT := in; + SINT_TO_USINT := in; END_FUNCTION (******************** @@ -653,9 +653,9 @@ END_FUNCTION *********************) FUNCTION ULINT_TO_LREAL : LREAL VAR_INPUT - in : ULINT; + in : ULINT; END_VAR - ULINT_TO_LREAL := in; + ULINT_TO_LREAL := in; END_FUNCTION (******************** @@ -665,9 +665,9 @@ END_FUNCTION *********************) FUNCTION ULINT_TO_REAL : REAL VAR_INPUT - in : ULINT; + in : ULINT; END_VAR - ULINT_TO_REAL := in; + ULINT_TO_REAL := in; END_FUNCTION (******************** @@ -677,9 +677,9 @@ END_FUNCTION *********************) FUNCTION ULINT_TO_LINT : LINT VAR_INPUT - in : ULINT; + in : ULINT; END_VAR - ULINT_TO_LINT := in; + ULINT_TO_LINT := in; END_FUNCTION (******************** @@ -689,9 +689,9 @@ END_FUNCTION *********************) FUNCTION ULINT_TO_DINT : DINT VAR_INPUT - in : ULINT; + in : ULINT; END_VAR - ULINT_TO_DINT := in; + ULINT_TO_DINT := in; END_FUNCTION (******************** @@ -701,9 +701,9 @@ END_FUNCTION *********************) FUNCTION ULINT_TO_INT : INT VAR_INPUT - in : ULINT; + in : ULINT; END_VAR - ULINT_TO_INT := in; + ULINT_TO_INT := in; END_FUNCTION (******************** @@ -713,9 +713,9 @@ END_FUNCTION *********************) FUNCTION ULINT_TO_SINT : SINT VAR_INPUT - in : ULINT; + in : ULINT; END_VAR - ULINT_TO_SINT := in; + ULINT_TO_SINT := in; END_FUNCTION (******************** @@ -725,9 +725,9 @@ END_FUNCTION *********************) FUNCTION ULINT_TO_UDINT : UDINT VAR_INPUT - in : ULINT; + in : ULINT; END_VAR - ULINT_TO_UDINT := in; + ULINT_TO_UDINT := in; END_FUNCTION (******************** @@ -737,9 +737,9 @@ END_FUNCTION *********************) FUNCTION ULINT_TO_UINT : UINT VAR_INPUT - in : ULINT; + in : ULINT; END_VAR - ULINT_TO_UINT := in; + ULINT_TO_UINT := in; END_FUNCTION (******************** @@ -749,9 +749,9 @@ END_FUNCTION *********************) FUNCTION ULINT_TO_USINT : USINT VAR_INPUT - in : ULINT; + in : ULINT; END_VAR - ULINT_TO_USINT := in; + ULINT_TO_USINT := in; END_FUNCTION (******************** @@ -761,9 +761,9 @@ END_FUNCTION *********************) FUNCTION UDINT_TO_LREAL : LREAL VAR_INPUT - in : UDINT; + in : UDINT; END_VAR - UDINT_TO_LREAL := in; + UDINT_TO_LREAL := in; END_FUNCTION (******************** @@ -773,9 +773,9 @@ END_FUNCTION *********************) FUNCTION UDINT_TO_REAL : REAL VAR_INPUT - in : UDINT; + in : UDINT; END_VAR - UDINT_TO_REAL := in; + UDINT_TO_REAL := in; END_FUNCTION (******************** @@ -785,9 +785,9 @@ END_FUNCTION *********************) FUNCTION UDINT_TO_LINT : LINT VAR_INPUT - in : UDINT; + in : UDINT; END_VAR - UDINT_TO_LINT := in; + UDINT_TO_LINT := in; END_FUNCTION (******************** @@ -797,9 +797,9 @@ END_FUNCTION *********************) FUNCTION UDINT_TO_DINT : DINT VAR_INPUT - in : UDINT; + in : UDINT; END_VAR - UDINT_TO_DINT := in; + UDINT_TO_DINT := in; END_FUNCTION (******************** @@ -809,9 +809,9 @@ END_FUNCTION *********************) FUNCTION UDINT_TO_INT : INT VAR_INPUT - in : UDINT; + in : UDINT; END_VAR - UDINT_TO_INT := in; + UDINT_TO_INT := in; END_FUNCTION (******************** @@ -821,9 +821,9 @@ END_FUNCTION *********************) FUNCTION UDINT_TO_SINT : SINT VAR_INPUT - in : UDINT; + in : UDINT; END_VAR - UDINT_TO_SINT := in; + UDINT_TO_SINT := in; END_FUNCTION (******************** @@ -833,9 +833,9 @@ END_FUNCTION *********************) FUNCTION UDINT_TO_ULINT : ULINT VAR_INPUT - in : UDINT; + in : UDINT; END_VAR - UDINT_TO_ULINT := in; + UDINT_TO_ULINT := in; END_FUNCTION (******************** @@ -845,9 +845,9 @@ END_FUNCTION *********************) FUNCTION UDINT_TO_UINT : UINT VAR_INPUT - in : UDINT; + in : UDINT; END_VAR - UDINT_TO_UINT := in; + UDINT_TO_UINT := in; END_FUNCTION (******************** @@ -857,9 +857,9 @@ END_FUNCTION *********************) FUNCTION UDINT_TO_USINT : USINT VAR_INPUT - in : UDINT; + in : UDINT; END_VAR - UDINT_TO_USINT := in; + UDINT_TO_USINT := in; END_FUNCTION (******************** @@ -869,9 +869,9 @@ END_FUNCTION *********************) FUNCTION UINT_TO_LREAL : LREAL VAR_INPUT - in : UINT; + in : UINT; END_VAR - UINT_TO_LREAL := in; + UINT_TO_LREAL := in; END_FUNCTION (******************** @@ -881,9 +881,9 @@ END_FUNCTION *********************) FUNCTION UINT_TO_REAL : REAL VAR_INPUT - in : UINT; + in : UINT; END_VAR - UINT_TO_REAL := in; + UINT_TO_REAL := in; END_FUNCTION (******************** @@ -893,9 +893,9 @@ END_FUNCTION *********************) FUNCTION UINT_TO_LINT : LINT VAR_INPUT - in : UINT; + in : UINT; END_VAR - UINT_TO_LINT := in; + UINT_TO_LINT := in; END_FUNCTION (******************** @@ -905,9 +905,9 @@ END_FUNCTION *********************) FUNCTION UINT_TO_DINT : DINT VAR_INPUT - in : UINT; + in : UINT; END_VAR - UINT_TO_DINT := in; + UINT_TO_DINT := in; END_FUNCTION (******************** @@ -917,9 +917,9 @@ END_FUNCTION *********************) FUNCTION UINT_TO_INT : INT VAR_INPUT - in : UINT; + in : UINT; END_VAR - UINT_TO_INT := in; + UINT_TO_INT := in; END_FUNCTION (******************** @@ -929,9 +929,9 @@ END_FUNCTION *********************) FUNCTION UINT_TO_SINT : SINT VAR_INPUT - in : UINT; + in : UINT; END_VAR - UINT_TO_SINT := in; + UINT_TO_SINT := in; END_FUNCTION (******************** @@ -941,9 +941,9 @@ END_FUNCTION *********************) FUNCTION UINT_TO_ULINT : ULINT VAR_INPUT - in : UINT; + in : UINT; END_VAR - UINT_TO_ULINT := in; + UINT_TO_ULINT := in; END_FUNCTION (******************** @@ -953,9 +953,9 @@ END_FUNCTION *********************) FUNCTION UINT_TO_UDINT : UDINT VAR_INPUT - in : UINT; + in : UINT; END_VAR - UINT_TO_UDINT := in; + UINT_TO_UDINT := in; END_FUNCTION (******************** @@ -965,9 +965,9 @@ END_FUNCTION *********************) FUNCTION UINT_TO_USINT : USINT VAR_INPUT - in : UINT; + in : UINT; END_VAR - UINT_TO_USINT := in; + UINT_TO_USINT := in; END_FUNCTION (******************** @@ -977,9 +977,9 @@ END_FUNCTION *********************) FUNCTION USINT_TO_LREAL : LREAL VAR_INPUT - in : USINT; + in : USINT; END_VAR - USINT_TO_LREAL := in; + USINT_TO_LREAL := in; END_FUNCTION (******************** @@ -989,9 +989,9 @@ END_FUNCTION *********************) FUNCTION USINT_TO_REAL : REAL VAR_INPUT - in : USINT; + in : USINT; END_VAR - USINT_TO_REAL := in; + USINT_TO_REAL := in; END_FUNCTION (******************** @@ -1001,9 +1001,9 @@ END_FUNCTION *********************) FUNCTION USINT_TO_LINT : LINT VAR_INPUT - in : USINT; + in : USINT; END_VAR - USINT_TO_LINT := in; + USINT_TO_LINT := in; END_FUNCTION (******************** @@ -1013,9 +1013,9 @@ END_FUNCTION *********************) FUNCTION USINT_TO_DINT : DINT VAR_INPUT - in : USINT; + in : USINT; END_VAR - USINT_TO_DINT := in; + USINT_TO_DINT := in; END_FUNCTION (******************** @@ -1025,9 +1025,9 @@ END_FUNCTION *********************) FUNCTION USINT_TO_INT : INT VAR_INPUT - in : USINT; + in : USINT; END_VAR - USINT_TO_INT := in; + USINT_TO_INT := in; END_FUNCTION (******************** @@ -1037,9 +1037,9 @@ END_FUNCTION *********************) FUNCTION USINT_TO_SINT : SINT VAR_INPUT - in : USINT; + in : USINT; END_VAR - USINT_TO_SINT := in; + USINT_TO_SINT := in; END_FUNCTION (******************** @@ -1049,9 +1049,9 @@ END_FUNCTION *********************) FUNCTION USINT_TO_ULINT : ULINT VAR_INPUT - in : USINT; + in : USINT; END_VAR - USINT_TO_ULINT := in; + USINT_TO_ULINT := in; END_FUNCTION (******************** @@ -1061,9 +1061,9 @@ END_FUNCTION *********************) FUNCTION USINT_TO_UDINT : UDINT VAR_INPUT - in : USINT; + in : USINT; END_VAR - USINT_TO_UDINT := in; + USINT_TO_UDINT := in; END_FUNCTION (******************** @@ -1073,7 +1073,7 @@ END_FUNCTION *********************) FUNCTION USINT_TO_UINT : UINT VAR_INPUT - in : USINT; + in : USINT; END_VAR - USINT_TO_UINT := in; -END_FUNCTION \ No newline at end of file + USINT_TO_UINT := in; +END_FUNCTION diff --git a/libs/stdlib/iec61131-st/numerical_functions.st b/libs/stdlib/iec61131-st/numerical_functions.st index 7374d9f93d..398034000a 100644 --- a/libs/stdlib/iec61131-st/numerical_functions.st +++ b/libs/stdlib/iec61131-st/numerical_functions.st @@ -1,11 +1,11 @@ (************************** - * + * *This operator returns the absolute value of a number. - * + * *************************) -FUNCTION ABS : T +FUNCTION ABS : T VAR_INPUT - IN : T; + IN : T; END_VAR END_FUNCTION @@ -14,69 +14,69 @@ END_FUNCTION /* FUNCTION ABS__DINT : DINT */ FUNCTION ABS__DINT : DINT VAR_INPUT - IN : DINT; + IN : DINT; END_VAR - ABS__DINT := IN; - IF ABS__DINT < 0 THEN - ABS__DINT := -1 * ABS__DINT; - END_IF + ABS__DINT := IN; + IF ABS__DINT < 0 THEN + ABS__DINT := -1 * ABS__DINT; + END_IF END_FUNCTION (* Specialized implementation of ABS for SINT *) FUNCTION ABS__SINT : SINT VAR_INPUT - IN : SINT; + IN : SINT; END_VAR - ABS__SINT := ABS__DINT(IN); + ABS__SINT := ABS__DINT(IN); END_FUNCTION (* Specialized implementation of ABS for INT *) FUNCTION ABS__INT : INT VAR_INPUT - IN : INT; + IN : INT; END_VAR - ABS__INT := ABS__DINT(IN); + ABS__INT := ABS__DINT(IN); END_FUNCTION (* Specialized implementation of ABS for LINT *) FUNCTION ABS__LINT : LINT VAR_INPUT - IN : LINT; + IN : LINT; END_VAR - ABS__LINT := IN; - IF ABS__LINT < 0 THEN - ABS__LINT := -1 * ABS__LINT; - END_IF + ABS__LINT := IN; + IF ABS__LINT < 0 THEN + ABS__LINT := -1 * ABS__LINT; + END_IF END_FUNCTION (* Specialized implementation of ABS for REAL *) FUNCTION ABS__REAL : REAL VAR_INPUT - IN : REAL; + IN : REAL; END_VAR - ABS__REAL := ABS__LREAL(IN); + ABS__REAL := ABS__LREAL(IN); END_FUNCTION (* Specialized implementation of ABS for LREAL *) FUNCTION ABS__LREAL : LREAL VAR_INPUT - IN : LREAL; + IN : LREAL; END_VAR - ABS__LREAL := IN; - IF ABS__LREAL < 0 THEN - ABS__LREAL := -1.0 * ABS__LREAL; - END_IF + ABS__LREAL := IN; + IF ABS__LREAL < 0 THEN + ABS__LREAL := -1.0 * ABS__LREAL; + END_IF END_FUNCTION (************************** - * + * * Rounds a given ANY_REAL to the nearest integer * Rounds half values away from zero - * + * *************************) {external} -FUNCTION ROUND : T +FUNCTION ROUND : T VAR_INPUT - in : T; + in : T; END_VAR END_FUNCTION diff --git a/libs/stdlib/iec61131-st/selectors.st b/libs/stdlib/iec61131-st/selectors.st index df70b0eb85..c6a48676b9 100644 --- a/libs/stdlib/iec61131-st/selectors.st +++ b/libs/stdlib/iec61131-st/selectors.st @@ -1,9 +1,9 @@ (************************** - * + * * MAX(IN0, IN1, ...) - * + * * This operator produces the larger value of the given operands. - * + * *************************) {external} FUNCTION MAX : T @@ -13,11 +13,11 @@ END_VAR END_FUNCTION (************************** - * + * * MIN(IN0, IN1, ...) - * + * * This operator produces the smaller value of the given operands. - * + * *************************) {external} FUNCTION MIN : T @@ -27,14 +27,14 @@ END_VAR END_FUNCTION (************************** - * + * * LIMIT(Min, IN, Max) - * + * * This operator limits an input value to the range between Min and Max. * If IN lies between the range of Min and Max, IN is displayed as a result. * If IN > Max, Max is displayed as a result. * If IN < Min, Min is displayed as a result. - * + * *************************) {external} FUNCTION LIMIT : T @@ -43,4 +43,4 @@ VAR_INPUT IN : T; MAX : T; END_VAR -END_FUNCTION \ No newline at end of file +END_FUNCTION diff --git a/libs/stdlib/iec61131-st/string_conversion.st b/libs/stdlib/iec61131-st/string_conversion.st index 31b1919ed7..1903738316 100644 --- a/libs/stdlib/iec61131-st/string_conversion.st +++ b/libs/stdlib/iec61131-st/string_conversion.st @@ -5,18 +5,18 @@ *********************) FUNCTION WSTRING_TO_STRING : STRING[__STRING_LENGTH] VAR_INPUT {ref} - in : WSTRING[__STRING_LENGTH]; + in : WSTRING[__STRING_LENGTH]; END_VAR - WSTRING_TO_STRING_EXT(in, WSTRING_TO_STRING); + WSTRING_TO_STRING_EXT(in, WSTRING_TO_STRING); END_FUNCTION {external} FUNCTION WSTRING_TO_STRING_EXT : DINT VAR_INPUT {ref} - in : WSTRING[__STRING_LENGTH]; + in : WSTRING[__STRING_LENGTH]; END_VAR -VAR_IN_OUT - out : STRING[__STRING_LENGTH]; +VAR_IN_OUT + out : STRING[__STRING_LENGTH]; END_VAR END_FUNCTION @@ -27,13 +27,13 @@ END_FUNCTION *********************) FUNCTION WSTRING_TO_WCHAR : WCHAR VAR_INPUT {ref} - in : WSTRING; + in : WSTRING; END_VAR VAR - ptr : REF_TO WCHAR; + ptr : REF_TO WCHAR; END_VAR - ptr := ∈ - WSTRING_TO_WCHAR := ptr^; + ptr := ∈ + WSTRING_TO_WCHAR := ptr^; END_FUNCTION (******************** @@ -44,18 +44,18 @@ END_FUNCTION *********************) FUNCTION STRING_TO_WSTRING : WSTRING[__STRING_LENGTH] VAR_INPUT {ref} - in : STRING[__STRING_LENGTH]; + in : STRING[__STRING_LENGTH]; END_VAR - STRING_TO_WSTRING_EXT(in, STRING_TO_WSTRING); + STRING_TO_WSTRING_EXT(in, STRING_TO_WSTRING); END_FUNCTION {external} FUNCTION STRING_TO_WSTRING_EXT : DINT VAR_INPUT {ref} - in : STRING[__STRING_LENGTH]; + in : STRING[__STRING_LENGTH]; END_VAR VAR_IN_OUT - out : WSTRING[__STRING_LENGTH]; + out : WSTRING[__STRING_LENGTH]; END_VAR END_FUNCTION @@ -66,13 +66,13 @@ END_FUNCTION *********************) FUNCTION STRING_TO_CHAR : CHAR VAR_INPUT {ref} - in : STRING; + in : STRING; END_VAR VAR - ptr : REF_TO CHAR; + ptr : REF_TO CHAR; END_VAR - ptr := ∈ - STRING_TO_CHAR := ptr^; + ptr := ∈ + STRING_TO_CHAR := ptr^; END_FUNCTION (******************** @@ -82,13 +82,13 @@ END_FUNCTION *********************) FUNCTION WCHAR_TO_WSTRING : WSTRING VAR_INPUT - in : WCHAR; + in : WCHAR; END_VAR VAR - ptr : REF_TO WSTRING; + ptr : REF_TO WSTRING; END_VAR - ptr := ∈ - WCHAR_TO_WSTRING := ptr^; + ptr := ∈ + WCHAR_TO_WSTRING := ptr^; END_FUNCTION (******************** @@ -99,7 +99,7 @@ END_FUNCTION {external} FUNCTION WCHAR_TO_CHAR : CHAR VAR_INPUT - in : WCHAR; + in : WCHAR; END_VAR END_FUNCTION @@ -110,13 +110,13 @@ END_FUNCTION *********************) FUNCTION CHAR_TO_STRING : STRING VAR_INPUT - in : CHAR; + in : CHAR; END_VAR VAR - ptr : REF_TO STRING; + ptr : REF_TO STRING; END_VAR - ptr := ∈ - CHAR_TO_STRING := ptr^; + ptr := ∈ + CHAR_TO_STRING := ptr^; END_FUNCTION (******************** @@ -127,6 +127,6 @@ END_FUNCTION {external} FUNCTION CHAR_TO_WCHAR : WCHAR VAR_INPUT - in : CHAR; + in : CHAR; END_VAR -END_FUNCTION \ No newline at end of file +END_FUNCTION diff --git a/libs/stdlib/iec61131-st/string_functions.st b/libs/stdlib/iec61131-st/string_functions.st index 4095e2ee89..01af032984 100644 --- a/libs/stdlib/iec61131-st/string_functions.st +++ b/libs/stdlib/iec61131-st/string_functions.st @@ -11,7 +11,7 @@ Return: String length {external} FUNCTION LEN : DINT VAR_INPUT {ref} - IN : T; + IN : T; END_VAR END_FUNCTION @@ -24,7 +24,7 @@ Return: A substring consisting of the leftmost L characters of IN ******************************************************************************) FUNCTION LEFT : T VAR_INPUT {ref} - IN : T; + IN : T; END_VAR VAR_INPUT L : DINT; @@ -34,7 +34,7 @@ END_FUNCTION {external} FUNCTION LEFT_EXT : DINT VAR_INPUT {ref} - IN : T; + IN : T; END_VAR VAR_INPUT L : DINT; @@ -46,7 +46,7 @@ END_FUNCTION FUNCTION LEFT__STRING : STRING[__STRING_LENGTH] VAR_INPUT {ref} - IN : STRING[__STRING_LENGTH]; + IN : STRING[__STRING_LENGTH]; END_VAR VAR_INPUT L : DINT; @@ -56,7 +56,7 @@ END_FUNCTION FUNCTION LEFT__WSTRING : WSTRING[__STRING_LENGTH] VAR_INPUT {ref} - IN : WSTRING[__STRING_LENGTH]; + IN : WSTRING[__STRING_LENGTH]; END_VAR VAR_INPUT L : DINT; @@ -67,7 +67,7 @@ END_FUNCTION {external} FUNCTION LEFT_EXT__STRING : DINT VAR_INPUT {ref} - IN : STRING[__STRING_LENGTH]; + IN : STRING[__STRING_LENGTH]; END_VAR VAR_INPUT L : DINT; @@ -80,7 +80,7 @@ END_FUNCTION {external} FUNCTION LEFT_EXT__WSTRING : DINT VAR_INPUT {ref} - IN : WSTRING[__STRING_LENGTH]; + IN : WSTRING[__STRING_LENGTH]; END_VAR VAR_INPUT L : DINT; @@ -99,7 +99,7 @@ Return: A substring consisting of the rightmost L characters of IN ******************************************************************************) FUNCTION RIGHT : T VAR_INPUT {ref} - IN : T; + IN : T; END_VAR VAR_INPUT L : DINT; @@ -109,7 +109,7 @@ END_FUNCTION {external} FUNCTION RIGHT_EXT : DINT VAR_INPUT {ref} - IN : T; + IN : T; END_VAR VAR_INPUT L : DINT; @@ -121,7 +121,7 @@ END_FUNCTION FUNCTION RIGHT__STRING : STRING[__STRING_LENGTH] VAR_INPUT {ref} - IN : STRING[__STRING_LENGTH]; + IN : STRING[__STRING_LENGTH]; END_VAR VAR_INPUT L : DINT; @@ -131,7 +131,7 @@ END_FUNCTION FUNCTION RIGHT__WSTRING : WSTRING[__STRING_LENGTH] VAR_INPUT {ref} - IN : WSTRING[__STRING_LENGTH]; + IN : WSTRING[__STRING_LENGTH]; END_VAR VAR_INPUT L : DINT; @@ -142,7 +142,7 @@ END_FUNCTION {external} FUNCTION RIGHT_EXT__STRING : DINT VAR_INPUT {ref} - IN : STRING[__STRING_LENGTH]; + IN : STRING[__STRING_LENGTH]; END_VAR VAR_INPUT L : DINT; @@ -155,7 +155,7 @@ END_FUNCTION {external} FUNCTION RIGHT_EXT__WSTRING : DINT VAR_INPUT {ref} - IN : WSTRING[__STRING_LENGTH]; + IN : WSTRING[__STRING_LENGTH]; END_VAR VAR_INPUT L : DINT; @@ -177,7 +177,7 @@ Return: ******************************************************************************) FUNCTION MID : T VAR_INPUT {ref} - IN : T; + IN : T; END_VAR VAR_INPUT L : DINT; @@ -188,7 +188,7 @@ END_FUNCTION {external} FUNCTION MID_EXT : DINT VAR_INPUT {ref} - IN : T; + IN : T; END_VAR VAR_INPUT L : DINT; @@ -201,7 +201,7 @@ END_FUNCTION FUNCTION MID__STRING : STRING[__STRING_LENGTH] VAR_INPUT {ref} - IN : STRING[__STRING_LENGTH]; + IN : STRING[__STRING_LENGTH]; END_VAR VAR_INPUT L : DINT; @@ -212,7 +212,7 @@ END_FUNCTION FUNCTION MID__WSTRING : WSTRING[__STRING_LENGTH] VAR_INPUT {ref} - IN : WSTRING[__STRING_LENGTH]; + IN : WSTRING[__STRING_LENGTH]; END_VAR VAR_INPUT L : DINT; @@ -224,7 +224,7 @@ END_FUNCTION {external} FUNCTION MID_EXT__STRING : DINT VAR_INPUT {ref} - IN : STRING[__STRING_LENGTH]; + IN : STRING[__STRING_LENGTH]; END_VAR VAR_INPUT L : DINT; @@ -238,7 +238,7 @@ END_FUNCTION {external} FUNCTION MID_EXT__WSTRING : DINT VAR_INPUT {ref} - IN : WSTRING[__STRING_LENGTH]; + IN : WSTRING[__STRING_LENGTH]; END_VAR VAR_INPUT L : DINT; @@ -261,20 +261,20 @@ Return: {external} FUNCTION CONCAT__STRING : STRING[2048] VAR_INPUT {ref} - args : {sized} STRING...; + args : {sized} STRING...; END_VAR END_FUNCTION {external} FUNCTION CONCAT__WSTRING : WSTRING[2048] VAR_INPUT {ref} - args : {sized} WSTRING...; + args : {sized} WSTRING...; END_VAR END_FUNCTION FUNCTION CONCAT : T VAR_INPUT {ref} - args : {sized} T...; + args : {sized} T...; END_VAR END_FUNCTION @@ -299,7 +299,7 @@ Return: ******************************************************************************) FUNCTION INSERT : T VAR_INPUT {ref} - IN1 : T; + IN1 : T; IN2 : T; END_VAR VAR_INPUT @@ -310,7 +310,7 @@ END_FUNCTION {external} FUNCTION INSERT_EXT : DINT VAR_INPUT {ref} - IN1 : T; + IN1 : T; IN2 : T; END_VAR VAR_INPUT @@ -323,7 +323,7 @@ END_FUNCTION FUNCTION INSERT__STRING : STRING[__STRING_LENGTH] VAR_INPUT {ref} - IN1 : STRING[__STRING_LENGTH]; + IN1 : STRING[__STRING_LENGTH]; IN2 : STRING[__STRING_LENGTH]; END_VAR VAR_INPUT @@ -334,7 +334,7 @@ END_FUNCTION FUNCTION INSERT__WSTRING : WSTRING[__STRING_LENGTH] VAR_INPUT {ref} - IN1 : WSTRING[__STRING_LENGTH]; + IN1 : WSTRING[__STRING_LENGTH]; IN2 : WSTRING[__STRING_LENGTH]; END_VAR VAR_INPUT @@ -346,7 +346,7 @@ END_FUNCTION {external} FUNCTION INSERT_EXT__STRING : DINT VAR_INPUT {ref} - IN1 : STRING[__STRING_LENGTH]; + IN1 : STRING[__STRING_LENGTH]; IN2 : STRING[__STRING_LENGTH]; END_VAR VAR_INPUT @@ -360,7 +360,7 @@ END_FUNCTION {external} FUNCTION INSERT_EXT__WSTRING : DINT VAR_INPUT {ref} - IN1 : WSTRING[__STRING_LENGTH]; + IN1 : WSTRING[__STRING_LENGTH]; IN2 : WSTRING[__STRING_LENGTH]; END_VAR VAR_INPUT @@ -381,7 +381,7 @@ Return: A new string with L characters deleted from P onwards ******************************************************************************) FUNCTION DELETE : T VAR_INPUT {ref} - IN : T; + IN : T; END_VAR VAR_INPUT L : DINT; @@ -392,7 +392,7 @@ END_FUNCTION {external} FUNCTION DELETE_EXT : DINT VAR_INPUT {ref} - IN : T; + IN : T; END_VAR VAR_INPUT L : DINT; @@ -405,7 +405,7 @@ END_FUNCTION FUNCTION DELETE__STRING : STRING[__STRING_LENGTH] VAR_INPUT {ref} - IN : STRING[__STRING_LENGTH]; + IN : STRING[__STRING_LENGTH]; END_VAR VAR_INPUT L : DINT; @@ -416,7 +416,7 @@ END_FUNCTION FUNCTION DELETE__WSTRING : WSTRING[__STRING_LENGTH] VAR_INPUT {ref} - IN : WSTRING[__STRING_LENGTH]; + IN : WSTRING[__STRING_LENGTH]; END_VAR VAR_INPUT L : DINT; @@ -428,7 +428,7 @@ END_FUNCTION {external} FUNCTION DELETE_EXT__STRING : DINT VAR_INPUT {ref} - IN : STRING[__STRING_LENGTH]; + IN : STRING[__STRING_LENGTH]; END_VAR VAR_INPUT L : DINT; @@ -442,7 +442,7 @@ END_FUNCTION {external} FUNCTION DELETE_EXT__WSTRING : DINT VAR_INPUT {ref} - IN : WSTRING[__STRING_LENGTH]; + IN : WSTRING[__STRING_LENGTH]; END_VAR VAR_INPUT L : DINT; @@ -463,7 +463,7 @@ Return: A new string which has L characters replaced by IN2 from position P onwa ******************************************************************************) FUNCTION REPLACE : T VAR_INPUT {ref} - IN1 : T; + IN1 : T; IN2 : T; END_VAR VAR_INPUT @@ -489,7 +489,7 @@ END_FUNCTION FUNCTION REPLACE__STRING : STRING[__STRING_LENGTH] VAR_INPUT {ref} - IN1 : STRING[__STRING_LENGTH]; + IN1 : STRING[__STRING_LENGTH]; IN2 : STRING[__STRING_LENGTH]; END_VAR VAR_INPUT @@ -552,7 +552,7 @@ Return: The character index of the first match. 0 if there are no matches. {external} FUNCTION FIND : DINT VAR_INPUT {ref} - IN1 : T; + IN1 : T; IN2 : T; END_VAR END_FUNCTION @@ -567,21 +567,21 @@ Return: {external} FUNCTION GT : BOOL VAR_INPUT {ref} - IN1 : {sized} T...; + IN1 : {sized} T...; END_VAR END_FUNCTION {external} FUNCTION GT__STRING : BOOL VAR_INPUT {ref} - IN1 : {sized} STRING...; + IN1 : {sized} STRING...; END_VAR END_FUNCTION {external} FUNCTION GT__WSTRING : BOOL VAR_INPUT {ref} - IN1 : {sized} WSTRING...; + IN1 : {sized} WSTRING...; END_VAR END_FUNCTION @@ -610,21 +610,21 @@ Return: {external} FUNCTION GE : BOOL VAR_INPUT {ref} - IN1 : {sized} T...; + IN1 : {sized} T...; END_VAR END_FUNCTION {external} FUNCTION GE__STRING : BOOL VAR_INPUT {ref} - IN1 : {sized} STRING...; + IN1 : {sized} STRING...; END_VAR END_FUNCTION {external} FUNCTION GE__WSTRING : BOOL VAR_INPUT {ref} - IN1 : {sized} WSTRING...; + IN1 : {sized} WSTRING...; END_VAR END_FUNCTION @@ -638,21 +638,21 @@ Return: {external} FUNCTION EQ : BOOL VAR_INPUT {ref} - IN1 : {sized} T...; + IN1 : {sized} T...; END_VAR END_FUNCTION {external} FUNCTION EQ__STRING : BOOL VAR_INPUT {ref} - IN1 : {sized} STRING...; + IN1 : {sized} STRING...; END_VAR END_FUNCTION {external} FUNCTION EQ__WSTRING : BOOL VAR_INPUT {ref} - IN1 : {sized} WSTRING...; + IN1 : {sized} WSTRING...; END_VAR END_FUNCTION @@ -680,21 +680,21 @@ Return: {external} FUNCTION LE : BOOL VAR_INPUT {ref} - IN1 : {sized} T...; + IN1 : {sized} T...; END_VAR END_FUNCTION {external} FUNCTION LE__STRING : BOOL VAR_INPUT {ref} - IN1 : {sized} STRING...; + IN1 : {sized} STRING...; END_VAR END_FUNCTION {external} FUNCTION LE__WSTRING : BOOL VAR_INPUT {ref} - IN1 : {sized} WSTRING...; + IN1 : {sized} WSTRING...; END_VAR END_FUNCTION @@ -708,21 +708,21 @@ Return: {external} FUNCTION LT : BOOL VAR_INPUT {ref} - IN1 : {sized} T...; + IN1 : {sized} T...; END_VAR END_FUNCTION {external} FUNCTION LT__STRING : BOOL VAR_INPUT {ref} - IN1 : {sized} STRING...; + IN1 : {sized} STRING...; END_VAR END_FUNCTION {external} FUNCTION LT__WSTRING : BOOL VAR_INPUT {ref} - IN1 : {sized} WSTRING...; + IN1 : {sized} WSTRING...; END_VAR END_FUNCTION @@ -750,7 +750,7 @@ Return: {external} FUNCTION NE : BOOL VAR_INPUT {ref} - IN1 : T; + IN1 : T; IN2 : T; END_VAR -END_FUNCTION \ No newline at end of file +END_FUNCTION diff --git a/libs/stdlib/iec61131-st/timers.st b/libs/stdlib/iec61131-st/timers.st index 8fb65477d9..7b3faea699 100644 --- a/libs/stdlib/iec61131-st/timers.st +++ b/libs/stdlib/iec61131-st/timers.st @@ -1,18 +1,18 @@ {external} (****************************************************************************** -Description: Timer Pulse +Description: Timer Pulse Input: - - IN: Trigger for Start of the Signal + - IN: Trigger for Start of the Signal - PT: The length of the High-Signal Output: - - Q: The pulse - - ET: The current phase of the High-Signal + - Q: The pulse + - ET: The current phase of the High-Signal Return: Output variables are used for return. ******************************************************************************) FUNCTION_BLOCK TP VAR_INPUT IN : BOOL; - PT : TIME; + PT : TIME; END_VAR VAR_OUTPUT Q : BOOL; @@ -26,19 +26,19 @@ END_FUNCTION_BLOCK {external} (****************************************************************************** -Description: Timer Pulse +Description: Timer Pulse Input: - - IN: Trigger for Start of the Signal + - IN: Trigger for Start of the Signal - PT: The length of the High-Signal Output: - - Q: The pulse - - ET: The current phase of the High-Signal + - Q: The pulse + - ET: The current phase of the High-Signal Return: Output variables are used for return. ******************************************************************************) FUNCTION_BLOCK TP_TIME VAR_INPUT IN : BOOL; - PT : TIME; + PT : TIME; END_VAR VAR_OUTPUT Q : BOOL; @@ -52,19 +52,19 @@ END_FUNCTION_BLOCK {external} (****************************************************************************** -Description: Timer Pulse +Description: Timer Pulse Input: - - IN: Trigger for Start of the Signal + - IN: Trigger for Start of the Signal - PT: The length of the High-Signal Output: - - Q: The pulse - - ET: The current phase of the High-Signal + - Q: The pulse + - ET: The current phase of the High-Signal Return: Output variables are used for return. ******************************************************************************) FUNCTION_BLOCK TP_LTIME VAR_INPUT IN : BOOL; - PT : TIME; + PT : TIME; END_VAR VAR_OUTPUT Q : BOOL; @@ -80,21 +80,21 @@ END_FUNCTION_BLOCK (****************************************************************************** Description: Timer on delay. Input: - - IN: Starts timer with rising edge, resets timer with falling edge - - PT: Time to pass, before Q is set + - IN: Starts timer with rising edge, resets timer with falling edge + - PT: Time to pass, before Q is set Output: - - Q: Is TRUE, PT seconds after IN had a rising edge - - ET: Elapsed time + - Q: Is TRUE, PT seconds after IN had a rising edge + - ET: Elapsed time Return: Output variables are used for return. ******************************************************************************) FUNCTION_BLOCK TON VAR_INPUT - IN: BOOL; - PT: TIME; + IN: BOOL; + PT: TIME; END_VAR VAR_OUTPUT - Q: BOOL; - ET: TIME; + Q: BOOL; + ET: TIME; END_VAR VAR __signal__ : BOOL; (* Value representing the internal signal *) @@ -106,21 +106,21 @@ END_FUNCTION_BLOCK (****************************************************************************** Description: Timer on delay. Input: - - IN: Starts timer with rising edge, resets timer with falling edge - - PT: Time to pass, before Q is set + - IN: Starts timer with rising edge, resets timer with falling edge + - PT: Time to pass, before Q is set Output: - - Q: Is TRUE, PT seconds after IN had a rising edge - - ET: Elapsed time + - Q: Is TRUE, PT seconds after IN had a rising edge + - ET: Elapsed time Return: Output variables are used for return. ******************************************************************************) FUNCTION_BLOCK TON_TIME VAR_INPUT - IN: BOOL; - PT: TIME; + IN: BOOL; + PT: TIME; END_VAR VAR_OUTPUT - Q: BOOL; - ET: TIME; + Q: BOOL; + ET: TIME; END_VAR VAR __signal__ : BOOL; (* Value representing the internal signal *) @@ -132,21 +132,21 @@ END_FUNCTION_BLOCK (****************************************************************************** Description: Timer on delay. Input: - - IN: Starts timer with rising edge, resets timer with falling edge - - PT: Time to pass, before Q is set + - IN: Starts timer with rising edge, resets timer with falling edge + - PT: Time to pass, before Q is set Output: - - Q: Is TRUE, PT seconds after IN had a rising edge - - ET: Elapsed time + - Q: Is TRUE, PT seconds after IN had a rising edge + - ET: Elapsed time Return: Output variables are used for return. ******************************************************************************) FUNCTION_BLOCK TON_LTIME VAR_INPUT - IN: BOOL; - PT: LTIME; + IN: BOOL; + PT: LTIME; END_VAR VAR_OUTPUT - Q: BOOL; - ET: TIME; + Q: BOOL; + ET: TIME; END_VAR VAR __signal__ : BOOL; (* Value representing the internal signal *) @@ -158,21 +158,21 @@ END_FUNCTION_BLOCK (****************************************************************************** Description: Timer of delay Input: - - IN: Starts timer with falling edge, resets timer with rising edge - - PT: Time to pass, before Q is set + - IN: Starts timer with falling edge, resets timer with rising edge + - PT: Time to pass, before Q is set Output: - Q: is FALSE, PT seconds after IN had a falling edge - - ET: Elapsed time + - ET: Elapsed time Return: Output variables are used for return. ******************************************************************************) FUNCTION_BLOCK TOF VAR_INPUT - IN: BOOL; - PT:TIME; + IN: BOOL; + PT:TIME; END_VAR VAR_OUTPUT - Q: BOOL; - ET: TIME; + Q: BOOL; + ET: TIME; END_VAR VAR __signal__ : BOOL; (* Value representing the internal signal *) @@ -184,21 +184,21 @@ END_FUNCTION_BLOCK (****************************************************************************** Description: Timer of delay Input: - - IN: Starts timer with falling edge, resets timer with rising edge - - PT: Time to pass, before Q is set + - IN: Starts timer with falling edge, resets timer with rising edge + - PT: Time to pass, before Q is set Output: - Q: is FALSE, PT seconds after IN had a falling edge - - ET: Elapsed time + - ET: Elapsed time Return: Output variables are used for return. ******************************************************************************) FUNCTION_BLOCK TOF_TIME VAR_INPUT - IN: BOOL; - PT:TIME; + IN: BOOL; + PT:TIME; END_VAR VAR_OUTPUT - Q: BOOL; - ET: TIME; + Q: BOOL; + ET: TIME; END_VAR VAR __signal__ : BOOL; (* Value representing the internal signal *) @@ -210,24 +210,24 @@ END_FUNCTION_BLOCK (****************************************************************************** Description: Timer of delay Input: - - IN: Starts timer with falling edge, resets timer with rising edge - - PT: Time to pass, before Q is set + - IN: Starts timer with falling edge, resets timer with rising edge + - PT: Time to pass, before Q is set Output: - Q: is FALSE, PT seconds after IN had a falling edge - - ET: Elapsed time + - ET: Elapsed time Return: Output variables are used for return. ******************************************************************************) FUNCTION_BLOCK TOF_LTIME VAR_INPUT - IN: BOOL; - PT:LTIME; + IN: BOOL; + PT:LTIME; END_VAR VAR_OUTPUT - Q: BOOL; - ET: LTIME; + Q: BOOL; + ET: LTIME; END_VAR VAR __signal__ : BOOL; (* Value representing the internal signal *) __BUFFER__ : ARRAY[1..24] OF BYTE; (* Buffer used for internal implementation *) END_VAR -END_FUNCTION_BLOCK \ No newline at end of file +END_FUNCTION_BLOCK diff --git a/libs/stdlib/iec61131-st/validation_functions.st b/libs/stdlib/iec61131-st/validation_functions.st index 738eb66244..39086c3dd7 100644 --- a/libs/stdlib/iec61131-st/validation_functions.st +++ b/libs/stdlib/iec61131-st/validation_functions.st @@ -9,7 +9,7 @@ Return: {external} FUNCTION IS_VALID : BOOL VAR_INPUT - IN : T; + IN : T; END_VAR END_FUNCTION @@ -26,6 +26,6 @@ Return: {external} FUNCTION IS_VALID_BCD : BOOL VAR_INPUT - IN : T; + IN : T; END_VAR -END_FUNCTION \ No newline at end of file +END_FUNCTION diff --git a/libs/stdlib/tests/arithmetic_functions_tests.rs b/libs/stdlib/tests/arithmetic_functions_tests.rs index 87411b1914..6327fd5942 100644 --- a/libs/stdlib/tests/arithmetic_functions_tests.rs +++ b/libs/stdlib/tests/arithmetic_functions_tests.rs @@ -186,7 +186,7 @@ fn sin_called_on_real() { a,b : REAL; END_VAR a := SIN(FRAC_PI_2_REAL) - REAL#1.0; - b := SIN(REAL#0.0); + b := SIN(REAL#0.0); END_PROGRAM "; let sources = add_std!(src, "arithmetic_functions.st"); @@ -204,7 +204,7 @@ fn sin_called_on_lreal() { a,b : LREAL; END_VAR a := SIN(FRAC_PI_2_LREAL) - LREAL#1.0; - b := SIN(LREAL#0.0); + b := SIN(LREAL#0.0); END_PROGRAM "; let sources = add_std!(src, "arithmetic_functions.st"); @@ -221,8 +221,8 @@ fn cos_called_on_real() { VAR a,b : REAL; END_VAR - a := COS(PI_REAL) + REAL#1.0; - b := COS(REAL#0.0) - REAL#1.0; + a := COS(PI_REAL) + REAL#1.0; + b := COS(REAL#0.0) - REAL#1.0; END_PROGRAM "; let sources = add_std!(src, "arithmetic_functions.st"); @@ -239,8 +239,8 @@ fn cos_called_on_lreal() { VAR a,b : LREAL; END_VAR - a := COS(PI_LREAL) + LREAL#1.0; - b := COS(LREAL#0.0) - LREAL#1.0; + a := COS(PI_LREAL) + LREAL#1.0; + b := COS(LREAL#0.0) - LREAL#1.0; END_PROGRAM "; let sources = add_std!(src, "arithmetic_functions.st"); @@ -257,8 +257,8 @@ fn tan_called_on_real() { VAR a,b : REAL; END_VAR - a := TAN(FRAC_PI_4_REAL) - REAL#1.0; - b := TAN(PI_REAL); + a := TAN(FRAC_PI_4_REAL) - REAL#1.0; + b := TAN(PI_REAL); END_PROGRAM "; let sources = add_std!(src, "arithmetic_functions.st"); @@ -275,8 +275,8 @@ fn tan_called_on_lreal() { VAR a,b : LREAL; END_VAR - a := TAN(FRAC_PI_4_LREAL) - LREAL#1.0; - a := TAN(PI_LREAL); + a := TAN(FRAC_PI_4_LREAL) - LREAL#1.0; + a := TAN(PI_LREAL); END_PROGRAM "; let sources = add_std!(src, "arithmetic_functions.st"); @@ -357,7 +357,7 @@ fn atan_called_on_real() { VAR a,b : REAL; END_VAR - a := ATAN(REAL#1.0) - FRAC_PI_4_REAL; + a := ATAN(REAL#1.0) - FRAC_PI_4_REAL; END_PROGRAM "; let sources = add_std!(src, "arithmetic_functions.st"); @@ -373,7 +373,7 @@ fn atan_called_on_lreal() { VAR a,b : LREAL; END_VAR - a := ATAN(LREAL#1.0) - FRAC_PI_4_LREAL; + a := ATAN(LREAL#1.0) - FRAC_PI_4_LREAL; END_PROGRAM "; let sources = add_std!(src, "arithmetic_functions.st"); @@ -389,8 +389,8 @@ fn atan2_called_on_real() { VAR a,b : REAL; END_VAR - a := ATAN2(REAL#-3.0, REAL#3.0) + FRAC_PI_4_REAL; - b := ATAN2(REAL#3.0, REAL#-3.0) - (REAL#3.0 * FRAC_PI_4_REAL); + a := ATAN2(REAL#-3.0, REAL#3.0) + FRAC_PI_4_REAL; + b := ATAN2(REAL#3.0, REAL#-3.0) - (REAL#3.0 * FRAC_PI_4_REAL); END_PROGRAM "; let sources = add_std!(src, "arithmetic_functions.st"); @@ -407,8 +407,8 @@ fn atan2_called_on_lreal() { VAR a,b : LREAL; END_VAR - a := ATAN2(LREAL#-3.0, LREAL#3.0) + FRAC_PI_4_LREAL; - b := ATAN2(LREAL#3.0, LREAL#-3.0) - (REAL#3.0 * FRAC_PI_4_LREAL); + a := ATAN2(LREAL#-3.0, LREAL#3.0) + FRAC_PI_4_LREAL; + b := ATAN2(LREAL#3.0, LREAL#-3.0) - (REAL#3.0 * FRAC_PI_4_LREAL); END_PROGRAM "; let sources = add_std!(src, "arithmetic_functions.st"); diff --git a/libs/stdlib/tests/bistable_functionblocks_tests.rs b/libs/stdlib/tests/bistable_functionblocks_tests.rs index 7bc40267aa..5813d558cb 100644 --- a/libs/stdlib/tests/bistable_functionblocks_tests.rs +++ b/libs/stdlib/tests/bistable_functionblocks_tests.rs @@ -25,26 +25,26 @@ struct MainType { fn sr() { let prog = r#" PROGRAM main - VAR - sr_inst : SR; - t_t_t : BOOL; - t_t_f : BOOL; - t_f_t : BOOL; - t_f_f : BOOL; - f_t_t : BOOL; - f_t_f : BOOL; - f_f_t : BOOL; - f_f_f : BOOL; - END_VAR - sr_inst(SET1 := TRUE, RESET := TRUE, Q1 => t_t_f); (* Q is in default state, S and R are asserted -> Q goes high *) - sr_inst(SET1 := FALSE, RESET := TRUE, Q1 => f_t_t); (* Q is high, R is asserted -> Q goes low *) - sr_inst(SET1 := FALSE, RESET := FALSE, Q1 => f_f_f); (* Q is low, neither S nor R are asserted -> Q stays low*) - sr_inst(SET1 := TRUE, RESET := FALSE, Q1 => t_f_f); (* Q is low, S is asserted -> Q goes high *) - sr_inst(SET1 := TRUE, RESET := TRUE, Q1 => t_t_t); (* Q is high, S and R are asserted -> Q stays high *) - sr_inst(SET1 := TRUE, RESET := FALSE, Q1 => t_f_t); (* Q is high, S is asserted -> Q stays high *) - sr_inst(SET1 := FALSE, RESET := FALSE, Q1 => f_f_t); (* Q is high, neither S nor R are asserted -> Q stays high *) + VAR + sr_inst : SR; + t_t_t : BOOL; + t_t_f : BOOL; + t_f_t : BOOL; + t_f_f : BOOL; + f_t_t : BOOL; + f_t_f : BOOL; + f_f_t : BOOL; + f_f_f : BOOL; + END_VAR + sr_inst(SET1 := TRUE, RESET := TRUE, Q1 => t_t_f); (* Q is in default state, S and R are asserted -> Q goes high *) + sr_inst(SET1 := FALSE, RESET := TRUE, Q1 => f_t_t); (* Q is high, R is asserted -> Q goes low *) + sr_inst(SET1 := FALSE, RESET := FALSE, Q1 => f_f_f); (* Q is low, neither S nor R are asserted -> Q stays low*) + sr_inst(SET1 := TRUE, RESET := FALSE, Q1 => t_f_f); (* Q is low, S is asserted -> Q goes high *) + sr_inst(SET1 := TRUE, RESET := TRUE, Q1 => t_t_t); (* Q is high, S and R are asserted -> Q stays high *) + sr_inst(SET1 := TRUE, RESET := FALSE, Q1 => t_f_t); (* Q is high, S is asserted -> Q stays high *) + sr_inst(SET1 := FALSE, RESET := FALSE, Q1 => f_f_t); (* Q is high, neither S nor R are asserted -> Q stays high *) sr_inst(SET1 := FALSE, RESET := TRUE, Q1 => f_t_f); (* reset *) - sr_inst(SET1 := FALSE, RESET := TRUE, Q1 => f_t_f); (* Q is low, R is asserted -> Q stays low *) + sr_inst(SET1 := FALSE, RESET := TRUE, Q1 => f_t_f); (* Q is low, R is asserted -> Q stays low *) END_PROGRAM "#; @@ -67,17 +67,17 @@ fn sr() { fn rs() { let prog = r#" PROGRAM main - VAR - rs_inst : RS; - t_t_t : BOOL; - t_t_f : BOOL; - t_f_t : BOOL; - t_f_f : BOOL; - f_t_t : BOOL; - f_t_f : BOOL; - f_f_t : BOOL; - f_f_f : BOOL; - END_VAR + VAR + rs_inst : RS; + t_t_t : BOOL; + t_t_f : BOOL; + t_f_t : BOOL; + t_f_f : BOOL; + f_t_t : BOOL; + f_t_f : BOOL; + f_f_t : BOOL; + f_f_f : BOOL; + END_VAR rs_inst(SET := TRUE, RESET1 := TRUE, Q1 => t_t_f); (* Q is in default state, S and R are asserted -> Q stays low *) rs_inst(SET := FALSE, RESET1 := FALSE, Q1 => f_f_f); (* Q is low, neither S nor R are asserted -> Q stays low*) rs_inst(SET := TRUE, RESET1 := FALSE, Q1 => t_f_f); (* Q is low, S is asserted -> Q goes high *) diff --git a/libs/stdlib/tests/bit_conversion_tests.rs b/libs/stdlib/tests/bit_conversion_tests.rs index 4adc3d3aaa..7eb478fc77 100644 --- a/libs/stdlib/tests/bit_conversion_tests.rs +++ b/libs/stdlib/tests/bit_conversion_tests.rs @@ -51,25 +51,25 @@ struct BoolType { #[test] fn lword_to_dword() { let src = r" - TYPE myType : STRUCT - zero : DWORD; positive : DWORD; negative : DWORD; - max_overflow: DWORD; min_overflow: DWORD; - END_STRUCT END_TYPE - - VAR_GLOBAL - max : LWORD := 4294967295; - min : LWORD := 0; - END_VAR - - PROGRAM main - VAR - ret : myType; - END_VAR - ret.zero := LWORD_TO_DWORD(LWORD#0); - ret.positive := LWORD_TO_DWORD(LWORD#100); - ret.negative := LWORD_TO_DWORD(-1); - ret.max_overflow := LWORD_TO_DWORD(max+1); - ret.min_overflow := LWORD_TO_DWORD(min-1); + TYPE myType : STRUCT + zero : DWORD; positive : DWORD; negative : DWORD; + max_overflow: DWORD; min_overflow: DWORD; + END_STRUCT END_TYPE + + VAR_GLOBAL + max : LWORD := 4294967295; + min : LWORD := 0; + END_VAR + + PROGRAM main + VAR + ret : myType; + END_VAR + ret.zero := LWORD_TO_DWORD(LWORD#0); + ret.positive := LWORD_TO_DWORD(LWORD#100); + ret.negative := LWORD_TO_DWORD(-1); + ret.max_overflow := LWORD_TO_DWORD(max+1); + ret.min_overflow := LWORD_TO_DWORD(min-1); END_PROGRAM "; let sources = add_std!(src, "bit_conversion.st"); @@ -85,25 +85,25 @@ fn lword_to_dword() { #[test] fn lword_to_word() { let src = r" - TYPE myType : STRUCT - zero : WORD; positive : WORD; negative : WORD; - max_overflow: WORD; min_overflow: WORD; - END_STRUCT END_TYPE - - VAR_GLOBAL - max : LWORD := 65535; - min : LWORD := 0; - END_VAR - - PROGRAM main - VAR - ret : myType; - END_VAR - ret.zero := LWORD_TO_WORD(LWORD#0); - ret.positive := LWORD_TO_WORD(LWORD#100); - ret.negative := LWORD_TO_WORD(-1); - ret.max_overflow := LWORD_TO_WORD(max+1); - ret.min_overflow := LWORD_TO_WORD(min-1); + TYPE myType : STRUCT + zero : WORD; positive : WORD; negative : WORD; + max_overflow: WORD; min_overflow: WORD; + END_STRUCT END_TYPE + + VAR_GLOBAL + max : LWORD := 65535; + min : LWORD := 0; + END_VAR + + PROGRAM main + VAR + ret : myType; + END_VAR + ret.zero := LWORD_TO_WORD(LWORD#0); + ret.positive := LWORD_TO_WORD(LWORD#100); + ret.negative := LWORD_TO_WORD(-1); + ret.max_overflow := LWORD_TO_WORD(max+1); + ret.min_overflow := LWORD_TO_WORD(min-1); END_PROGRAM "; let sources = add_std!(src, "bit_conversion.st"); @@ -119,25 +119,25 @@ fn lword_to_word() { #[test] fn lword_to_byte() { let src = r" - TYPE myType : STRUCT - zero : BYTE; positive : BYTE; negative : BYTE; - max_overflow: BYTE; min_overflow: BYTE; - END_STRUCT END_TYPE - - VAR_GLOBAL - max : LWORD := 255; - min : LWORD := 0; - END_VAR - - PROGRAM main - VAR - ret : myType; - END_VAR - ret.zero := LWORD_TO_BYTE(LWORD#0); - ret.positive := LWORD_TO_BYTE(LWORD#100); - ret.negative := LWORD_TO_BYTE(-1); - ret.max_overflow := LWORD_TO_BYTE(max+1); - ret.min_overflow := LWORD_TO_BYTE(min-1); + TYPE myType : STRUCT + zero : BYTE; positive : BYTE; negative : BYTE; + max_overflow: BYTE; min_overflow: BYTE; + END_STRUCT END_TYPE + + VAR_GLOBAL + max : LWORD := 255; + min : LWORD := 0; + END_VAR + + PROGRAM main + VAR + ret : myType; + END_VAR + ret.zero := LWORD_TO_BYTE(LWORD#0); + ret.positive := LWORD_TO_BYTE(LWORD#100); + ret.negative := LWORD_TO_BYTE(-1); + ret.max_overflow := LWORD_TO_BYTE(max+1); + ret.min_overflow := LWORD_TO_BYTE(min-1); END_PROGRAM "; let sources = add_std!(src, "bit_conversion.st"); @@ -153,19 +153,19 @@ fn lword_to_byte() { #[test] fn lword_to_bool() { let src = r" - TYPE myType : STRUCT - true_ : BOOL; false_ : BOOL; - max_overflow : BOOL; min_overflow : BOOL; - END_STRUCT END_TYPE - - PROGRAM main - VAR - ret : myType; - END_VAR - ret.true_ := LWORD_TO_BOOL(LWORD#1); - ret.false_ := LWORD_TO_BOOL(LWORD#0); - ret.max_overflow := LWORD_TO_BOOL(LWORD#2); - ret.min_overflow := LWORD_TO_BOOL(-1); + TYPE myType : STRUCT + true_ : BOOL; false_ : BOOL; + max_overflow : BOOL; min_overflow : BOOL; + END_STRUCT END_TYPE + + PROGRAM main + VAR + ret : myType; + END_VAR + ret.true_ := LWORD_TO_BOOL(LWORD#1); + ret.false_ := LWORD_TO_BOOL(LWORD#0); + ret.max_overflow := LWORD_TO_BOOL(LWORD#2); + ret.min_overflow := LWORD_TO_BOOL(-1); END_PROGRAM "; let sources = add_std!(src, "bit_conversion.st"); @@ -180,17 +180,17 @@ fn lword_to_bool() { #[test] fn dword_to_lword() { let src = r" - TYPE myType : STRUCT - zero : LWORD; positive : LWORD; negative : LWORD; - END_STRUCT END_TYPE - - PROGRAM main - VAR - ret : myType; - END_VAR - ret.zero := DWORD_TO_LWORD(DWORD#0); - ret.positive := DWORD_TO_LWORD(DWORD#100); - ret.negative := DWORD_TO_LWORD(-1); + TYPE myType : STRUCT + zero : LWORD; positive : LWORD; negative : LWORD; + END_STRUCT END_TYPE + + PROGRAM main + VAR + ret : myType; + END_VAR + ret.zero := DWORD_TO_LWORD(DWORD#0); + ret.positive := DWORD_TO_LWORD(DWORD#100); + ret.negative := DWORD_TO_LWORD(-1); END_PROGRAM "; let sources = add_std!(src, "bit_conversion.st"); @@ -204,25 +204,25 @@ fn dword_to_lword() { #[test] fn dword_to_word() { let src = r" - TYPE myType : STRUCT - zero : WORD; positive : WORD; negative : WORD; - max_overflow: WORD; min_overflow: WORD; - END_STRUCT END_TYPE - - VAR_GLOBAL - max : DWORD := 65535; - min : DWORD := 0; - END_VAR - - PROGRAM main - VAR - ret : myType; - END_VAR - ret.zero := DWORD_TO_WORD(DWORD#0); - ret.positive := DWORD_TO_WORD(DWORD#100); - ret.negative := DWORD_TO_WORD(-1); - ret.max_overflow := DWORD_TO_WORD(max+1); - ret.min_overflow := DWORD_TO_WORD(min-1); + TYPE myType : STRUCT + zero : WORD; positive : WORD; negative : WORD; + max_overflow: WORD; min_overflow: WORD; + END_STRUCT END_TYPE + + VAR_GLOBAL + max : DWORD := 65535; + min : DWORD := 0; + END_VAR + + PROGRAM main + VAR + ret : myType; + END_VAR + ret.zero := DWORD_TO_WORD(DWORD#0); + ret.positive := DWORD_TO_WORD(DWORD#100); + ret.negative := DWORD_TO_WORD(-1); + ret.max_overflow := DWORD_TO_WORD(max+1); + ret.min_overflow := DWORD_TO_WORD(min-1); END_PROGRAM "; let sources = add_std!(src, "bit_conversion.st"); @@ -238,25 +238,25 @@ fn dword_to_word() { #[test] fn dword_to_byte() { let src = r" - TYPE myType : STRUCT - zero : BYTE; positive : BYTE; negative : BYTE; - max_overflow: BYTE; min_overflow: BYTE; - END_STRUCT END_TYPE - - VAR_GLOBAL - max : DWORD := 255; - min : DWORD := 0; - END_VAR - - PROGRAM main - VAR - ret : myType; - END_VAR - ret.zero := DWORD_TO_BYTE(DWORD#0); - ret.positive := DWORD_TO_BYTE(DWORD#100); - ret.negative := DWORD_TO_BYTE(-1); - ret.max_overflow := DWORD_TO_BYTE(max+1); - ret.min_overflow := DWORD_TO_BYTE(min-1); + TYPE myType : STRUCT + zero : BYTE; positive : BYTE; negative : BYTE; + max_overflow: BYTE; min_overflow: BYTE; + END_STRUCT END_TYPE + + VAR_GLOBAL + max : DWORD := 255; + min : DWORD := 0; + END_VAR + + PROGRAM main + VAR + ret : myType; + END_VAR + ret.zero := DWORD_TO_BYTE(DWORD#0); + ret.positive := DWORD_TO_BYTE(DWORD#100); + ret.negative := DWORD_TO_BYTE(-1); + ret.max_overflow := DWORD_TO_BYTE(max+1); + ret.min_overflow := DWORD_TO_BYTE(min-1); END_PROGRAM "; let sources = add_std!(src, "bit_conversion.st"); @@ -272,19 +272,19 @@ fn dword_to_byte() { #[test] fn dword_to_bool() { let src = r" - TYPE myType : STRUCT - true_ : BOOL; false_ : BOOL; - max_overflow : BOOL; min_overflow : BOOL; - END_STRUCT END_TYPE - - PROGRAM main - VAR - ret : myType; - END_VAR - ret.true_ := DWORD_TO_BOOL(DWORD#1); - ret.false_ := DWORD_TO_BOOL(DWORD#0); - ret.max_overflow := DWORD_TO_BOOL(DWORD#2); - ret.min_overflow := DWORD_TO_BOOL(-1); + TYPE myType : STRUCT + true_ : BOOL; false_ : BOOL; + max_overflow : BOOL; min_overflow : BOOL; + END_STRUCT END_TYPE + + PROGRAM main + VAR + ret : myType; + END_VAR + ret.true_ := DWORD_TO_BOOL(DWORD#1); + ret.false_ := DWORD_TO_BOOL(DWORD#0); + ret.max_overflow := DWORD_TO_BOOL(DWORD#2); + ret.min_overflow := DWORD_TO_BOOL(-1); END_PROGRAM "; let sources = add_std!(src, "bit_conversion.st"); @@ -299,17 +299,17 @@ fn dword_to_bool() { #[test] fn word_to_lword() { let src = r" - TYPE myType : STRUCT - zero : LWORD; positive : LWORD; negative : LWORD; - END_STRUCT END_TYPE - - PROGRAM main - VAR - ret : myType; - END_VAR - ret.zero := WORD_TO_LWORD(WORD#0); - ret.positive := WORD_TO_LWORD(WORD#100); - ret.negative := WORD_TO_LWORD(-1); + TYPE myType : STRUCT + zero : LWORD; positive : LWORD; negative : LWORD; + END_STRUCT END_TYPE + + PROGRAM main + VAR + ret : myType; + END_VAR + ret.zero := WORD_TO_LWORD(WORD#0); + ret.positive := WORD_TO_LWORD(WORD#100); + ret.negative := WORD_TO_LWORD(-1); END_PROGRAM "; let sources = add_std!(src, "bit_conversion.st"); @@ -323,17 +323,17 @@ fn word_to_lword() { #[test] fn word_to_dword() { let src = r" - TYPE myType : STRUCT - zero : DWORD; positive : DWORD; negative : DWORD; - END_STRUCT END_TYPE - - PROGRAM main - VAR - ret : myType; - END_VAR - ret.zero := WORD_TO_DWORD(WORD#0); - ret.positive := WORD_TO_DWORD(WORD#100); - ret.negative := WORD_TO_DWORD(-1); + TYPE myType : STRUCT + zero : DWORD; positive : DWORD; negative : DWORD; + END_STRUCT END_TYPE + + PROGRAM main + VAR + ret : myType; + END_VAR + ret.zero := WORD_TO_DWORD(WORD#0); + ret.positive := WORD_TO_DWORD(WORD#100); + ret.negative := WORD_TO_DWORD(-1); END_PROGRAM "; let sources = add_std!(src, "bit_conversion.st"); @@ -347,25 +347,25 @@ fn word_to_dword() { #[test] fn word_to_byte() { let src = r" - TYPE myType : STRUCT - zero : BYTE; positive : BYTE; negative : BYTE; - max_overflow: BYTE; min_overflow: BYTE; - END_STRUCT END_TYPE - - VAR_GLOBAL - max : WORD := 255; - min : WORD := 0; - END_VAR - - PROGRAM main - VAR - ret : myType; - END_VAR - ret.zero := WORD_TO_BYTE(WORD#0); - ret.positive := WORD_TO_BYTE(WORD#100); - ret.negative := WORD_TO_BYTE(-1); - ret.max_overflow := WORD_TO_BYTE(max+1); - ret.min_overflow := WORD_TO_BYTE(min-1); + TYPE myType : STRUCT + zero : BYTE; positive : BYTE; negative : BYTE; + max_overflow: BYTE; min_overflow: BYTE; + END_STRUCT END_TYPE + + VAR_GLOBAL + max : WORD := 255; + min : WORD := 0; + END_VAR + + PROGRAM main + VAR + ret : myType; + END_VAR + ret.zero := WORD_TO_BYTE(WORD#0); + ret.positive := WORD_TO_BYTE(WORD#100); + ret.negative := WORD_TO_BYTE(-1); + ret.max_overflow := WORD_TO_BYTE(max+1); + ret.min_overflow := WORD_TO_BYTE(min-1); END_PROGRAM "; let sources = add_std!(src, "bit_conversion.st"); @@ -381,19 +381,19 @@ fn word_to_byte() { #[test] fn word_to_bool() { let src = r" - TYPE myType : STRUCT - true_ : BOOL; false_ : BOOL; - max_overflow : BOOL; min_overflow : BOOL; - END_STRUCT END_TYPE - - PROGRAM main - VAR - ret : myType; - END_VAR - ret.true_ := WORD_TO_BOOL(WORD#1); - ret.false_ := WORD_TO_BOOL(WORD#0); - ret.max_overflow := WORD_TO_BOOL(WORD#2); - ret.min_overflow := WORD_TO_BOOL(-1); + TYPE myType : STRUCT + true_ : BOOL; false_ : BOOL; + max_overflow : BOOL; min_overflow : BOOL; + END_STRUCT END_TYPE + + PROGRAM main + VAR + ret : myType; + END_VAR + ret.true_ := WORD_TO_BOOL(WORD#1); + ret.false_ := WORD_TO_BOOL(WORD#0); + ret.max_overflow := WORD_TO_BOOL(WORD#2); + ret.min_overflow := WORD_TO_BOOL(-1); END_PROGRAM "; let sources = add_std!(src, "bit_conversion.st"); @@ -408,17 +408,17 @@ fn word_to_bool() { #[test] fn byte_to_lword() { let src = r" - TYPE myType : STRUCT - zero : LWORD; positive : LWORD; negative : LWORD; - END_STRUCT END_TYPE - - PROGRAM main - VAR - ret : myType; - END_VAR - ret.zero := BYTE_TO_LWORD(BYTE#0); - ret.positive := BYTE_TO_LWORD(BYTE#100); - ret.negative := BYTE_TO_LWORD(-1); + TYPE myType : STRUCT + zero : LWORD; positive : LWORD; negative : LWORD; + END_STRUCT END_TYPE + + PROGRAM main + VAR + ret : myType; + END_VAR + ret.zero := BYTE_TO_LWORD(BYTE#0); + ret.positive := BYTE_TO_LWORD(BYTE#100); + ret.negative := BYTE_TO_LWORD(-1); END_PROGRAM "; let sources = add_std!(src, "bit_conversion.st"); @@ -432,17 +432,17 @@ fn byte_to_lword() { #[test] fn byte_to_dword() { let src = r" - TYPE myType : STRUCT - zero : DWORD; positive : DWORD; negative : DWORD; - END_STRUCT END_TYPE - - PROGRAM main - VAR - ret : myType; - END_VAR - ret.zero := BYTE_TO_DWORD(BYTE#0); - ret.positive := BYTE_TO_DWORD(BYTE#100); - ret.negative := BYTE_TO_DWORD(-1); + TYPE myType : STRUCT + zero : DWORD; positive : DWORD; negative : DWORD; + END_STRUCT END_TYPE + + PROGRAM main + VAR + ret : myType; + END_VAR + ret.zero := BYTE_TO_DWORD(BYTE#0); + ret.positive := BYTE_TO_DWORD(BYTE#100); + ret.negative := BYTE_TO_DWORD(-1); END_PROGRAM "; let sources = add_std!(src, "bit_conversion.st"); @@ -456,17 +456,17 @@ fn byte_to_dword() { #[test] fn byte_to_word() { let src = r" - TYPE myType : STRUCT - zero : WORD; positive : WORD; negative : WORD; - END_STRUCT END_TYPE - - PROGRAM main - VAR - ret : myType; - END_VAR - ret.zero := BYTE_TO_WORD(BYTE#0); - ret.positive := BYTE_TO_WORD(BYTE#100); - ret.negative := BYTE_TO_WORD(-1); + TYPE myType : STRUCT + zero : WORD; positive : WORD; negative : WORD; + END_STRUCT END_TYPE + + PROGRAM main + VAR + ret : myType; + END_VAR + ret.zero := BYTE_TO_WORD(BYTE#0); + ret.positive := BYTE_TO_WORD(BYTE#100); + ret.negative := BYTE_TO_WORD(-1); END_PROGRAM "; let sources = add_std!(src, "bit_conversion.st"); @@ -480,19 +480,19 @@ fn byte_to_word() { #[test] fn byte_to_bool() { let src = r" - TYPE myType : STRUCT - true_ : BOOL; false_ : BOOL; - max_overflow : BOOL; min_overflow : BOOL; - END_STRUCT END_TYPE - - PROGRAM main - VAR - ret : myType; - END_VAR - ret.true_ := BYTE_TO_BOOL(BYTE#1); - ret.false_ := BYTE_TO_BOOL(BYTE#0); - ret.max_overflow := BYTE_TO_BOOL(BYTE#2); - ret.min_overflow := BYTE_TO_BOOL(-1); + TYPE myType : STRUCT + true_ : BOOL; false_ : BOOL; + max_overflow : BOOL; min_overflow : BOOL; + END_STRUCT END_TYPE + + PROGRAM main + VAR + ret : myType; + END_VAR + ret.true_ := BYTE_TO_BOOL(BYTE#1); + ret.false_ := BYTE_TO_BOOL(BYTE#0); + ret.max_overflow := BYTE_TO_BOOL(BYTE#2); + ret.min_overflow := BYTE_TO_BOOL(-1); END_PROGRAM "; let sources = add_std!(src, "bit_conversion.st"); @@ -514,15 +514,15 @@ fn byte_to_char() { } let src = r" - PROGRAM main - VAR - a : CHAR; - b : CHAR; - c : CHAR; - END_VAR - a := BYTE_TO_CHAR(BYTE#97); - b := BYTE_TO_CHAR(BYTE#98); - c := BYTE_TO_CHAR(BYTE#99); + PROGRAM main + VAR + a : CHAR; + b : CHAR; + c : CHAR; + END_VAR + a := BYTE_TO_CHAR(BYTE#97); + b := BYTE_TO_CHAR(BYTE#98); + c := BYTE_TO_CHAR(BYTE#99); END_PROGRAM "; let sources = add_std!(src, "bit_conversion.st"); @@ -536,19 +536,19 @@ fn byte_to_char() { #[test] fn bool_to_lword() { let src = r" - TYPE myType : STRUCT - zero : LWORD; positive : LWORD; negative : LWORD; - max_overflow : LWORD; - END_STRUCT END_TYPE - - PROGRAM main - VAR - ret : myType; - END_VAR - ret.zero := BOOL_TO_LWORD(BOOL#0); - ret.positive := BOOL_TO_LWORD(BOOL#1); - ret.negative := BOOL_TO_LWORD(-1); - ret.max_overflow := BOOL_TO_LWORD(10); + TYPE myType : STRUCT + zero : LWORD; positive : LWORD; negative : LWORD; + max_overflow : LWORD; + END_STRUCT END_TYPE + + PROGRAM main + VAR + ret : myType; + END_VAR + ret.zero := BOOL_TO_LWORD(BOOL#0); + ret.positive := BOOL_TO_LWORD(BOOL#1); + ret.negative := BOOL_TO_LWORD(-1); + ret.max_overflow := BOOL_TO_LWORD(10); END_PROGRAM "; let sources = add_std!(src, "bit_conversion.st"); @@ -563,19 +563,19 @@ fn bool_to_lword() { #[test] fn bool_to_dword() { let src = r" - TYPE myType : STRUCT - zero : DWORD; positive : DWORD; negative : DWORD; - max_overflow : DWORD; - END_STRUCT END_TYPE - - PROGRAM main - VAR - ret : myType; - END_VAR - ret.zero := BOOL_TO_DWORD(BOOL#0); - ret.positive := BOOL_TO_DWORD(BOOL#1); - ret.negative := BOOL_TO_DWORD(-1); - ret.max_overflow := BOOL_TO_DWORD(10); + TYPE myType : STRUCT + zero : DWORD; positive : DWORD; negative : DWORD; + max_overflow : DWORD; + END_STRUCT END_TYPE + + PROGRAM main + VAR + ret : myType; + END_VAR + ret.zero := BOOL_TO_DWORD(BOOL#0); + ret.positive := BOOL_TO_DWORD(BOOL#1); + ret.negative := BOOL_TO_DWORD(-1); + ret.max_overflow := BOOL_TO_DWORD(10); END_PROGRAM "; let sources = add_std!(src, "bit_conversion.st"); @@ -590,19 +590,19 @@ fn bool_to_dword() { #[test] fn bool_to_word() { let src = r" - TYPE myType : STRUCT - zero : WORD; positive : WORD; negative : WORD; - max_overflow : WORD; - END_STRUCT END_TYPE - - PROGRAM main - VAR - ret : myType; - END_VAR - ret.zero := BOOL_TO_WORD(BOOL#0); - ret.positive := BOOL_TO_WORD(BOOL#1); - ret.negative := BOOL_TO_WORD(-1); - ret.max_overflow := BOOL_TO_WORD(10); + TYPE myType : STRUCT + zero : WORD; positive : WORD; negative : WORD; + max_overflow : WORD; + END_STRUCT END_TYPE + + PROGRAM main + VAR + ret : myType; + END_VAR + ret.zero := BOOL_TO_WORD(BOOL#0); + ret.positive := BOOL_TO_WORD(BOOL#1); + ret.negative := BOOL_TO_WORD(-1); + ret.max_overflow := BOOL_TO_WORD(10); END_PROGRAM "; let sources = add_std!(src, "bit_conversion.st"); @@ -617,19 +617,19 @@ fn bool_to_word() { #[test] fn bool_to_byte() { let src = r" - TYPE myType : STRUCT - zero : BYTE; positive : BYTE; negative : BYTE; - max_overflow : BYTE; - END_STRUCT END_TYPE - - PROGRAM main - VAR - ret : myType; - END_VAR - ret.zero := BOOL_TO_BYTE(BOOL#0); - ret.positive := BOOL_TO_BYTE(BOOL#1); - ret.negative := BOOL_TO_BYTE(-1); - ret.max_overflow := BOOL_TO_BYTE(10); + TYPE myType : STRUCT + zero : BYTE; positive : BYTE; negative : BYTE; + max_overflow : BYTE; + END_STRUCT END_TYPE + + PROGRAM main + VAR + ret : myType; + END_VAR + ret.zero := BOOL_TO_BYTE(BOOL#0); + ret.positive := BOOL_TO_BYTE(BOOL#1); + ret.negative := BOOL_TO_BYTE(-1); + ret.max_overflow := BOOL_TO_BYTE(10); END_PROGRAM "; let sources = add_std!(src, "bit_conversion.st"); @@ -651,15 +651,15 @@ fn char_to_byte() { } let src = r" - PROGRAM main - VAR - a : BYTE; - b : BYTE; - c : BYTE; - END_VAR - a := CHAR_TO_BYTE(CHAR#'a'); - b := CHAR_TO_BYTE(CHAR#'b'); - c := CHAR_TO_BYTE(CHAR#'c'); + PROGRAM main + VAR + a : BYTE; + b : BYTE; + c : BYTE; + END_VAR + a := CHAR_TO_BYTE(CHAR#'a'); + b := CHAR_TO_BYTE(CHAR#'b'); + c := CHAR_TO_BYTE(CHAR#'c'); END_PROGRAM "; let sources = add_std!(src, "bit_conversion.st"); @@ -680,15 +680,15 @@ fn char_to_word() { } let src = r" - PROGRAM main - VAR - a : WORD; - b : WORD; - c : WORD; - END_VAR - a := CHAR_TO_WORD(CHAR#'a'); - b := CHAR_TO_WORD(CHAR#'b'); - c := CHAR_TO_WORD(CHAR#'c'); + PROGRAM main + VAR + a : WORD; + b : WORD; + c : WORD; + END_VAR + a := CHAR_TO_WORD(CHAR#'a'); + b := CHAR_TO_WORD(CHAR#'b'); + c := CHAR_TO_WORD(CHAR#'c'); END_PROGRAM "; let sources = add_std!(src, "bit_conversion.st"); @@ -709,15 +709,15 @@ fn char_to_dword() { } let src = r" - PROGRAM main - VAR - a : DWORD; - b : DWORD; - c : DWORD; - END_VAR - a := CHAR_TO_DWORD(CHAR#'a'); - b := CHAR_TO_DWORD(CHAR#'b'); - c := CHAR_TO_DWORD(CHAR#'c'); + PROGRAM main + VAR + a : DWORD; + b : DWORD; + c : DWORD; + END_VAR + a := CHAR_TO_DWORD(CHAR#'a'); + b := CHAR_TO_DWORD(CHAR#'b'); + c := CHAR_TO_DWORD(CHAR#'c'); END_PROGRAM "; let sources = add_std!(src, "bit_conversion.st"); @@ -738,15 +738,15 @@ fn char_to_lword() { } let src = r" - PROGRAM main - VAR - a : LWORD; - b : LWORD; - c : LWORD; - END_VAR - a := CHAR_TO_LWORD(CHAR#'a'); - b := CHAR_TO_LWORD(CHAR#'b'); - c := CHAR_TO_LWORD(CHAR#'c'); + PROGRAM main + VAR + a : LWORD; + b : LWORD; + c : LWORD; + END_VAR + a := CHAR_TO_LWORD(CHAR#'a'); + b := CHAR_TO_LWORD(CHAR#'b'); + c := CHAR_TO_LWORD(CHAR#'c'); END_PROGRAM "; let sources = add_std!(src, "bit_conversion.st"); @@ -767,15 +767,15 @@ fn wchar_to_word() { } let src = r" - PROGRAM main - VAR - a : WORD; - b : WORD; - c : WORD; - END_VAR - a := WCHAR_TO_WORD(WCHAR#'a'); - b := WCHAR_TO_WORD(WCHAR#'b'); - c := WCHAR_TO_WORD(WCHAR#'c'); + PROGRAM main + VAR + a : WORD; + b : WORD; + c : WORD; + END_VAR + a := WCHAR_TO_WORD(WCHAR#'a'); + b := WCHAR_TO_WORD(WCHAR#'b'); + c := WCHAR_TO_WORD(WCHAR#'c'); END_PROGRAM "; let sources = add_std!(src, "bit_conversion.st"); @@ -796,15 +796,15 @@ fn wchar_to_dword() { } let src = r" - PROGRAM main - VAR - a : DWORD; - b : DWORD; - c : DWORD; - END_VAR - a := WCHAR_TO_DWORD(WCHAR#'a'); - b := WCHAR_TO_DWORD(WCHAR#'b'); - c := WCHAR_TO_DWORD(WCHAR#'c'); + PROGRAM main + VAR + a : DWORD; + b : DWORD; + c : DWORD; + END_VAR + a := WCHAR_TO_DWORD(WCHAR#'a'); + b := WCHAR_TO_DWORD(WCHAR#'b'); + c := WCHAR_TO_DWORD(WCHAR#'c'); END_PROGRAM "; let sources = add_std!(src, "bit_conversion.st"); @@ -825,15 +825,15 @@ fn wchar_to_lword() { } let src = r" - PROGRAM main - VAR - a : LWORD; - b : LWORD; - c : LWORD; - END_VAR - a := WCHAR_TO_LWORD(WCHAR#'a'); - b := WCHAR_TO_LWORD(WCHAR#'b'); - c := WCHAR_TO_LWORD(WCHAR#'c'); + PROGRAM main + VAR + a : LWORD; + b : LWORD; + c : LWORD; + END_VAR + a := WCHAR_TO_LWORD(WCHAR#'a'); + b := WCHAR_TO_LWORD(WCHAR#'b'); + c := WCHAR_TO_LWORD(WCHAR#'c'); END_PROGRAM "; let sources = add_std!(src, "bit_conversion.st"); diff --git a/libs/stdlib/tests/bit_num_conversion_tests.rs b/libs/stdlib/tests/bit_num_conversion_tests.rs index 64814e5d2c..b67fac7512 100644 --- a/libs/stdlib/tests/bit_num_conversion_tests.rs +++ b/libs/stdlib/tests/bit_num_conversion_tests.rs @@ -70,17 +70,17 @@ struct U8Type { #[test] fn lword_to_lreal_conversion() { let src = r" - TYPE myType : STRUCT - zero : LREAL; max : LREAL; - END_STRUCT END_TYPE + TYPE myType : STRUCT + zero : LREAL; max : LREAL; + END_STRUCT END_TYPE - PROGRAM main - VAR - ret : myType; - END_VAR - ret.zero := LWORD_TO_LREAL(LWORD#0); - // bit transfer for conversion 4611686018427387904 should be the first bit from the exponent resulting in decimal 2 - ret.max := LWORD_TO_LREAL(LWORD#4611686018427387904); + PROGRAM main + VAR + ret : myType; + END_VAR + ret.zero := LWORD_TO_LREAL(LWORD#0); + // bit transfer for conversion 4611686018427387904 should be the first bit from the exponent resulting in decimal 2 + ret.max := LWORD_TO_LREAL(LWORD#4611686018427387904); END_PROGRAM "; let sources = add_std!(src, "bit_num_conversion.st"); @@ -93,16 +93,16 @@ fn lword_to_lreal_conversion() { #[test] fn lword_to_lint_conversion() { let src = r" - TYPE myType : STRUCT - zero : LINT; max : LINT; - END_STRUCT END_TYPE + TYPE myType : STRUCT + zero : LINT; max : LINT; + END_STRUCT END_TYPE - PROGRAM main - VAR - ret : myType; - END_VAR - ret.zero := LWORD_TO_LINT(LWORD#0); - ret.max := LWORD_TO_LINT(LWORD#9223372036854775807); + PROGRAM main + VAR + ret : myType; + END_VAR + ret.zero := LWORD_TO_LINT(LWORD#0); + ret.max := LWORD_TO_LINT(LWORD#9223372036854775807); END_PROGRAM "; let sources = add_std!(src, "bit_num_conversion.st"); @@ -115,16 +115,16 @@ fn lword_to_lint_conversion() { #[test] fn lword_to_dint_conversion() { let src = r" - TYPE myType : STRUCT - zero : DINT; max : DINT; - END_STRUCT END_TYPE + TYPE myType : STRUCT + zero : DINT; max : DINT; + END_STRUCT END_TYPE - PROGRAM main - VAR - ret : myType; - END_VAR - ret.zero := LWORD_TO_DINT(LWORD#0); - ret.max := LWORD_TO_DINT(LWORD#2147483647); + PROGRAM main + VAR + ret : myType; + END_VAR + ret.zero := LWORD_TO_DINT(LWORD#0); + ret.max := LWORD_TO_DINT(LWORD#2147483647); END_PROGRAM "; let sources = add_std!(src, "bit_num_conversion.st"); @@ -137,16 +137,16 @@ fn lword_to_dint_conversion() { #[test] fn lword_to_int_conversion() { let src = r" - TYPE myType : STRUCT - zero : INT; max : INT; - END_STRUCT END_TYPE + TYPE myType : STRUCT + zero : INT; max : INT; + END_STRUCT END_TYPE - PROGRAM main - VAR - ret : myType; - END_VAR - ret.zero := LWORD_TO_INT(LWORD#0); - ret.max := LWORD_TO_INT(LWORD#32767); + PROGRAM main + VAR + ret : myType; + END_VAR + ret.zero := LWORD_TO_INT(LWORD#0); + ret.max := LWORD_TO_INT(LWORD#32767); END_PROGRAM "; let sources = add_std!(src, "bit_num_conversion.st"); @@ -159,16 +159,16 @@ fn lword_to_int_conversion() { #[test] fn lword_to_sint_conversion() { let src = r" - TYPE myType : STRUCT - zero : SINT; max : SINT; - END_STRUCT END_TYPE + TYPE myType : STRUCT + zero : SINT; max : SINT; + END_STRUCT END_TYPE - PROGRAM main - VAR - ret : myType; - END_VAR - ret.zero := LWORD_TO_SINT(LWORD#0); - ret.max := LWORD_TO_SINT(LWORD#127); + PROGRAM main + VAR + ret : myType; + END_VAR + ret.zero := LWORD_TO_SINT(LWORD#0); + ret.max := LWORD_TO_SINT(LWORD#127); END_PROGRAM "; let sources = add_std!(src, "bit_num_conversion.st"); @@ -181,16 +181,16 @@ fn lword_to_sint_conversion() { #[test] fn lword_to_ulint_conversion() { let src = r" - TYPE myType : STRUCT - zero : ULINT; max : ULINT; - END_STRUCT END_TYPE + TYPE myType : STRUCT + zero : ULINT; max : ULINT; + END_STRUCT END_TYPE - PROGRAM main - VAR - ret : myType; - END_VAR - ret.zero := LWORD_TO_ULINT(LWORD#0); - ret.max := LWORD_TO_ULINT(LWORD#18446744073709551615); + PROGRAM main + VAR + ret : myType; + END_VAR + ret.zero := LWORD_TO_ULINT(LWORD#0); + ret.max := LWORD_TO_ULINT(LWORD#18446744073709551615); END_PROGRAM "; let sources = add_std!(src, "bit_num_conversion.st"); @@ -203,16 +203,16 @@ fn lword_to_ulint_conversion() { #[test] fn lword_to_udint_conversion() { let src = r" - TYPE myType : STRUCT - zero : UDINT; max : UDINT; - END_STRUCT END_TYPE + TYPE myType : STRUCT + zero : UDINT; max : UDINT; + END_STRUCT END_TYPE - PROGRAM main - VAR - ret : myType; - END_VAR - ret.zero := LWORD_TO_UDINT(LWORD#0); - ret.max := LWORD_TO_UDINT(LWORD#4294967295); + PROGRAM main + VAR + ret : myType; + END_VAR + ret.zero := LWORD_TO_UDINT(LWORD#0); + ret.max := LWORD_TO_UDINT(LWORD#4294967295); END_PROGRAM "; let sources = add_std!(src, "bit_num_conversion.st"); @@ -225,16 +225,16 @@ fn lword_to_udint_conversion() { #[test] fn lword_to_uint_conversion() { let src = r" - TYPE myType : STRUCT - zero : UINT; max : UINT; - END_STRUCT END_TYPE + TYPE myType : STRUCT + zero : UINT; max : UINT; + END_STRUCT END_TYPE - PROGRAM main - VAR - ret : myType; - END_VAR - ret.zero := LWORD_TO_UINT(LWORD#0); - ret.max := LWORD_TO_UINT(LWORD#65535); + PROGRAM main + VAR + ret : myType; + END_VAR + ret.zero := LWORD_TO_UINT(LWORD#0); + ret.max := LWORD_TO_UINT(LWORD#65535); END_PROGRAM "; let sources = add_std!(src, "bit_num_conversion.st"); @@ -247,16 +247,16 @@ fn lword_to_uint_conversion() { #[test] fn lword_to_usint_conversion() { let src = r" - TYPE myType : STRUCT - zero : USINT; max : USINT; - END_STRUCT END_TYPE + TYPE myType : STRUCT + zero : USINT; max : USINT; + END_STRUCT END_TYPE - PROGRAM main - VAR - ret : myType; - END_VAR - ret.zero := LWORD_TO_USINT(LWORD#0); - ret.max := LWORD_TO_USINT(LWORD#255); + PROGRAM main + VAR + ret : myType; + END_VAR + ret.zero := LWORD_TO_USINT(LWORD#0); + ret.max := LWORD_TO_USINT(LWORD#255); END_PROGRAM "; let sources = add_std!(src, "bit_num_conversion.st"); @@ -269,17 +269,17 @@ fn lword_to_usint_conversion() { #[test] fn dword_to_real_conversion() { let src = r" - TYPE myType : STRUCT - zero : REAL; max : REAL; - END_STRUCT END_TYPE + TYPE myType : STRUCT + zero : REAL; max : REAL; + END_STRUCT END_TYPE - PROGRAM main - VAR - ret : myType; - END_VAR - ret.zero := DWORD_TO_REAL(DWORD#0); - // bit transfer for conversion 1073741824 should be the first bit from the exponent resulting in decimal 2 - ret.max := DWORD_TO_REAL(DWORD#1073741824); + PROGRAM main + VAR + ret : myType; + END_VAR + ret.zero := DWORD_TO_REAL(DWORD#0); + // bit transfer for conversion 1073741824 should be the first bit from the exponent resulting in decimal 2 + ret.max := DWORD_TO_REAL(DWORD#1073741824); END_PROGRAM "; let sources = add_std!(src, "bit_num_conversion.st"); @@ -292,16 +292,16 @@ fn dword_to_real_conversion() { #[test] fn dword_to_lint_conversion() { let src = r" - TYPE myType : STRUCT - zero : LINT; max : LINT; - END_STRUCT END_TYPE + TYPE myType : STRUCT + zero : LINT; max : LINT; + END_STRUCT END_TYPE - PROGRAM main - VAR - ret : myType; - END_VAR - ret.zero := DWORD_TO_LINT(DWORD#0); - ret.max := DWORD_TO_LINT(DWORD#4294967295); + PROGRAM main + VAR + ret : myType; + END_VAR + ret.zero := DWORD_TO_LINT(DWORD#0); + ret.max := DWORD_TO_LINT(DWORD#4294967295); END_PROGRAM "; let sources = add_std!(src, "bit_num_conversion.st"); @@ -314,18 +314,18 @@ fn dword_to_lint_conversion() { #[test] fn dword_to_dint_conversion() { let src = r" - TYPE myType : STRUCT - zero : DINT; max : DINT; max_overflow : DINT; negative : DINT; - END_STRUCT END_TYPE + TYPE myType : STRUCT + zero : DINT; max : DINT; max_overflow : DINT; negative : DINT; + END_STRUCT END_TYPE - PROGRAM main - VAR - ret : myType; - END_VAR - ret.zero := DWORD_TO_DINT(DWORD#0); - ret.max := DWORD_TO_DINT(DWORD#2147483647); - ret.max_overflow := DWORD_TO_DINT(DWORD#4294967295); - ret.negative := DWORD_TO_DINT(-1); + PROGRAM main + VAR + ret : myType; + END_VAR + ret.zero := DWORD_TO_DINT(DWORD#0); + ret.max := DWORD_TO_DINT(DWORD#2147483647); + ret.max_overflow := DWORD_TO_DINT(DWORD#4294967295); + ret.negative := DWORD_TO_DINT(-1); END_PROGRAM "; let sources = add_std!(src, "bit_num_conversion.st"); @@ -340,16 +340,16 @@ fn dword_to_dint_conversion() { #[test] fn dword_to_int_conversion() { let src = r" - TYPE myType : STRUCT - zero : INT; max : INT; - END_STRUCT END_TYPE + TYPE myType : STRUCT + zero : INT; max : INT; + END_STRUCT END_TYPE - PROGRAM main - VAR - ret : myType; - END_VAR - ret.zero := DWORD_TO_INT(DWORD#0); - ret.max := DWORD_TO_INT(DWORD#32767); + PROGRAM main + VAR + ret : myType; + END_VAR + ret.zero := DWORD_TO_INT(DWORD#0); + ret.max := DWORD_TO_INT(DWORD#32767); END_PROGRAM "; let sources = add_std!(src, "bit_num_conversion.st"); @@ -362,16 +362,16 @@ fn dword_to_int_conversion() { #[test] fn dword_to_sint_conversion() { let src = r" - TYPE myType : STRUCT - zero : SINT; max : SINT; - END_STRUCT END_TYPE + TYPE myType : STRUCT + zero : SINT; max : SINT; + END_STRUCT END_TYPE - PROGRAM main - VAR - ret : myType; - END_VAR - ret.zero := DWORD_TO_SINT(DWORD#0); - ret.max := DWORD_TO_SINT(DWORD#127); + PROGRAM main + VAR + ret : myType; + END_VAR + ret.zero := DWORD_TO_SINT(DWORD#0); + ret.max := DWORD_TO_SINT(DWORD#127); END_PROGRAM "; let sources = add_std!(src, "bit_num_conversion.st"); @@ -384,16 +384,16 @@ fn dword_to_sint_conversion() { #[test] fn dword_to_ulint_conversion() { let src = r" - TYPE myType : STRUCT - zero : ULINT; max : ULINT; - END_STRUCT END_TYPE + TYPE myType : STRUCT + zero : ULINT; max : ULINT; + END_STRUCT END_TYPE - PROGRAM main - VAR - ret : myType; - END_VAR - ret.zero := DWORD_TO_ULINT(DWORD#0); - ret.max := DWORD_TO_ULINT(DWORD#4294967295); + PROGRAM main + VAR + ret : myType; + END_VAR + ret.zero := DWORD_TO_ULINT(DWORD#0); + ret.max := DWORD_TO_ULINT(DWORD#4294967295); END_PROGRAM "; let sources = add_std!(src, "bit_num_conversion.st"); @@ -406,16 +406,16 @@ fn dword_to_ulint_conversion() { #[test] fn dword_to_udint_conversion() { let src = r" - TYPE myType : STRUCT - zero : UDINT; max : UDINT; - END_STRUCT END_TYPE + TYPE myType : STRUCT + zero : UDINT; max : UDINT; + END_STRUCT END_TYPE - PROGRAM main - VAR - ret : myType; - END_VAR - ret.zero := DWORD_TO_UDINT(DWORD#0); - ret.max := DWORD_TO_UDINT(DWORD#4294967295); + PROGRAM main + VAR + ret : myType; + END_VAR + ret.zero := DWORD_TO_UDINT(DWORD#0); + ret.max := DWORD_TO_UDINT(DWORD#4294967295); END_PROGRAM "; let sources = add_std!(src, "bit_num_conversion.st"); @@ -428,16 +428,16 @@ fn dword_to_udint_conversion() { #[test] fn dword_to_uint_conversion() { let src = r" - TYPE myType : STRUCT - zero : UINT; max : UINT; - END_STRUCT END_TYPE + TYPE myType : STRUCT + zero : UINT; max : UINT; + END_STRUCT END_TYPE - PROGRAM main - VAR - ret : myType; - END_VAR - ret.zero := DWORD_TO_UINT(DWORD#0); - ret.max := DWORD_TO_UINT(DWORD#65535); + PROGRAM main + VAR + ret : myType; + END_VAR + ret.zero := DWORD_TO_UINT(DWORD#0); + ret.max := DWORD_TO_UINT(DWORD#65535); END_PROGRAM "; let sources = add_std!(src, "bit_num_conversion.st"); @@ -450,16 +450,16 @@ fn dword_to_uint_conversion() { #[test] fn dword_to_usint_conversion() { let src = r" - TYPE myType : STRUCT - zero : USINT; max : USINT; - END_STRUCT END_TYPE + TYPE myType : STRUCT + zero : USINT; max : USINT; + END_STRUCT END_TYPE - PROGRAM main - VAR - ret : myType; - END_VAR - ret.zero := DWORD_TO_USINT(DWORD#0); - ret.max := DWORD_TO_USINT(DWORD#255); + PROGRAM main + VAR + ret : myType; + END_VAR + ret.zero := DWORD_TO_USINT(DWORD#0); + ret.max := DWORD_TO_USINT(DWORD#255); END_PROGRAM "; let sources = add_std!(src, "bit_num_conversion.st"); @@ -472,16 +472,16 @@ fn dword_to_usint_conversion() { #[test] fn word_to_lint_conversion() { let src = r" - TYPE myType : STRUCT - zero : LINT; max : LINT; - END_STRUCT END_TYPE + TYPE myType : STRUCT + zero : LINT; max : LINT; + END_STRUCT END_TYPE - PROGRAM main - VAR - ret : myType; - END_VAR - ret.zero := WORD_TO_LINT(WORD#0); - ret.max := WORD_TO_LINT(WORD#65535); + PROGRAM main + VAR + ret : myType; + END_VAR + ret.zero := WORD_TO_LINT(WORD#0); + ret.max := WORD_TO_LINT(WORD#65535); END_PROGRAM "; let sources = add_std!(src, "bit_num_conversion.st"); @@ -494,16 +494,16 @@ fn word_to_lint_conversion() { #[test] fn word_to_dint_conversion() { let src = r" - TYPE myType : STRUCT - zero : DINT; max : DINT; - END_STRUCT END_TYPE + TYPE myType : STRUCT + zero : DINT; max : DINT; + END_STRUCT END_TYPE - PROGRAM main - VAR - ret : myType; - END_VAR - ret.zero := WORD_TO_DINT(WORD#0); - ret.max := WORD_TO_DINT(WORD#65535); + PROGRAM main + VAR + ret : myType; + END_VAR + ret.zero := WORD_TO_DINT(WORD#0); + ret.max := WORD_TO_DINT(WORD#65535); END_PROGRAM "; let sources = add_std!(src, "bit_num_conversion.st"); @@ -516,16 +516,16 @@ fn word_to_dint_conversion() { #[test] fn word_to_int_conversion() { let src = r" - TYPE myType : STRUCT - zero : INT; max : INT; - END_STRUCT END_TYPE + TYPE myType : STRUCT + zero : INT; max : INT; + END_STRUCT END_TYPE - PROGRAM main - VAR - ret : myType; - END_VAR - ret.zero := WORD_TO_INT(WORD#0); - ret.max := WORD_TO_INT(WORD#32767); + PROGRAM main + VAR + ret : myType; + END_VAR + ret.zero := WORD_TO_INT(WORD#0); + ret.max := WORD_TO_INT(WORD#32767); END_PROGRAM "; let sources = add_std!(src, "bit_num_conversion.st"); @@ -538,16 +538,16 @@ fn word_to_int_conversion() { #[test] fn word_to_sint_conversion() { let src = r" - TYPE myType : STRUCT - zero : SINT; max : SINT; - END_STRUCT END_TYPE + TYPE myType : STRUCT + zero : SINT; max : SINT; + END_STRUCT END_TYPE - PROGRAM main - VAR - ret : myType; - END_VAR - ret.zero := WORD_TO_SINT(WORD#0); - ret.max := WORD_TO_SINT(WORD#127); + PROGRAM main + VAR + ret : myType; + END_VAR + ret.zero := WORD_TO_SINT(WORD#0); + ret.max := WORD_TO_SINT(WORD#127); END_PROGRAM "; let sources = add_std!(src, "bit_num_conversion.st"); @@ -560,16 +560,16 @@ fn word_to_sint_conversion() { #[test] fn word_to_ulint_conversion() { let src = r" - TYPE myType : STRUCT - zero : ULINT; max : ULINT; - END_STRUCT END_TYPE + TYPE myType : STRUCT + zero : ULINT; max : ULINT; + END_STRUCT END_TYPE - PROGRAM main - VAR - ret : myType; - END_VAR - ret.zero := WORD_TO_ULINT(WORD#0); - ret.max := WORD_TO_ULINT(WORD#65535); + PROGRAM main + VAR + ret : myType; + END_VAR + ret.zero := WORD_TO_ULINT(WORD#0); + ret.max := WORD_TO_ULINT(WORD#65535); END_PROGRAM "; let sources = add_std!(src, "bit_num_conversion.st"); @@ -582,16 +582,16 @@ fn word_to_ulint_conversion() { #[test] fn word_to_udint_conversion() { let src = r" - TYPE myType : STRUCT - zero : UDINT; max : UDINT; - END_STRUCT END_TYPE + TYPE myType : STRUCT + zero : UDINT; max : UDINT; + END_STRUCT END_TYPE - PROGRAM main - VAR - ret : myType; - END_VAR - ret.zero := WORD_TO_UDINT(WORD#0); - ret.max := WORD_TO_UDINT(WORD#65535); + PROGRAM main + VAR + ret : myType; + END_VAR + ret.zero := WORD_TO_UDINT(WORD#0); + ret.max := WORD_TO_UDINT(WORD#65535); END_PROGRAM "; let sources = add_std!(src, "bit_num_conversion.st"); @@ -604,16 +604,16 @@ fn word_to_udint_conversion() { #[test] fn word_to_uint_conversion() { let src = r" - TYPE myType : STRUCT - zero : UINT; max : UINT; - END_STRUCT END_TYPE + TYPE myType : STRUCT + zero : UINT; max : UINT; + END_STRUCT END_TYPE - PROGRAM main - VAR - ret : myType; - END_VAR - ret.zero := WORD_TO_UINT(WORD#0); - ret.max := WORD_TO_UINT(WORD#65535); + PROGRAM main + VAR + ret : myType; + END_VAR + ret.zero := WORD_TO_UINT(WORD#0); + ret.max := WORD_TO_UINT(WORD#65535); END_PROGRAM "; let sources = add_std!(src, "bit_num_conversion.st"); @@ -626,16 +626,16 @@ fn word_to_uint_conversion() { #[test] fn word_to_usint_conversion() { let src = r" - TYPE myType : STRUCT - zero : USINT; max : USINT; - END_STRUCT END_TYPE + TYPE myType : STRUCT + zero : USINT; max : USINT; + END_STRUCT END_TYPE - PROGRAM main - VAR - ret : myType; - END_VAR - ret.zero := WORD_TO_USINT(WORD#0); - ret.max := WORD_TO_USINT(WORD#255); + PROGRAM main + VAR + ret : myType; + END_VAR + ret.zero := WORD_TO_USINT(WORD#0); + ret.max := WORD_TO_USINT(WORD#255); END_PROGRAM "; let sources = add_std!(src, "bit_num_conversion.st"); @@ -648,16 +648,16 @@ fn word_to_usint_conversion() { #[test] fn byte_to_lint_conversion() { let src = r" - TYPE myType : STRUCT - zero : LINT; max : LINT; - END_STRUCT END_TYPE + TYPE myType : STRUCT + zero : LINT; max : LINT; + END_STRUCT END_TYPE - PROGRAM main - VAR - ret : myType; - END_VAR - ret.zero := BYTE_TO_LINT(BYTE#0); - ret.max := BYTE_TO_LINT(BYTE#255); + PROGRAM main + VAR + ret : myType; + END_VAR + ret.zero := BYTE_TO_LINT(BYTE#0); + ret.max := BYTE_TO_LINT(BYTE#255); END_PROGRAM "; let sources = add_std!(src, "bit_num_conversion.st"); @@ -670,16 +670,16 @@ fn byte_to_lint_conversion() { #[test] fn byte_to_dint_conversion() { let src = r" - TYPE myType : STRUCT - zero : DINT; max : DINT; - END_STRUCT END_TYPE + TYPE myType : STRUCT + zero : DINT; max : DINT; + END_STRUCT END_TYPE - PROGRAM main - VAR - ret : myType; - END_VAR - ret.zero := BYTE_TO_DINT(BYTE#0); - ret.max := BYTE_TO_DINT(BYTE#255); + PROGRAM main + VAR + ret : myType; + END_VAR + ret.zero := BYTE_TO_DINT(BYTE#0); + ret.max := BYTE_TO_DINT(BYTE#255); END_PROGRAM "; let sources = add_std!(src, "bit_num_conversion.st"); @@ -692,16 +692,16 @@ fn byte_to_dint_conversion() { #[test] fn byte_to_int_conversion() { let src = r" - TYPE myType : STRUCT - zero : INT; max : INT; - END_STRUCT END_TYPE + TYPE myType : STRUCT + zero : INT; max : INT; + END_STRUCT END_TYPE - PROGRAM main - VAR - ret : myType; - END_VAR - ret.zero := BYTE_TO_INT(BYTE#0); - ret.max := BYTE_TO_INT(BYTE#255); + PROGRAM main + VAR + ret : myType; + END_VAR + ret.zero := BYTE_TO_INT(BYTE#0); + ret.max := BYTE_TO_INT(BYTE#255); END_PROGRAM "; let sources = add_std!(src, "bit_num_conversion.st"); @@ -714,16 +714,16 @@ fn byte_to_int_conversion() { #[test] fn byte_to_sint_conversion() { let src = r" - TYPE myType : STRUCT - zero : SINT; max : SINT; - END_STRUCT END_TYPE + TYPE myType : STRUCT + zero : SINT; max : SINT; + END_STRUCT END_TYPE - PROGRAM main - VAR - ret : myType; - END_VAR - ret.zero := BYTE_TO_SINT(BYTE#0); - ret.max := BYTE_TO_SINT(BYTE#127); + PROGRAM main + VAR + ret : myType; + END_VAR + ret.zero := BYTE_TO_SINT(BYTE#0); + ret.max := BYTE_TO_SINT(BYTE#127); END_PROGRAM "; let sources = add_std!(src, "bit_num_conversion.st"); @@ -736,16 +736,16 @@ fn byte_to_sint_conversion() { #[test] fn byte_to_ulint_conversion() { let src = r" - TYPE myType : STRUCT - zero : ULINT; max : ULINT; - END_STRUCT END_TYPE + TYPE myType : STRUCT + zero : ULINT; max : ULINT; + END_STRUCT END_TYPE - PROGRAM main - VAR - ret : myType; - END_VAR - ret.zero := BYTE_TO_ULINT(BYTE#0); - ret.max := BYTE_TO_ULINT(BYTE#255); + PROGRAM main + VAR + ret : myType; + END_VAR + ret.zero := BYTE_TO_ULINT(BYTE#0); + ret.max := BYTE_TO_ULINT(BYTE#255); END_PROGRAM "; let sources = add_std!(src, "bit_num_conversion.st"); @@ -758,16 +758,16 @@ fn byte_to_ulint_conversion() { #[test] fn byte_to_udint_conversion() { let src = r" - TYPE myType : STRUCT - zero : UDINT; max : UDINT; - END_STRUCT END_TYPE + TYPE myType : STRUCT + zero : UDINT; max : UDINT; + END_STRUCT END_TYPE - PROGRAM main - VAR - ret : myType; - END_VAR - ret.zero := BYTE_TO_UDINT(BYTE#0); - ret.max := BYTE_TO_UDINT(BYTE#255); + PROGRAM main + VAR + ret : myType; + END_VAR + ret.zero := BYTE_TO_UDINT(BYTE#0); + ret.max := BYTE_TO_UDINT(BYTE#255); END_PROGRAM "; let sources = add_std!(src, "bit_num_conversion.st"); @@ -780,16 +780,16 @@ fn byte_to_udint_conversion() { #[test] fn byte_to_uint_conversion() { let src = r" - TYPE myType : STRUCT - zero : UINT; max : UINT; - END_STRUCT END_TYPE + TYPE myType : STRUCT + zero : UINT; max : UINT; + END_STRUCT END_TYPE - PROGRAM main - VAR - ret : myType; - END_VAR - ret.zero := BYTE_TO_UINT(BYTE#0); - ret.max := BYTE_TO_UINT(BYTE#255); + PROGRAM main + VAR + ret : myType; + END_VAR + ret.zero := BYTE_TO_UINT(BYTE#0); + ret.max := BYTE_TO_UINT(BYTE#255); END_PROGRAM "; let sources = add_std!(src, "bit_num_conversion.st"); @@ -802,16 +802,16 @@ fn byte_to_uint_conversion() { #[test] fn byte_to_usint_conversion() { let src = r" - TYPE myType : STRUCT - zero : USINT; max : USINT; - END_STRUCT END_TYPE + TYPE myType : STRUCT + zero : USINT; max : USINT; + END_STRUCT END_TYPE - PROGRAM main - VAR - ret : myType; - END_VAR - ret.zero := BYTE_TO_USINT(BYTE#0); - ret.max := BYTE_TO_USINT(BYTE#255); + PROGRAM main + VAR + ret : myType; + END_VAR + ret.zero := BYTE_TO_USINT(BYTE#0); + ret.max := BYTE_TO_USINT(BYTE#255); END_PROGRAM "; let sources = add_std!(src, "bit_num_conversion.st"); @@ -824,16 +824,16 @@ fn byte_to_usint_conversion() { #[test] fn bool_to_lint_conversion() { let src = r" - TYPE myType : STRUCT - zero : LINT; max : LINT; - END_STRUCT END_TYPE + TYPE myType : STRUCT + zero : LINT; max : LINT; + END_STRUCT END_TYPE - PROGRAM main - VAR - ret : myType; - END_VAR - ret.zero := BOOL_TO_LINT(BOOL#0); - ret.max := BOOL_TO_LINT(BOOL#1); + PROGRAM main + VAR + ret : myType; + END_VAR + ret.zero := BOOL_TO_LINT(BOOL#0); + ret.max := BOOL_TO_LINT(BOOL#1); END_PROGRAM "; let sources = add_std!(src, "bit_num_conversion.st"); @@ -846,16 +846,16 @@ fn bool_to_lint_conversion() { #[test] fn bool_to_dint_conversion() { let src = r" - TYPE myType : STRUCT - zero : DINT; max : DINT; - END_STRUCT END_TYPE + TYPE myType : STRUCT + zero : DINT; max : DINT; + END_STRUCT END_TYPE - PROGRAM main - VAR - ret : myType; - END_VAR - ret.zero := BOOL_TO_DINT(BOOL#0); - ret.max := BOOL_TO_DINT(BOOL#1); + PROGRAM main + VAR + ret : myType; + END_VAR + ret.zero := BOOL_TO_DINT(BOOL#0); + ret.max := BOOL_TO_DINT(BOOL#1); END_PROGRAM "; let sources = add_std!(src, "bit_num_conversion.st"); @@ -868,16 +868,16 @@ fn bool_to_dint_conversion() { #[test] fn bool_to_int_conversion() { let src = r" - TYPE myType : STRUCT - zero : INT; max : INT; - END_STRUCT END_TYPE + TYPE myType : STRUCT + zero : INT; max : INT; + END_STRUCT END_TYPE - PROGRAM main - VAR - ret : myType; - END_VAR - ret.zero := BOOL_TO_INT(BOOL#0); - ret.max := BOOL_TO_INT(BOOL#1); + PROGRAM main + VAR + ret : myType; + END_VAR + ret.zero := BOOL_TO_INT(BOOL#0); + ret.max := BOOL_TO_INT(BOOL#1); END_PROGRAM "; let sources = add_std!(src, "bit_num_conversion.st"); @@ -890,16 +890,16 @@ fn bool_to_int_conversion() { #[test] fn bool_to_sint_conversion() { let src = r" - TYPE myType : STRUCT - zero : SINT; max : SINT; - END_STRUCT END_TYPE + TYPE myType : STRUCT + zero : SINT; max : SINT; + END_STRUCT END_TYPE - PROGRAM main - VAR - ret : myType; - END_VAR - ret.zero := BOOL_TO_SINT(BOOL#0); - ret.max := BOOL_TO_SINT(BOOL#1); + PROGRAM main + VAR + ret : myType; + END_VAR + ret.zero := BOOL_TO_SINT(BOOL#0); + ret.max := BOOL_TO_SINT(BOOL#1); END_PROGRAM "; let sources = add_std!(src, "bit_num_conversion.st"); @@ -912,16 +912,16 @@ fn bool_to_sint_conversion() { #[test] fn bool_to_ulint_conversion() { let src = r" - TYPE myType : STRUCT - zero : ULINT; max : ULINT; - END_STRUCT END_TYPE + TYPE myType : STRUCT + zero : ULINT; max : ULINT; + END_STRUCT END_TYPE - PROGRAM main - VAR - ret : myType; - END_VAR - ret.zero := BOOL_TO_ULINT(BOOL#0); - ret.max := BOOL_TO_ULINT(BOOL#1); + PROGRAM main + VAR + ret : myType; + END_VAR + ret.zero := BOOL_TO_ULINT(BOOL#0); + ret.max := BOOL_TO_ULINT(BOOL#1); END_PROGRAM "; let sources = add_std!(src, "bit_num_conversion.st"); @@ -934,16 +934,16 @@ fn bool_to_ulint_conversion() { #[test] fn bool_to_udint_conversion() { let src = r" - TYPE myType : STRUCT - zero : UDINT; max : UDINT; - END_STRUCT END_TYPE + TYPE myType : STRUCT + zero : UDINT; max : UDINT; + END_STRUCT END_TYPE - PROGRAM main - VAR - ret : myType; - END_VAR - ret.zero := BOOL_TO_UDINT(BOOL#0); - ret.max := BOOL_TO_UDINT(BOOL#1); + PROGRAM main + VAR + ret : myType; + END_VAR + ret.zero := BOOL_TO_UDINT(BOOL#0); + ret.max := BOOL_TO_UDINT(BOOL#1); END_PROGRAM "; let sources = add_std!(src, "bit_num_conversion.st"); @@ -956,16 +956,16 @@ fn bool_to_udint_conversion() { #[test] fn bool_to_uint_conversion() { let src = r" - TYPE myType : STRUCT - zero : UINT; max : UINT; - END_STRUCT END_TYPE + TYPE myType : STRUCT + zero : UINT; max : UINT; + END_STRUCT END_TYPE - PROGRAM main - VAR - ret : myType; - END_VAR - ret.zero := BOOL_TO_UINT(BOOL#0); - ret.max := BOOL_TO_UINT(BOOL#1); + PROGRAM main + VAR + ret : myType; + END_VAR + ret.zero := BOOL_TO_UINT(BOOL#0); + ret.max := BOOL_TO_UINT(BOOL#1); END_PROGRAM "; let sources = add_std!(src, "bit_num_conversion.st"); @@ -978,16 +978,16 @@ fn bool_to_uint_conversion() { #[test] fn bool_to_usint_conversion() { let src = r" - TYPE myType : STRUCT - zero : USINT; max : USINT; - END_STRUCT END_TYPE + TYPE myType : STRUCT + zero : USINT; max : USINT; + END_STRUCT END_TYPE - PROGRAM main - VAR - ret : myType; - END_VAR - ret.zero := BOOL_TO_USINT(BOOL#0); - ret.max := BOOL_TO_USINT(BOOL#1); + PROGRAM main + VAR + ret : myType; + END_VAR + ret.zero := BOOL_TO_USINT(BOOL#0); + ret.max := BOOL_TO_USINT(BOOL#1); END_PROGRAM "; let sources = add_std!(src, "bit_num_conversion.st"); @@ -1000,18 +1000,18 @@ fn bool_to_usint_conversion() { #[test] fn lreal_to_lword_conversion() { let src = r" - TYPE myType : STRUCT - zero : LWORD; max : LWORD; - END_STRUCT END_TYPE + TYPE myType : STRUCT + zero : LWORD; max : LWORD; + END_STRUCT END_TYPE - PROGRAM main - VAR - ret : myType; - END_VAR - ret.zero := LREAL_TO_LWORD(LREAL#0); - // counter test LWORD_TO_LREAL - // 2 in LREAL is the first bit from exponent 2^62 = 4611686018427387904 - ret.max := LREAL_TO_LWORD(LREAL#2); + PROGRAM main + VAR + ret : myType; + END_VAR + ret.zero := LREAL_TO_LWORD(LREAL#0); + // counter test LWORD_TO_LREAL + // 2 in LREAL is the first bit from exponent 2^62 = 4611686018427387904 + ret.max := LREAL_TO_LWORD(LREAL#2); END_PROGRAM "; let sources = add_std!(src, "bit_num_conversion.st"); @@ -1024,18 +1024,18 @@ fn lreal_to_lword_conversion() { #[test] fn real_to_dword_conversion() { let src = r" - TYPE myType : STRUCT - zero : DWORD; max : DWORD; - END_STRUCT END_TYPE + TYPE myType : STRUCT + zero : DWORD; max : DWORD; + END_STRUCT END_TYPE - PROGRAM main - VAR - ret : myType; - END_VAR - ret.zero := REAL_TO_DWORD(REAL#0); - // counter test DWORD_TO_REAL - // 2 in REAL is the first bit from exponent 30 = 1073741824 - ret.max := REAL_TO_DWORD(REAL#2); + PROGRAM main + VAR + ret : myType; + END_VAR + ret.zero := REAL_TO_DWORD(REAL#0); + // counter test DWORD_TO_REAL + // 2 in REAL is the first bit from exponent 30 = 1073741824 + ret.max := REAL_TO_DWORD(REAL#2); END_PROGRAM "; let sources = add_std!(src, "bit_num_conversion.st"); @@ -1048,16 +1048,16 @@ fn real_to_dword_conversion() { #[test] fn lint_to_lword_conversion() { let src = r" - TYPE myType : STRUCT - zero : LWORD; max : LWORD; - END_STRUCT END_TYPE + TYPE myType : STRUCT + zero : LWORD; max : LWORD; + END_STRUCT END_TYPE - PROGRAM main - VAR - ret : myType; - END_VAR - ret.zero := LINT_TO_LWORD(LINT#0); - ret.max := LINT_TO_LWORD(LINT#9223372036854775807); + PROGRAM main + VAR + ret : myType; + END_VAR + ret.zero := LINT_TO_LWORD(LINT#0); + ret.max := LINT_TO_LWORD(LINT#9223372036854775807); END_PROGRAM "; let sources = add_std!(src, "bit_num_conversion.st"); @@ -1070,16 +1070,16 @@ fn lint_to_lword_conversion() { #[test] fn lint_to_dword_conversion() { let src = r" - TYPE myType : STRUCT - zero : DWORD; max : DWORD; - END_STRUCT END_TYPE + TYPE myType : STRUCT + zero : DWORD; max : DWORD; + END_STRUCT END_TYPE - PROGRAM main - VAR - ret : myType; - END_VAR - ret.zero := LINT_TO_DWORD(LINT#0); - ret.max := LINT_TO_DWORD(LINT#4294967295); + PROGRAM main + VAR + ret : myType; + END_VAR + ret.zero := LINT_TO_DWORD(LINT#0); + ret.max := LINT_TO_DWORD(LINT#4294967295); END_PROGRAM "; let sources = add_std!(src, "bit_num_conversion.st"); @@ -1092,16 +1092,16 @@ fn lint_to_dword_conversion() { #[test] fn lint_to_word_conversion() { let src = r" - TYPE myType : STRUCT - zero : WORD; max : WORD; - END_STRUCT END_TYPE + TYPE myType : STRUCT + zero : WORD; max : WORD; + END_STRUCT END_TYPE - PROGRAM main - VAR - ret : myType; - END_VAR - ret.zero := LINT_TO_WORD(LINT#0); - ret.max := LINT_TO_WORD(LINT#65535); + PROGRAM main + VAR + ret : myType; + END_VAR + ret.zero := LINT_TO_WORD(LINT#0); + ret.max := LINT_TO_WORD(LINT#65535); END_PROGRAM "; let sources = add_std!(src, "bit_num_conversion.st"); @@ -1114,16 +1114,16 @@ fn lint_to_word_conversion() { #[test] fn lint_to_byte_conversion() { let src = r" - TYPE myType : STRUCT - zero : BYTE; max : BYTE; - END_STRUCT END_TYPE + TYPE myType : STRUCT + zero : BYTE; max : BYTE; + END_STRUCT END_TYPE - PROGRAM main - VAR - ret : myType; - END_VAR - ret.zero := LINT_TO_BYTE(LINT#0); - ret.max := LINT_TO_BYTE(LINT#255); + PROGRAM main + VAR + ret : myType; + END_VAR + ret.zero := LINT_TO_BYTE(LINT#0); + ret.max := LINT_TO_BYTE(LINT#255); END_PROGRAM "; let sources = add_std!(src, "bit_num_conversion.st"); @@ -1136,16 +1136,16 @@ fn lint_to_byte_conversion() { #[test] fn dint_to_lword_conversion() { let src = r" - TYPE myType : STRUCT - zero : LWORD; max : LWORD; - END_STRUCT END_TYPE + TYPE myType : STRUCT + zero : LWORD; max : LWORD; + END_STRUCT END_TYPE - PROGRAM main - VAR - ret : myType; - END_VAR - ret.zero := DINT_TO_LWORD(DINT#0); - ret.max := DINT_TO_LWORD(DINT#2147483647); + PROGRAM main + VAR + ret : myType; + END_VAR + ret.zero := DINT_TO_LWORD(DINT#0); + ret.max := DINT_TO_LWORD(DINT#2147483647); END_PROGRAM "; let sources = add_std!(src, "bit_num_conversion.st"); @@ -1158,16 +1158,16 @@ fn dint_to_lword_conversion() { #[test] fn dint_to_dword_conversion() { let src = r" - TYPE myType : STRUCT - zero : DWORD; max : DWORD; - END_STRUCT END_TYPE + TYPE myType : STRUCT + zero : DWORD; max : DWORD; + END_STRUCT END_TYPE - PROGRAM main - VAR - ret : myType; - END_VAR - ret.zero := DINT_TO_DWORD(DINT#0); - ret.max := DINT_TO_DWORD(DINT#2147483647); + PROGRAM main + VAR + ret : myType; + END_VAR + ret.zero := DINT_TO_DWORD(DINT#0); + ret.max := DINT_TO_DWORD(DINT#2147483647); END_PROGRAM "; let sources = add_std!(src, "bit_num_conversion.st"); @@ -1180,16 +1180,16 @@ fn dint_to_dword_conversion() { #[test] fn dint_to_word_conversion() { let src = r" - TYPE myType : STRUCT - zero : WORD; max : WORD; - END_STRUCT END_TYPE + TYPE myType : STRUCT + zero : WORD; max : WORD; + END_STRUCT END_TYPE - PROGRAM main - VAR - ret : myType; - END_VAR - ret.zero := DINT_TO_WORD(DINT#0); - ret.max := DINT_TO_WORD(DINT#65535); + PROGRAM main + VAR + ret : myType; + END_VAR + ret.zero := DINT_TO_WORD(DINT#0); + ret.max := DINT_TO_WORD(DINT#65535); END_PROGRAM "; let sources = add_std!(src, "bit_num_conversion.st"); @@ -1202,16 +1202,16 @@ fn dint_to_word_conversion() { #[test] fn dint_to_byte_conversion() { let src = r" - TYPE myType : STRUCT - zero : BYTE; max : BYTE; - END_STRUCT END_TYPE + TYPE myType : STRUCT + zero : BYTE; max : BYTE; + END_STRUCT END_TYPE - PROGRAM main - VAR - ret : myType; - END_VAR - ret.zero := DINT_TO_BYTE(DINT#0); - ret.max := DINT_TO_BYTE(DINT#255); + PROGRAM main + VAR + ret : myType; + END_VAR + ret.zero := DINT_TO_BYTE(DINT#0); + ret.max := DINT_TO_BYTE(DINT#255); END_PROGRAM "; let sources = add_std!(src, "bit_num_conversion.st"); @@ -1224,16 +1224,16 @@ fn dint_to_byte_conversion() { #[test] fn int_to_lword_conversion() { let src = r" - TYPE myType : STRUCT - zero : LWORD; max : LWORD; - END_STRUCT END_TYPE + TYPE myType : STRUCT + zero : LWORD; max : LWORD; + END_STRUCT END_TYPE - PROGRAM main - VAR - ret : myType; - END_VAR - ret.zero := INT_TO_LWORD(INT#0); - ret.max := INT_TO_LWORD(INT#32767); + PROGRAM main + VAR + ret : myType; + END_VAR + ret.zero := INT_TO_LWORD(INT#0); + ret.max := INT_TO_LWORD(INT#32767); END_PROGRAM "; let sources = add_std!(src, "bit_num_conversion.st"); @@ -1246,16 +1246,16 @@ fn int_to_lword_conversion() { #[test] fn int_to_dword_conversion() { let src = r" - TYPE myType : STRUCT - zero : DWORD; max : DWORD; - END_STRUCT END_TYPE + TYPE myType : STRUCT + zero : DWORD; max : DWORD; + END_STRUCT END_TYPE - PROGRAM main - VAR - ret : myType; - END_VAR - ret.zero := INT_TO_DWORD(INT#0); - ret.max := INT_TO_DWORD(INT#32767); + PROGRAM main + VAR + ret : myType; + END_VAR + ret.zero := INT_TO_DWORD(INT#0); + ret.max := INT_TO_DWORD(INT#32767); END_PROGRAM "; let sources = add_std!(src, "bit_num_conversion.st"); @@ -1268,16 +1268,16 @@ fn int_to_dword_conversion() { #[test] fn int_to_word_conversion() { let src = r" - TYPE myType : STRUCT - zero : WORD; max : WORD; - END_STRUCT END_TYPE + TYPE myType : STRUCT + zero : WORD; max : WORD; + END_STRUCT END_TYPE - PROGRAM main - VAR - ret : myType; - END_VAR - ret.zero := INT_TO_WORD(INT#0); - ret.max := INT_TO_WORD(INT#32767); + PROGRAM main + VAR + ret : myType; + END_VAR + ret.zero := INT_TO_WORD(INT#0); + ret.max := INT_TO_WORD(INT#32767); END_PROGRAM "; let sources = add_std!(src, "bit_num_conversion.st"); @@ -1290,16 +1290,16 @@ fn int_to_word_conversion() { #[test] fn int_to_byte_conversion() { let src = r" - TYPE myType : STRUCT - zero : BYTE; max : BYTE; - END_STRUCT END_TYPE + TYPE myType : STRUCT + zero : BYTE; max : BYTE; + END_STRUCT END_TYPE - PROGRAM main - VAR - ret : myType; - END_VAR - ret.zero := INT_TO_BYTE(INT#0); - ret.max := INT_TO_BYTE(INT#255); + PROGRAM main + VAR + ret : myType; + END_VAR + ret.zero := INT_TO_BYTE(INT#0); + ret.max := INT_TO_BYTE(INT#255); END_PROGRAM "; let sources = add_std!(src, "bit_num_conversion.st"); @@ -1312,16 +1312,16 @@ fn int_to_byte_conversion() { #[test] fn sint_to_lword_conversion() { let src = r" - TYPE myType : STRUCT - zero : LWORD; max : LWORD; - END_STRUCT END_TYPE + TYPE myType : STRUCT + zero : LWORD; max : LWORD; + END_STRUCT END_TYPE - PROGRAM main - VAR - ret : myType; - END_VAR - ret.zero := SINT_TO_LWORD(SINT#0); - ret.max := SINT_TO_LWORD(SINT#127); + PROGRAM main + VAR + ret : myType; + END_VAR + ret.zero := SINT_TO_LWORD(SINT#0); + ret.max := SINT_TO_LWORD(SINT#127); END_PROGRAM "; let sources = add_std!(src, "bit_num_conversion.st"); @@ -1334,16 +1334,16 @@ fn sint_to_lword_conversion() { #[test] fn sint_to_dword_conversion() { let src = r" - TYPE myType : STRUCT - zero : DWORD; max :DWORD; - END_STRUCT END_TYPE + TYPE myType : STRUCT + zero : DWORD; max :DWORD; + END_STRUCT END_TYPE - PROGRAM main - VAR - ret : myType; - END_VAR - ret.zero := SINT_TO_DWORD(SINT#0); - ret.max := SINT_TO_DWORD(SINT#127); + PROGRAM main + VAR + ret : myType; + END_VAR + ret.zero := SINT_TO_DWORD(SINT#0); + ret.max := SINT_TO_DWORD(SINT#127); END_PROGRAM "; let sources = add_std!(src, "bit_num_conversion.st"); @@ -1356,16 +1356,16 @@ fn sint_to_dword_conversion() { #[test] fn sint_to_word_conversion() { let src = r" - TYPE myType : STRUCT - zero : WORD; max : WORD; - END_STRUCT END_TYPE + TYPE myType : STRUCT + zero : WORD; max : WORD; + END_STRUCT END_TYPE - PROGRAM main - VAR - ret : myType; - END_VAR - ret.zero := SINT_TO_WORD(SINT#0); - ret.max := SINT_TO_WORD(SINT#127); + PROGRAM main + VAR + ret : myType; + END_VAR + ret.zero := SINT_TO_WORD(SINT#0); + ret.max := SINT_TO_WORD(SINT#127); END_PROGRAM "; let sources = add_std!(src, "bit_num_conversion.st"); @@ -1378,16 +1378,16 @@ fn sint_to_word_conversion() { #[test] fn sint_to_byte_conversion() { let src = r" - TYPE myType : STRUCT - zero : BYTE; max : BYTE; - END_STRUCT END_TYPE + TYPE myType : STRUCT + zero : BYTE; max : BYTE; + END_STRUCT END_TYPE - PROGRAM main - VAR - ret : myType; - END_VAR - ret.zero := SINT_TO_BYTE(SINT#0); - ret.max := SINT_TO_BYTE(SINT#127); + PROGRAM main + VAR + ret : myType; + END_VAR + ret.zero := SINT_TO_BYTE(SINT#0); + ret.max := SINT_TO_BYTE(SINT#127); END_PROGRAM "; let sources = add_std!(src, "bit_num_conversion.st"); @@ -1400,16 +1400,16 @@ fn sint_to_byte_conversion() { #[test] fn ulint_to_lword_conversion() { let src = r" - TYPE myType : STRUCT - zero : LWORD; max : LWORD; - END_STRUCT END_TYPE + TYPE myType : STRUCT + zero : LWORD; max : LWORD; + END_STRUCT END_TYPE - PROGRAM main - VAR - ret : myType; - END_VAR - ret.zero := ULINT_TO_LWORD(ULINT#0); - ret.max := ULINT_TO_LWORD(ULINT#18446744073709551615); + PROGRAM main + VAR + ret : myType; + END_VAR + ret.zero := ULINT_TO_LWORD(ULINT#0); + ret.max := ULINT_TO_LWORD(ULINT#18446744073709551615); END_PROGRAM "; let sources = add_std!(src, "bit_num_conversion.st"); @@ -1422,16 +1422,16 @@ fn ulint_to_lword_conversion() { #[test] fn ulint_to_dword_conversion() { let src = r" - TYPE myType : STRUCT - zero : DWORD; max : DWORD; - END_STRUCT END_TYPE + TYPE myType : STRUCT + zero : DWORD; max : DWORD; + END_STRUCT END_TYPE - PROGRAM main - VAR - ret : myType; - END_VAR - ret.zero := ULINT_TO_DWORD(ULINT#0); - ret.max := ULINT_TO_DWORD(ULINT#4294967295); + PROGRAM main + VAR + ret : myType; + END_VAR + ret.zero := ULINT_TO_DWORD(ULINT#0); + ret.max := ULINT_TO_DWORD(ULINT#4294967295); END_PROGRAM "; let sources = add_std!(src, "bit_num_conversion.st"); @@ -1444,16 +1444,16 @@ fn ulint_to_dword_conversion() { #[test] fn ulint_to_word_conversion() { let src = r" - TYPE myType : STRUCT - zero : WORD; max : WORD; - END_STRUCT END_TYPE + TYPE myType : STRUCT + zero : WORD; max : WORD; + END_STRUCT END_TYPE - PROGRAM main - VAR - ret : myType; - END_VAR - ret.zero := ULINT_TO_WORD(ULINT#0); - ret.max := ULINT_TO_WORD(ULINT#65535); + PROGRAM main + VAR + ret : myType; + END_VAR + ret.zero := ULINT_TO_WORD(ULINT#0); + ret.max := ULINT_TO_WORD(ULINT#65535); END_PROGRAM "; let sources = add_std!(src, "bit_num_conversion.st"); @@ -1466,16 +1466,16 @@ fn ulint_to_word_conversion() { #[test] fn ulint_to_byte_conversion() { let src = r" - TYPE myType : STRUCT - zero : BYTE; max : BYTE; - END_STRUCT END_TYPE + TYPE myType : STRUCT + zero : BYTE; max : BYTE; + END_STRUCT END_TYPE - PROGRAM main - VAR - ret : myType; - END_VAR - ret.zero := ULINT_TO_BYTE(ULINT#0); - ret.max := ULINT_TO_BYTE(ULINT#255); + PROGRAM main + VAR + ret : myType; + END_VAR + ret.zero := ULINT_TO_BYTE(ULINT#0); + ret.max := ULINT_TO_BYTE(ULINT#255); END_PROGRAM "; let sources = add_std!(src, "bit_num_conversion.st"); @@ -1488,16 +1488,16 @@ fn ulint_to_byte_conversion() { #[test] fn udint_to_lword_conversion() { let src = r" - TYPE myType : STRUCT - zero : LWORD; max : LWORD; - END_STRUCT END_TYPE + TYPE myType : STRUCT + zero : LWORD; max : LWORD; + END_STRUCT END_TYPE - PROGRAM main - VAR - ret : myType; - END_VAR - ret.zero := UDINT_TO_LWORD(UDINT#0); - ret.max := UDINT_TO_LWORD(UDINT#4294967295); + PROGRAM main + VAR + ret : myType; + END_VAR + ret.zero := UDINT_TO_LWORD(UDINT#0); + ret.max := UDINT_TO_LWORD(UDINT#4294967295); END_PROGRAM "; let sources = add_std!(src, "bit_num_conversion.st"); @@ -1510,16 +1510,16 @@ fn udint_to_lword_conversion() { #[test] fn udint_to_dword_conversion() { let src = r" - TYPE myType : STRUCT - zero : DWORD; max : DWORD; - END_STRUCT END_TYPE + TYPE myType : STRUCT + zero : DWORD; max : DWORD; + END_STRUCT END_TYPE - PROGRAM main - VAR - ret : myType; - END_VAR - ret.zero := UDINT_TO_DWORD(UDINT#0); - ret.max := UDINT_TO_DWORD(UDINT#4294967295); + PROGRAM main + VAR + ret : myType; + END_VAR + ret.zero := UDINT_TO_DWORD(UDINT#0); + ret.max := UDINT_TO_DWORD(UDINT#4294967295); END_PROGRAM "; let sources = add_std!(src, "bit_num_conversion.st"); @@ -1532,16 +1532,16 @@ fn udint_to_dword_conversion() { #[test] fn udint_to_word_conversion() { let src = r" - TYPE myType : STRUCT - zero : WORD; max : WORD; - END_STRUCT END_TYPE + TYPE myType : STRUCT + zero : WORD; max : WORD; + END_STRUCT END_TYPE - PROGRAM main - VAR - ret : myType; - END_VAR - ret.zero := UDINT_TO_WORD(UDINT#0); - ret.max := UDINT_TO_WORD(UDINT#65535); + PROGRAM main + VAR + ret : myType; + END_VAR + ret.zero := UDINT_TO_WORD(UDINT#0); + ret.max := UDINT_TO_WORD(UDINT#65535); END_PROGRAM "; let sources = add_std!(src, "bit_num_conversion.st"); @@ -1554,16 +1554,16 @@ fn udint_to_word_conversion() { #[test] fn udint_to_byte_conversion() { let src = r" - TYPE myType : STRUCT - zero : BYTE; max : BYTE; - END_STRUCT END_TYPE + TYPE myType : STRUCT + zero : BYTE; max : BYTE; + END_STRUCT END_TYPE - PROGRAM main - VAR - ret : myType; - END_VAR - ret.zero := UDINT_TO_BYTE(UDINT#0); - ret.max := UDINT_TO_BYTE(UDINT#255); + PROGRAM main + VAR + ret : myType; + END_VAR + ret.zero := UDINT_TO_BYTE(UDINT#0); + ret.max := UDINT_TO_BYTE(UDINT#255); END_PROGRAM "; let sources = add_std!(src, "bit_num_conversion.st"); @@ -1576,16 +1576,16 @@ fn udint_to_byte_conversion() { #[test] fn uint_to_lword_conversion() { let src = r" - TYPE myType : STRUCT - zero : LWORD; max : LWORD; - END_STRUCT END_TYPE + TYPE myType : STRUCT + zero : LWORD; max : LWORD; + END_STRUCT END_TYPE - PROGRAM main - VAR - ret : myType; - END_VAR - ret.zero := UINT_TO_LWORD(UINT#0); - ret.max := UINT_TO_LWORD(UINT#65535); + PROGRAM main + VAR + ret : myType; + END_VAR + ret.zero := UINT_TO_LWORD(UINT#0); + ret.max := UINT_TO_LWORD(UINT#65535); END_PROGRAM "; let sources = add_std!(src, "bit_num_conversion.st"); @@ -1598,16 +1598,16 @@ fn uint_to_lword_conversion() { #[test] fn uint_to_dword_conversion() { let src = r" - TYPE myType : STRUCT - zero : DWORD; max : DWORD; - END_STRUCT END_TYPE + TYPE myType : STRUCT + zero : DWORD; max : DWORD; + END_STRUCT END_TYPE - PROGRAM main - VAR - ret : myType; - END_VAR - ret.zero := UINT_TO_DWORD(UINT#0); - ret.max := UINT_TO_DWORD(UINT#65535); + PROGRAM main + VAR + ret : myType; + END_VAR + ret.zero := UINT_TO_DWORD(UINT#0); + ret.max := UINT_TO_DWORD(UINT#65535); END_PROGRAM "; let sources = add_std!(src, "bit_num_conversion.st"); @@ -1620,16 +1620,16 @@ fn uint_to_dword_conversion() { #[test] fn uint_to_word_conversion() { let src = r" - TYPE myType : STRUCT - zero : WORD; max : WORD; - END_STRUCT END_TYPE + TYPE myType : STRUCT + zero : WORD; max : WORD; + END_STRUCT END_TYPE - PROGRAM main - VAR - ret : myType; - END_VAR - ret.zero := UINT_TO_WORD(UINT#0); - ret.max := UINT_TO_WORD(UINT#65535); + PROGRAM main + VAR + ret : myType; + END_VAR + ret.zero := UINT_TO_WORD(UINT#0); + ret.max := UINT_TO_WORD(UINT#65535); END_PROGRAM "; let sources = add_std!(src, "bit_num_conversion.st"); @@ -1642,16 +1642,16 @@ fn uint_to_word_conversion() { #[test] fn uint_to_byte_conversion() { let src = r" - TYPE myType : STRUCT - zero : BYTE; max : BYTE; - END_STRUCT END_TYPE + TYPE myType : STRUCT + zero : BYTE; max : BYTE; + END_STRUCT END_TYPE - PROGRAM main - VAR - ret : myType; - END_VAR - ret.zero := UINT_TO_BYTE(UINT#0); - ret.max := UINT_TO_BYTE(UINT#255); + PROGRAM main + VAR + ret : myType; + END_VAR + ret.zero := UINT_TO_BYTE(UINT#0); + ret.max := UINT_TO_BYTE(UINT#255); END_PROGRAM "; let sources = add_std!(src, "bit_num_conversion.st"); @@ -1664,16 +1664,16 @@ fn uint_to_byte_conversion() { #[test] fn usint_to_lword_conversion() { let src = r" - TYPE myType : STRUCT - zero : LWORD; max : LWORD; - END_STRUCT END_TYPE + TYPE myType : STRUCT + zero : LWORD; max : LWORD; + END_STRUCT END_TYPE - PROGRAM main - VAR - ret : myType; - END_VAR - ret.zero := USINT_TO_LWORD(USINT#0); - ret.max := USINT_TO_LWORD(USINT#255); + PROGRAM main + VAR + ret : myType; + END_VAR + ret.zero := USINT_TO_LWORD(USINT#0); + ret.max := USINT_TO_LWORD(USINT#255); END_PROGRAM "; let sources = add_std!(src, "bit_num_conversion.st"); @@ -1686,16 +1686,16 @@ fn usint_to_lword_conversion() { #[test] fn usint_to_dword_conversion() { let src = r" - TYPE myType : STRUCT - zero : DWORD; max : DWORD; - END_STRUCT END_TYPE + TYPE myType : STRUCT + zero : DWORD; max : DWORD; + END_STRUCT END_TYPE - PROGRAM main - VAR - ret : myType; - END_VAR - ret.zero := USINT_TO_DWORD(USINT#0); - ret.max := USINT_TO_DWORD(USINT#255); + PROGRAM main + VAR + ret : myType; + END_VAR + ret.zero := USINT_TO_DWORD(USINT#0); + ret.max := USINT_TO_DWORD(USINT#255); END_PROGRAM "; let sources = add_std!(src, "bit_num_conversion.st"); @@ -1708,16 +1708,16 @@ fn usint_to_dword_conversion() { #[test] fn usint_to_word_conversion() { let src = r" - TYPE myType : STRUCT - zero : WORD; max : WORD; - END_STRUCT END_TYPE + TYPE myType : STRUCT + zero : WORD; max : WORD; + END_STRUCT END_TYPE - PROGRAM main - VAR - ret : myType; - END_VAR - ret.zero := USINT_TO_WORD(USINT#0); - ret.max := USINT_TO_WORD(USINT#255); + PROGRAM main + VAR + ret : myType; + END_VAR + ret.zero := USINT_TO_WORD(USINT#0); + ret.max := USINT_TO_WORD(USINT#255); END_PROGRAM "; let sources = add_std!(src, "bit_num_conversion.st"); @@ -1730,16 +1730,16 @@ fn usint_to_word_conversion() { #[test] fn usint_to_byte_conversion() { let src = r" - TYPE myType : STRUCT - zero : BYTE; max : BYTE; - END_STRUCT END_TYPE + TYPE myType : STRUCT + zero : BYTE; max : BYTE; + END_STRUCT END_TYPE - PROGRAM main - VAR - ret : myType; - END_VAR - ret.zero := USINT_TO_BYTE(USINT#0); - ret.max := USINT_TO_BYTE(USINT#255); + PROGRAM main + VAR + ret : myType; + END_VAR + ret.zero := USINT_TO_BYTE(USINT#0); + ret.max := USINT_TO_BYTE(USINT#255); END_PROGRAM "; let sources = add_std!(src, "bit_num_conversion.st"); diff --git a/libs/stdlib/tests/counters_tests.rs b/libs/stdlib/tests/counters_tests.rs index a64f75171d..d9793768b7 100644 --- a/libs/stdlib/tests/counters_tests.rs +++ b/libs/stdlib/tests/counters_tests.rs @@ -21,19 +21,19 @@ struct CTUType { fn ctu() { let prog = r#" PROGRAM main - VAR - ctu_inst : CTU; - Q_res : BOOL; - CV_res : INT; - END_VAR - // count up until Q_res true and then reset CV_res - IF Q_res THEN - ctu_inst(CU:= TRUE, R:= TRUE, PV:= INT#3, Q:= Q_res, CV:= CV_res); - ELSE - ctu_inst(CU:= TRUE, R:= FALSE, PV:= INT#3, Q:= Q_res, CV:= CV_res); - // input CU evaluated by R_EDGE, this call will enable to count up again - ctu_inst(CU:= FALSE, R:= FALSE, PV:= INT#3, Q:= Q_res, CV:= CV_res); - END_IF + VAR + ctu_inst : CTU; + Q_res : BOOL; + CV_res : INT; + END_VAR + // count up until Q_res true and then reset CV_res + IF Q_res THEN + ctu_inst(CU:= TRUE, R:= TRUE, PV:= INT#3, Q:= Q_res, CV:= CV_res); + ELSE + ctu_inst(CU:= TRUE, R:= FALSE, PV:= INT#3, Q:= Q_res, CV:= CV_res); + // input CU evaluated by R_EDGE, this call will enable to count up again + ctu_inst(CU:= FALSE, R:= FALSE, PV:= INT#3, Q:= Q_res, CV:= CV_res); + END_IF END_PROGRAM "#; @@ -63,19 +63,19 @@ fn ctu() { fn ctu_int() { let prog = r#" PROGRAM main - VAR - ctu_inst : CTU_INT; - Q_res : BOOL; - CV_res : INT; - END_VAR - // count up until Q_res true and then reset CV_res - IF Q_res THEN - ctu_inst(CU:= TRUE, R:= TRUE, PV:= INT#3, Q:= Q_res, CV:= CV_res); - ELSE - ctu_inst(CU:= TRUE, R:= FALSE, PV:= INT#3, Q:= Q_res, CV:= CV_res); - // input CU evaluated by R_EDGE, this call will enable to count up again - ctu_inst(CU:= FALSE, R:= FALSE, PV:= INT#3, Q:= Q_res, CV:= CV_res); - END_IF + VAR + ctu_inst : CTU_INT; + Q_res : BOOL; + CV_res : INT; + END_VAR + // count up until Q_res true and then reset CV_res + IF Q_res THEN + ctu_inst(CU:= TRUE, R:= TRUE, PV:= INT#3, Q:= Q_res, CV:= CV_res); + ELSE + ctu_inst(CU:= TRUE, R:= FALSE, PV:= INT#3, Q:= Q_res, CV:= CV_res); + // input CU evaluated by R_EDGE, this call will enable to count up again + ctu_inst(CU:= FALSE, R:= FALSE, PV:= INT#3, Q:= Q_res, CV:= CV_res); + END_IF END_PROGRAM "#; @@ -105,19 +105,19 @@ fn ctu_int() { fn ctu_dint() { let prog = r#" PROGRAM main - VAR - ctu_inst : CTU_DINT; - Q_res : BOOL; - CV_res : DINT; - END_VAR - // count up until Q_res true and then reset CV_res - IF Q_res THEN - ctu_inst(CU:= TRUE, R:= TRUE, PV:= DINT#3, Q:= Q_res, CV:= CV_res); - ELSE - ctu_inst(CU:= TRUE, R:= FALSE, PV:= DINT#3, Q:= Q_res, CV:= CV_res); - // input CU evaluated by R_EDGE, this call will enable to count up again - ctu_inst(CU:= FALSE, R:= FALSE, PV:= DINT#3, Q:= Q_res, CV:= CV_res); - END_IF + VAR + ctu_inst : CTU_DINT; + Q_res : BOOL; + CV_res : DINT; + END_VAR + // count up until Q_res true and then reset CV_res + IF Q_res THEN + ctu_inst(CU:= TRUE, R:= TRUE, PV:= DINT#3, Q:= Q_res, CV:= CV_res); + ELSE + ctu_inst(CU:= TRUE, R:= FALSE, PV:= DINT#3, Q:= Q_res, CV:= CV_res); + // input CU evaluated by R_EDGE, this call will enable to count up again + ctu_inst(CU:= FALSE, R:= FALSE, PV:= DINT#3, Q:= Q_res, CV:= CV_res); + END_IF END_PROGRAM "#; @@ -147,19 +147,19 @@ fn ctu_dint() { fn ctu_udint() { let prog = r#" PROGRAM main - VAR - ctu_inst : CTU_UDINT; - Q_res : BOOL; - CV_res : UDINT; - END_VAR - // count up until Q_res true and then reset CV_res - IF Q_res THEN - ctu_inst(CU:= TRUE, R:= TRUE, PV:= UDINT#3, Q:= Q_res, CV:= CV_res); - ELSE - ctu_inst(CU:= TRUE, R:= FALSE, PV:= UDINT#3, Q:= Q_res, CV:= CV_res); - // input CU evaluated by R_EDGE, this call will enable to count up again - ctu_inst(CU:= FALSE, R:= FALSE, PV:= UDINT#3, Q:= Q_res, CV:= CV_res); - END_IF + VAR + ctu_inst : CTU_UDINT; + Q_res : BOOL; + CV_res : UDINT; + END_VAR + // count up until Q_res true and then reset CV_res + IF Q_res THEN + ctu_inst(CU:= TRUE, R:= TRUE, PV:= UDINT#3, Q:= Q_res, CV:= CV_res); + ELSE + ctu_inst(CU:= TRUE, R:= FALSE, PV:= UDINT#3, Q:= Q_res, CV:= CV_res); + // input CU evaluated by R_EDGE, this call will enable to count up again + ctu_inst(CU:= FALSE, R:= FALSE, PV:= UDINT#3, Q:= Q_res, CV:= CV_res); + END_IF END_PROGRAM "#; @@ -189,19 +189,19 @@ fn ctu_udint() { fn ctu_lint() { let prog = r#" PROGRAM main - VAR - ctu_inst : CTU_LINT; - Q_res : BOOL; - CV_res : LINT; - END_VAR - // count up until Q_res true and then reset CV_res - IF Q_res THEN - ctu_inst(CU:= TRUE, R:= TRUE, PV:= LINT#3, Q:= Q_res, CV:= CV_res); - ELSE - ctu_inst(CU:= TRUE, R:= FALSE, PV:= LINT#3, Q:= Q_res, CV:= CV_res); - // input CU evaluated by R_EDGE, this call will enable to count up again - ctu_inst(CU:= FALSE, R:= FALSE, PV:= LINT#3, Q:= Q_res, CV:= CV_res); - END_IF + VAR + ctu_inst : CTU_LINT; + Q_res : BOOL; + CV_res : LINT; + END_VAR + // count up until Q_res true and then reset CV_res + IF Q_res THEN + ctu_inst(CU:= TRUE, R:= TRUE, PV:= LINT#3, Q:= Q_res, CV:= CV_res); + ELSE + ctu_inst(CU:= TRUE, R:= FALSE, PV:= LINT#3, Q:= Q_res, CV:= CV_res); + // input CU evaluated by R_EDGE, this call will enable to count up again + ctu_inst(CU:= FALSE, R:= FALSE, PV:= LINT#3, Q:= Q_res, CV:= CV_res); + END_IF END_PROGRAM "#; @@ -231,19 +231,19 @@ fn ctu_lint() { fn ctu_ulint() { let prog = r#" PROGRAM main - VAR - ctu_inst : CTU_ULINT; - Q_res : BOOL; - CV_res : ULINT; - END_VAR - // count up until Q_res true and then reset CV_res - IF Q_res THEN - ctu_inst(CU:= TRUE, R:= TRUE, PV:= ULINT#3, Q:= Q_res, CV:= CV_res); - ELSE - ctu_inst(CU:= TRUE, R:= FALSE, PV:= ULINT#3, Q:= Q_res, CV:= CV_res); - // input CU evaluated by R_EDGE, this call will enable to count up again - ctu_inst(CU:= FALSE, R:= FALSE, PV:= ULINT#3, Q:= Q_res, CV:= CV_res); - END_IF + VAR + ctu_inst : CTU_ULINT; + Q_res : BOOL; + CV_res : ULINT; + END_VAR + // count up until Q_res true and then reset CV_res + IF Q_res THEN + ctu_inst(CU:= TRUE, R:= TRUE, PV:= ULINT#3, Q:= Q_res, CV:= CV_res); + ELSE + ctu_inst(CU:= TRUE, R:= FALSE, PV:= ULINT#3, Q:= Q_res, CV:= CV_res); + // input CU evaluated by R_EDGE, this call will enable to count up again + ctu_inst(CU:= FALSE, R:= FALSE, PV:= ULINT#3, Q:= Q_res, CV:= CV_res); + END_IF END_PROGRAM "#; @@ -282,20 +282,20 @@ struct CTDType { fn ctd() { let prog = r#" PROGRAM main - VAR - ctd_inst : CTD; - load : BOOL := TRUE; - Q_res : BOOL; - CV_res : INT; - END_VAR - // load PV value - IF load THEN - ctd_inst(CD:= TRUE, LD:= load, PV:= INT#3, Q:= Q_res, CV:= CV_res); - load := FALSE; - END_IF - ctd_inst(CD:= TRUE, LD:= load, PV:= INT#3, Q:= Q_res, CV:= CV_res); - // input CD evaluated by R_EDGE, this call will enable to count down again - ctd_inst(CD:= FALSE, LD:= load, PV:= INT#3, Q:= Q_res, CV:= CV_res); + VAR + ctd_inst : CTD; + load : BOOL := TRUE; + Q_res : BOOL; + CV_res : INT; + END_VAR + // load PV value + IF load THEN + ctd_inst(CD:= TRUE, LD:= load, PV:= INT#3, Q:= Q_res, CV:= CV_res); + load := FALSE; + END_IF + ctd_inst(CD:= TRUE, LD:= load, PV:= INT#3, Q:= Q_res, CV:= CV_res); + // input CD evaluated by R_EDGE, this call will enable to count down again + ctd_inst(CD:= FALSE, LD:= load, PV:= INT#3, Q:= Q_res, CV:= CV_res); END_PROGRAM "#; @@ -325,20 +325,20 @@ fn ctd() { fn ctd_int() { let prog = r#" PROGRAM main - VAR - ctd_inst : CTD_INT; - load : BOOL := TRUE; - Q_res : BOOL; - CV_res : INT; - END_VAR - // load PV value - IF load THEN - ctd_inst(CD:= TRUE, LD:= load, PV:= INT#3, Q:= Q_res, CV:= CV_res); - load := FALSE; - END_IF - ctd_inst(CD:= TRUE, LD:= load, PV:= INT#3, Q:= Q_res, CV:= CV_res); - // input CD evaluated by R_EDGE, this call will enable to count down again - ctd_inst(CD:= FALSE, LD:= load, PV:= INT#3, Q:= Q_res, CV:= CV_res); + VAR + ctd_inst : CTD_INT; + load : BOOL := TRUE; + Q_res : BOOL; + CV_res : INT; + END_VAR + // load PV value + IF load THEN + ctd_inst(CD:= TRUE, LD:= load, PV:= INT#3, Q:= Q_res, CV:= CV_res); + load := FALSE; + END_IF + ctd_inst(CD:= TRUE, LD:= load, PV:= INT#3, Q:= Q_res, CV:= CV_res); + // input CD evaluated by R_EDGE, this call will enable to count down again + ctd_inst(CD:= FALSE, LD:= load, PV:= INT#3, Q:= Q_res, CV:= CV_res); END_PROGRAM "#; @@ -368,20 +368,20 @@ fn ctd_int() { fn ctd_dint() { let prog = r#" PROGRAM main - VAR - ctd_inst : CTD_DINT; - load : BOOL := TRUE; - Q_res : BOOL; - CV_res : DINT; - END_VAR - // load PV value - IF load THEN - ctd_inst(CD:= TRUE, LD:= load, PV:= DINT#3, Q:= Q_res, CV:= CV_res); - load := FALSE; - END_IF - ctd_inst(CD:= TRUE, LD:= load, PV:= DINT#3, Q:= Q_res, CV:= CV_res); - // input CD evaluated by R_EDGE, this call will enable to count down again - ctd_inst(CD:= FALSE, LD:= load, PV:= DINT#3, Q:= Q_res, CV:= CV_res); + VAR + ctd_inst : CTD_DINT; + load : BOOL := TRUE; + Q_res : BOOL; + CV_res : DINT; + END_VAR + // load PV value + IF load THEN + ctd_inst(CD:= TRUE, LD:= load, PV:= DINT#3, Q:= Q_res, CV:= CV_res); + load := FALSE; + END_IF + ctd_inst(CD:= TRUE, LD:= load, PV:= DINT#3, Q:= Q_res, CV:= CV_res); + // input CD evaluated by R_EDGE, this call will enable to count down again + ctd_inst(CD:= FALSE, LD:= load, PV:= DINT#3, Q:= Q_res, CV:= CV_res); END_PROGRAM "#; @@ -411,20 +411,20 @@ fn ctd_dint() { fn ctd_udint() { let prog = r#" PROGRAM main - VAR - ctd_inst : CTD_UDINT; - load : BOOL := TRUE; - Q_res : BOOL; - CV_res : UDINT; - END_VAR - // load PV value - IF load THEN - ctd_inst(CD:= TRUE, LD:= load, PV:= UDINT#3, Q:= Q_res, CV:= CV_res); - load := FALSE; - END_IF - ctd_inst(CD:= TRUE, LD:= load, PV:= UDINT#3, Q:= Q_res, CV:= CV_res); - // input CD evaluated by R_EDGE, this call will enable to count down again - ctd_inst(CD:= FALSE, LD:= load, PV:= UDINT#3, Q:= Q_res, CV:= CV_res); + VAR + ctd_inst : CTD_UDINT; + load : BOOL := TRUE; + Q_res : BOOL; + CV_res : UDINT; + END_VAR + // load PV value + IF load THEN + ctd_inst(CD:= TRUE, LD:= load, PV:= UDINT#3, Q:= Q_res, CV:= CV_res); + load := FALSE; + END_IF + ctd_inst(CD:= TRUE, LD:= load, PV:= UDINT#3, Q:= Q_res, CV:= CV_res); + // input CD evaluated by R_EDGE, this call will enable to count down again + ctd_inst(CD:= FALSE, LD:= load, PV:= UDINT#3, Q:= Q_res, CV:= CV_res); END_PROGRAM "#; @@ -454,20 +454,20 @@ fn ctd_udint() { fn ctd_lint() { let prog = r#" PROGRAM main - VAR - ctd_inst : CTD_LINT; - load : BOOL := TRUE; - Q_res : BOOL; - CV_res : LINT; - END_VAR - // load PV value - IF load THEN - ctd_inst(CD:= TRUE, LD:= load, PV:= LINT#3, Q:= Q_res, CV:= CV_res); - load := FALSE; - END_IF - ctd_inst(CD:= TRUE, LD:= load, PV:= LINT#3, Q:= Q_res, CV:= CV_res); - // input CD evaluated by R_EDGE, this call will enable to count down again - ctd_inst(CD:= FALSE, LD:= load, PV:= LINT#3, Q:= Q_res, CV:= CV_res); + VAR + ctd_inst : CTD_LINT; + load : BOOL := TRUE; + Q_res : BOOL; + CV_res : LINT; + END_VAR + // load PV value + IF load THEN + ctd_inst(CD:= TRUE, LD:= load, PV:= LINT#3, Q:= Q_res, CV:= CV_res); + load := FALSE; + END_IF + ctd_inst(CD:= TRUE, LD:= load, PV:= LINT#3, Q:= Q_res, CV:= CV_res); + // input CD evaluated by R_EDGE, this call will enable to count down again + ctd_inst(CD:= FALSE, LD:= load, PV:= LINT#3, Q:= Q_res, CV:= CV_res); END_PROGRAM "#; @@ -497,20 +497,20 @@ fn ctd_lint() { fn ctd_ulint() { let prog = r#" PROGRAM main - VAR - ctd_inst : CTD_ULINT; - load : BOOL := TRUE; - Q_res : BOOL; - CV_res : ULINT; - END_VAR - // load PV value - IF load THEN - ctd_inst(CD:= TRUE, LD:= load, PV:= ULINT#3, Q:= Q_res, CV:= CV_res); - load := FALSE; - END_IF - ctd_inst(CD:= TRUE, LD:= load, PV:= ULINT#3, Q:= Q_res, CV:= CV_res); - // input CD evaluated by R_EDGE, this call will enable to count down again - ctd_inst(CD:= FALSE, LD:= load, PV:= ULINT#3, Q:= Q_res, CV:= CV_res); + VAR + ctd_inst : CTD_ULINT; + load : BOOL := TRUE; + Q_res : BOOL; + CV_res : ULINT; + END_VAR + // load PV value + IF load THEN + ctd_inst(CD:= TRUE, LD:= load, PV:= ULINT#3, Q:= Q_res, CV:= CV_res); + load := FALSE; + END_IF + ctd_inst(CD:= TRUE, LD:= load, PV:= ULINT#3, Q:= Q_res, CV:= CV_res); + // input CD evaluated by R_EDGE, this call will enable to count down again + ctd_inst(CD:= FALSE, LD:= load, PV:= ULINT#3, Q:= Q_res, CV:= CV_res); END_PROGRAM "#; @@ -551,43 +551,43 @@ struct CTUDType { fn ctud() { let prog = r#" PROGRAM main - VAR - ctud_inst : CTUD; - load : BOOL := TRUE; - QU_res : BOOL; - QD_res : BOOL; - CV_res : INT; - i : SINT; - END_VAR - // 1st call, load PV value - IF load THEN - ctud_inst(CU:= FALSE, CD:= FALSE, R:= FALSE, LD:= TRUE, PV:= INT#1, QU:= QU_res, QD:= QD_res, CV:= CV_res); - load := FALSE; - END_IF - - // 2nd call, CU/CD both true, nothing should happen - IF i = 1 THEN - ctud_inst(CU:= TRUE, CD:= TRUE, R:= FALSE, LD:= FALSE, PV:= INT#1, QU:= QU_res, QD:= QD_res, CV:= CV_res); - END_IF - - // 3rd call, count down - IF i = 2 THEN - // input CD evaluated by R_EDGE, this call will enable count down again - ctud_inst(CU:= FALSE, CD:= FALSE, R:= FALSE, LD:= FALSE, PV:= INT#1, QU:= QU_res, QD:= QD_res, CV:= CV_res); - ctud_inst(CU:= FALSE, CD:= TRUE, R:= FALSE, LD:= FALSE, PV:= INT#1, QU:= QU_res, QD:= QD_res, CV:= CV_res); - END_IF - - // 4th call, count up - IF i = 3 THEN - // input CU evaluated by R_EDGE, third call enabled count up again - ctud_inst(CU:= TRUE, CD:= FALSE, R:= FALSE, LD:= FALSE, PV:= INT#1, QU:= QU_res, QD:= QD_res, CV:= CV_res); - END_IF - - // 5th call, reset - IF i = 4 THEN - ctud_inst(CU:= FALSE, CD:= FALSE, R:= TRUE, LD:= FALSE, PV:= INT#1, QU:= QU_res, QD:= QD_res, CV:= CV_res); - END_IF - i := i + 1; + VAR + ctud_inst : CTUD; + load : BOOL := TRUE; + QU_res : BOOL; + QD_res : BOOL; + CV_res : INT; + i : SINT; + END_VAR + // 1st call, load PV value + IF load THEN + ctud_inst(CU:= FALSE, CD:= FALSE, R:= FALSE, LD:= TRUE, PV:= INT#1, QU:= QU_res, QD:= QD_res, CV:= CV_res); + load := FALSE; + END_IF + + // 2nd call, CU/CD both true, nothing should happen + IF i = 1 THEN + ctud_inst(CU:= TRUE, CD:= TRUE, R:= FALSE, LD:= FALSE, PV:= INT#1, QU:= QU_res, QD:= QD_res, CV:= CV_res); + END_IF + + // 3rd call, count down + IF i = 2 THEN + // input CD evaluated by R_EDGE, this call will enable count down again + ctud_inst(CU:= FALSE, CD:= FALSE, R:= FALSE, LD:= FALSE, PV:= INT#1, QU:= QU_res, QD:= QD_res, CV:= CV_res); + ctud_inst(CU:= FALSE, CD:= TRUE, R:= FALSE, LD:= FALSE, PV:= INT#1, QU:= QU_res, QD:= QD_res, CV:= CV_res); + END_IF + + // 4th call, count up + IF i = 3 THEN + // input CU evaluated by R_EDGE, third call enabled count up again + ctud_inst(CU:= TRUE, CD:= FALSE, R:= FALSE, LD:= FALSE, PV:= INT#1, QU:= QU_res, QD:= QD_res, CV:= CV_res); + END_IF + + // 5th call, reset + IF i = 4 THEN + ctud_inst(CU:= FALSE, CD:= FALSE, R:= TRUE, LD:= FALSE, PV:= INT#1, QU:= QU_res, QD:= QD_res, CV:= CV_res); + END_IF + i := i + 1; END_PROGRAM "#; @@ -626,43 +626,43 @@ fn ctud() { fn ctud_int() { let prog = r#" PROGRAM main - VAR - ctud_inst : CTUD_INT; - load : BOOL := TRUE; - QU_res : BOOL; - QD_res : BOOL; - CV_res : INT; - i : SINT; - END_VAR - // 1st call, load PV value - IF load THEN - ctud_inst(CU:= FALSE, CD:= FALSE, R:= FALSE, LD:= TRUE, PV:= INT#1, QU:= QU_res, QD:= QD_res, CV:= CV_res); - load := FALSE; - END_IF - - // 2nd call, CU/CD both true, nothing should happen - IF i = 1 THEN - ctud_inst(CU:= TRUE, CD:= TRUE, R:= FALSE, LD:= FALSE, PV:= INT#1, QU:= QU_res, QD:= QD_res, CV:= CV_res); - END_IF - - // 3rd call, count down - IF i = 2 THEN - // input CD evaluated by R_EDGE, this call will enable count down again - ctud_inst(CU:= FALSE, CD:= FALSE, R:= FALSE, LD:= FALSE, PV:= INT#1, QU:= QU_res, QD:= QD_res, CV:= CV_res); - ctud_inst(CU:= FALSE, CD:= TRUE, R:= FALSE, LD:= FALSE, PV:= INT#1, QU:= QU_res, QD:= QD_res, CV:= CV_res); - END_IF - - // 4th call, count up - IF i = 3 THEN - // input CU evaluated by R_EDGE, third call enabled count up again - ctud_inst(CU:= TRUE, CD:= FALSE, R:= FALSE, LD:= FALSE, PV:= INT#1, QU:= QU_res, QD:= QD_res, CV:= CV_res); - END_IF - - // 5th call, reset - IF i = 4 THEN - ctud_inst(CU:= FALSE, CD:= FALSE, R:= TRUE, LD:= FALSE, PV:= INT#1, QU:= QU_res, QD:= QD_res, CV:= CV_res); - END_IF - i := i + 1; + VAR + ctud_inst : CTUD_INT; + load : BOOL := TRUE; + QU_res : BOOL; + QD_res : BOOL; + CV_res : INT; + i : SINT; + END_VAR + // 1st call, load PV value + IF load THEN + ctud_inst(CU:= FALSE, CD:= FALSE, R:= FALSE, LD:= TRUE, PV:= INT#1, QU:= QU_res, QD:= QD_res, CV:= CV_res); + load := FALSE; + END_IF + + // 2nd call, CU/CD both true, nothing should happen + IF i = 1 THEN + ctud_inst(CU:= TRUE, CD:= TRUE, R:= FALSE, LD:= FALSE, PV:= INT#1, QU:= QU_res, QD:= QD_res, CV:= CV_res); + END_IF + + // 3rd call, count down + IF i = 2 THEN + // input CD evaluated by R_EDGE, this call will enable count down again + ctud_inst(CU:= FALSE, CD:= FALSE, R:= FALSE, LD:= FALSE, PV:= INT#1, QU:= QU_res, QD:= QD_res, CV:= CV_res); + ctud_inst(CU:= FALSE, CD:= TRUE, R:= FALSE, LD:= FALSE, PV:= INT#1, QU:= QU_res, QD:= QD_res, CV:= CV_res); + END_IF + + // 4th call, count up + IF i = 3 THEN + // input CU evaluated by R_EDGE, third call enabled count up again + ctud_inst(CU:= TRUE, CD:= FALSE, R:= FALSE, LD:= FALSE, PV:= INT#1, QU:= QU_res, QD:= QD_res, CV:= CV_res); + END_IF + + // 5th call, reset + IF i = 4 THEN + ctud_inst(CU:= FALSE, CD:= FALSE, R:= TRUE, LD:= FALSE, PV:= INT#1, QU:= QU_res, QD:= QD_res, CV:= CV_res); + END_IF + i := i + 1; END_PROGRAM "#; @@ -701,43 +701,43 @@ fn ctud_int() { fn ctud_dint() { let prog = r#" PROGRAM main - VAR - ctud_inst : CTUD_DINT; - load : BOOL := TRUE; - QU_res : BOOL; - QD_res : BOOL; - CV_res : DINT; - i : SINT; - END_VAR - // 1st call, load PV value - IF load THEN - ctud_inst(CU:= FALSE, CD:= FALSE, R:= FALSE, LD:= TRUE, PV:= DINT#1, QU:= QU_res, QD:= QD_res, CV:= CV_res); - load := FALSE; - END_IF - - // 2nd call, CU/CD both true, nothing should happen - IF i = 1 THEN - ctud_inst(CU:= TRUE, CD:= TRUE, R:= FALSE, LD:= FALSE, PV:= DINT#1, QU:= QU_res, QD:= QD_res, CV:= CV_res); - END_IF - - // 3rd call, count down - IF i = 2 THEN - // input CD evaluated by R_EDGE, this call will enable count down again - ctud_inst(CU:= FALSE, CD:= FALSE, R:= FALSE, LD:= FALSE, PV:= DINT#1, QU:= QU_res, QD:= QD_res, CV:= CV_res); - ctud_inst(CU:= FALSE, CD:= TRUE, R:= FALSE, LD:= FALSE, PV:= DINT#1, QU:= QU_res, QD:= QD_res, CV:= CV_res); - END_IF - - // 4th call, count up - IF i = 3 THEN - // input CU evaluated by R_EDGE, third call enabled count up again - ctud_inst(CU:= TRUE, CD:= FALSE, R:= FALSE, LD:= FALSE, PV:= DINT#1, QU:= QU_res, QD:= QD_res, CV:= CV_res); - END_IF - - // 5th call, reset - IF i = 4 THEN - ctud_inst(CU:= FALSE, CD:= FALSE, R:= TRUE, LD:= FALSE, PV:= DINT#1, QU:= QU_res, QD:= QD_res, CV:= CV_res); - END_IF - i := i + 1; + VAR + ctud_inst : CTUD_DINT; + load : BOOL := TRUE; + QU_res : BOOL; + QD_res : BOOL; + CV_res : DINT; + i : SINT; + END_VAR + // 1st call, load PV value + IF load THEN + ctud_inst(CU:= FALSE, CD:= FALSE, R:= FALSE, LD:= TRUE, PV:= DINT#1, QU:= QU_res, QD:= QD_res, CV:= CV_res); + load := FALSE; + END_IF + + // 2nd call, CU/CD both true, nothing should happen + IF i = 1 THEN + ctud_inst(CU:= TRUE, CD:= TRUE, R:= FALSE, LD:= FALSE, PV:= DINT#1, QU:= QU_res, QD:= QD_res, CV:= CV_res); + END_IF + + // 3rd call, count down + IF i = 2 THEN + // input CD evaluated by R_EDGE, this call will enable count down again + ctud_inst(CU:= FALSE, CD:= FALSE, R:= FALSE, LD:= FALSE, PV:= DINT#1, QU:= QU_res, QD:= QD_res, CV:= CV_res); + ctud_inst(CU:= FALSE, CD:= TRUE, R:= FALSE, LD:= FALSE, PV:= DINT#1, QU:= QU_res, QD:= QD_res, CV:= CV_res); + END_IF + + // 4th call, count up + IF i = 3 THEN + // input CU evaluated by R_EDGE, third call enabled count up again + ctud_inst(CU:= TRUE, CD:= FALSE, R:= FALSE, LD:= FALSE, PV:= DINT#1, QU:= QU_res, QD:= QD_res, CV:= CV_res); + END_IF + + // 5th call, reset + IF i = 4 THEN + ctud_inst(CU:= FALSE, CD:= FALSE, R:= TRUE, LD:= FALSE, PV:= DINT#1, QU:= QU_res, QD:= QD_res, CV:= CV_res); + END_IF + i := i + 1; END_PROGRAM "#; @@ -776,43 +776,43 @@ fn ctud_dint() { fn ctud_udint() { let prog = r#" PROGRAM main - VAR - ctud_inst : CTUD_UDINT; - load : BOOL := TRUE; - QU_res : BOOL; - QD_res : BOOL; - CV_res : UDINT; - i : SINT; - END_VAR - // 1st call, load PV value - IF load THEN - ctud_inst(CU:= FALSE, CD:= FALSE, R:= FALSE, LD:= TRUE, PV:= UDINT#1, QU:= QU_res, QD:= QD_res, CV:= CV_res); - load := FALSE; - END_IF - - // 2nd call, CU/CD both true, nothing should happen - IF i = 1 THEN - ctud_inst(CU:= TRUE, CD:= TRUE, R:= FALSE, LD:= FALSE, PV:= UDINT#1, QU:= QU_res, QD:= QD_res, CV:= CV_res); - END_IF - - // 3rd call, count down - IF i = 2 THEN - // input CD evaluated by R_EDGE, this call will enable count down again - ctud_inst(CU:= FALSE, CD:= FALSE, R:= FALSE, LD:= FALSE, PV:= UDINT#1, QU:= QU_res, QD:= QD_res, CV:= CV_res); - ctud_inst(CU:= FALSE, CD:= TRUE, R:= FALSE, LD:= FALSE, PV:= UDINT#1, QU:= QU_res, QD:= QD_res, CV:= CV_res); - END_IF - - // 4th call, count up - IF i = 3 THEN - // input CU evaluated by R_EDGE, third call enabled count up again - ctud_inst(CU:= TRUE, CD:= FALSE, R:= FALSE, LD:= FALSE, PV:= UDINT#1, QU:= QU_res, QD:= QD_res, CV:= CV_res); - END_IF - - // 5th call, reset - IF i = 4 THEN - ctud_inst(CU:= FALSE, CD:= FALSE, R:= TRUE, LD:= FALSE, PV:= UDINT#1, QU:= QU_res, QD:= QD_res, CV:= CV_res); - END_IF - i := i + 1; + VAR + ctud_inst : CTUD_UDINT; + load : BOOL := TRUE; + QU_res : BOOL; + QD_res : BOOL; + CV_res : UDINT; + i : SINT; + END_VAR + // 1st call, load PV value + IF load THEN + ctud_inst(CU:= FALSE, CD:= FALSE, R:= FALSE, LD:= TRUE, PV:= UDINT#1, QU:= QU_res, QD:= QD_res, CV:= CV_res); + load := FALSE; + END_IF + + // 2nd call, CU/CD both true, nothing should happen + IF i = 1 THEN + ctud_inst(CU:= TRUE, CD:= TRUE, R:= FALSE, LD:= FALSE, PV:= UDINT#1, QU:= QU_res, QD:= QD_res, CV:= CV_res); + END_IF + + // 3rd call, count down + IF i = 2 THEN + // input CD evaluated by R_EDGE, this call will enable count down again + ctud_inst(CU:= FALSE, CD:= FALSE, R:= FALSE, LD:= FALSE, PV:= UDINT#1, QU:= QU_res, QD:= QD_res, CV:= CV_res); + ctud_inst(CU:= FALSE, CD:= TRUE, R:= FALSE, LD:= FALSE, PV:= UDINT#1, QU:= QU_res, QD:= QD_res, CV:= CV_res); + END_IF + + // 4th call, count up + IF i = 3 THEN + // input CU evaluated by R_EDGE, third call enabled count up again + ctud_inst(CU:= TRUE, CD:= FALSE, R:= FALSE, LD:= FALSE, PV:= UDINT#1, QU:= QU_res, QD:= QD_res, CV:= CV_res); + END_IF + + // 5th call, reset + IF i = 4 THEN + ctud_inst(CU:= FALSE, CD:= FALSE, R:= TRUE, LD:= FALSE, PV:= UDINT#1, QU:= QU_res, QD:= QD_res, CV:= CV_res); + END_IF + i := i + 1; END_PROGRAM "#; @@ -851,43 +851,43 @@ fn ctud_udint() { fn ctud_lint() { let prog = r#" PROGRAM main - VAR - ctud_inst : CTUD_LINT; - load : BOOL := TRUE; - QU_res : BOOL; - QD_res : BOOL; - CV_res : LINT; - i : SINT; - END_VAR - // 1st call, load PV value - IF load THEN - ctud_inst(CU:= FALSE, CD:= FALSE, R:= FALSE, LD:= TRUE, PV:= LINT#1, QU:= QU_res, QD:= QD_res, CV:= CV_res); - load := FALSE; - END_IF - - // 2nd call, CU/CD both true, nothing should happen - IF i = 1 THEN - ctud_inst(CU:= TRUE, CD:= TRUE, R:= FALSE, LD:= FALSE, PV:= LINT#1, QU:= QU_res, QD:= QD_res, CV:= CV_res); - END_IF - - // 3rd call, count down - IF i = 2 THEN - // input CD evaluated by R_EDGE, this call will enable count down again - ctud_inst(CU:= FALSE, CD:= FALSE, R:= FALSE, LD:= FALSE, PV:= LINT#1, QU:= QU_res, QD:= QD_res, CV:= CV_res); - ctud_inst(CU:= FALSE, CD:= TRUE, R:= FALSE, LD:= FALSE, PV:= LINT#1, QU:= QU_res, QD:= QD_res, CV:= CV_res); - END_IF - - // 4th call, count up - IF i = 3 THEN - // input CU evaluated by R_EDGE, third call enabled count up again - ctud_inst(CU:= TRUE, CD:= FALSE, R:= FALSE, LD:= FALSE, PV:= LINT#1, QU:= QU_res, QD:= QD_res, CV:= CV_res); - END_IF - - // 5th call, reset - IF i = 4 THEN - ctud_inst(CU:= FALSE, CD:= FALSE, R:= TRUE, LD:= FALSE, PV:= LINT#1, QU:= QU_res, QD:= QD_res, CV:= CV_res); - END_IF - i := i + 1; + VAR + ctud_inst : CTUD_LINT; + load : BOOL := TRUE; + QU_res : BOOL; + QD_res : BOOL; + CV_res : LINT; + i : SINT; + END_VAR + // 1st call, load PV value + IF load THEN + ctud_inst(CU:= FALSE, CD:= FALSE, R:= FALSE, LD:= TRUE, PV:= LINT#1, QU:= QU_res, QD:= QD_res, CV:= CV_res); + load := FALSE; + END_IF + + // 2nd call, CU/CD both true, nothing should happen + IF i = 1 THEN + ctud_inst(CU:= TRUE, CD:= TRUE, R:= FALSE, LD:= FALSE, PV:= LINT#1, QU:= QU_res, QD:= QD_res, CV:= CV_res); + END_IF + + // 3rd call, count down + IF i = 2 THEN + // input CD evaluated by R_EDGE, this call will enable count down again + ctud_inst(CU:= FALSE, CD:= FALSE, R:= FALSE, LD:= FALSE, PV:= LINT#1, QU:= QU_res, QD:= QD_res, CV:= CV_res); + ctud_inst(CU:= FALSE, CD:= TRUE, R:= FALSE, LD:= FALSE, PV:= LINT#1, QU:= QU_res, QD:= QD_res, CV:= CV_res); + END_IF + + // 4th call, count up + IF i = 3 THEN + // input CU evaluated by R_EDGE, third call enabled count up again + ctud_inst(CU:= TRUE, CD:= FALSE, R:= FALSE, LD:= FALSE, PV:= LINT#1, QU:= QU_res, QD:= QD_res, CV:= CV_res); + END_IF + + // 5th call, reset + IF i = 4 THEN + ctud_inst(CU:= FALSE, CD:= FALSE, R:= TRUE, LD:= FALSE, PV:= LINT#1, QU:= QU_res, QD:= QD_res, CV:= CV_res); + END_IF + i := i + 1; END_PROGRAM "#; @@ -926,43 +926,43 @@ fn ctud_lint() { fn ctud_ulint() { let prog = r#" PROGRAM main - VAR - ctud_inst : CTUD_ULINT; - load : BOOL := TRUE; - QU_res : BOOL; - QD_res : BOOL; - CV_res : ULINT; - i : SINT; - END_VAR - // 1st call, load PV value - IF load THEN - ctud_inst(CU:= FALSE, CD:= FALSE, R:= FALSE, LD:= TRUE, PV:= ULINT#1, QU:= QU_res, QD:= QD_res, CV:= CV_res); - load := FALSE; - END_IF - - // 2nd call, CU/CD both true, nothing should happen - IF i = 1 THEN - ctud_inst(CU:= TRUE, CD:= TRUE, R:= FALSE, LD:= FALSE, PV:= ULINT#1, QU:= QU_res, QD:= QD_res, CV:= CV_res); - END_IF - - // 3rd call, count down - IF i = 2 THEN - // input CD evaluated by R_EDGE, this call will enable count down again - ctud_inst(CU:= FALSE, CD:= FALSE, R:= FALSE, LD:= FALSE, PV:= ULINT#1, QU:= QU_res, QD:= QD_res, CV:= CV_res); - ctud_inst(CU:= FALSE, CD:= TRUE, R:= FALSE, LD:= FALSE, PV:= ULINT#1, QU:= QU_res, QD:= QD_res, CV:= CV_res); - END_IF - - // 4th call, count up - IF i = 3 THEN - // input CU evaluated by R_EDGE, third call enabled count up again - ctud_inst(CU:= TRUE, CD:= FALSE, R:= FALSE, LD:= FALSE, PV:= ULINT#1, QU:= QU_res, QD:= QD_res, CV:= CV_res); - END_IF - - // 5th call, reset - IF i = 4 THEN - ctud_inst(CU:= FALSE, CD:= FALSE, R:= TRUE, LD:= FALSE, PV:= ULINT#1, QU:= QU_res, QD:= QD_res, CV:= CV_res); - END_IF - i := i + 1; + VAR + ctud_inst : CTUD_ULINT; + load : BOOL := TRUE; + QU_res : BOOL; + QD_res : BOOL; + CV_res : ULINT; + i : SINT; + END_VAR + // 1st call, load PV value + IF load THEN + ctud_inst(CU:= FALSE, CD:= FALSE, R:= FALSE, LD:= TRUE, PV:= ULINT#1, QU:= QU_res, QD:= QD_res, CV:= CV_res); + load := FALSE; + END_IF + + // 2nd call, CU/CD both true, nothing should happen + IF i = 1 THEN + ctud_inst(CU:= TRUE, CD:= TRUE, R:= FALSE, LD:= FALSE, PV:= ULINT#1, QU:= QU_res, QD:= QD_res, CV:= CV_res); + END_IF + + // 3rd call, count down + IF i = 2 THEN + // input CD evaluated by R_EDGE, this call will enable count down again + ctud_inst(CU:= FALSE, CD:= FALSE, R:= FALSE, LD:= FALSE, PV:= ULINT#1, QU:= QU_res, QD:= QD_res, CV:= CV_res); + ctud_inst(CU:= FALSE, CD:= TRUE, R:= FALSE, LD:= FALSE, PV:= ULINT#1, QU:= QU_res, QD:= QD_res, CV:= CV_res); + END_IF + + // 4th call, count up + IF i = 3 THEN + // input CU evaluated by R_EDGE, third call enabled count up again + ctud_inst(CU:= TRUE, CD:= FALSE, R:= FALSE, LD:= FALSE, PV:= ULINT#1, QU:= QU_res, QD:= QD_res, CV:= CV_res); + END_IF + + // 5th call, reset + IF i = 4 THEN + ctud_inst(CU:= FALSE, CD:= FALSE, R:= TRUE, LD:= FALSE, PV:= ULINT#1, QU:= QU_res, QD:= QD_res, CV:= CV_res); + END_IF + i := i + 1; END_PROGRAM "#; diff --git a/libs/stdlib/tests/date_time_conversion_tests.rs b/libs/stdlib/tests/date_time_conversion_tests.rs index 292052b31d..0749bd8d32 100644 --- a/libs/stdlib/tests/date_time_conversion_tests.rs +++ b/libs/stdlib/tests/date_time_conversion_tests.rs @@ -20,9 +20,9 @@ impl Default for MainType { #[test] fn ltime_to_time_conversion() { let src = " - FUNCTION main : TIME - main := LTIME_TO_TIME(LTIME#10s); - END_FUNCTION"; + FUNCTION main : TIME + main := LTIME_TO_TIME(LTIME#10s); + END_FUNCTION"; let sources = add_std!(src, "date_time_conversion.st"); let mut maintype = MainType::default(); let res: i64 = compile_and_run(sources, &mut maintype); @@ -32,9 +32,9 @@ fn ltime_to_time_conversion() { #[test] fn time_to_ltime_conversion() { let src = " - FUNCTION main : LTIME - main := TIME_TO_LTIME(TIME#10s); - END_FUNCTION"; + FUNCTION main : LTIME + main := TIME_TO_LTIME(TIME#10s); + END_FUNCTION"; let sources = add_std!(src, "date_time_conversion.st"); let mut maintype = MainType::default(); let res: i64 = compile_and_run(sources, &mut maintype); @@ -44,9 +44,9 @@ fn time_to_ltime_conversion() { #[test] fn ldt_to_dt_conversion() { let src = " - FUNCTION main : DT - main := LDT_TO_DT(LDT#2021-04-20-22:33:14); - END_FUNCTION"; + FUNCTION main : DT + main := LDT_TO_DT(LDT#2021-04-20-22:33:14); + END_FUNCTION"; let sources = add_std!(src, "date_time_conversion.st"); let mut maintype = MainType::default(); let res: i64 = compile_and_run(sources, &mut maintype); @@ -63,9 +63,9 @@ fn ldt_to_dt_conversion() { #[test] fn ldt_to_date_conversion() { let src = " - FUNCTION main : DATE - main := LDT_TO_DATE(LDT#2000-01-01-20:15:11); - END_FUNCTION"; + FUNCTION main : DATE + main := LDT_TO_DATE(LDT#2000-01-01-20:15:11); + END_FUNCTION"; let sources = add_std!(src, "date_time_conversion.st"); let mut maintype = MainType::default(); let res: i64 = compile_and_run(sources, &mut maintype); @@ -78,9 +78,9 @@ fn ldt_to_date_conversion() { #[test] fn ldt_to_ltod_conversion() { let src = " - FUNCTION main : LTOD - main := LDT_TO_LTOD(LDT#2000-01-01-15:36:30.123456); - END_FUNCTION"; + FUNCTION main : LTOD + main := LDT_TO_LTOD(LDT#2000-01-01-15:36:30.123456); + END_FUNCTION"; let sources = add_std!(src, "date_time_conversion.st"); let mut maintype = MainType::default(); let res: i64 = compile_and_run(sources, &mut maintype); @@ -97,9 +97,9 @@ fn ldt_to_ltod_conversion() { #[test] fn ldt_to_tod_conversion() { let src = " - FUNCTION main : TOD - main := LDT_TO_TOD(LDT#2120-02-12-20:15:11.543); - END_FUNCTION"; + FUNCTION main : TOD + main := LDT_TO_TOD(LDT#2120-02-12-20:15:11.543); + END_FUNCTION"; let sources = add_std!(src, "date_time_conversion.st"); let mut maintype = MainType::default(); let res: i64 = compile_and_run(sources, &mut maintype); @@ -116,9 +116,9 @@ fn ldt_to_tod_conversion() { #[test] fn dt_to_ldt_conversion() { let src = " - FUNCTION main : LDT - main := DT_TO_LDT(DT#2021-04-20-22:33:14); - END_FUNCTION"; + FUNCTION main : LDT + main := DT_TO_LDT(DT#2021-04-20-22:33:14); + END_FUNCTION"; let sources = add_std!(src, "date_time_conversion.st"); let mut maintype = MainType::default(); let res: i64 = compile_and_run(sources, &mut maintype); @@ -135,9 +135,9 @@ fn dt_to_ldt_conversion() { #[test] fn dt_to_date_conversion() { let src = " - FUNCTION main : DATE - main := DT_TO_DATE(DT#2000-01-01-20:15:11); - END_FUNCTION"; + FUNCTION main : DATE + main := DT_TO_DATE(DT#2000-01-01-20:15:11); + END_FUNCTION"; let sources = add_std!(src, "date_time_conversion.st"); let mut maintype = MainType::default(); let res: i64 = compile_and_run(sources, &mut maintype); @@ -150,9 +150,9 @@ fn dt_to_date_conversion() { #[test] fn dt_to_ltod_conversion() { let src = " - FUNCTION main : LTOD - main := DT_TO_LTOD(DT#2000-01-01-15:36:30.123); - END_FUNCTION"; + FUNCTION main : LTOD + main := DT_TO_LTOD(DT#2000-01-01-15:36:30.123); + END_FUNCTION"; let sources = add_std!(src, "date_time_conversion.st"); let mut maintype = MainType::default(); let res: i64 = compile_and_run(sources, &mut maintype); @@ -169,9 +169,9 @@ fn dt_to_ltod_conversion() { #[test] fn dt_to_tod_conversion() { let src = " - FUNCTION main : TOD - main := DT_TO_TOD(DT#2120-02-12-20:15:11.543); - END_FUNCTION"; + FUNCTION main : TOD + main := DT_TO_TOD(DT#2120-02-12-20:15:11.543); + END_FUNCTION"; let sources = add_std!(src, "date_time_conversion.st"); let mut maintype = MainType::default(); let res: i64 = compile_and_run(sources, &mut maintype); @@ -188,9 +188,9 @@ fn dt_to_tod_conversion() { #[test] fn ltod_to_tod_conversion() { let src = " - FUNCTION main : TOD - main := LTOD_TO_TOD(LTOD#10:20:30); - END_FUNCTION"; + FUNCTION main : TOD + main := LTOD_TO_TOD(LTOD#10:20:30); + END_FUNCTION"; let sources = add_std!(src, "date_time_conversion.st"); let mut maintype = MainType::default(); let res: i64 = compile_and_run(sources, &mut maintype); @@ -207,9 +207,9 @@ fn ltod_to_tod_conversion() { #[test] fn tod_to_ltod_conversion() { let src = " - FUNCTION main : LTOD - main := TOD_TO_LTOD(TOD#10:20:30); - END_FUNCTION"; + FUNCTION main : LTOD + main := TOD_TO_LTOD(TOD#10:20:30); + END_FUNCTION"; let sources = add_std!(src, "date_time_conversion.st"); let mut maintype = MainType::default(); let res: i64 = compile_and_run(sources, &mut maintype); diff --git a/libs/stdlib/tests/date_time_extra_functions_tests.rs b/libs/stdlib/tests/date_time_extra_functions_tests.rs index 452da98374..e21528c40e 100644 --- a/libs/stdlib/tests/date_time_extra_functions_tests.rs +++ b/libs/stdlib/tests/date_time_extra_functions_tests.rs @@ -24,9 +24,9 @@ fn get_time_from_hms_milli(hour: u32, min: u32, sec: u32, milli: u32) -> chrono: #[test] fn concat_date_tod() { let src = " - FUNCTION main : DT - main := CONCAT_DATE_TOD(D#2010-03-12, TOD#12:30:15.121121121); - END_FUNCTION"; + FUNCTION main : DT + main := CONCAT_DATE_TOD(D#2010-03-12, TOD#12:30:15.121121121); + END_FUNCTION"; let sources = add_std!(src, "date_time_extra_functions.st"); let mut maintype = SingleType::default(); let res: i64 = compile_and_run(sources, &mut maintype); @@ -41,9 +41,9 @@ fn concat_date_tod() { #[test] fn concat_date_ltod() { let src = " - FUNCTION main : LDT - main := CONCAT_DATE_LTOD(D#2010-03-12, LTOD#12:30:15.121121121); - END_FUNCTION"; + FUNCTION main : LDT + main := CONCAT_DATE_LTOD(D#2010-03-12, LTOD#12:30:15.121121121); + END_FUNCTION"; let sources = add_std!(src, "date_time_extra_functions.st"); let mut maintype = SingleType::default(); let res: i64 = compile_and_run(sources, &mut maintype); @@ -69,16 +69,16 @@ struct MainType { #[test] fn concat_date_signed_ints() { let src = " - PROGRAM main - VAR - a : DATE; - b : DATE; - c : DATE; - END_VAR - a := CONCAT_DATE(INT#2000,SINT#01,SINT#01); - b := CONCAT_DATE(DINT#2000,DINT#01,DINT#01); - c := CONCAT_DATE(LINT#2000,LINT#01,LINT#01); - END_PROGRAM"; + PROGRAM main + VAR + a : DATE; + b : DATE; + c : DATE; + END_VAR + a := CONCAT_DATE(INT#2000,SINT#01,SINT#01); + b := CONCAT_DATE(DINT#2000,DINT#01,DINT#01); + c := CONCAT_DATE(LINT#2000,LINT#01,LINT#01); + END_PROGRAM"; let sources = add_std!(src, "date_time_extra_functions.st"); let mut maintype = MainType::::default(); let _: i64 = compile_and_run(sources, &mut maintype); @@ -92,16 +92,16 @@ fn concat_date_signed_ints() { #[test] fn concat_date_unsigned_ints() { let src = " - PROGRAM main - VAR - a : DATE; - b : DATE; - c : DATE; - END_VAR - a := CONCAT_DATE(UINT#2000,USINT#01,USINT#01); - b := CONCAT_DATE(UDINT#2000,UDINT#01,UDINT#01); - c := CONCAT_DATE(ULINT#2000,ULINT#01,ULINT#01); - END_PROGRAM"; + PROGRAM main + VAR + a : DATE; + b : DATE; + c : DATE; + END_VAR + a := CONCAT_DATE(UINT#2000,USINT#01,USINT#01); + b := CONCAT_DATE(UDINT#2000,UDINT#01,UDINT#01); + c := CONCAT_DATE(ULINT#2000,ULINT#01,ULINT#01); + END_PROGRAM"; let sources = add_std!(src, "date_time_extra_functions.st"); let mut maintype = MainType::::default(); let _: i64 = compile_and_run(sources, &mut maintype); @@ -115,18 +115,18 @@ fn concat_date_unsigned_ints() { #[test] fn concat_tod_signed_ints() { let src = " - PROGRAM main - VAR - a : TOD; - b : TOD; - c : TOD; - d : TOD; - END_VAR - a := CONCAT_TOD(SINT#20,SINT#15,SINT#12,SINT#34); - b := CONCAT_TOD(INT#20,INT#15,INT#12,INT#341); - c := CONCAT_TOD(DINT#20,DINT#15,DINT#12,DINT#341); - d := CONCAT_TOD(LINT#20,LINT#15,LINT#12,LINT#341); - END_PROGRAM"; + PROGRAM main + VAR + a : TOD; + b : TOD; + c : TOD; + d : TOD; + END_VAR + a := CONCAT_TOD(SINT#20,SINT#15,SINT#12,SINT#34); + b := CONCAT_TOD(INT#20,INT#15,INT#12,INT#341); + c := CONCAT_TOD(DINT#20,DINT#15,DINT#12,DINT#341); + d := CONCAT_TOD(LINT#20,LINT#15,LINT#12,LINT#341); + END_PROGRAM"; let sources = add_std!(src, "date_time_extra_functions.st"); let mut maintype = MainType::::default(); let _: i64 = compile_and_run(sources, &mut maintype); @@ -140,18 +140,18 @@ fn concat_tod_signed_ints() { #[test] fn concat_tod_unsigned_ints() { let src = " - PROGRAM main - VAR - a : TOD; - b : TOD; - c : TOD; - d : TOD; - END_VAR - a := CONCAT_TOD(USINT#20,USINT#15,USINT#12,USINT#34); - b := CONCAT_TOD(UINT#20,UINT#15,UINT#12,UINT#341); - c := CONCAT_TOD(UDINT#20,UDINT#15,UDINT#12,UDINT#341); - d := CONCAT_TOD(ULINT#20,ULINT#15,ULINT#12,ULINT#341); - END_PROGRAM"; + PROGRAM main + VAR + a : TOD; + b : TOD; + c : TOD; + d : TOD; + END_VAR + a := CONCAT_TOD(USINT#20,USINT#15,USINT#12,USINT#34); + b := CONCAT_TOD(UINT#20,UINT#15,UINT#12,UINT#341); + c := CONCAT_TOD(UDINT#20,UDINT#15,UDINT#12,UDINT#341); + d := CONCAT_TOD(ULINT#20,ULINT#15,ULINT#12,ULINT#341); + END_PROGRAM"; let sources = add_std!(src, "date_time_extra_functions.st"); let mut maintype = MainType::::default(); let _: i64 = compile_and_run(sources, &mut maintype); @@ -165,18 +165,18 @@ fn concat_tod_unsigned_ints() { #[test] fn concat_ltod_signed_ints() { let src = " - PROGRAM main - VAR - a : TOD; - b : TOD; - c : TOD; - d : TOD; - END_VAR - a := CONCAT_LTOD(SINT#20,SINT#15,SINT#12,SINT#34); - b := CONCAT_LTOD(INT#20,INT#15,INT#12,INT#341); - c := CONCAT_LTOD(DINT#20,DINT#15,DINT#12,DINT#341); - d := CONCAT_LTOD(LINT#20,LINT#15,LINT#12,LINT#341); - END_PROGRAM"; + PROGRAM main + VAR + a : TOD; + b : TOD; + c : TOD; + d : TOD; + END_VAR + a := CONCAT_LTOD(SINT#20,SINT#15,SINT#12,SINT#34); + b := CONCAT_LTOD(INT#20,INT#15,INT#12,INT#341); + c := CONCAT_LTOD(DINT#20,DINT#15,DINT#12,DINT#341); + d := CONCAT_LTOD(LINT#20,LINT#15,LINT#12,LINT#341); + END_PROGRAM"; let sources = add_std!(src, "date_time_extra_functions.st"); let mut maintype = MainType::::default(); let _: i64 = compile_and_run(sources, &mut maintype); @@ -190,18 +190,18 @@ fn concat_ltod_signed_ints() { #[test] fn concat_ltod_unsigned_ints() { let src = " - PROGRAM main - VAR - a : TOD; - b : TOD; - c : TOD; - d : TOD; - END_VAR - a := CONCAT_LTOD(USINT#20,USINT#15,USINT#12,USINT#34); - b := CONCAT_LTOD(UINT#20,UINT#15,UINT#12,UINT#341); - c := CONCAT_LTOD(UDINT#20,UDINT#15,UDINT#12,UDINT#341); - d := CONCAT_LTOD(ULINT#20,ULINT#15,ULINT#12,ULINT#341); - END_PROGRAM"; + PROGRAM main + VAR + a : TOD; + b : TOD; + c : TOD; + d : TOD; + END_VAR + a := CONCAT_LTOD(USINT#20,USINT#15,USINT#12,USINT#34); + b := CONCAT_LTOD(UINT#20,UINT#15,UINT#12,UINT#341); + c := CONCAT_LTOD(UDINT#20,UDINT#15,UDINT#12,UDINT#341); + d := CONCAT_LTOD(ULINT#20,ULINT#15,ULINT#12,ULINT#341); + END_PROGRAM"; let sources = add_std!(src, "date_time_extra_functions.st"); let mut maintype = MainType::::default(); let _: i64 = compile_and_run(sources, &mut maintype); @@ -215,16 +215,16 @@ fn concat_ltod_unsigned_ints() { #[test] fn concat_dt_signed_ints() { let src = " - PROGRAM main - VAR - a : DT; - b : DT; - c : DT; - END_VAR - a := CONCAT_DT(INT#2000,SINT#1,SINT#2,SINT#20,SINT#15,SINT#12,SINT#111); - b := CONCAT_DT(DINT#2000,DINT#1,DINT#2,DINT#20,DINT#15,DINT#12,DINT#111); - c := CONCAT_DT(LINT#2000,LINT#1,LINT#2,LINT#20,LINT#15,LINT#12,LINT#111); - END_PROGRAM"; + PROGRAM main + VAR + a : DT; + b : DT; + c : DT; + END_VAR + a := CONCAT_DT(INT#2000,SINT#1,SINT#2,SINT#20,SINT#15,SINT#12,SINT#111); + b := CONCAT_DT(DINT#2000,DINT#1,DINT#2,DINT#20,DINT#15,DINT#12,DINT#111); + c := CONCAT_DT(LINT#2000,LINT#1,LINT#2,LINT#20,LINT#15,LINT#12,LINT#111); + END_PROGRAM"; let sources = add_std!(src, "date_time_extra_functions.st"); let mut maintype = MainType::::default(); let _: i64 = compile_and_run(sources, &mut maintype); @@ -241,16 +241,16 @@ fn concat_dt_signed_ints() { #[test] fn concat_dt_unsigned_ints() { let src = " - PROGRAM main - VAR - a : DT; - b : DT; - c : DT; - END_VAR - a := CONCAT_DT(UINT#2000,USINT#1,USINT#2,USINT#20,USINT#15,USINT#12,USINT#111); - b := CONCAT_DT(UDINT#2000,UDINT#1,UDINT#2,UDINT#20,UDINT#15,UDINT#12,UDINT#111); - c := CONCAT_DT(ULINT#2000,ULINT#1,ULINT#2,ULINT#20,ULINT#15,ULINT#12,ULINT#111); - END_PROGRAM"; + PROGRAM main + VAR + a : DT; + b : DT; + c : DT; + END_VAR + a := CONCAT_DT(UINT#2000,USINT#1,USINT#2,USINT#20,USINT#15,USINT#12,USINT#111); + b := CONCAT_DT(UDINT#2000,UDINT#1,UDINT#2,UDINT#20,UDINT#15,UDINT#12,UDINT#111); + c := CONCAT_DT(ULINT#2000,ULINT#1,ULINT#2,ULINT#20,ULINT#15,ULINT#12,ULINT#111); + END_PROGRAM"; let sources = add_std!(src, "date_time_extra_functions.st"); let mut maintype = MainType::::default(); let _: i64 = compile_and_run(sources, &mut maintype); @@ -267,16 +267,16 @@ fn concat_dt_unsigned_ints() { #[test] fn concat_ldt_signed_ints() { let src = " - PROGRAM main - VAR - a : LDT; - b : LDT; - c : LDT; - END_VAR - a := CONCAT_LDT(INT#2000,SINT#1,SINT#2,SINT#20,SINT#15,SINT#12,SINT#111); - b := CONCAT_LDT(DINT#2000,DINT#1,DINT#2,DINT#20,DINT#15,DINT#12,DINT#111); - c := CONCAT_LDT(LINT#2000,LINT#1,LINT#2,LINT#20,LINT#15,LINT#12,LINT#111); - END_PROGRAM"; + PROGRAM main + VAR + a : LDT; + b : LDT; + c : LDT; + END_VAR + a := CONCAT_LDT(INT#2000,SINT#1,SINT#2,SINT#20,SINT#15,SINT#12,SINT#111); + b := CONCAT_LDT(DINT#2000,DINT#1,DINT#2,DINT#20,DINT#15,DINT#12,DINT#111); + c := CONCAT_LDT(LINT#2000,LINT#1,LINT#2,LINT#20,LINT#15,LINT#12,LINT#111); + END_PROGRAM"; let sources = add_std!(src, "date_time_extra_functions.st"); let mut maintype = MainType::::default(); let _: i64 = compile_and_run(sources, &mut maintype); @@ -293,16 +293,16 @@ fn concat_ldt_signed_ints() { #[test] fn concat_ldt_unsigned_ints() { let src = " - PROGRAM main - VAR - a : LDT; - b : LDT; - c : LDT; - END_VAR - a := CONCAT_LDT(UINT#2000,USINT#1,USINT#2,USINT#20,USINT#15,USINT#12,USINT#111); - b := CONCAT_LDT(UDINT#2000,UDINT#1,UDINT#2,UDINT#20,UDINT#15,UDINT#12,UDINT#111); - c := CONCAT_LDT(ULINT#2000,ULINT#1,ULINT#2,ULINT#20,ULINT#15,ULINT#12,ULINT#111); - END_PROGRAM"; + PROGRAM main + VAR + a : LDT; + b : LDT; + c : LDT; + END_VAR + a := CONCAT_LDT(UINT#2000,USINT#1,USINT#2,USINT#20,USINT#15,USINT#12,USINT#111); + b := CONCAT_LDT(UDINT#2000,UDINT#1,UDINT#2,UDINT#20,UDINT#15,UDINT#12,UDINT#111); + c := CONCAT_LDT(ULINT#2000,ULINT#1,ULINT#2,ULINT#20,ULINT#15,ULINT#12,ULINT#111); + END_PROGRAM"; let sources = add_std!(src, "date_time_extra_functions.st"); let mut maintype = MainType::::default(); let _: i64 = compile_and_run(sources, &mut maintype); @@ -319,14 +319,14 @@ fn concat_ldt_unsigned_ints() { #[test] fn split_date_int() { let src = " - PROGRAM main - VAR - a : INT; // year - b : INT; // month - c : INT; // day - END_VAR - SPLIT_DATE(DATE#2000-01-02, a, b, c); - END_PROGRAM"; + PROGRAM main + VAR + a : INT; // year + b : INT; // month + c : INT; // day + END_VAR + SPLIT_DATE(DATE#2000-01-02, a, b, c); + END_PROGRAM"; let sources = add_std!(src, "date_time_extra_functions.st"); let mut maintype = MainType::::default(); let _: i64 = compile_and_run(sources, &mut maintype); @@ -338,14 +338,14 @@ fn split_date_int() { #[test] fn split_date_uint() { let src = " - PROGRAM main - VAR - a : UINT; // year - b : UINT; // month - c : UINT; // day - END_VAR - SPLIT_DATE(DATE#2000-01-02, a, b, c); - END_PROGRAM"; + PROGRAM main + VAR + a : UINT; // year + b : UINT; // month + c : UINT; // day + END_VAR + SPLIT_DATE(DATE#2000-01-02, a, b, c); + END_PROGRAM"; let sources = add_std!(src, "date_time_extra_functions.st"); let mut maintype = MainType::::default(); let _: i64 = compile_and_run(sources, &mut maintype); @@ -357,14 +357,14 @@ fn split_date_uint() { #[test] fn split_date_dint() { let src = " - PROGRAM main - VAR - a : DINT; // year - b : DINT; // month - c : DINT; // day - END_VAR - SPLIT_DATE(DATE#2000-01-02, a, b, c); - END_PROGRAM"; + PROGRAM main + VAR + a : DINT; // year + b : DINT; // month + c : DINT; // day + END_VAR + SPLIT_DATE(DATE#2000-01-02, a, b, c); + END_PROGRAM"; let sources = add_std!(src, "date_time_extra_functions.st"); let mut maintype = MainType::::default(); let _: i64 = compile_and_run(sources, &mut maintype); @@ -376,14 +376,14 @@ fn split_date_dint() { #[test] fn split_date_udint() { let src = " - PROGRAM main - VAR - a : UDINT; // year - b : UDINT; // month - c : UDINT; // day - END_VAR - SPLIT_DATE(DATE#2000-01-02, a, b, c); - END_PROGRAM"; + PROGRAM main + VAR + a : UDINT; // year + b : UDINT; // month + c : UDINT; // day + END_VAR + SPLIT_DATE(DATE#2000-01-02, a, b, c); + END_PROGRAM"; let sources = add_std!(src, "date_time_extra_functions.st"); let mut maintype = MainType::::default(); let _: i64 = compile_and_run(sources, &mut maintype); @@ -395,14 +395,14 @@ fn split_date_udint() { #[test] fn split_date_lint() { let src = " - PROGRAM main - VAR - a : LINT; // year - b : LINT; // month - c : LINT; // day - END_VAR - SPLIT_DATE(DATE#2000-01-02, a, b, c); - END_PROGRAM"; + PROGRAM main + VAR + a : LINT; // year + b : LINT; // month + c : LINT; // day + END_VAR + SPLIT_DATE(DATE#2000-01-02, a, b, c); + END_PROGRAM"; let sources = add_std!(src, "date_time_extra_functions.st"); let mut maintype = MainType::::default(); let _: i64 = compile_and_run(sources, &mut maintype); @@ -414,14 +414,14 @@ fn split_date_lint() { #[test] fn split_date_ulint() { let src = " - PROGRAM main - VAR - a : ULINT; // year - b : ULINT; // month - c : ULINT; // day - END_VAR - SPLIT_DATE(DATE#2000-01-02, a, b, c); - END_PROGRAM"; + PROGRAM main + VAR + a : ULINT; // year + b : ULINT; // month + c : ULINT; // day + END_VAR + SPLIT_DATE(DATE#2000-01-02, a, b, c); + END_PROGRAM"; let sources = add_std!(src, "date_time_extra_functions.st"); let mut maintype = MainType::::default(); let _: i64 = compile_and_run(sources, &mut maintype); @@ -433,15 +433,15 @@ fn split_date_ulint() { #[test] fn split_tod_int() { let src = " - PROGRAM main - VAR - a : INT; // hour - b : INT; // minute - c : INT; // second - d : INT; // millisecond - END_VAR - SPLIT_TOD(TOD#14:12:03.123, a, b, c, d); - END_PROGRAM"; + PROGRAM main + VAR + a : INT; // hour + b : INT; // minute + c : INT; // second + d : INT; // millisecond + END_VAR + SPLIT_TOD(TOD#14:12:03.123, a, b, c, d); + END_PROGRAM"; let sources = add_std!(src, "date_time_extra_functions.st"); let mut maintype = MainType::::default(); let _: i64 = compile_and_run(sources, &mut maintype); @@ -454,15 +454,15 @@ fn split_tod_int() { #[test] fn split_tod_uint() { let src = " - PROGRAM main - VAR - a : UINT; // hour - b : UINT; // minute - c : UINT; // second - d : UINT; // millisecond - END_VAR - SPLIT_TOD(TOD#14:12:03.123, a, b, c, d); - END_PROGRAM"; + PROGRAM main + VAR + a : UINT; // hour + b : UINT; // minute + c : UINT; // second + d : UINT; // millisecond + END_VAR + SPLIT_TOD(TOD#14:12:03.123, a, b, c, d); + END_PROGRAM"; let sources = add_std!(src, "date_time_extra_functions.st"); let mut maintype = MainType::::default(); let _: i64 = compile_and_run(sources, &mut maintype); @@ -475,15 +475,15 @@ fn split_tod_uint() { #[test] fn split_tod_dint() { let src = " - PROGRAM main - VAR - a : DINT; // hour - b : DINT; // minute - c : DINT; // second - d : DINT; // millisecond - END_VAR - SPLIT_TOD(TOD#14:12:03.123, a, b, c, d); - END_PROGRAM"; + PROGRAM main + VAR + a : DINT; // hour + b : DINT; // minute + c : DINT; // second + d : DINT; // millisecond + END_VAR + SPLIT_TOD(TOD#14:12:03.123, a, b, c, d); + END_PROGRAM"; let sources = add_std!(src, "date_time_extra_functions.st"); let mut maintype = MainType::::default(); let _: i64 = compile_and_run(sources, &mut maintype); @@ -496,15 +496,15 @@ fn split_tod_dint() { #[test] fn split_tod_udint() { let src = " - PROGRAM main - VAR - a : UDINT; // hour - b : UDINT; // minute - c : UDINT; // second - d : UDINT; // millisecond - END_VAR - SPLIT_TOD(TOD#14:12:03.123, a, b, c, d); - END_PROGRAM"; + PROGRAM main + VAR + a : UDINT; // hour + b : UDINT; // minute + c : UDINT; // second + d : UDINT; // millisecond + END_VAR + SPLIT_TOD(TOD#14:12:03.123, a, b, c, d); + END_PROGRAM"; let sources = add_std!(src, "date_time_extra_functions.st"); let mut maintype = MainType::::default(); let _: i64 = compile_and_run(sources, &mut maintype); @@ -517,15 +517,15 @@ fn split_tod_udint() { #[test] fn split_tod_lint() { let src = " - PROGRAM main - VAR - a : LINT; // hour - b : LINT; // minute - c : LINT; // second - d : LINT; // millisecond - END_VAR - SPLIT_TOD(TOD#14:12:03.123, a, b, c, d); - END_PROGRAM"; + PROGRAM main + VAR + a : LINT; // hour + b : LINT; // minute + c : LINT; // second + d : LINT; // millisecond + END_VAR + SPLIT_TOD(TOD#14:12:03.123, a, b, c, d); + END_PROGRAM"; let sources = add_std!(src, "date_time_extra_functions.st"); let mut maintype = MainType::::default(); let _: i64 = compile_and_run(sources, &mut maintype); @@ -538,15 +538,15 @@ fn split_tod_lint() { #[test] fn split_tod_ulint() { let src = " - PROGRAM main - VAR - a : ULINT; // hour - b : ULINT; // minute - c : ULINT; // second - d : ULINT; // millisecond - END_VAR - SPLIT_TOD(TOD#14:12:03.123, a, b, c, d); - END_PROGRAM"; + PROGRAM main + VAR + a : ULINT; // hour + b : ULINT; // minute + c : ULINT; // second + d : ULINT; // millisecond + END_VAR + SPLIT_TOD(TOD#14:12:03.123, a, b, c, d); + END_PROGRAM"; let sources = add_std!(src, "date_time_extra_functions.st"); let mut maintype = MainType::::default(); let _: i64 = compile_and_run(sources, &mut maintype); @@ -559,15 +559,15 @@ fn split_tod_ulint() { #[test] fn split_ltod_int() { let src = " - PROGRAM main - VAR - a : INT; // hour - b : INT; // minute - c : INT; // second - d : INT; // millisecond - END_VAR - SPLIT_TOD(LTOD#14:12:03.123, a, b, c, d); - END_PROGRAM"; + PROGRAM main + VAR + a : INT; // hour + b : INT; // minute + c : INT; // second + d : INT; // millisecond + END_VAR + SPLIT_TOD(LTOD#14:12:03.123, a, b, c, d); + END_PROGRAM"; let sources = add_std!(src, "date_time_extra_functions.st"); let mut maintype = MainType::::default(); let _: i64 = compile_and_run(sources, &mut maintype); @@ -580,15 +580,15 @@ fn split_ltod_int() { #[test] fn split_ltod_uint() { let src = " - PROGRAM main - VAR - a : UINT; // hour - b : UINT; // minute - c : UINT; // second - d : UINT; // millisecond - END_VAR - SPLIT_TOD(LTOD#14:12:03.123, a, b, c, d); - END_PROGRAM"; + PROGRAM main + VAR + a : UINT; // hour + b : UINT; // minute + c : UINT; // second + d : UINT; // millisecond + END_VAR + SPLIT_TOD(LTOD#14:12:03.123, a, b, c, d); + END_PROGRAM"; let sources = add_std!(src, "date_time_extra_functions.st"); let mut maintype = MainType::::default(); let _: i64 = compile_and_run(sources, &mut maintype); @@ -601,15 +601,15 @@ fn split_ltod_uint() { #[test] fn split_ltod_dint() { let src = " - PROGRAM main - VAR - a : DINT; // hour - b : DINT; // minute - c : DINT; // second - d : DINT; // millisecond - END_VAR - SPLIT_TOD(LTOD#14:12:03.123, a, b, c, d); - END_PROGRAM"; + PROGRAM main + VAR + a : DINT; // hour + b : DINT; // minute + c : DINT; // second + d : DINT; // millisecond + END_VAR + SPLIT_TOD(LTOD#14:12:03.123, a, b, c, d); + END_PROGRAM"; let sources = add_std!(src, "date_time_extra_functions.st"); let mut maintype = MainType::::default(); let _: i64 = compile_and_run(sources, &mut maintype); @@ -622,15 +622,15 @@ fn split_ltod_dint() { #[test] fn split_ltod_udint() { let src = " - PROGRAM main - VAR - a : UDINT; // hour - b : UDINT; // minute - c : UDINT; // second - d : UDINT; // millisecond - END_VAR - SPLIT_TOD(LTOD#14:12:03.123, a, b, c, d); - END_PROGRAM"; + PROGRAM main + VAR + a : UDINT; // hour + b : UDINT; // minute + c : UDINT; // second + d : UDINT; // millisecond + END_VAR + SPLIT_TOD(LTOD#14:12:03.123, a, b, c, d); + END_PROGRAM"; let sources = add_std!(src, "date_time_extra_functions.st"); let mut maintype = MainType::::default(); let _: i64 = compile_and_run(sources, &mut maintype); @@ -643,15 +643,15 @@ fn split_ltod_udint() { #[test] fn split_ltod_lint() { let src = " - PROGRAM main - VAR - a : LINT; // hour - b : LINT; // minute - c : LINT; // second - d : LINT; // millisecond - END_VAR - SPLIT_TOD(LTOD#14:12:03.123, a, b, c, d); - END_PROGRAM"; + PROGRAM main + VAR + a : LINT; // hour + b : LINT; // minute + c : LINT; // second + d : LINT; // millisecond + END_VAR + SPLIT_TOD(LTOD#14:12:03.123, a, b, c, d); + END_PROGRAM"; let sources = add_std!(src, "date_time_extra_functions.st"); let mut maintype = MainType::::default(); let _: i64 = compile_and_run(sources, &mut maintype); @@ -664,15 +664,15 @@ fn split_ltod_lint() { #[test] fn split_ltod_ulint() { let src = " - PROGRAM main - VAR - a : ULINT; // hour - b : ULINT; // minute - c : ULINT; // second - d : ULINT; // millisecond - END_VAR - SPLIT_TOD(LTOD#14:12:03.123, a, b, c, d); - END_PROGRAM"; + PROGRAM main + VAR + a : ULINT; // hour + b : ULINT; // minute + c : ULINT; // second + d : ULINT; // millisecond + END_VAR + SPLIT_TOD(LTOD#14:12:03.123, a, b, c, d); + END_PROGRAM"; let sources = add_std!(src, "date_time_extra_functions.st"); let mut maintype = MainType::::default(); let _: i64 = compile_and_run(sources, &mut maintype); @@ -685,18 +685,18 @@ fn split_ltod_ulint() { #[test] fn split_dt_int() { let src = " - PROGRAM main - VAR - a : INT; // year - b : INT; // month - c : INT; // day - d : INT; // hour - e : INT; // minute - f : INT; // second - g : INT; // millisecond - END_VAR - SPLIT_DT(DT#2000-01-02-14:12:03.123, a, b, c, d, e, f, g); - END_PROGRAM"; + PROGRAM main + VAR + a : INT; // year + b : INT; // month + c : INT; // day + d : INT; // hour + e : INT; // minute + f : INT; // second + g : INT; // millisecond + END_VAR + SPLIT_DT(DT#2000-01-02-14:12:03.123, a, b, c, d, e, f, g); + END_PROGRAM"; let sources = add_std!(src, "date_time_extra_functions.st"); let mut maintype = MainType::::default(); let _: i64 = compile_and_run(sources, &mut maintype); @@ -712,18 +712,18 @@ fn split_dt_int() { #[test] fn split_dt_uint() { let src = " - PROGRAM main - VAR - a : UINT; // year - b : UINT; // month - c : UINT; // day - d : UINT; // hour - e : UINT; // minute - f : UINT; // second - g : UINT; // millisecond - END_VAR - SPLIT_DT(DT#2000-01-02-14:12:03.123, a, b, c, d, e, f, g); - END_PROGRAM"; + PROGRAM main + VAR + a : UINT; // year + b : UINT; // month + c : UINT; // day + d : UINT; // hour + e : UINT; // minute + f : UINT; // second + g : UINT; // millisecond + END_VAR + SPLIT_DT(DT#2000-01-02-14:12:03.123, a, b, c, d, e, f, g); + END_PROGRAM"; let sources = add_std!(src, "date_time_extra_functions.st"); let mut maintype = MainType::::default(); let _: i64 = compile_and_run(sources, &mut maintype); @@ -739,18 +739,18 @@ fn split_dt_uint() { #[test] fn split_dt_dint() { let src = " - PROGRAM main - VAR - a : DINT; // year - b : DINT; // month - c : DINT; // day - d : DINT; // hour - e : DINT; // minute - f : DINT; // second - g : DINT; // millisecond - END_VAR - SPLIT_DT(DT#2000-01-02-14:12:03.123, a, b, c, d, e, f, g); - END_PROGRAM"; + PROGRAM main + VAR + a : DINT; // year + b : DINT; // month + c : DINT; // day + d : DINT; // hour + e : DINT; // minute + f : DINT; // second + g : DINT; // millisecond + END_VAR + SPLIT_DT(DT#2000-01-02-14:12:03.123, a, b, c, d, e, f, g); + END_PROGRAM"; let sources = add_std!(src, "date_time_extra_functions.st"); let mut maintype = MainType::::default(); let _: i64 = compile_and_run(sources, &mut maintype); @@ -766,18 +766,18 @@ fn split_dt_dint() { #[test] fn split_dt_udint() { let src = " - PROGRAM main - VAR - a : UDINT; // year - b : UDINT; // month - c : UDINT; // day - d : UDINT; // hour - e : UDINT; // minute - f : UDINT; // second - g : UDINT; // millisecond - END_VAR - SPLIT_DT(DT#2000-01-02-14:12:03.123, a, b, c, d, e, f, g); - END_PROGRAM"; + PROGRAM main + VAR + a : UDINT; // year + b : UDINT; // month + c : UDINT; // day + d : UDINT; // hour + e : UDINT; // minute + f : UDINT; // second + g : UDINT; // millisecond + END_VAR + SPLIT_DT(DT#2000-01-02-14:12:03.123, a, b, c, d, e, f, g); + END_PROGRAM"; let sources = add_std!(src, "date_time_extra_functions.st"); let mut maintype = MainType::::default(); let _: i64 = compile_and_run(sources, &mut maintype); @@ -793,18 +793,18 @@ fn split_dt_udint() { #[test] fn split_dt_lint() { let src = " - PROGRAM main - VAR - a : LINT; // year - b : LINT; // month - c : LINT; // day - d : LINT; // hour - e : LINT; // minute - f : LINT; // second - g : LINT; // millisecond - END_VAR - SPLIT_DT(DT#2000-01-02-14:12:03.123, a, b, c, d, e, f, g); - END_PROGRAM"; + PROGRAM main + VAR + a : LINT; // year + b : LINT; // month + c : LINT; // day + d : LINT; // hour + e : LINT; // minute + f : LINT; // second + g : LINT; // millisecond + END_VAR + SPLIT_DT(DT#2000-01-02-14:12:03.123, a, b, c, d, e, f, g); + END_PROGRAM"; let sources = add_std!(src, "date_time_extra_functions.st"); let mut maintype = MainType::::default(); let _: i64 = compile_and_run(sources, &mut maintype); @@ -820,18 +820,18 @@ fn split_dt_lint() { #[test] fn split_dt_ulint() { let src = " - PROGRAM main - VAR - a : ULINT; // year - b : ULINT; // month - c : ULINT; // day - d : ULINT; // hour - e : ULINT; // minute - f : ULINT; // second - g : ULINT; // millisecond - END_VAR - SPLIT_DT(DT#2000-01-02-14:12:03.123, a, b, c, d, e, f, g); - END_PROGRAM"; + PROGRAM main + VAR + a : ULINT; // year + b : ULINT; // month + c : ULINT; // day + d : ULINT; // hour + e : ULINT; // minute + f : ULINT; // second + g : ULINT; // millisecond + END_VAR + SPLIT_DT(DT#2000-01-02-14:12:03.123, a, b, c, d, e, f, g); + END_PROGRAM"; let sources = add_std!(src, "date_time_extra_functions.st"); let mut maintype = MainType::::default(); let _: i64 = compile_and_run(sources, &mut maintype); @@ -847,18 +847,18 @@ fn split_dt_ulint() { #[test] fn split_ldt_int() { let src = " - PROGRAM main - VAR - a : INT; // year - b : INT; // month - c : INT; // day - d : INT; // hour - e : INT; // minute - f : INT; // second - g : INT; // millisecond - END_VAR - SPLIT_DT(LDT#2000-01-02-14:12:03.123, a, b, c, d, e, f, g); - END_PROGRAM"; + PROGRAM main + VAR + a : INT; // year + b : INT; // month + c : INT; // day + d : INT; // hour + e : INT; // minute + f : INT; // second + g : INT; // millisecond + END_VAR + SPLIT_DT(LDT#2000-01-02-14:12:03.123, a, b, c, d, e, f, g); + END_PROGRAM"; let sources = add_std!(src, "date_time_extra_functions.st"); let mut maintype = MainType::::default(); let _: i64 = compile_and_run(sources, &mut maintype); @@ -874,18 +874,18 @@ fn split_ldt_int() { #[test] fn split_ldt_uint() { let src = " - PROGRAM main - VAR - a : UINT; // year - b : UINT; // month - c : UINT; // day - d : UINT; // hour - e : UINT; // minute - f : UINT; // second - g : UINT; // millisecond - END_VAR - SPLIT_DT(LDT#2000-01-02-14:12:03.123, a, b, c, d, e, f, g); - END_PROGRAM"; + PROGRAM main + VAR + a : UINT; // year + b : UINT; // month + c : UINT; // day + d : UINT; // hour + e : UINT; // minute + f : UINT; // second + g : UINT; // millisecond + END_VAR + SPLIT_DT(LDT#2000-01-02-14:12:03.123, a, b, c, d, e, f, g); + END_PROGRAM"; let sources = add_std!(src, "date_time_extra_functions.st"); let mut maintype = MainType::::default(); let _: i64 = compile_and_run(sources, &mut maintype); @@ -901,18 +901,18 @@ fn split_ldt_uint() { #[test] fn split_ldt_dint() { let src = " - PROGRAM main - VAR - a : DINT; // year - b : DINT; // month - c : DINT; // day - d : DINT; // hour - e : DINT; // minute - f : DINT; // second - g : DINT; // millisecond - END_VAR - SPLIT_DT(LDT#2000-01-02-14:12:03.123, a, b, c, d, e, f, g); - END_PROGRAM"; + PROGRAM main + VAR + a : DINT; // year + b : DINT; // month + c : DINT; // day + d : DINT; // hour + e : DINT; // minute + f : DINT; // second + g : DINT; // millisecond + END_VAR + SPLIT_DT(LDT#2000-01-02-14:12:03.123, a, b, c, d, e, f, g); + END_PROGRAM"; let sources = add_std!(src, "date_time_extra_functions.st"); let mut maintype = MainType::::default(); let _: i64 = compile_and_run(sources, &mut maintype); @@ -928,18 +928,18 @@ fn split_ldt_dint() { #[test] fn split_ldt_udint() { let src = " - PROGRAM main - VAR - a : UDINT; // year - b : UDINT; // month - c : UDINT; // day - d : UDINT; // hour - e : UDINT; // minute - f : UDINT; // second - g : UDINT; // millisecond - END_VAR - SPLIT_DT(LDT#2000-01-02-14:12:03.123, a, b, c, d, e, f, g); - END_PROGRAM"; + PROGRAM main + VAR + a : UDINT; // year + b : UDINT; // month + c : UDINT; // day + d : UDINT; // hour + e : UDINT; // minute + f : UDINT; // second + g : UDINT; // millisecond + END_VAR + SPLIT_DT(LDT#2000-01-02-14:12:03.123, a, b, c, d, e, f, g); + END_PROGRAM"; let sources = add_std!(src, "date_time_extra_functions.st"); let mut maintype = MainType::::default(); let _: i64 = compile_and_run(sources, &mut maintype); @@ -955,18 +955,18 @@ fn split_ldt_udint() { #[test] fn split_ldt_lint() { let src = " - PROGRAM main - VAR - a : LINT; // year - b : LINT; // month - c : LINT; // day - d : LINT; // hour - e : LINT; // minute - f : LINT; // second - g : LINT; // millisecond - END_VAR - SPLIT_DT(LDT#2000-01-02-14:12:03.123, a, b, c, d, e, f, g); - END_PROGRAM"; + PROGRAM main + VAR + a : LINT; // year + b : LINT; // month + c : LINT; // day + d : LINT; // hour + e : LINT; // minute + f : LINT; // second + g : LINT; // millisecond + END_VAR + SPLIT_DT(LDT#2000-01-02-14:12:03.123, a, b, c, d, e, f, g); + END_PROGRAM"; let sources = add_std!(src, "date_time_extra_functions.st"); let mut maintype = MainType::::default(); let _: i64 = compile_and_run(sources, &mut maintype); @@ -982,18 +982,18 @@ fn split_ldt_lint() { #[test] fn split_ldt_ulint() { let src = " - PROGRAM main - VAR - a : ULINT; // year - b : ULINT; // month - c : ULINT; // day - d : ULINT; // hour - e : ULINT; // minute - f : ULINT; // second - g : ULINT; // millisecond - END_VAR - SPLIT_DT(LDT#2000-01-02-14:12:03.123, a, b, c, d, e, f, g); - END_PROGRAM"; + PROGRAM main + VAR + a : ULINT; // year + b : ULINT; // month + c : ULINT; // day + d : ULINT; // hour + e : ULINT; // minute + f : ULINT; // second + g : ULINT; // millisecond + END_VAR + SPLIT_DT(LDT#2000-01-02-14:12:03.123, a, b, c, d, e, f, g); + END_PROGRAM"; let sources = add_std!(src, "date_time_extra_functions.st"); let mut maintype = MainType::::default(); let _: i64 = compile_and_run(sources, &mut maintype); @@ -1009,16 +1009,16 @@ fn split_ldt_ulint() { #[test] fn day_of_week() { let src = " - PROGRAM main - VAR - a : SINT; - b : SINT; - c : SINT; - END_VAR - a := DAY_OF_WEEK(DATE#2022-06-14); // tuesday = 2 - b := DAY_OF_WEEK(DATE#2022-06-12); // sunday = 0 - c := DAY_OF_WEEK(DATE#2022-06-18); // saturday = 6 - END_PROGRAM"; + PROGRAM main + VAR + a : SINT; + b : SINT; + c : SINT; + END_VAR + a := DAY_OF_WEEK(DATE#2022-06-14); // tuesday = 2 + b := DAY_OF_WEEK(DATE#2022-06-12); // sunday = 0 + c := DAY_OF_WEEK(DATE#2022-06-18); // saturday = 6 + END_PROGRAM"; let sources = add_std!(src, "date_time_extra_functions.st"); let mut maintype = MainType::::default(); let _: i64 = compile_and_run(sources, &mut maintype); diff --git a/libs/stdlib/tests/date_time_numeric_functions_tests.rs b/libs/stdlib/tests/date_time_numeric_functions_tests.rs index 60841de260..2c40fdff06 100644 --- a/libs/stdlib/tests/date_time_numeric_functions_tests.rs +++ b/libs/stdlib/tests/date_time_numeric_functions_tests.rs @@ -28,19 +28,19 @@ fn get_time_from_hms_milli(hour: u32, min: u32, sec: u32, milli: u32) -> chrono: #[test] fn add_time() { let src = " - PROGRAM main - VAR - a : TIME; - b : TIME; - c : LTIME; - d : LTIME; - END_VAR - a := ADD(TIME#5h,TIME#30s); - b := ADD_TIME(TIME#10s,TIME#-5s); + PROGRAM main + VAR + a : TIME; + b : TIME; + c : LTIME; + d : LTIME; + END_VAR + a := ADD(TIME#5h,TIME#30s); + b := ADD_TIME(TIME#10s,TIME#-5s); - c := ADD(LTIME#-10s,LTIME#-10s); - d := ADD_LTIME(LTIME#10s,LTIME#10s); - END_PROGRAM"; + c := ADD(LTIME#-10s,LTIME#-10s); + d := ADD_LTIME(LTIME#10s,LTIME#10s); + END_PROGRAM"; let sources = add_std!(src, "date_time_numeric_functions.st"); let mut maintype = MainType::default(); let _: i64 = compile_and_run(sources, &mut maintype); @@ -54,18 +54,18 @@ fn add_time() { #[test] fn add_tod_time() { let src = " - PROGRAM main - VAR - a : TOD; - b : TOD; - c : LTOD; - d : LTOD; - END_VAR - a := ADD_TOD_TIME(TOD#20:00:00, TIME#1s); - b := ADD(TOD#20:00:02, TIME#-1s); - c := ADD_LTOD_LTIME(LTOD#12:00:00, LTIME#12m12s); - d := ADD(LTOD#12:00:00, LTIME#12m12s); - END_PROGRAM"; + PROGRAM main + VAR + a : TOD; + b : TOD; + c : LTOD; + d : LTOD; + END_VAR + a := ADD_TOD_TIME(TOD#20:00:00, TIME#1s); + b := ADD(TOD#20:00:02, TIME#-1s); + c := ADD_LTOD_LTIME(LTOD#12:00:00, LTIME#12m12s); + d := ADD(LTOD#12:00:00, LTIME#12m12s); + END_PROGRAM"; let sources = add_std!(src, "date_time_numeric_functions.st"); let mut maintype = MainType::default(); let _: i64 = compile_and_run(sources, &mut maintype); @@ -80,18 +80,18 @@ fn add_tod_time() { #[test] fn add_dt_time() { let src = " - PROGRAM main - VAR - a : DT; - b : DT; - c : LDT; - d : LDT; - END_VAR - a := ADD_DT_TIME(DT#2000-01-01-12:00:00, TIME#1d12m12s123ms); - b := ADD(DT#2000-01-01-12:00:00, TIME#1d12m12s123ms); - c := ADD_LDT_LTIME(LDT#2000-01-01-12:00:00, LTIME#1d12m12s123ms); - d := ADD(LDT#2000-01-01-12:00:00, LTIME#1d12m12s123ms); - END_PROGRAM"; + PROGRAM main + VAR + a : DT; + b : DT; + c : LDT; + d : LDT; + END_VAR + a := ADD_DT_TIME(DT#2000-01-01-12:00:00, TIME#1d12m12s123ms); + b := ADD(DT#2000-01-01-12:00:00, TIME#1d12m12s123ms); + c := ADD_LDT_LTIME(LDT#2000-01-01-12:00:00, LTIME#1d12m12s123ms); + d := ADD(LDT#2000-01-01-12:00:00, LTIME#1d12m12s123ms); + END_PROGRAM"; let sources = add_std!(src, "date_time_numeric_functions.st"); let mut maintype = MainType::default(); let _: i64 = compile_and_run(sources, &mut maintype); @@ -111,12 +111,12 @@ fn add_dt_time() { #[cfg_attr(target_arch = "aarch64", ignore = "https://github.com/PLC-lang/rusty/pull/960")] fn add_overflow() { let src = " - PROGRAM main - VAR - a : TIME; - END_VAR - a := ADD(TIME#9223372036854775807ms, TIME#1ms); - END_PROGRAM"; + PROGRAM main + VAR + a : TIME; + END_VAR + a := ADD(TIME#9223372036854775807ms, TIME#1ms); + END_PROGRAM"; let sources = add_std!(src, "date_time_numeric_functions.st"); let mut maintype = MainType::default(); let _: i64 = compile_and_run(sources, &mut maintype); @@ -125,19 +125,19 @@ fn add_overflow() { #[test] fn sub_time() { let src = " - PROGRAM main - VAR - a : TIME; - b : TIME; - c : LTIME; - d : LTIME; - END_VAR - a := SUB(TIME#10h50m, TIME#-10m); - b := SUB_TIME(TIME#5h35m20s, TIME#1h5m20s); + PROGRAM main + VAR + a : TIME; + b : TIME; + c : LTIME; + d : LTIME; + END_VAR + a := SUB(TIME#10h50m, TIME#-10m); + b := SUB_TIME(TIME#5h35m20s, TIME#1h5m20s); - c := SUB(LTIME#10h50m, LTIME#6h20m); - d := SUB_LTIME(LTIME#5h35m20s, LTIME#1h5m20s); - END_PROGRAM"; + c := SUB(LTIME#10h50m, LTIME#6h20m); + d := SUB_LTIME(LTIME#5h35m20s, LTIME#1h5m20s); + END_PROGRAM"; let sources = add_std!(src, "date_time_numeric_functions.st"); let mut maintype = MainType::default(); let _: i64 = compile_and_run(sources, &mut maintype); @@ -151,19 +151,19 @@ fn sub_time() { #[test] fn sub_date() { let src = " - PROGRAM main - VAR - a : TIME; - b : TIME; - c : LTIME; - d : LTIME; - END_VAR - a := SUB(DATE#2000-12-31, DATE#2000-01-01); - b := SUB_DATE_DATE(DATE#2000-05-21, DATE#2000-05-01); - - c := SUB(LDATE#2000-12-31, LDATE#2000-01-01); - d := SUB_LDATE_LDATE(LDATE#2000-05-21, LDATE#2000-05-01); - END_PROGRAM"; + PROGRAM main + VAR + a : TIME; + b : TIME; + c : LTIME; + d : LTIME; + END_VAR + a := SUB(DATE#2000-12-31, DATE#2000-01-01); + b := SUB_DATE_DATE(DATE#2000-05-21, DATE#2000-05-01); + + c := SUB(LDATE#2000-12-31, LDATE#2000-01-01); + d := SUB_LDATE_LDATE(LDATE#2000-05-21, LDATE#2000-05-01); + END_PROGRAM"; let sources = add_std!(src, "date_time_numeric_functions.st"); let mut maintype = MainType::default(); let _: i64 = compile_and_run(sources, &mut maintype); @@ -178,18 +178,18 @@ fn sub_date() { #[test] fn sub_tod_time() { let src = " - PROGRAM main - VAR - a : TOD; - b : TOD; - c : LTOD; - d : LTOD; - END_VAR - a := SUB_TOD_TIME(TOD#23:10:05.123, TIME#3h10m5s123ms); - b := SUB(TOD#23:10:05.123, TIME#3h10m5s123ms); - c := SUB_LTOD_LTIME(LTOD#23:10:05.123, LTIME#3h10m5s123ms); - d := SUB(LTOD#23:10:05.123, LTIME#3h10m5s123ms); - END_PROGRAM"; + PROGRAM main + VAR + a : TOD; + b : TOD; + c : LTOD; + d : LTOD; + END_VAR + a := SUB_TOD_TIME(TOD#23:10:05.123, TIME#3h10m5s123ms); + b := SUB(TOD#23:10:05.123, TIME#3h10m5s123ms); + c := SUB_LTOD_LTIME(LTOD#23:10:05.123, LTIME#3h10m5s123ms); + d := SUB(LTOD#23:10:05.123, LTIME#3h10m5s123ms); + END_PROGRAM"; let sources = add_std!(src, "date_time_numeric_functions.st"); let mut maintype = MainType::default(); let _: i64 = compile_and_run(sources, &mut maintype); @@ -203,18 +203,18 @@ fn sub_tod_time() { #[test] fn sub_tod() { let src = " - PROGRAM main - VAR - a : TIME; - b : TIME; - c : LTIME; - d : LTIME; - END_VAR - a := SUB(TOD#23:10:05.123, TOD#3:10:05.123); - b := SUB_TOD_TOD(TOD#23:10:05.123, TOD#3:10:05.123); - c := SUB(LTOD#23:10:05.123, LTOD#3:10:05.123); - d := SUB_LTOD_LTOD(LTOD#23:10:05.123, LTOD#3:10:05.123); - END_PROGRAM"; + PROGRAM main + VAR + a : TIME; + b : TIME; + c : LTIME; + d : LTIME; + END_VAR + a := SUB(TOD#23:10:05.123, TOD#3:10:05.123); + b := SUB_TOD_TOD(TOD#23:10:05.123, TOD#3:10:05.123); + c := SUB(LTOD#23:10:05.123, LTOD#3:10:05.123); + d := SUB_LTOD_LTOD(LTOD#23:10:05.123, LTOD#3:10:05.123); + END_PROGRAM"; let sources = add_std!(src, "date_time_numeric_functions.st"); let mut maintype = MainType::default(); let _: i64 = compile_and_run(sources, &mut maintype); @@ -228,18 +228,18 @@ fn sub_tod() { #[test] fn sub_dt_time() { let src = " - PROGRAM main - VAR - a : DT; - b : DT; - c : LDT; - d : LDT; - END_VAR - a := SUB(DT#2000-01-02-21:15:12.345, TIME#1d1h15m12s345ms); - b := SUB_DT_TIME(DT#2000-01-02-21:15:12.345, TIME#1d1h15m12s345ms); - c := SUB(LDT#2000-01-02-21:15:12.345, LTIME#1d1h15m12s345ms); - d := SUB_LDT_LTIME(LDT#2000-01-02-21:15:12.345, LTIME#1d1h15m12s345ms); - END_PROGRAM"; + PROGRAM main + VAR + a : DT; + b : DT; + c : LDT; + d : LDT; + END_VAR + a := SUB(DT#2000-01-02-21:15:12.345, TIME#1d1h15m12s345ms); + b := SUB_DT_TIME(DT#2000-01-02-21:15:12.345, TIME#1d1h15m12s345ms); + c := SUB(LDT#2000-01-02-21:15:12.345, LTIME#1d1h15m12s345ms); + d := SUB_LDT_LTIME(LDT#2000-01-02-21:15:12.345, LTIME#1d1h15m12s345ms); + END_PROGRAM"; let sources = add_std!(src, "date_time_numeric_functions.st"); let mut maintype = MainType::default(); let _: i64 = compile_and_run(sources, &mut maintype); @@ -254,18 +254,18 @@ fn sub_dt_time() { #[test] fn sub_dt() { let src = " - PROGRAM main - VAR - a : TIME; - b : TIME; - c : LTIME; - d : LTIME; - END_VAR - a := SUB(DT#2000-01-02-21:22:33.444, DT#2000-01-01-10:00:00.000); - b := SUB_DT_DT(DT#2000-01-02-21:22:33.444, DT#2000-01-01-10:00:00.000); - c := SUB(LDT#2000-01-02-21:22:33.444, LDT#2000-01-01-10:00:00.000); - d := SUB_LDT_LDT(LDT#2000-01-02-21:22:33.444, LDT#2000-01-01-10:00:00.000); - END_PROGRAM"; + PROGRAM main + VAR + a : TIME; + b : TIME; + c : LTIME; + d : LTIME; + END_VAR + a := SUB(DT#2000-01-02-21:22:33.444, DT#2000-01-01-10:00:00.000); + b := SUB_DT_DT(DT#2000-01-02-21:22:33.444, DT#2000-01-01-10:00:00.000); + c := SUB(LDT#2000-01-02-21:22:33.444, LDT#2000-01-01-10:00:00.000); + d := SUB_LDT_LDT(LDT#2000-01-02-21:22:33.444, LDT#2000-01-01-10:00:00.000); + END_PROGRAM"; let sources = add_std!(src, "date_time_numeric_functions.st"); let mut maintype = MainType::default(); let _: i64 = compile_and_run(sources, &mut maintype); @@ -284,12 +284,12 @@ fn sub_dt() { #[cfg_attr(target_arch = "aarch64", ignore = "https://github.com/PLC-lang/rusty/pull/960")] fn sub_overflow() { let src = " - PROGRAM main - VAR - a : TIME; - END_VAR - a := SUB(TIME#-9223372036854775807ms, TIME#1ms); - END_PROGRAM"; + PROGRAM main + VAR + a : TIME; + END_VAR + a := SUB(TIME#-9223372036854775807ms, TIME#1ms); + END_PROGRAM"; let sources = add_std!(src, "date_time_numeric_functions.st"); let mut maintype = MainType::default(); let _: i64 = compile_and_run(sources, &mut maintype); @@ -298,18 +298,18 @@ fn sub_overflow() { #[test] fn mul_signed() { let src = " - PROGRAM main - VAR - a : TIME; - b : TIME; - c : LTIME; - d : LTIME; - END_VAR - a := MUL(TIME#1d, SINT#-120); - b := MUL(TIME#1s, INT#3600); - c := MUL(LTIME#1000ms, DINT#86400); - d := MUL(LTIME#1000ms, LINT#864000000); - END_PROGRAM"; + PROGRAM main + VAR + a : TIME; + b : TIME; + c : LTIME; + d : LTIME; + END_VAR + a := MUL(TIME#1d, SINT#-120); + b := MUL(TIME#1s, INT#3600); + c := MUL(LTIME#1000ms, DINT#86400); + d := MUL(LTIME#1000ms, LINT#864000000); + END_PROGRAM"; let sources = add_std!(src, "date_time_numeric_functions.st"); let mut maintype = MainType::default(); let _: i64 = compile_and_run(sources, &mut maintype); @@ -327,13 +327,13 @@ fn mul_signed() { #[cfg_attr(target_arch = "aarch64", ignore = "https://github.com/PLC-lang/rusty/pull/960")] fn mul_signed_overflow() { let src = " - PROGRAM main - VAR - a : TIME; - END_VAR - // overflow -> 0 will be returned - a := MUL(TIME#10ns, LINT#9223372036854775807); - END_PROGRAM"; + PROGRAM main + VAR + a : TIME; + END_VAR + // overflow -> 0 will be returned + a := MUL(TIME#10ns, LINT#9223372036854775807); + END_PROGRAM"; let sources = add_std!(src, "date_time_numeric_functions.st"); let mut maintype = MainType::default(); let _: i64 = compile_and_run(sources, &mut maintype); @@ -342,18 +342,18 @@ fn mul_signed_overflow() { #[test] fn mul_unsigned() { let src = " - PROGRAM main - VAR - a : TIME; - b : TIME; - c : LTIME; - d : LTIME; - END_VAR - a := MUL(TIME#-1d, USINT#120); - b := MUL(TIME#1s, UINT#3600); - c := MUL(LTIME#1000ms, UDINT#86400); - d := MUL(LTIME#1000ms, ULINT#864000000); - END_PROGRAM"; + PROGRAM main + VAR + a : TIME; + b : TIME; + c : LTIME; + d : LTIME; + END_VAR + a := MUL(TIME#-1d, USINT#120); + b := MUL(TIME#1s, UINT#3600); + c := MUL(LTIME#1000ms, UDINT#86400); + d := MUL(LTIME#1000ms, ULINT#864000000); + END_PROGRAM"; let sources = add_std!(src, "date_time_numeric_functions.st"); let mut maintype = MainType::default(); let _: i64 = compile_and_run(sources, &mut maintype); @@ -371,13 +371,13 @@ fn mul_unsigned() { #[cfg_attr(target_arch = "aarch64", ignore = "https://github.com/PLC-lang/rusty/pull/960")] fn mul_unsigned_overflow() { let src = " - PROGRAM main - VAR - a : TIME; - END_VAR - // overflow -> 0 will be returned - a := MUL(TIME#1ns, ULINT#9223372036854775808); - END_PROGRAM"; + PROGRAM main + VAR + a : TIME; + END_VAR + // overflow -> 0 will be returned + a := MUL(TIME#1ns, ULINT#9223372036854775808); + END_PROGRAM"; let sources = add_std!(src, "date_time_numeric_functions.st"); let mut maintype = MainType::default(); let _: i64 = compile_and_run(sources, &mut maintype); @@ -386,18 +386,18 @@ fn mul_unsigned_overflow() { #[test] fn mul_time_signed() { let src = " - PROGRAM main - VAR - a : TIME; - b : TIME; - c : TIME; - d : TIME; - END_VAR - a := MUL_TIME(TIME#1d, SINT#-120); - b := MUL_TIME(TIME#1s, INT#3600); - c := MUL_TIME(TIME#1000ms, DINT#86400); - d := MUL_TIME(TIME#1000ms, LINT#864000000); - END_PROGRAM"; + PROGRAM main + VAR + a : TIME; + b : TIME; + c : TIME; + d : TIME; + END_VAR + a := MUL_TIME(TIME#1d, SINT#-120); + b := MUL_TIME(TIME#1s, INT#3600); + c := MUL_TIME(TIME#1000ms, DINT#86400); + d := MUL_TIME(TIME#1000ms, LINT#864000000); + END_PROGRAM"; let sources = add_std!(src, "date_time_numeric_functions.st"); let mut maintype = MainType::default(); let _: i64 = compile_and_run(sources, &mut maintype); @@ -413,18 +413,18 @@ fn mul_time_signed() { #[test] fn mul_time_unsigned() { let src = " - PROGRAM main - VAR - a : TIME; - b : TIME; - c : TIME; - d : TIME; - END_VAR - a := MUL_TIME(TIME#-1d, USINT#120); - b := MUL_TIME(TIME#1s, UINT#3600); - c := MUL_TIME(TIME#1000ms, UDINT#86400); - d := MUL_TIME(TIME#1000ms, ULINT#864000000); - END_PROGRAM"; + PROGRAM main + VAR + a : TIME; + b : TIME; + c : TIME; + d : TIME; + END_VAR + a := MUL_TIME(TIME#-1d, USINT#120); + b := MUL_TIME(TIME#1s, UINT#3600); + c := MUL_TIME(TIME#1000ms, UDINT#86400); + d := MUL_TIME(TIME#1000ms, ULINT#864000000); + END_PROGRAM"; let sources = add_std!(src, "date_time_numeric_functions.st"); let mut maintype = MainType::default(); let _: i64 = compile_and_run(sources, &mut maintype); @@ -440,18 +440,18 @@ fn mul_time_unsigned() { #[test] fn mul_ltime_signed() { let src = " - PROGRAM main - VAR - a : LTIME; - b : LTIME; - c : LTIME; - d : LTIME; - END_VAR - a := MUL_LTIME(LTIME#1d, SINT#-120); - b := MUL_LTIME(LTIME#1s, INT#3600); - c := MUL_LTIME(LTIME#1000ms, DINT#86400); - d := MUL_LTIME(LTIME#1000ms, LINT#864000000); - END_PROGRAM"; + PROGRAM main + VAR + a : LTIME; + b : LTIME; + c : LTIME; + d : LTIME; + END_VAR + a := MUL_LTIME(LTIME#1d, SINT#-120); + b := MUL_LTIME(LTIME#1s, INT#3600); + c := MUL_LTIME(LTIME#1000ms, DINT#86400); + d := MUL_LTIME(LTIME#1000ms, LINT#864000000); + END_PROGRAM"; let sources = add_std!(src, "date_time_numeric_functions.st"); let mut maintype = MainType::default(); let _: i64 = compile_and_run(sources, &mut maintype); @@ -467,18 +467,18 @@ fn mul_ltime_signed() { #[test] fn mul_ltime_unsigned() { let src = " - PROGRAM main - VAR - a : LTIME; - b : LTIME; - c : LTIME; - d : LTIME; - END_VAR - a := MUL_LTIME(LTIME#-1d, USINT#120); - b := MUL_LTIME(LTIME#1s, UINT#3600); - c := MUL_LTIME(LTIME#1000ms, UDINT#86400); - d := MUL_LTIME(LTIME#1000ms, ULINT#864000000); - END_PROGRAM"; + PROGRAM main + VAR + a : LTIME; + b : LTIME; + c : LTIME; + d : LTIME; + END_VAR + a := MUL_LTIME(LTIME#-1d, USINT#120); + b := MUL_LTIME(LTIME#1s, UINT#3600); + c := MUL_LTIME(LTIME#1000ms, UDINT#86400); + d := MUL_LTIME(LTIME#1000ms, ULINT#864000000); + END_PROGRAM"; let sources = add_std!(src, "date_time_numeric_functions.st"); let mut maintype = MainType::default(); let _: i64 = compile_and_run(sources, &mut maintype); @@ -494,18 +494,18 @@ fn mul_ltime_unsigned() { #[test] fn div_signed() { let src = " - PROGRAM main - VAR - a : TIME; - b : TIME; - c : LTIME; - d : LTIME; - END_VAR - a := DIV(TIME#1m, SINT#60); - b := DIV(TIME#1h, INT#-3600); - c := DIV(LTIME#1d, DINT#86400); - d := DIV(LTIME#10000d, DINT#864000000); - END_PROGRAM"; + PROGRAM main + VAR + a : TIME; + b : TIME; + c : LTIME; + d : LTIME; + END_VAR + a := DIV(TIME#1m, SINT#60); + b := DIV(TIME#1h, INT#-3600); + c := DIV(LTIME#1d, DINT#86400); + d := DIV(LTIME#10000d, DINT#864000000); + END_PROGRAM"; let sources = add_std!(src, "date_time_numeric_functions.st"); let mut maintype = MainType::default(); let _: i64 = compile_and_run(sources, &mut maintype); @@ -519,18 +519,18 @@ fn div_signed() { #[test] fn div_unsigned() { let src = " - PROGRAM main - VAR - a : TIME; - b : TIME; - c : LTIME; - d : LTIME; - END_VAR - a := DIV(TIME#1m, USINT#60); - b := DIV(TIME#-1h, UINT#3600); - c := DIV(LTIME#1d, UDINT#86400); - d := DIV(LTIME#10000d, UDINT#864000000); - END_PROGRAM"; + PROGRAM main + VAR + a : TIME; + b : TIME; + c : LTIME; + d : LTIME; + END_VAR + a := DIV(TIME#1m, USINT#60); + b := DIV(TIME#-1h, UINT#3600); + c := DIV(LTIME#1d, UDINT#86400); + d := DIV(LTIME#10000d, UDINT#864000000); + END_PROGRAM"; let sources = add_std!(src, "date_time_numeric_functions.st"); let mut maintype = MainType::default(); let _: i64 = compile_and_run(sources, &mut maintype); @@ -546,12 +546,12 @@ fn div_unsigned() { #[cfg_attr(target_arch = "aarch64", ignore = "https://github.com/PLC-lang/rusty/pull/960")] fn div_by_zero() { let src = " - PROGRAM main - VAR - a : TIME; - END_VAR - a := DIV(TIME#1m, USINT#0); - END_PROGRAM"; + PROGRAM main + VAR + a : TIME; + END_VAR + a := DIV(TIME#1m, USINT#0); + END_PROGRAM"; let sources = add_std!(src, "date_time_numeric_functions.st"); let mut maintype = MainType::default(); let _: i64 = compile_and_run(sources, &mut maintype); @@ -560,18 +560,18 @@ fn div_by_zero() { #[test] fn div_time_signed() { let src = " - PROGRAM main - VAR - a : TIME; - b : TIME; - c : TIME; - d : TIME; - END_VAR - a := DIV_TIME(TIME#1m, SINT#60); - b := DIV_TIME(TIME#1h, INT#-3600); - c := DIV_TIME(TIME#1d, DINT#86400); - d := DIV_TIME(TIME#10000d, DINT#864000000); - END_PROGRAM"; + PROGRAM main + VAR + a : TIME; + b : TIME; + c : TIME; + d : TIME; + END_VAR + a := DIV_TIME(TIME#1m, SINT#60); + b := DIV_TIME(TIME#1h, INT#-3600); + c := DIV_TIME(TIME#1d, DINT#86400); + d := DIV_TIME(TIME#10000d, DINT#864000000); + END_PROGRAM"; let sources = add_std!(src, "date_time_numeric_functions.st"); let mut maintype = MainType::default(); let _: i64 = compile_and_run(sources, &mut maintype); @@ -585,18 +585,18 @@ fn div_time_signed() { #[test] fn div_time_unsigned() { let src = " - PROGRAM main - VAR - a : TIME; - b : TIME; - c : TIME; - d : TIME; - END_VAR - a := DIV_TIME(TIME#1m, USINT#60); - b := DIV_TIME(TIME#-1h, UINT#3600); - c := DIV_TIME(TIME#1d, UDINT#86400); - d := DIV_TIME(TIME#10000d, UDINT#864000000); - END_PROGRAM"; + PROGRAM main + VAR + a : TIME; + b : TIME; + c : TIME; + d : TIME; + END_VAR + a := DIV_TIME(TIME#1m, USINT#60); + b := DIV_TIME(TIME#-1h, UINT#3600); + c := DIV_TIME(TIME#1d, UDINT#86400); + d := DIV_TIME(TIME#10000d, UDINT#864000000); + END_PROGRAM"; let sources = add_std!(src, "date_time_numeric_functions.st"); let mut maintype = MainType::default(); let _: i64 = compile_and_run(sources, &mut maintype); @@ -610,18 +610,18 @@ fn div_time_unsigned() { #[test] fn div_ltime_signed() { let src = " - PROGRAM main - VAR - a : LTIME; - b : LTIME; - c : LTIME; - d : LTIME; - END_VAR - a := DIV_LTIME(LTIME#1m, SINT#60); - b := DIV_LTIME(LTIME#1h, INT#-3600); - c := DIV_LTIME(LTIME#1d, DINT#86400); - d := DIV_LTIME(LTIME#10000d, DINT#864000000); - END_PROGRAM"; + PROGRAM main + VAR + a : LTIME; + b : LTIME; + c : LTIME; + d : LTIME; + END_VAR + a := DIV_LTIME(LTIME#1m, SINT#60); + b := DIV_LTIME(LTIME#1h, INT#-3600); + c := DIV_LTIME(LTIME#1d, DINT#86400); + d := DIV_LTIME(LTIME#10000d, DINT#864000000); + END_PROGRAM"; let sources = add_std!(src, "date_time_numeric_functions.st"); let mut maintype = MainType::default(); let _: i64 = compile_and_run(sources, &mut maintype); @@ -635,18 +635,18 @@ fn div_ltime_signed() { #[test] fn div_ltime_unsigned() { let src = " - PROGRAM main - VAR - a : LTIME; - b : LTIME; - c : LTIME; - d : LTIME; - END_VAR - a := DIV_LTIME(LTIME#1m, USINT#60); - b := DIV_LTIME(LTIME#-1h, UINT#3600); - c := DIV_LTIME(LTIME#1d, UDINT#86400); - d := DIV_LTIME(LTIME#10000d, UDINT#864000000); - END_PROGRAM"; + PROGRAM main + VAR + a : LTIME; + b : LTIME; + c : LTIME; + d : LTIME; + END_VAR + a := DIV_LTIME(LTIME#1m, USINT#60); + b := DIV_LTIME(LTIME#-1h, UINT#3600); + c := DIV_LTIME(LTIME#1d, UDINT#86400); + d := DIV_LTIME(LTIME#10000d, UDINT#864000000); + END_PROGRAM"; let sources = add_std!(src, "date_time_numeric_functions.st"); let mut maintype = MainType::default(); let _: i64 = compile_and_run(sources, &mut maintype); @@ -660,16 +660,16 @@ fn div_ltime_unsigned() { #[test] fn mul_real() { let src = " - PROGRAM main - VAR - a : TIME; - b : LTIME; - c : TIME; - END_VAR - a := MUL(TIME#-2s700ms, REAL#3.14); - b := MUL(LTIME#2s700ms, REAL#3.14e5); - c := MUL(TIME#2s700ms, REAL#-3.14); - END_PROGRAM"; + PROGRAM main + VAR + a : TIME; + b : LTIME; + c : TIME; + END_VAR + a := MUL(TIME#-2s700ms, REAL#3.14); + b := MUL(LTIME#2s700ms, REAL#3.14e5); + c := MUL(TIME#2s700ms, REAL#-3.14); + END_PROGRAM"; let sources = add_std!(src, "date_time_numeric_functions.st"); let mut maintype = MainType::default(); let _: i64 = compile_and_run(sources, &mut maintype); @@ -692,12 +692,12 @@ fn mul_real() { #[cfg_attr(target_arch = "aarch64", ignore = "https://github.com/PLC-lang/rusty/pull/960")] fn mul_real_overflow() { let src = " - PROGRAM main - VAR - a : TIME; - END_VAR - a := MUL(TIME#-2s700ms, REAL#3.40282347e38); - END_PROGRAM"; + PROGRAM main + VAR + a : TIME; + END_VAR + a := MUL(TIME#-2s700ms, REAL#3.40282347e38); + END_PROGRAM"; let sources = add_std!(src, "date_time_numeric_functions.st"); let mut maintype = MainType::default(); let _: i64 = compile_and_run(sources, &mut maintype); @@ -706,16 +706,16 @@ fn mul_real_overflow() { #[test] fn mul_lreal() { let src = " - PROGRAM main - VAR - a : TIME; - b : LTIME; - c : TIME; - END_VAR - a := MUL(TIME#-2s700ms, LREAL#3.14); - b := MUL(LTIME#2s700ms, LREAL#3.14e5); - c := MUL(TIME#-2s700ms, LREAL#-3.14); - END_PROGRAM"; + PROGRAM main + VAR + a : TIME; + b : LTIME; + c : TIME; + END_VAR + a := MUL(TIME#-2s700ms, LREAL#3.14); + b := MUL(LTIME#2s700ms, LREAL#3.14e5); + c := MUL(TIME#-2s700ms, LREAL#-3.14); + END_PROGRAM"; let sources = add_std!(src, "date_time_numeric_functions.st"); let mut maintype = MainType::default(); let _: i64 = compile_and_run(sources, &mut maintype); @@ -744,12 +744,12 @@ fn mul_lreal() { #[cfg_attr(target_arch = "aarch64", ignore = "https://github.com/PLC-lang/rusty/pull/960")] fn mul_lreal_overflow() { let src = " - PROGRAM main - VAR - a : TIME; - END_VAR - a := MUL(TIME#-2s700ms, LREAL#3.40282347e38); - END_PROGRAM"; + PROGRAM main + VAR + a : TIME; + END_VAR + a := MUL(TIME#-2s700ms, LREAL#3.40282347e38); + END_PROGRAM"; let sources = add_std!(src, "date_time_numeric_functions.st"); let mut maintype = MainType::default(); let _: i64 = compile_and_run(sources, &mut maintype); @@ -758,14 +758,14 @@ fn mul_lreal_overflow() { #[test] fn mul_time() { let src = " - PROGRAM main - VAR - a : TIME; - b : TIME; - END_VAR - a := MUL_TIME(TIME#2s700ms, REAL#3.14); - b := MUL_TIME(TIME#2s700ms, LREAL#3.14e5); - END_PROGRAM"; + PROGRAM main + VAR + a : TIME; + b : TIME; + END_VAR + a := MUL_TIME(TIME#2s700ms, REAL#3.14); + b := MUL_TIME(TIME#2s700ms, LREAL#3.14e5); + END_PROGRAM"; let sources = add_std!(src, "date_time_numeric_functions.st"); let mut maintype = MainType::default(); let _: i64 = compile_and_run(sources, &mut maintype); @@ -783,14 +783,14 @@ fn mul_time() { #[test] fn mul_ltime() { let src = " - PROGRAM main - VAR - a : LTIME; - b : LTIME; - END_VAR - a := MUL_LTIME(LTIME#2s700ms, REAL#3.14); - b := MUL_LTIME(LTIME#2s700ms, LREAL#3.14e5); - END_PROGRAM"; + PROGRAM main + VAR + a : LTIME; + b : LTIME; + END_VAR + a := MUL_LTIME(LTIME#2s700ms, REAL#3.14); + b := MUL_LTIME(LTIME#2s700ms, LREAL#3.14e5); + END_PROGRAM"; let sources = add_std!(src, "date_time_numeric_functions.st"); let mut maintype = MainType::default(); let _: i64 = compile_and_run(sources, &mut maintype); @@ -809,14 +809,14 @@ fn mul_ltime() { #[test] fn div_real() { let src = " - PROGRAM main - VAR - a : TIME; - b : LTIME; - END_VAR - a := DIV(TIME#-8s478ms, REAL#3.14); - b := DIV(LTIME#847800s, REAL#3.14e5); - END_PROGRAM"; + PROGRAM main + VAR + a : TIME; + b : LTIME; + END_VAR + a := DIV(TIME#-8s478ms, REAL#3.14); + b := DIV(LTIME#847800s, REAL#3.14e5); + END_PROGRAM"; let sources = add_std!(src, "date_time_numeric_functions.st"); let mut maintype = MainType::default(); let _: i64 = compile_and_run(sources, &mut maintype); @@ -835,12 +835,12 @@ fn div_real() { #[cfg_attr(target_arch = "aarch64", ignore = "https://github.com/PLC-lang/rusty/pull/960")] fn div_real_by_zero() { let src = " - PROGRAM main - VAR - a : TIME; - END_VAR - a := DIV(TIME#-2s700ms, REAL#0.0); - END_PROGRAM"; + PROGRAM main + VAR + a : TIME; + END_VAR + a := DIV(TIME#-2s700ms, REAL#0.0); + END_PROGRAM"; let sources = add_std!(src, "date_time_numeric_functions.st"); let mut maintype = MainType::default(); let _: i64 = compile_and_run(sources, &mut maintype); @@ -849,14 +849,14 @@ fn div_real_by_zero() { #[test] fn div_lreal() { let src = " - PROGRAM main - VAR - a : TIME; - b : LTIME; - END_VAR - a := DIV(TIME#-8s478ms, LREAL#3.14); - b := DIV(LTIME#847800s, LREAL#3.14e5); - END_PROGRAM"; + PROGRAM main + VAR + a : TIME; + b : LTIME; + END_VAR + a := DIV(TIME#-8s478ms, LREAL#3.14); + b := DIV(LTIME#847800s, LREAL#3.14e5); + END_PROGRAM"; let sources = add_std!(src, "date_time_numeric_functions.st"); let mut maintype = MainType::default(); let _: i64 = compile_and_run(sources, &mut maintype); @@ -875,12 +875,12 @@ fn div_lreal() { #[cfg_attr(target_arch = "aarch64", ignore = "https://github.com/PLC-lang/rusty/pull/960")] fn div_lreal_by_zero() { let src = " - PROGRAM main - VAR - a : TIME; - END_VAR - a := DIV(TIME#-2s700ms, LREAL#0.0); - END_PROGRAM"; + PROGRAM main + VAR + a : TIME; + END_VAR + a := DIV(TIME#-2s700ms, LREAL#0.0); + END_PROGRAM"; let sources = add_std!(src, "date_time_numeric_functions.st"); let mut maintype = MainType::default(); let _: i64 = compile_and_run(sources, &mut maintype); @@ -889,14 +889,14 @@ fn div_lreal_by_zero() { #[test] fn div_time() { let src = " - PROGRAM main - VAR - a : TIME; - b : TIME; - END_VAR - a := DIV_TIME(TIME#8s478ms, REAL#3.14); - b := DIV_TIME(TIME#847800s, LREAL#3.14e5); - END_PROGRAM"; + PROGRAM main + VAR + a : TIME; + b : TIME; + END_VAR + a := DIV_TIME(TIME#8s478ms, REAL#3.14); + b := DIV_TIME(TIME#847800s, LREAL#3.14e5); + END_PROGRAM"; let sources = add_std!(src, "date_time_numeric_functions.st"); let mut maintype = MainType::default(); let _: i64 = compile_and_run(sources, &mut maintype); @@ -913,14 +913,14 @@ fn div_time() { #[test] fn div_ltime() { let src = " - PROGRAM main - VAR - a : LTIME; - b : LTIME; - END_VAR - a := DIV_LTIME(LTIME#8s478ms, REAL#3.14); - b := DIV_LTIME(LTIME#847800s, LREAL#3.14e5); - END_PROGRAM"; + PROGRAM main + VAR + a : LTIME; + b : LTIME; + END_VAR + a := DIV_LTIME(LTIME#8s478ms, REAL#3.14); + b := DIV_LTIME(LTIME#847800s, LREAL#3.14e5); + END_PROGRAM"; let sources = add_std!(src, "date_time_numeric_functions.st"); let mut maintype = MainType::default(); let _: i64 = compile_and_run(sources, &mut maintype); diff --git a/libs/stdlib/tests/endianness_conversion_functions_tests.rs b/libs/stdlib/tests/endianness_conversion_functions_tests.rs index 27521fc701..472c9959e3 100644 --- a/libs/stdlib/tests/endianness_conversion_functions_tests.rs +++ b/libs/stdlib/tests/endianness_conversion_functions_tests.rs @@ -12,7 +12,7 @@ const DURATION_NANOS: i64 = DURATION_MILLIS * 1000000; fn test_to_big_endian_int() { let src = r#"FUNCTION main : INT main := TO_BIG_ENDIAN(INT#16#1001); - END_FUNCTION + END_FUNCTION "#; let src = add_std!(src, "endianness_conversion_functions.st"); @@ -24,7 +24,7 @@ fn test_to_big_endian_int() { fn test_to_little_endian_int() { let src = r#"FUNCTION main : INT main := TO_LITTLE_ENDIAN(INT#16#1001); - END_FUNCTION + END_FUNCTION "#; let src = add_std!(src, "endianness_conversion_functions.st"); @@ -36,7 +36,7 @@ fn test_to_little_endian_int() { fn test_from_big_endian_int() { let src = r#"FUNCTION main : INT main := FROM_BIG_ENDIAN(INT#16#1001); - END_FUNCTION + END_FUNCTION "#; let src = add_std!(src, "endianness_conversion_functions.st"); @@ -48,7 +48,7 @@ fn test_from_big_endian_int() { fn test_from_little_endian_int() { let src = r#"FUNCTION main : INT main := FROM_LITTLE_ENDIAN(INT#16#1001); - END_FUNCTION + END_FUNCTION "#; let src = add_std!(src, "endianness_conversion_functions.st"); @@ -61,7 +61,7 @@ fn test_from_little_endian_int() { fn test_to_big_endian_dint() { let src = r#"FUNCTION main : DINT main := TO_BIG_ENDIAN(DINT#16#10010A0B); - END_FUNCTION + END_FUNCTION "#; let src = add_std!(src, "endianness_conversion_functions.st"); @@ -73,7 +73,7 @@ fn test_to_big_endian_dint() { fn test_to_little_endian_dint() { let src = r#"FUNCTION main : DINT main := TO_LITTLE_ENDIAN(DINT#16#10010A0B); - END_FUNCTION + END_FUNCTION "#; let src = add_std!(src, "endianness_conversion_functions.st"); @@ -85,7 +85,7 @@ fn test_to_little_endian_dint() { fn test_from_big_endian_dint() { let src = r#"FUNCTION main : DINT main := FROM_BIG_ENDIAN(DINT#16#10010A0B); - END_FUNCTION + END_FUNCTION "#; let src = add_std!(src, "endianness_conversion_functions.st"); @@ -97,7 +97,7 @@ fn test_from_big_endian_dint() { fn test_from_little_endian_dint() { let src = r#"FUNCTION main : DINT main := FROM_LITTLE_ENDIAN(DINT#16#10010A0B); - END_FUNCTION + END_FUNCTION "#; let src = add_std!(src, "endianness_conversion_functions.st"); @@ -110,7 +110,7 @@ fn test_from_little_endian_dint() { fn test_to_big_endian_lint() { let src = r#"FUNCTION main : LINT main := TO_BIG_ENDIAN(LINT#16#10010A0B10010A0B); - END_FUNCTION + END_FUNCTION "#; let src = add_std!(src, "endianness_conversion_functions.st"); @@ -122,7 +122,7 @@ fn test_to_big_endian_lint() { fn test_to_little_endian_lint() { let src = r#"FUNCTION main : LINT main := TO_LITTLE_ENDIAN(LINT#16#10010A0B10010A0B); - END_FUNCTION + END_FUNCTION "#; let src = add_std!(src, "endianness_conversion_functions.st"); @@ -134,7 +134,7 @@ fn test_to_little_endian_lint() { fn test_from_big_endian_lint() { let src = r#"FUNCTION main : LINT main := FROM_BIG_ENDIAN(LINT#16#10010A0B10010A0B); - END_FUNCTION + END_FUNCTION "#; let src = add_std!(src, "endianness_conversion_functions.st"); @@ -146,7 +146,7 @@ fn test_from_big_endian_lint() { fn test_from_little_endian_lint() { let src = r#"FUNCTION main : LINT main := FROM_LITTLE_ENDIAN(LINT#16#10010A0B10010A0B); - END_FUNCTION + END_FUNCTION "#; let src = add_std!(src, "endianness_conversion_functions.st"); @@ -159,7 +159,7 @@ fn test_from_little_endian_lint() { fn test_to_big_endian_uint() { let src = r#"FUNCTION main : UINT main := TO_BIG_ENDIAN(UINT#16#ABBA); - END_FUNCTION + END_FUNCTION "#; let src = add_std!(src, "endianness_conversion_functions.st"); @@ -171,7 +171,7 @@ fn test_to_big_endian_uint() { fn test_to_little_endian_uint() { let src = r#"FUNCTION main : UINT main := TO_LITTLE_ENDIAN(UINT#16#1001); - END_FUNCTION + END_FUNCTION "#; let src = add_std!(src, "endianness_conversion_functions.st"); @@ -183,7 +183,7 @@ fn test_to_little_endian_uint() { fn test_from_big_endian_uint() { let src = r#"FUNCTION main : UINT main := FROM_BIG_ENDIAN(UINT#16#1001); - END_FUNCTION + END_FUNCTION "#; let src = add_std!(src, "endianness_conversion_functions.st"); @@ -195,7 +195,7 @@ fn test_from_big_endian_uint() { fn test_from_little_endian_uint() { let src = r#"FUNCTION main : UINT main := FROM_LITTLE_ENDIAN(UINT#16#ABBA); - END_FUNCTION + END_FUNCTION "#; let src = add_std!(src, "endianness_conversion_functions.st"); @@ -208,7 +208,7 @@ fn test_from_little_endian_uint() { fn test_to_big_endian_udint() { let src = r#"FUNCTION main : UDINT main := TO_BIG_ENDIAN(UDINT#16#10010A0B); - END_FUNCTION + END_FUNCTION "#; let src = add_std!(src, "endianness_conversion_functions.st"); @@ -220,7 +220,7 @@ fn test_to_big_endian_udint() { fn test_to_little_endian_udint() { let src = r#"FUNCTION main : UDINT main := TO_LITTLE_ENDIAN(UDINT#16#10010A0B); - END_FUNCTION + END_FUNCTION "#; let src = add_std!(src, "endianness_conversion_functions.st"); @@ -232,7 +232,7 @@ fn test_to_little_endian_udint() { fn test_from_big_endian_udint() { let src = r#"FUNCTION main : UDINT main := FROM_BIG_ENDIAN(UDINT#16#10010A0B); - END_FUNCTION + END_FUNCTION "#; let src = add_std!(src, "endianness_conversion_functions.st"); @@ -244,7 +244,7 @@ fn test_from_big_endian_udint() { fn test_from_little_endian_udint() { let src = r#"FUNCTION main : UDINT main := FROM_LITTLE_ENDIAN(UDINT#16#10010A0B); - END_FUNCTION + END_FUNCTION "#; let src = add_std!(src, "endianness_conversion_functions.st"); @@ -257,7 +257,7 @@ fn test_from_little_endian_udint() { fn test_to_big_endian_ulint() { let src = r#"FUNCTION main : ULINT main := TO_BIG_ENDIAN(LINT#16#10010A0B10010A0B); - END_FUNCTION + END_FUNCTION "#; let src = add_std!(src, "endianness_conversion_functions.st"); @@ -269,7 +269,7 @@ fn test_to_big_endian_ulint() { fn test_to_little_endian_ulint() { let src = r#"FUNCTION main : ULINT main := TO_LITTLE_ENDIAN(LINT#16#10010A0B10010A0B); - END_FUNCTION + END_FUNCTION "#; let src = add_std!(src, "endianness_conversion_functions.st"); @@ -281,7 +281,7 @@ fn test_to_little_endian_ulint() { fn test_from_big_endian_ulint() { let src = r#"FUNCTION main : ULINT main := FROM_BIG_ENDIAN(LINT#16#10010A0B10010A0B); - END_FUNCTION + END_FUNCTION "#; let src = add_std!(src, "endianness_conversion_functions.st"); @@ -293,7 +293,7 @@ fn test_from_big_endian_ulint() { fn test_from_little_endian_ulint() { let src = r#"FUNCTION main : ULINT main := FROM_LITTLE_ENDIAN(LINT#16#10010A0B10010A0B); - END_FUNCTION + END_FUNCTION "#; let src = add_std!(src, "endianness_conversion_functions.st"); @@ -306,7 +306,7 @@ fn test_from_little_endian_ulint() { fn test_to_big_endian_f32() { let src = r#"FUNCTION main : REAL main := TO_BIG_ENDIAN(REAL#12.5); - END_FUNCTION + END_FUNCTION "#; let src = add_std!(src, "endianness_conversion_functions.st"); @@ -318,7 +318,7 @@ fn test_to_big_endian_f32() { fn test_to_little_endian_f32() { let src = r#"FUNCTION main : REAL main := TO_LITTLE_ENDIAN(REAL#12.5); - END_FUNCTION + END_FUNCTION "#; let src = add_std!(src, "endianness_conversion_functions.st"); @@ -330,7 +330,7 @@ fn test_to_little_endian_f32() { fn test_from_big_endian_f32() { let src = r#"FUNCTION main : REAL main := FROM_BIG_ENDIAN(REAL#12.5); - END_FUNCTION + END_FUNCTION "#; let src = add_std!(src, "endianness_conversion_functions.st"); @@ -342,7 +342,7 @@ fn test_from_big_endian_f32() { fn test_from_little_endian_f32() { let src = r#"FUNCTION main : REAL main := FROM_LITTLE_ENDIAN(REAL#12.5); - END_FUNCTION + END_FUNCTION "#; let src = add_std!(src, "endianness_conversion_functions.st"); @@ -355,7 +355,7 @@ fn test_from_little_endian_f32() { fn test_to_big_endian_f64() { let src = r#"FUNCTION main : LREAL main := TO_BIG_ENDIAN(LREAL#12.5); - END_FUNCTION + END_FUNCTION "#; let src = add_std!(src, "endianness_conversion_functions.st"); @@ -367,7 +367,7 @@ fn test_to_big_endian_f64() { fn test_to_little_endian_f64() { let src = r#"FUNCTION main : LREAL main := TO_LITTLE_ENDIAN(LREAL#12.5); - END_FUNCTION + END_FUNCTION "#; let src = add_std!(src, "endianness_conversion_functions.st"); @@ -379,7 +379,7 @@ fn test_to_little_endian_f64() { fn test_from_big_endian_f64() { let src = r#"FUNCTION main : LREAL main := FROM_BIG_ENDIAN(LREAL#12.5); - END_FUNCTION + END_FUNCTION "#; let src = add_std!(src, "endianness_conversion_functions.st"); @@ -391,7 +391,7 @@ fn test_from_big_endian_f64() { fn test_from_little_endian_f64() { let src = r#"FUNCTION main : LREAL main := FROM_LITTLE_ENDIAN(LREAL#12.5); - END_FUNCTION + END_FUNCTION "#; let src = add_std!(src, "endianness_conversion_functions.st"); @@ -404,7 +404,7 @@ fn test_from_little_endian_f64() { fn test_to_big_endian_word() { let src = r#"FUNCTION main : WORD main := TO_BIG_ENDIAN(WORD#16#ABBA); - END_FUNCTION + END_FUNCTION "#; let src = add_std!(src, "endianness_conversion_functions.st"); @@ -416,7 +416,7 @@ fn test_to_big_endian_word() { fn test_to_little_endian_word() { let src = r#"FUNCTION main : WORD main := TO_LITTLE_ENDIAN(WORD#16#1001); - END_FUNCTION + END_FUNCTION "#; let src = add_std!(src, "endianness_conversion_functions.st"); @@ -428,7 +428,7 @@ fn test_to_little_endian_word() { fn test_from_big_endian_word() { let src = r#"FUNCTION main : WORD main := FROM_BIG_ENDIAN(WORD#16#1001); - END_FUNCTION + END_FUNCTION "#; let src = add_std!(src, "endianness_conversion_functions.st"); @@ -440,7 +440,7 @@ fn test_from_big_endian_word() { fn test_from_little_endian_word() { let src = r#"FUNCTION main : WORD main := FROM_LITTLE_ENDIAN(WORD#16#ABBA); - END_FUNCTION + END_FUNCTION "#; let src = add_std!(src, "endianness_conversion_functions.st"); @@ -453,7 +453,7 @@ fn test_from_little_endian_word() { fn test_to_big_endian_dword() { let src = r#"FUNCTION main : UDINT main := TO_BIG_ENDIAN(UDINT#16#10010A0B); - END_FUNCTION + END_FUNCTION "#; let src = add_std!(src, "endianness_conversion_functions.st"); @@ -465,7 +465,7 @@ fn test_to_big_endian_dword() { fn test_to_little_endian_dword() { let src = r#"FUNCTION main : DWORD main := TO_LITTLE_ENDIAN(DWORD#16#10010A0B); - END_FUNCTION + END_FUNCTION "#; let src = add_std!(src, "endianness_conversion_functions.st"); @@ -477,7 +477,7 @@ fn test_to_little_endian_dword() { fn test_from_big_endian_dword() { let src = r#"FUNCTION main : DWORD main := FROM_BIG_ENDIAN(DWORD#16#10010A0B); - END_FUNCTION + END_FUNCTION "#; let src = add_std!(src, "endianness_conversion_functions.st"); @@ -489,7 +489,7 @@ fn test_from_big_endian_dword() { fn test_from_little_endian_dword() { let src = r#"FUNCTION main : DWORD main := FROM_LITTLE_ENDIAN(DWORD#16#10010A0B); - END_FUNCTION + END_FUNCTION "#; let src = add_std!(src, "endianness_conversion_functions.st"); @@ -502,7 +502,7 @@ fn test_from_little_endian_dword() { fn test_to_big_endian_lword() { let src = r#"FUNCTION main : LWORD main := TO_BIG_ENDIAN(LINT#16#10010A0B10010A0B); - END_FUNCTION + END_FUNCTION "#; let src = add_std!(src, "endianness_conversion_functions.st"); @@ -514,7 +514,7 @@ fn test_to_big_endian_lword() { fn test_to_little_endian_lword() { let src = r#"FUNCTION main : LWORD main := TO_LITTLE_ENDIAN(LINT#16#10010A0B10010A0B); - END_FUNCTION + END_FUNCTION "#; let src = add_std!(src, "endianness_conversion_functions.st"); @@ -526,7 +526,7 @@ fn test_to_little_endian_lword() { fn test_from_big_endian_lword() { let src = r#"FUNCTION main : LWORD main := FROM_BIG_ENDIAN(LINT#16#10010A0B10010A0B); - END_FUNCTION + END_FUNCTION "#; let src = add_std!(src, "endianness_conversion_functions.st"); @@ -538,7 +538,7 @@ fn test_from_big_endian_lword() { fn test_from_little_endian_lword() { let src = r#"FUNCTION main : LWORD main := FROM_LITTLE_ENDIAN(LINT#16#10010A0B10010A0B); - END_FUNCTION + END_FUNCTION "#; let src = add_std!(src, "endianness_conversion_functions.st"); @@ -551,7 +551,7 @@ fn test_from_little_endian_lword() { fn test_to_big_endian_wchar() { let src = r#"FUNCTION main : WCHAR main := TO_BIG_ENDIAN(WCHAR#'C'); - END_FUNCTION + END_FUNCTION "#; let src = add_std!(src, "endianness_conversion_functions.st"); @@ -563,7 +563,7 @@ fn test_to_big_endian_wchar() { fn test_to_little_endian_wchar() { let src = r#"FUNCTION main : WCHAR main := TO_LITTLE_ENDIAN(WCHAR#'C'); - END_FUNCTION + END_FUNCTION "#; let src = add_std!(src, "endianness_conversion_functions.st"); @@ -575,7 +575,7 @@ fn test_to_little_endian_wchar() { fn test_from_big_endian_wchar() { let src = r#"FUNCTION main : WCHAR main := FROM_BIG_ENDIAN(WCHAR#'C'); - END_FUNCTION + END_FUNCTION "#; let src = add_std!(src, "endianness_conversion_functions.st"); @@ -587,7 +587,7 @@ fn test_from_big_endian_wchar() { fn test_from_little_endian_wchar() { let src = r#"FUNCTION main : WCHAR main := FROM_LITTLE_ENDIAN(WCHAR#'C'); - END_FUNCTION + END_FUNCTION "#; let src = add_std!(src, "endianness_conversion_functions.st"); @@ -600,7 +600,7 @@ fn test_from_little_endian_wchar() { fn test_to_big_endian_date() { let src = r#"FUNCTION main : DATE main := TO_BIG_ENDIAN(DATE#1984-06-25); - END_FUNCTION + END_FUNCTION "#; let src = add_std!(src, "endianness_conversion_functions.st"); let res: i64 = compile_and_run_no_params(src); @@ -614,7 +614,7 @@ fn test_to_big_endian_date() { fn test_to_little_endian_date() { let src = r#"FUNCTION main : DATE main := TO_LITTLE_ENDIAN(DATE#1984-06-25); - END_FUNCTION + END_FUNCTION "#; let src = add_std!(src, "endianness_conversion_functions.st"); let res: i64 = compile_and_run_no_params(src); @@ -628,7 +628,7 @@ fn test_to_little_endian_date() { fn test_from_big_endian_date() { let src = r#"FUNCTION main : DATE main := FROM_BIG_ENDIAN(DATE#1984-06-25); - END_FUNCTION + END_FUNCTION "#; let src = add_std!(src, "endianness_conversion_functions.st"); let res: i64 = compile_and_run_no_params(src); @@ -644,7 +644,7 @@ fn test_from_big_endian_date() { fn test_from_little_endian_date() { let src = r#"FUNCTION main : DATE main := FROM_LITTLE_ENDIAN(DATE#1984-06-25); - END_FUNCTION + END_FUNCTION "#; let src = add_std!(src, "endianness_conversion_functions.st"); let res: i64 = compile_and_run_no_params(src); @@ -661,7 +661,7 @@ fn test_from_little_endian_date() { fn test_to_big_endian_tod() { let src = r#"FUNCTION main : TIME_OF_DAY main := TO_BIG_ENDIAN(TIME_OF_DAY#22:22:22); - END_FUNCTION + END_FUNCTION "#; let src = add_std!(src, "endianness_conversion_functions.st"); @@ -673,7 +673,7 @@ fn test_to_big_endian_tod() { fn test_to_little_endian_tod() { let src = r#"FUNCTION main : TIME_OF_DAY main := TO_LITTLE_ENDIAN(TIME_OF_DAY#22:22:22); - END_FUNCTION + END_FUNCTION "#; let src = add_std!(src, "endianness_conversion_functions.st"); @@ -685,7 +685,7 @@ fn test_to_little_endian_tod() { fn test_from_big_endian_tod() { let src = r#"FUNCTION main : TIME_OF_DAY main := FROM_BIG_ENDIAN(TIME_OF_DAY#22:22:22); - END_FUNCTION + END_FUNCTION "#; let src = add_std!(src, "endianness_conversion_functions.st"); @@ -697,7 +697,7 @@ fn test_from_big_endian_tod() { fn test_from_little_endian_tod() { let src = r#"FUNCTION main : TIME_OF_DAY main := FROM_LITTLE_ENDIAN(TIME_OF_DAY#22:22:22); - END_FUNCTION + END_FUNCTION "#; let src = add_std!(src, "endianness_conversion_functions.st"); @@ -710,7 +710,7 @@ fn test_from_little_endian_tod() { fn test_to_big_endian_dt() { let src = r#"FUNCTION main : DATE_AND_TIME main := TO_BIG_ENDIAN(DATE_AND_TIME#1984-06-25-00:00:00); - END_FUNCTION + END_FUNCTION "#; let src = add_std!(src, "endianness_conversion_functions.st"); @@ -725,7 +725,7 @@ fn test_to_big_endian_dt() { fn test_to_little_endian_dt() { let src = r#"FUNCTION main : DATE_AND_TIME main := TO_LITTLE_ENDIAN(DATE_AND_TIME#1984-06-25-00:00:00); - END_FUNCTION + END_FUNCTION "#; let src = add_std!(src, "endianness_conversion_functions.st"); @@ -740,7 +740,7 @@ fn test_to_little_endian_dt() { fn test_from_big_endian_dt() { let src = r#"FUNCTION main : DATE_AND_TIME main := FROM_BIG_ENDIAN(DATE_AND_TIME#1984-06-25-00:00:00); - END_FUNCTION + END_FUNCTION "#; let src = add_std!(src, "endianness_conversion_functions.st"); @@ -757,7 +757,7 @@ fn test_from_big_endian_dt() { fn test_from_little_endian_dt() { let src = r#"FUNCTION main : DATE_AND_TIME main := FROM_LITTLE_ENDIAN(DATE_AND_TIME#1984-06-25-00:00:00); - END_FUNCTION + END_FUNCTION "#; let src = add_std!(src, "endianness_conversion_functions.st"); @@ -776,7 +776,7 @@ fn test_from_little_endian_dt() { fn test_to_big_endian_ldate_nanos() { let src = r#"FUNCTION main : LDATE main := TO_BIG_ENDIAN(LDATE#1984-06-25); - END_FUNCTION + END_FUNCTION "#; let src = add_std!(src, "endianness_conversion_functions.st"); @@ -791,7 +791,7 @@ fn test_to_big_endian_ldate_nanos() { fn test_to_little_endian_ldate_nanos() { let src = r#"FUNCTION main : LDATE main := TO_LITTLE_ENDIAN(LDATE#1984-06-25); - END_FUNCTION + END_FUNCTION "#; let src = add_std!(src, "endianness_conversion_functions.st"); @@ -806,7 +806,7 @@ fn test_to_little_endian_ldate_nanos() { fn test_from_big_endian_ldate_nanos() { let src = r#"FUNCTION main : LDATE main := FROM_BIG_ENDIAN(LDATE#1984-06-25); - END_FUNCTION + END_FUNCTION "#; let src = add_std!(src, "endianness_conversion_functions.st"); @@ -823,7 +823,7 @@ fn test_from_big_endian_ldate_nanos() { fn test_from_little_endian_ldate_nanos() { let src = r#"FUNCTION main : LDATE main := FROM_LITTLE_ENDIAN(LDATE#1984-06-25); - END_FUNCTION + END_FUNCTION "#; let src = add_std!(src, "endianness_conversion_functions.st"); @@ -841,7 +841,7 @@ fn test_from_little_endian_ldate_nanos() { fn test_to_big_endian_ldt_nanos() { let src = r#"FUNCTION main : LDT main := TO_BIG_ENDIAN(LDT#1984-06-25-00:00:00); - END_FUNCTION + END_FUNCTION "#; let src = add_std!(src, "endianness_conversion_functions.st"); @@ -862,7 +862,7 @@ fn test_to_big_endian_ldt_nanos() { fn test_to_little_endian_ldt_nanos() { let src = r#"FUNCTION main : LDT main := TO_LITTLE_ENDIAN(LDT#1984-06-25-00:00:00); - END_FUNCTION + END_FUNCTION "#; let src = add_std!(src, "endianness_conversion_functions.st"); @@ -877,7 +877,7 @@ fn test_to_little_endian_ldt_nanos() { fn test_from_big_endian_nanos() { let src = r#"FUNCTION main : LDT main := FROM_BIG_ENDIAN(LDT#1984-06-25-00:00:00); - END_FUNCTION + END_FUNCTION "#; let src = add_std!(src, "endianness_conversion_functions.st"); @@ -894,7 +894,7 @@ fn test_from_big_endian_nanos() { fn test_from_little_endian_nanos() { let src = r#"FUNCTION main : LDT main := FROM_LITTLE_ENDIAN(LDT#1984-06-25-00:00:00); - END_FUNCTION + END_FUNCTION "#; let src = add_std!(src, "endianness_conversion_functions.st"); @@ -912,7 +912,7 @@ fn test_from_little_endian_nanos() { fn test_to_big_endian_ltod_nanos() { let src = r#"FUNCTION main : LTOD main := TO_BIG_ENDIAN(LTOD#22:22:22); - END_FUNCTION + END_FUNCTION "#; let src = add_std!(src, "endianness_conversion_functions.st"); @@ -924,7 +924,7 @@ fn test_to_big_endian_ltod_nanos() { fn test_to_little_endian_ltod_nanos() { let src = r#"FUNCTION main : LTOD main := TO_LITTLE_ENDIAN(LTOD#22:22:22); - END_FUNCTION + END_FUNCTION "#; let src = add_std!(src, "endianness_conversion_functions.st"); @@ -936,7 +936,7 @@ fn test_to_little_endian_ltod_nanos() { fn test_from_big_endian_ltod_nanos() { let src = r#"FUNCTION main : LTOD main := FROM_BIG_ENDIAN(LTOD#22:22:22); - END_FUNCTION + END_FUNCTION "#; let src = add_std!(src, "endianness_conversion_functions.st"); @@ -948,7 +948,7 @@ fn test_from_big_endian_ltod_nanos() { fn test_from_little_endian_ltod_nanos() { let src = r#"FUNCTION main : LTOD main := FROM_LITTLE_ENDIAN(LTOD#22:22:22); - END_FUNCTION + END_FUNCTION "#; let src = add_std!(src, "endianness_conversion_functions.st"); diff --git a/libs/stdlib/tests/extra_function_tests.rs b/libs/stdlib/tests/extra_function_tests.rs index 8350749ae3..fcf93c56bc 100644 --- a/libs/stdlib/tests/extra_function_tests.rs +++ b/libs/stdlib/tests/extra_function_tests.rs @@ -439,7 +439,7 @@ fn real_to_string_conversion() { FUNCTION main : STRING VAR in: REAL := 13234.25; - END_VAR + END_VAR main := REAL_TO_STRING(in); END_FUNCTION "#; @@ -1590,7 +1590,7 @@ fn u64_to_ldate_signed_overflow() { let src = r#" FUNCTION main : DATE VAR - ul : ULINT := 9_223_372_036_854_775_807 + 1; //i64::MAX + 1 + ul : ULINT := 9_223_372_036_854_775_807 + 1; //i64::MAX + 1 END_VAR main := ULINT_TO_DATE(ul); END_FUNCTION @@ -1770,7 +1770,7 @@ fn dt_to_string_conversion() { FUNCTION main : STRING VAR in: DT := DT#1970-01-01-01:10:00; - END_VAR + END_VAR main := DT_TO_STRING(in); END_FUNCTION "#; @@ -1796,7 +1796,7 @@ fn dt_to_wstring_conversion() { FUNCTION main : WSTRING VAR in: DT := DT#1970-01-01-01:10:00; - END_VAR + END_VAR main := DT_TO_WSTRING(in); END_FUNCTION "#; @@ -1849,7 +1849,7 @@ fn date_to_wstring_conversion() { FUNCTION main : WSTRING VAR in: DATE := DATE#1970-01-01; - END_VAR + END_VAR main := DATE_TO_WSTRING(in); END_FUNCTION "#; @@ -1876,7 +1876,7 @@ fn time_to_string_conversion() { FUNCTION main : STRING VAR in: TIME := T#6d2m123ms456us789ns; - END_VAR + END_VAR main := TIME_TO_STRING(in); END_FUNCTION "#; @@ -1902,7 +1902,7 @@ fn time_to_wstring_conversion() { FUNCTION main : WSTRING VAR in: TIME := T#6d3h2m9ns; - END_VAR + END_VAR main := TIME_TO_WSTRING(in); END_FUNCTION "#; @@ -1929,7 +1929,7 @@ fn tod_ltod_to_string_conversion() { FUNCTION main : STRING VAR in: TOD := TOD#15:36:55.123; - END_VAR + END_VAR main := TOD_TO_STRING(in); END_FUNCTION "#; @@ -1955,7 +1955,7 @@ fn tod_to_wstring_conversion() { FUNCTION main : WSTRING VAR in: TOD := TOD#15:36:55.123; - END_VAR + END_VAR main := TOD_TO_WSTRING(in); END_FUNCTION "#; @@ -1982,7 +1982,7 @@ fn ldt_to_string_conversion() { FUNCTION main : STRING VAR in: LDT := LDT#1970-01-01-01:10:00; - END_VAR + END_VAR main := LDT_TO_STRING(in); END_FUNCTION "#; @@ -2008,7 +2008,7 @@ fn ldt_to_wstring_conversion() { FUNCTION main : WSTRING VAR in: LDT := LDT#1970-01-01-01:10:00; - END_VAR + END_VAR main := LDT_TO_WSTRING(in); END_FUNCTION "#; @@ -2061,7 +2061,7 @@ fn ldate_to_wstring_conversion() { FUNCTION main : WSTRING VAR in: LDATE := LDATE#1970-01-01; - END_VAR + END_VAR main := LDATE_TO_WSTRING(in); END_FUNCTION "#; @@ -2088,7 +2088,7 @@ fn ltime_to_string_conversion() { FUNCTION main : STRING VAR in: LTIME := LT#6d3h2m9ns; - END_VAR + END_VAR main := LTIME_TO_STRING(in); END_FUNCTION "#; @@ -2114,7 +2114,7 @@ fn ltime_to_wstring_conversion() { FUNCTION main : WSTRING VAR in: LTIME := LT#6d3h2m9ns; - END_VAR + END_VAR main := LTIME_TO_WSTRING(in); END_FUNCTION "#; @@ -2141,7 +2141,7 @@ fn ltod_to_string_conversion() { FUNCTION main : STRING VAR in: LTOD := LTOD#15:36:55.123; - END_VAR + END_VAR main := LTOD_TO_STRING(in); END_FUNCTION "#; @@ -2167,7 +2167,7 @@ fn ltod_to_wstring_conversion() { FUNCTION main : WSTRING VAR in: LTOD := LTOD#15:36:55.123; - END_VAR + END_VAR main := LTOD_TO_WSTRING(in); END_FUNCTION "#; diff --git a/libs/stdlib/tests/num_conversion_tests.rs b/libs/stdlib/tests/num_conversion_tests.rs index 89fa88b5b8..677dd20cbe 100644 --- a/libs/stdlib/tests/num_conversion_tests.rs +++ b/libs/stdlib/tests/num_conversion_tests.rs @@ -119,17 +119,17 @@ struct F64Type { #[test] fn lreal_to_real_conversion() { let src = r" - TYPE myType : STRUCT - zero : REAL; negative : REAL; positive : REAL; - END_STRUCT END_TYPE + TYPE myType : STRUCT + zero : REAL; negative : REAL; positive : REAL; + END_STRUCT END_TYPE - PROGRAM main - VAR - ret : myType; - END_VAR - ret.zero := LREAL_to_REAL(LREAL#0.0); - ret.negative := LREAL_to_REAL(LREAL#-1.7e+10); - ret.positive := LREAL_to_REAL(LREAL#1.7e+10); + PROGRAM main + VAR + ret : myType; + END_VAR + ret.zero := LREAL_to_REAL(LREAL#0.0); + ret.negative := LREAL_to_REAL(LREAL#-1.7e+10); + ret.positive := LREAL_to_REAL(LREAL#1.7e+10); END_PROGRAM "; let sources = add_std!(src, "num_conversion.st", "numerical_functions.st"); @@ -143,17 +143,17 @@ fn lreal_to_real_conversion() { #[test] fn lreal_to_lint_conversion() { let src = r" - TYPE myType : STRUCT - zero : LINT; negative : LINT; positive : LINT; - END_STRUCT END_TYPE + TYPE myType : STRUCT + zero : LINT; negative : LINT; positive : LINT; + END_STRUCT END_TYPE - PROGRAM main - VAR - ret : myType; - END_VAR - ret.zero := LREAL_to_LINT(LREAL#0.0); - ret.negative := LREAL_to_LINT(LREAL#-9.2233714871e+18); - ret.positive := LREAL_to_LINT(LREAL#9.2233714871e+18); + PROGRAM main + VAR + ret : myType; + END_VAR + ret.zero := LREAL_to_LINT(LREAL#0.0); + ret.negative := LREAL_to_LINT(LREAL#-9.2233714871e+18); + ret.positive := LREAL_to_LINT(LREAL#9.2233714871e+18); END_PROGRAM "; let sources = add_std!(src, "num_conversion.st", "numerical_functions.st"); @@ -167,17 +167,17 @@ fn lreal_to_lint_conversion() { #[test] fn lreal_to_dint_conversion() { let src = r" - TYPE myType : STRUCT - zero : DINT; negative : DINT; positive : DINT; - END_STRUCT END_TYPE + TYPE myType : STRUCT + zero : DINT; negative : DINT; positive : DINT; + END_STRUCT END_TYPE - PROGRAM main - VAR - ret : myType; - END_VAR - ret.zero := LREAL_to_DINT(LREAL#0.4); - ret.negative := LREAL_to_DINT(LREAL#-2.147483520e+9); - ret.positive := LREAL_to_DINT(LREAL#2.147483520e+9); + PROGRAM main + VAR + ret : myType; + END_VAR + ret.zero := LREAL_to_DINT(LREAL#0.4); + ret.negative := LREAL_to_DINT(LREAL#-2.147483520e+9); + ret.positive := LREAL_to_DINT(LREAL#2.147483520e+9); END_PROGRAM "; let sources = add_std!(src, "num_conversion.st", "numerical_functions.st"); @@ -191,17 +191,17 @@ fn lreal_to_dint_conversion() { #[test] fn lreal_to_int_conversion() { let src = r" - TYPE myType : STRUCT - zero : INT; negative : INT; positive : INT; - END_STRUCT END_TYPE + TYPE myType : STRUCT + zero : INT; negative : INT; positive : INT; + END_STRUCT END_TYPE - PROGRAM main - VAR - ret : myType; - END_VAR - ret.zero := LREAL_to_INT(LREAL#-0.3); - ret.negative := LREAL_to_INT(LREAL#-3.2767e+4); - ret.positive := LREAL_to_INT(LREAL#3.2767e+4); + PROGRAM main + VAR + ret : myType; + END_VAR + ret.zero := LREAL_to_INT(LREAL#-0.3); + ret.negative := LREAL_to_INT(LREAL#-3.2767e+4); + ret.positive := LREAL_to_INT(LREAL#3.2767e+4); END_PROGRAM "; let sources = add_std!(src, "num_conversion.st", "numerical_functions.st"); @@ -215,17 +215,17 @@ fn lreal_to_int_conversion() { #[test] fn lreal_to_sint_conversion() { let src = r" - TYPE myType : STRUCT - zero : SINT; negative : SINT; positive : SINT; - END_STRUCT END_TYPE + TYPE myType : STRUCT + zero : SINT; negative : SINT; positive : SINT; + END_STRUCT END_TYPE - PROGRAM main - VAR - ret : myType; - END_VAR - ret.zero := LREAL_to_SINT(LREAL#0.4); - ret.negative := LREAL_to_SINT(LREAL#-1.27e+2); - ret.positive := LREAL_to_SINT(LREAL#1.27e+2); + PROGRAM main + VAR + ret : myType; + END_VAR + ret.zero := LREAL_to_SINT(LREAL#0.4); + ret.negative := LREAL_to_SINT(LREAL#-1.27e+2); + ret.positive := LREAL_to_SINT(LREAL#1.27e+2); END_PROGRAM "; let sources = add_std!(src, "num_conversion.st", "numerical_functions.st"); @@ -245,16 +245,16 @@ fn lreal_to_ulint_conversion() { } let src = r" - TYPE myType : STRUCT - zero : ULINT; positive : ULINT; - END_STRUCT END_TYPE + TYPE myType : STRUCT + zero : ULINT; positive : ULINT; + END_STRUCT END_TYPE - PROGRAM main - VAR - ret : myType; - END_VAR - ret.zero := LREAL_to_ULINT(LREAL#0.2); - ret.positive := LREAL_to_ULINT(LREAL#1.84467429742e+19); + PROGRAM main + VAR + ret : myType; + END_VAR + ret.zero := LREAL_to_ULINT(LREAL#0.2); + ret.positive := LREAL_to_ULINT(LREAL#1.84467429742e+19); END_PROGRAM "; let sources = add_std!(src, "num_conversion.st", "numerical_functions.st"); @@ -273,16 +273,16 @@ fn lreal_to_udint_conversion() { } let src = r" - TYPE myType : STRUCT - zero : UDINT; positive : UDINT; - END_STRUCT END_TYPE + TYPE myType : STRUCT + zero : UDINT; positive : UDINT; + END_STRUCT END_TYPE - PROGRAM main - VAR - ret : myType; - END_VAR - ret.zero := LREAL_to_UDINT(LREAL#0.4); - ret.positive := LREAL_to_UDINT(LREAL#4.294967040e+9); + PROGRAM main + VAR + ret : myType; + END_VAR + ret.zero := LREAL_to_UDINT(LREAL#0.4); + ret.positive := LREAL_to_UDINT(LREAL#4.294967040e+9); END_PROGRAM "; let sources = add_std!(src, "num_conversion.st", "numerical_functions.st"); @@ -301,16 +301,16 @@ fn lreal_to_uint_conversion() { } let src = r" - TYPE myType : STRUCT - zero : UINT; positive : UINT; - END_STRUCT END_TYPE + TYPE myType : STRUCT + zero : UINT; positive : UINT; + END_STRUCT END_TYPE - PROGRAM main - VAR - ret : myType; - END_VAR - ret.zero := LREAL_to_UINT(LREAL#0.4); - ret.positive := LREAL_to_UINT(LREAL#6.5535e+4); + PROGRAM main + VAR + ret : myType; + END_VAR + ret.zero := LREAL_to_UINT(LREAL#0.4); + ret.positive := LREAL_to_UINT(LREAL#6.5535e+4); END_PROGRAM "; let sources = add_std!(src, "num_conversion.st", "numerical_functions.st"); @@ -329,16 +329,16 @@ fn lreal_to_usint_conversion() { } let src = r" - TYPE myType : STRUCT - zero : USINT; positive : USINT; - END_STRUCT END_TYPE + TYPE myType : STRUCT + zero : USINT; positive : USINT; + END_STRUCT END_TYPE - PROGRAM main - VAR - ret : myType; - END_VAR - ret.zero := LREAL_to_USINT(LREAL#0.3); - ret.positive := LREAL_to_USINT(LREAL#2.25e+2); + PROGRAM main + VAR + ret : myType; + END_VAR + ret.zero := LREAL_to_USINT(LREAL#0.3); + ret.positive := LREAL_to_USINT(LREAL#2.25e+2); END_PROGRAM "; let sources = add_std!(src, "num_conversion.st", "numerical_functions.st"); @@ -351,17 +351,17 @@ fn lreal_to_usint_conversion() { #[test] fn real_to_lreal_conversion() { let src = r" - TYPE myType : STRUCT - zero : LREAL; negative : LREAL; positive : LREAL; - END_STRUCT END_TYPE + TYPE myType : STRUCT + zero : LREAL; negative : LREAL; positive : LREAL; + END_STRUCT END_TYPE - PROGRAM main - VAR - ret : myType; - END_VAR - ret.zero := REAL_to_LREAL(REAL#0.0); - ret.negative := REAL_to_LREAL(REAL#-2.2e+5); - ret.positive := REAL_to_LREAL(REAL#2.2e+5); + PROGRAM main + VAR + ret : myType; + END_VAR + ret.zero := REAL_to_LREAL(REAL#0.0); + ret.negative := REAL_to_LREAL(REAL#-2.2e+5); + ret.positive := REAL_to_LREAL(REAL#2.2e+5); END_PROGRAM "; let sources = add_std!(src, "num_conversion.st", "numerical_functions.st"); @@ -375,17 +375,17 @@ fn real_to_lreal_conversion() { #[test] fn real_to_lint_conversion() { let src = r" - TYPE myType : STRUCT - zero : LINT; negative : LINT; positive : LINT; - END_STRUCT END_TYPE + TYPE myType : STRUCT + zero : LINT; negative : LINT; positive : LINT; + END_STRUCT END_TYPE - PROGRAM main - VAR - ret : myType; - END_VAR - ret.zero := REAL_to_LINT(REAL#0.2); - ret.negative := REAL_to_LINT(REAL#-9.2233714871e+18); - ret.positive := REAL_to_LINT(REAL#9.2233714871e+18); + PROGRAM main + VAR + ret : myType; + END_VAR + ret.zero := REAL_to_LINT(REAL#0.2); + ret.negative := REAL_to_LINT(REAL#-9.2233714871e+18); + ret.positive := REAL_to_LINT(REAL#9.2233714871e+18); END_PROGRAM "; let sources = add_std!(src, "num_conversion.st", "numerical_functions.st"); @@ -399,17 +399,17 @@ fn real_to_lint_conversion() { #[test] fn real_to_dint_conversion() { let src = r" - TYPE myType : STRUCT - zero : DINT; negative : DINT; positive : DINT; - END_STRUCT END_TYPE + TYPE myType : STRUCT + zero : DINT; negative : DINT; positive : DINT; + END_STRUCT END_TYPE - PROGRAM main - VAR - ret : myType; - END_VAR - ret.zero := REAL_to_DINT(REAL#0.2); - ret.negative := REAL_to_DINT(REAL#-2.147483520e+9); - ret.positive := REAL_to_DINT(REAL#2.147483520e+9); + PROGRAM main + VAR + ret : myType; + END_VAR + ret.zero := REAL_to_DINT(REAL#0.2); + ret.negative := REAL_to_DINT(REAL#-2.147483520e+9); + ret.positive := REAL_to_DINT(REAL#2.147483520e+9); END_PROGRAM "; let sources = add_std!(src, "num_conversion.st", "numerical_functions.st"); @@ -423,17 +423,17 @@ fn real_to_dint_conversion() { #[test] fn real_to_int_conversion() { let src = r" - TYPE myType : STRUCT - zero : INT; negative : INT; positive : INT; - END_STRUCT END_TYPE + TYPE myType : STRUCT + zero : INT; negative : INT; positive : INT; + END_STRUCT END_TYPE - PROGRAM main - VAR - ret : myType; - END_VAR - ret.zero := REAL_to_INT(REAL#0.3); - ret.negative := REAL_to_INT(REAL#-3.2767e+4); - ret.positive := REAL_to_INT(REAL#3.2767e+4); + PROGRAM main + VAR + ret : myType; + END_VAR + ret.zero := REAL_to_INT(REAL#0.3); + ret.negative := REAL_to_INT(REAL#-3.2767e+4); + ret.positive := REAL_to_INT(REAL#3.2767e+4); END_PROGRAM "; let sources = add_std!(src, "num_conversion.st", "numerical_functions.st"); @@ -447,17 +447,17 @@ fn real_to_int_conversion() { #[test] fn real_to_sint_conversion() { let src = r" - TYPE myType : STRUCT - zero : SINT; negative : SINT; positive : SINT; - END_STRUCT END_TYPE + TYPE myType : STRUCT + zero : SINT; negative : SINT; positive : SINT; + END_STRUCT END_TYPE - PROGRAM main - VAR - ret : myType; - END_VAR - ret.zero := REAL_to_SINT(REAL#0.2); - ret.negative := REAL_to_SINT(REAL#-1.27e+2); - ret.positive := REAL_to_SINT(REAL#1.27e+2); + PROGRAM main + VAR + ret : myType; + END_VAR + ret.zero := REAL_to_SINT(REAL#0.2); + ret.negative := REAL_to_SINT(REAL#-1.27e+2); + ret.positive := REAL_to_SINT(REAL#1.27e+2); END_PROGRAM "; let sources = add_std!(src, "num_conversion.st", "numerical_functions.st"); @@ -477,16 +477,16 @@ fn real_to_ulint_conversion() { } let src = r" - TYPE myType : STRUCT - zero : ULINT; positive : ULINT; - END_STRUCT END_TYPE + TYPE myType : STRUCT + zero : ULINT; positive : ULINT; + END_STRUCT END_TYPE - PROGRAM main - VAR - ret : myType; - END_VAR - ret.zero := REAL_to_ULINT(REAL#0.1); - ret.positive := REAL_to_ULINT(REAL#1.84467429742e+19); + PROGRAM main + VAR + ret : myType; + END_VAR + ret.zero := REAL_to_ULINT(REAL#0.1); + ret.positive := REAL_to_ULINT(REAL#1.84467429742e+19); END_PROGRAM "; let sources = add_std!(src, "num_conversion.st", "numerical_functions.st"); @@ -505,16 +505,16 @@ fn real_to_udint_conversion() { } let src = r" - TYPE myType : STRUCT - zero : UDINT; positive : UDINT; - END_STRUCT END_TYPE + TYPE myType : STRUCT + zero : UDINT; positive : UDINT; + END_STRUCT END_TYPE - PROGRAM main - VAR - ret : myType; - END_VAR - ret.zero := REAL_to_UDINT(REAL#0.2); - ret.positive := REAL_to_UDINT(REAL#4.294967040e+9); + PROGRAM main + VAR + ret : myType; + END_VAR + ret.zero := REAL_to_UDINT(REAL#0.2); + ret.positive := REAL_to_UDINT(REAL#4.294967040e+9); END_PROGRAM "; let sources = add_std!(src, "num_conversion.st", "numerical_functions.st"); @@ -533,16 +533,16 @@ fn real_to_uint_conversion() { } let src = r" - TYPE myType : STRUCT - zero : UINT; positive : UINT; - END_STRUCT END_TYPE + TYPE myType : STRUCT + zero : UINT; positive : UINT; + END_STRUCT END_TYPE - PROGRAM main - VAR - ret : myType; - END_VAR - ret.zero := REAL_to_UINT(REAL#0.4); - ret.positive := REAL_to_UINT(REAL#6.5535e+4); + PROGRAM main + VAR + ret : myType; + END_VAR + ret.zero := REAL_to_UINT(REAL#0.4); + ret.positive := REAL_to_UINT(REAL#6.5535e+4); END_PROGRAM "; let sources = add_std!(src, "num_conversion.st", "numerical_functions.st"); @@ -561,16 +561,16 @@ fn real_to_usint_conversion() { } let src = r" - TYPE myType : STRUCT - zero : USINT; positive : USINT; - END_STRUCT END_TYPE + TYPE myType : STRUCT + zero : USINT; positive : USINT; + END_STRUCT END_TYPE - PROGRAM main - VAR - ret : myType; - END_VAR - ret.zero := REAL_to_USINT(REAL#0.2); - ret.positive := REAL_to_USINT(REAL#2.25e+2); + PROGRAM main + VAR + ret : myType; + END_VAR + ret.zero := REAL_to_USINT(REAL#0.2); + ret.positive := REAL_to_USINT(REAL#2.25e+2); END_PROGRAM "; let sources = add_std!(src, "num_conversion.st", "numerical_functions.st"); @@ -583,27 +583,27 @@ fn real_to_usint_conversion() { #[test] fn lint_to_lreal_conversion() { let src = r" - TYPE myType : STRUCT - zero : LREAL; negative : LREAL; positive : LREAL; - max_minus_one : LREAL; min_plus_one : LREAL; max_overflow : LREAL; min_overflow : LREAL; - END_STRUCT END_TYPE + TYPE myType : STRUCT + zero : LREAL; negative : LREAL; positive : LREAL; + max_minus_one : LREAL; min_plus_one : LREAL; max_overflow : LREAL; min_overflow : LREAL; + END_STRUCT END_TYPE - VAR_GLOBAL - MAX : LINT := 9223372036854775807; - MIN : LINT := -9223372036854775808; - END_VAR + VAR_GLOBAL + MAX : LINT := 9223372036854775807; + MIN : LINT := -9223372036854775808; + END_VAR - PROGRAM main - VAR - ret : myType; - END_VAR - ret.zero := LINT_to_LREAL(LINT#0); - ret.negative := LINT_to_LREAL(LINT#-11); - ret.positive := LINT_to_LREAL(LINT#22); - ret.max_minus_one := LINT_to_LREAL(MAX-1); - ret.min_plus_one := LINT_to_LREAL(MIN+1); - ret.max_overflow := LINT_to_LREAL(MAX+1); - ret.min_overflow := LINT_to_LREAL(MIN-1); + PROGRAM main + VAR + ret : myType; + END_VAR + ret.zero := LINT_to_LREAL(LINT#0); + ret.negative := LINT_to_LREAL(LINT#-11); + ret.positive := LINT_to_LREAL(LINT#22); + ret.max_minus_one := LINT_to_LREAL(MAX-1); + ret.min_plus_one := LINT_to_LREAL(MIN+1); + ret.max_overflow := LINT_to_LREAL(MAX+1); + ret.min_overflow := LINT_to_LREAL(MIN-1); END_PROGRAM "; let sources = add_std!(src, "num_conversion.st", "numerical_functions.st"); @@ -621,27 +621,27 @@ fn lint_to_lreal_conversion() { #[test] fn lint_to_real_conversion() { let src = r" - TYPE myType : STRUCT - zero : REAL; negative : REAL; positive : REAL; - max_minus_one : REAL; min_plus_one : REAL; max_overflow : REAL; min_overflow : REAL; - END_STRUCT END_TYPE + TYPE myType : STRUCT + zero : REAL; negative : REAL; positive : REAL; + max_minus_one : REAL; min_plus_one : REAL; max_overflow : REAL; min_overflow : REAL; + END_STRUCT END_TYPE - VAR_GLOBAL - MAX : LINT := 9223372036854775807; - MIN : LINT := -9223372036854775808; - END_VAR + VAR_GLOBAL + MAX : LINT := 9223372036854775807; + MIN : LINT := -9223372036854775808; + END_VAR - PROGRAM main - VAR - ret : myType; - END_VAR - ret.zero := LINT_to_REAL(LINT#0); - ret.negative := LINT_to_REAL(LINT#-11); - ret.positive := LINT_to_REAL(LINT#22); - ret.max_minus_one := LINT_to_REAL(MAX-1); - ret.min_plus_one := LINT_to_REAL(MIN+1); - ret.max_overflow := LINT_to_REAL(MAX+1); - ret.min_overflow := LINT_to_REAL(MIN-1); + PROGRAM main + VAR + ret : myType; + END_VAR + ret.zero := LINT_to_REAL(LINT#0); + ret.negative := LINT_to_REAL(LINT#-11); + ret.positive := LINT_to_REAL(LINT#22); + ret.max_minus_one := LINT_to_REAL(MAX-1); + ret.min_plus_one := LINT_to_REAL(MIN+1); + ret.max_overflow := LINT_to_REAL(MAX+1); + ret.min_overflow := LINT_to_REAL(MIN-1); END_PROGRAM "; let sources = add_std!(src, "num_conversion.st", "numerical_functions.st"); @@ -659,27 +659,27 @@ fn lint_to_real_conversion() { #[test] fn lint_to_dint_conversion() { let src = r" - TYPE myType : STRUCT - zero : DINT; negative : DINT; positive : DINT; - max_minus_one : DINT; min_plus_one : DINT; max_overflow : DINT; min_overflow : DINT; - END_STRUCT END_TYPE - - VAR_GLOBAL - MAX : LINT := 2147483647; - MIN : LINT := -2147483648; - END_VAR - - PROGRAM main - VAR - ret : myType; - END_VAR - ret.zero := LINT_to_DINT(LINT#0); - ret.negative := LINT_to_DINT(LINT#-11); - ret.positive := LINT_to_DINT(LINT#22); - ret.max_minus_one := LINT_to_DINT(MAX-1); - ret.min_plus_one := LINT_to_DINT(MIN+1); - ret.max_overflow := LINT_to_DINT(MAX+1); - ret.min_overflow := LINT_to_DINT(MIN-1); + TYPE myType : STRUCT + zero : DINT; negative : DINT; positive : DINT; + max_minus_one : DINT; min_plus_one : DINT; max_overflow : DINT; min_overflow : DINT; + END_STRUCT END_TYPE + + VAR_GLOBAL + MAX : LINT := 2147483647; + MIN : LINT := -2147483648; + END_VAR + + PROGRAM main + VAR + ret : myType; + END_VAR + ret.zero := LINT_to_DINT(LINT#0); + ret.negative := LINT_to_DINT(LINT#-11); + ret.positive := LINT_to_DINT(LINT#22); + ret.max_minus_one := LINT_to_DINT(MAX-1); + ret.min_plus_one := LINT_to_DINT(MIN+1); + ret.max_overflow := LINT_to_DINT(MAX+1); + ret.min_overflow := LINT_to_DINT(MIN-1); END_PROGRAM "; let sources = add_std!(src, "num_conversion.st", "numerical_functions.st"); @@ -697,27 +697,27 @@ fn lint_to_dint_conversion() { #[test] fn lint_to_int_conversion() { let src = r" - TYPE myType : STRUCT - zero : INT; negative : INT; positive : INT; - max_minus_one : INT; min_plus_one : INT; max_overflow : INT; min_overflow : INT; - END_STRUCT END_TYPE + TYPE myType : STRUCT + zero : INT; negative : INT; positive : INT; + max_minus_one : INT; min_plus_one : INT; max_overflow : INT; min_overflow : INT; + END_STRUCT END_TYPE - VAR_GLOBAL - MAX : LINT := 32767; - MIN : LINT := -32768; - END_VAR + VAR_GLOBAL + MAX : LINT := 32767; + MIN : LINT := -32768; + END_VAR - PROGRAM main - VAR - ret : myType; - END_VAR - ret.zero := LINT_to_INT(LINT#0); - ret.negative := LINT_to_INT(LINT#-11); - ret.positive := LINT_to_INT(LINT#22); - ret.max_minus_one := LINT_to_INT(MAX-1); - ret.min_plus_one := LINT_to_INT(MIN+1); - ret.max_overflow := LINT_to_INT(MAX+1); - ret.min_overflow := LINT_to_INT(MIN-1); + PROGRAM main + VAR + ret : myType; + END_VAR + ret.zero := LINT_to_INT(LINT#0); + ret.negative := LINT_to_INT(LINT#-11); + ret.positive := LINT_to_INT(LINT#22); + ret.max_minus_one := LINT_to_INT(MAX-1); + ret.min_plus_one := LINT_to_INT(MIN+1); + ret.max_overflow := LINT_to_INT(MAX+1); + ret.min_overflow := LINT_to_INT(MIN-1); END_PROGRAM "; let sources = add_std!(src, "num_conversion.st", "numerical_functions.st"); @@ -735,27 +735,27 @@ fn lint_to_int_conversion() { #[test] fn lint_to_sint_conversion() { let src = r" - TYPE myType : STRUCT - zero : SINT; negative : SINT; positive : SINT; - max_minus_one : SINT; min_plus_one : SINT; max_overflow : SINT; min_overflow : SINT; - END_STRUCT END_TYPE + TYPE myType : STRUCT + zero : SINT; negative : SINT; positive : SINT; + max_minus_one : SINT; min_plus_one : SINT; max_overflow : SINT; min_overflow : SINT; + END_STRUCT END_TYPE - VAR_GLOBAL - MAX : LINT := 127; - MIN : LINT := -128; - END_VAR + VAR_GLOBAL + MAX : LINT := 127; + MIN : LINT := -128; + END_VAR - PROGRAM main - VAR - ret : myType; - END_VAR - ret.zero := LINT_to_SINT(LINT#0); - ret.negative := LINT_to_SINT(LINT#-11); - ret.positive := LINT_to_SINT(LINT#22); - ret.max_minus_one := LINT_to_SINT(MAX-1); - ret.min_plus_one := LINT_to_SINT(MIN+1); - ret.max_overflow := LINT_to_SINT(MAX+1); - ret.min_overflow := LINT_to_SINT(MIN-1); + PROGRAM main + VAR + ret : myType; + END_VAR + ret.zero := LINT_to_SINT(LINT#0); + ret.negative := LINT_to_SINT(LINT#-11); + ret.positive := LINT_to_SINT(LINT#22); + ret.max_minus_one := LINT_to_SINT(MAX-1); + ret.min_plus_one := LINT_to_SINT(MIN+1); + ret.max_overflow := LINT_to_SINT(MAX+1); + ret.min_overflow := LINT_to_SINT(MIN-1); END_PROGRAM "; let sources = add_std!(src, "num_conversion.st", "numerical_functions.st"); @@ -773,27 +773,27 @@ fn lint_to_sint_conversion() { #[test] fn lint_to_ulint_conversion() { let src = r" - TYPE myType : STRUCT - zero : ULINT; negative : ULINT; positive : ULINT; - max_minus_one : ULINT; min_plus_one : ULINT; max_overflow : ULINT; min_overflow : ULINT; - END_STRUCT END_TYPE + TYPE myType : STRUCT + zero : ULINT; negative : ULINT; positive : ULINT; + max_minus_one : ULINT; min_plus_one : ULINT; max_overflow : ULINT; min_overflow : ULINT; + END_STRUCT END_TYPE - VAR_GLOBAL - MAX : LINT := 9223372036854775807; - MIN : LINT := -9223372036854775808; - END_VAR + VAR_GLOBAL + MAX : LINT := 9223372036854775807; + MIN : LINT := -9223372036854775808; + END_VAR - PROGRAM main - VAR - ret : myType; - END_VAR - ret.zero := LINT_to_ULINT(LINT#0); - ret.negative := LINT_to_ULINT(LINT#-1); - ret.positive := LINT_to_ULINT(LINT#22); - ret.max_minus_one := LINT_to_ULINT(MAX-1); - ret.min_plus_one := LINT_to_ULINT(MIN+1); - ret.max_overflow := LINT_to_ULINT(MAX+1); - ret.min_overflow := LINT_to_ULINT(MIN-1); + PROGRAM main + VAR + ret : myType; + END_VAR + ret.zero := LINT_to_ULINT(LINT#0); + ret.negative := LINT_to_ULINT(LINT#-1); + ret.positive := LINT_to_ULINT(LINT#22); + ret.max_minus_one := LINT_to_ULINT(MAX-1); + ret.min_plus_one := LINT_to_ULINT(MIN+1); + ret.max_overflow := LINT_to_ULINT(MAX+1); + ret.min_overflow := LINT_to_ULINT(MIN-1); END_PROGRAM "; let sources = add_std!(src, "num_conversion.st", "numerical_functions.st"); @@ -811,27 +811,27 @@ fn lint_to_ulint_conversion() { #[test] fn lint_to_udint_conversion() { let src = r" - TYPE myType : STRUCT - zero : UDINT; negative : UDINT; positive : UDINT; - max_minus_one : UDINT; min_plus_one : UDINT; max_overflow : UDINT; min_overflow : UDINT; - END_STRUCT END_TYPE + TYPE myType : STRUCT + zero : UDINT; negative : UDINT; positive : UDINT; + max_minus_one : UDINT; min_plus_one : UDINT; max_overflow : UDINT; min_overflow : UDINT; + END_STRUCT END_TYPE - VAR_GLOBAL - MAX : LINT := 4294967295; - MIN : LINT := 0; - END_VAR + VAR_GLOBAL + MAX : LINT := 4294967295; + MIN : LINT := 0; + END_VAR - PROGRAM main - VAR - ret : myType; - END_VAR - ret.zero := LINT_to_UDINT(LINT#0); - ret.negative := LINT_to_UDINT(LINT#-1); - ret.positive := LINT_to_UDINT(LINT#22); - ret.max_minus_one := LINT_to_UDINT(MAX-1); - ret.min_plus_one := LINT_to_UDINT(MIN+1); - ret.max_overflow := LINT_to_UDINT(MAX+1); - ret.min_overflow := LINT_to_UDINT(MIN-1); + PROGRAM main + VAR + ret : myType; + END_VAR + ret.zero := LINT_to_UDINT(LINT#0); + ret.negative := LINT_to_UDINT(LINT#-1); + ret.positive := LINT_to_UDINT(LINT#22); + ret.max_minus_one := LINT_to_UDINT(MAX-1); + ret.min_plus_one := LINT_to_UDINT(MIN+1); + ret.max_overflow := LINT_to_UDINT(MAX+1); + ret.min_overflow := LINT_to_UDINT(MIN-1); END_PROGRAM "; let sources = add_std!(src, "num_conversion.st", "numerical_functions.st"); @@ -849,27 +849,27 @@ fn lint_to_udint_conversion() { #[test] fn lint_to_uint_conversion() { let src = r" - TYPE myType : STRUCT - zero : UINT; negative : UINT; positive : UINT; - max_minus_one : UINT; min_plus_one : UINT; max_overflow : UINT; min_overflow : UINT; - END_STRUCT END_TYPE + TYPE myType : STRUCT + zero : UINT; negative : UINT; positive : UINT; + max_minus_one : UINT; min_plus_one : UINT; max_overflow : UINT; min_overflow : UINT; + END_STRUCT END_TYPE - VAR_GLOBAL - MAX : LINT := 65535; - MIN : LINT := 0; - END_VAR + VAR_GLOBAL + MAX : LINT := 65535; + MIN : LINT := 0; + END_VAR - PROGRAM main - VAR - ret : myType; - END_VAR - ret.zero := LINT_to_UINT(LINT#0); - ret.negative := LINT_to_UINT(LINT#-1); - ret.positive := LINT_to_UINT(LINT#22); - ret.max_minus_one := LINT_to_UINT(MAX-1); - ret.min_plus_one := LINT_to_UINT(MIN+1); - ret.max_overflow := LINT_to_UINT(MAX+1); - ret.min_overflow := LINT_to_UINT(MIN-1); + PROGRAM main + VAR + ret : myType; + END_VAR + ret.zero := LINT_to_UINT(LINT#0); + ret.negative := LINT_to_UINT(LINT#-1); + ret.positive := LINT_to_UINT(LINT#22); + ret.max_minus_one := LINT_to_UINT(MAX-1); + ret.min_plus_one := LINT_to_UINT(MIN+1); + ret.max_overflow := LINT_to_UINT(MAX+1); + ret.min_overflow := LINT_to_UINT(MIN-1); END_PROGRAM "; let sources = add_std!(src, "num_conversion.st", "numerical_functions.st"); @@ -887,27 +887,27 @@ fn lint_to_uint_conversion() { #[test] fn lint_to_usint_conversion() { let src = r" - TYPE myType : STRUCT - zero : USINT; negative : USINT; positive : USINT; - max_minus_one : USINT; min_plus_one : USINT; max_overflow : USINT; min_overflow : USINT; - END_STRUCT END_TYPE + TYPE myType : STRUCT + zero : USINT; negative : USINT; positive : USINT; + max_minus_one : USINT; min_plus_one : USINT; max_overflow : USINT; min_overflow : USINT; + END_STRUCT END_TYPE - VAR_GLOBAL - MAX : LINT := 255; - MIN : LINT := 0; - END_VAR + VAR_GLOBAL + MAX : LINT := 255; + MIN : LINT := 0; + END_VAR - PROGRAM main - VAR - ret : myType; - END_VAR - ret.zero := LINT_to_USINT(LINT#0); - ret.negative := LINT_to_USINT(LINT#-1); - ret.positive := LINT_to_USINT(LINT#22); - ret.max_minus_one := LINT_to_USINT(MAX-1); - ret.min_plus_one := LINT_to_USINT(MIN+1); - ret.max_overflow := LINT_to_USINT(MAX+1); - ret.min_overflow := LINT_to_USINT(MIN-1); + PROGRAM main + VAR + ret : myType; + END_VAR + ret.zero := LINT_to_USINT(LINT#0); + ret.negative := LINT_to_USINT(LINT#-1); + ret.positive := LINT_to_USINT(LINT#22); + ret.max_minus_one := LINT_to_USINT(MAX-1); + ret.min_plus_one := LINT_to_USINT(MIN+1); + ret.max_overflow := LINT_to_USINT(MAX+1); + ret.min_overflow := LINT_to_USINT(MIN-1); END_PROGRAM "; let sources = add_std!(src, "num_conversion.st", "numerical_functions.st"); @@ -925,27 +925,27 @@ fn lint_to_usint_conversion() { #[test] fn dint_to_lreal_conversion() { let src = r" - TYPE myType : STRUCT - zero : LREAL; negative : LREAL; positive : LREAL; - max_minus_one : LREAL; min_plus_one : LREAL; max_overflow : LREAL; min_overflow : LREAL; - END_STRUCT END_TYPE + TYPE myType : STRUCT + zero : LREAL; negative : LREAL; positive : LREAL; + max_minus_one : LREAL; min_plus_one : LREAL; max_overflow : LREAL; min_overflow : LREAL; + END_STRUCT END_TYPE - VAR_GLOBAL - MAX : DINT := 2147483647; - MIN : DINT := -2147483648; - END_VAR + VAR_GLOBAL + MAX : DINT := 2147483647; + MIN : DINT := -2147483648; + END_VAR - PROGRAM main - VAR - ret : myType; - END_VAR - ret.zero := DINT_to_LREAL(DINT#0); - ret.negative := DINT_to_LREAL(DINT#-11); - ret.positive := DINT_to_LREAL(DINT#22); - ret.max_minus_one := DINT_to_LREAL(MAX-1); - ret.min_plus_one := DINT_to_LREAL(MIN+1); - ret.max_overflow := DINT_to_LREAL(MAX+1); - ret.min_overflow := DINT_to_LREAL(MIN-1); + PROGRAM main + VAR + ret : myType; + END_VAR + ret.zero := DINT_to_LREAL(DINT#0); + ret.negative := DINT_to_LREAL(DINT#-11); + ret.positive := DINT_to_LREAL(DINT#22); + ret.max_minus_one := DINT_to_LREAL(MAX-1); + ret.min_plus_one := DINT_to_LREAL(MIN+1); + ret.max_overflow := DINT_to_LREAL(MAX+1); + ret.min_overflow := DINT_to_LREAL(MIN-1); END_PROGRAM "; let sources = add_std!(src, "num_conversion.st", "numerical_functions.st"); @@ -963,27 +963,27 @@ fn dint_to_lreal_conversion() { #[test] fn dint_to_real_conversion() { let src = r" - TYPE myType : STRUCT - zero : REAL; negative : REAL; positive : REAL; - max_minus_one : REAL; min_plus_one : REAL; max_overflow : REAL; min_overflow : REAL; - END_STRUCT END_TYPE + TYPE myType : STRUCT + zero : REAL; negative : REAL; positive : REAL; + max_minus_one : REAL; min_plus_one : REAL; max_overflow : REAL; min_overflow : REAL; + END_STRUCT END_TYPE - VAR_GLOBAL - MAX : DINT := 2147483647; - MIN : DINT := -2147483648; - END_VAR + VAR_GLOBAL + MAX : DINT := 2147483647; + MIN : DINT := -2147483648; + END_VAR - PROGRAM main - VAR - ret : myType; - END_VAR - ret.zero := DINT_to_REAL(DINT#0); - ret.negative := DINT_to_REAL(DINT#-11); - ret.positive := DINT_to_REAL(DINT#22); - ret.max_minus_one := DINT_to_REAL(MAX-1); - ret.min_plus_one := DINT_to_REAL(MIN+1); - ret.max_overflow := DINT_to_REAL(MAX+1); - ret.min_overflow := DINT_to_REAL(MIN-1); + PROGRAM main + VAR + ret : myType; + END_VAR + ret.zero := DINT_to_REAL(DINT#0); + ret.negative := DINT_to_REAL(DINT#-11); + ret.positive := DINT_to_REAL(DINT#22); + ret.max_minus_one := DINT_to_REAL(MAX-1); + ret.min_plus_one := DINT_to_REAL(MIN+1); + ret.max_overflow := DINT_to_REAL(MAX+1); + ret.min_overflow := DINT_to_REAL(MIN-1); END_PROGRAM "; let sources = add_std!(src, "num_conversion.st", "numerical_functions.st"); @@ -1001,27 +1001,27 @@ fn dint_to_real_conversion() { #[test] fn dint_to_lint_conversion() { let src = r" - TYPE myType : STRUCT - zero : LINT; negative : LINT; positive : LINT; - max_minus_one : LINT; min_plus_one : LINT; max_overflow : LINT; min_overflow : LINT; - END_STRUCT END_TYPE + TYPE myType : STRUCT + zero : LINT; negative : LINT; positive : LINT; + max_minus_one : LINT; min_plus_one : LINT; max_overflow : LINT; min_overflow : LINT; + END_STRUCT END_TYPE - VAR_GLOBAL - MAX : DINT := 2147483647; - MIN : DINT := -2147483648; - END_VAR + VAR_GLOBAL + MAX : DINT := 2147483647; + MIN : DINT := -2147483648; + END_VAR - PROGRAM main - VAR - ret : myType; - END_VAR - ret.zero := DINT_to_LINT(DINT#0); - ret.negative := DINT_to_LINT(DINT#-11); - ret.positive := DINT_to_LINT(DINT#22); - ret.max_minus_one := DINT_to_LINT(MAX-1); - ret.min_plus_one := DINT_to_LINT(MIN+1); - ret.max_overflow := DINT_to_LINT(MAX+1); - ret.min_overflow := DINT_to_LINT(MIN-1); + PROGRAM main + VAR + ret : myType; + END_VAR + ret.zero := DINT_to_LINT(DINT#0); + ret.negative := DINT_to_LINT(DINT#-11); + ret.positive := DINT_to_LINT(DINT#22); + ret.max_minus_one := DINT_to_LINT(MAX-1); + ret.min_plus_one := DINT_to_LINT(MIN+1); + ret.max_overflow := DINT_to_LINT(MAX+1); + ret.min_overflow := DINT_to_LINT(MIN-1); END_PROGRAM "; let sources = add_std!(src, "num_conversion.st", "numerical_functions.st"); @@ -1039,27 +1039,27 @@ fn dint_to_lint_conversion() { #[test] fn dint_to_int_conversion() { let src = r" - TYPE myType : STRUCT - zero : INT; negative : INT; positive : INT; - max_minus_one : INT; min_plus_one : INT; max_overflow : INT; min_overflow : INT; - END_STRUCT END_TYPE + TYPE myType : STRUCT + zero : INT; negative : INT; positive : INT; + max_minus_one : INT; min_plus_one : INT; max_overflow : INT; min_overflow : INT; + END_STRUCT END_TYPE - VAR_GLOBAL - MAX : DINT := 32767; - MIN : DINT := -32768; - END_VAR + VAR_GLOBAL + MAX : DINT := 32767; + MIN : DINT := -32768; + END_VAR - PROGRAM main - VAR - ret : myType; - END_VAR - ret.zero := DINT_to_INT(DINT#0); - ret.negative := DINT_to_INT(DINT#-11); - ret.positive := DINT_to_INT(DINT#22); - ret.max_minus_one := DINT_to_INT(MAX-1); - ret.min_plus_one := DINT_to_INT(MIN+1); - ret.max_overflow := DINT_to_INT(MAX+1); - ret.min_overflow := DINT_to_INT(MIN-1); + PROGRAM main + VAR + ret : myType; + END_VAR + ret.zero := DINT_to_INT(DINT#0); + ret.negative := DINT_to_INT(DINT#-11); + ret.positive := DINT_to_INT(DINT#22); + ret.max_minus_one := DINT_to_INT(MAX-1); + ret.min_plus_one := DINT_to_INT(MIN+1); + ret.max_overflow := DINT_to_INT(MAX+1); + ret.min_overflow := DINT_to_INT(MIN-1); END_PROGRAM "; let sources = add_std!(src, "num_conversion.st", "numerical_functions.st"); @@ -1077,27 +1077,27 @@ fn dint_to_int_conversion() { #[test] fn dint_to_sint_conversion() { let src = r" - TYPE myType : STRUCT - zero : SINT; negative : SINT; positive : SINT; - max_minus_one : SINT; min_plus_one : SINT; max_overflow : SINT; min_overflow : SINT; - END_STRUCT END_TYPE + TYPE myType : STRUCT + zero : SINT; negative : SINT; positive : SINT; + max_minus_one : SINT; min_plus_one : SINT; max_overflow : SINT; min_overflow : SINT; + END_STRUCT END_TYPE - VAR_GLOBAL - MAX : DINT := 127; - MIN : DINT := -128; - END_VAR + VAR_GLOBAL + MAX : DINT := 127; + MIN : DINT := -128; + END_VAR - PROGRAM main - VAR - ret : myType; - END_VAR - ret.zero := DINT_to_SINT(DINT#0); - ret.negative := DINT_to_SINT(DINT#-11); - ret.positive := DINT_to_SINT(DINT#22); - ret.max_minus_one := DINT_to_SINT(MAX-1); - ret.min_plus_one := DINT_to_SINT(MIN+1); - ret.max_overflow := DINT_to_SINT(MAX+1); - ret.min_overflow := DINT_to_SINT(MIN-1); + PROGRAM main + VAR + ret : myType; + END_VAR + ret.zero := DINT_to_SINT(DINT#0); + ret.negative := DINT_to_SINT(DINT#-11); + ret.positive := DINT_to_SINT(DINT#22); + ret.max_minus_one := DINT_to_SINT(MAX-1); + ret.min_plus_one := DINT_to_SINT(MIN+1); + ret.max_overflow := DINT_to_SINT(MAX+1); + ret.min_overflow := DINT_to_SINT(MIN-1); END_PROGRAM "; let sources = add_std!(src, "num_conversion.st", "numerical_functions.st"); @@ -1115,27 +1115,27 @@ fn dint_to_sint_conversion() { #[test] fn dint_to_ulint_conversion() { let src = r" - TYPE myType : STRUCT - zero : ULINT; negative : ULINT; positive : ULINT; - max_minus_one : ULINT; min_plus_one : ULINT; max_overflow : ULINT; min_overflow : ULINT; - END_STRUCT END_TYPE + TYPE myType : STRUCT + zero : ULINT; negative : ULINT; positive : ULINT; + max_minus_one : ULINT; min_plus_one : ULINT; max_overflow : ULINT; min_overflow : ULINT; + END_STRUCT END_TYPE - VAR_GLOBAL - MAX : DINT := 2147483647; - MIN : DINT := -2147483648; - END_VAR + VAR_GLOBAL + MAX : DINT := 2147483647; + MIN : DINT := -2147483648; + END_VAR - PROGRAM main - VAR - ret : myType; - END_VAR - ret.zero := DINT_to_ULINT(DINT#0); - ret.negative := DINT_to_ULINT(DINT#-1); - ret.positive := DINT_to_ULINT(DINT#22); - ret.max_minus_one := DINT_to_ULINT(MAX-1); - ret.min_plus_one := DINT_to_ULINT(MIN+1); - ret.max_overflow := DINT_to_ULINT(MAX+1); - ret.min_overflow := DINT_to_ULINT(MIN-1); + PROGRAM main + VAR + ret : myType; + END_VAR + ret.zero := DINT_to_ULINT(DINT#0); + ret.negative := DINT_to_ULINT(DINT#-1); + ret.positive := DINT_to_ULINT(DINT#22); + ret.max_minus_one := DINT_to_ULINT(MAX-1); + ret.min_plus_one := DINT_to_ULINT(MIN+1); + ret.max_overflow := DINT_to_ULINT(MAX+1); + ret.min_overflow := DINT_to_ULINT(MIN-1); END_PROGRAM "; let sources = add_std!(src, "num_conversion.st", "numerical_functions.st"); @@ -1153,27 +1153,27 @@ fn dint_to_ulint_conversion() { #[test] fn dint_to_udint_conversion() { let src = r" - TYPE myType : STRUCT - zero : UDINT; negative : UDINT; positive : UDINT; - max_minus_one : UDINT; min_plus_one : UDINT; max_overflow : UDINT; min_overflow : UDINT; - END_STRUCT END_TYPE + TYPE myType : STRUCT + zero : UDINT; negative : UDINT; positive : UDINT; + max_minus_one : UDINT; min_plus_one : UDINT; max_overflow : UDINT; min_overflow : UDINT; + END_STRUCT END_TYPE - VAR_GLOBAL - MAX : DINT := 2147483647; - MIN : DINT := -2147483648; - END_VAR + VAR_GLOBAL + MAX : DINT := 2147483647; + MIN : DINT := -2147483648; + END_VAR - PROGRAM main - VAR - ret : myType; - END_VAR - ret.zero := DINT_to_UDINT(DINT#0); - ret.negative := DINT_to_UDINT(DINT#-1); - ret.positive := DINT_to_UDINT(DINT#22); - ret.max_minus_one := DINT_to_UDINT(MAX-1); - ret.min_plus_one := DINT_to_UDINT(MIN+1); - ret.max_overflow := DINT_to_UDINT(MAX+1); - ret.min_overflow := DINT_to_UDINT(MIN-1); + PROGRAM main + VAR + ret : myType; + END_VAR + ret.zero := DINT_to_UDINT(DINT#0); + ret.negative := DINT_to_UDINT(DINT#-1); + ret.positive := DINT_to_UDINT(DINT#22); + ret.max_minus_one := DINT_to_UDINT(MAX-1); + ret.min_plus_one := DINT_to_UDINT(MIN+1); + ret.max_overflow := DINT_to_UDINT(MAX+1); + ret.min_overflow := DINT_to_UDINT(MIN-1); END_PROGRAM "; let sources = add_std!(src, "num_conversion.st", "numerical_functions.st"); @@ -1191,27 +1191,27 @@ fn dint_to_udint_conversion() { #[test] fn dint_to_uint_conversion() { let src = r" - TYPE myType : STRUCT - zero : UINT; negative : UINT; positive : UINT; - max_minus_one : UINT; min_plus_one : UINT; max_overflow : UINT; min_overflow : UINT; - END_STRUCT END_TYPE + TYPE myType : STRUCT + zero : UINT; negative : UINT; positive : UINT; + max_minus_one : UINT; min_plus_one : UINT; max_overflow : UINT; min_overflow : UINT; + END_STRUCT END_TYPE - VAR_GLOBAL - MAX : DINT := 65535; - MIN : DINT := 0; - END_VAR + VAR_GLOBAL + MAX : DINT := 65535; + MIN : DINT := 0; + END_VAR - PROGRAM main - VAR - ret : myType; - END_VAR - ret.zero := DINT_to_UINT(DINT#0); - ret.negative := DINT_to_UINT(DINT#-1); - ret.positive := DINT_to_UINT(DINT#22); - ret.max_minus_one := DINT_to_UINT(MAX-1); - ret.min_plus_one := DINT_to_UINT(MIN+1); - ret.max_overflow := DINT_to_UINT(MAX+1); - ret.min_overflow := DINT_to_UINT(MIN-1); + PROGRAM main + VAR + ret : myType; + END_VAR + ret.zero := DINT_to_UINT(DINT#0); + ret.negative := DINT_to_UINT(DINT#-1); + ret.positive := DINT_to_UINT(DINT#22); + ret.max_minus_one := DINT_to_UINT(MAX-1); + ret.min_plus_one := DINT_to_UINT(MIN+1); + ret.max_overflow := DINT_to_UINT(MAX+1); + ret.min_overflow := DINT_to_UINT(MIN-1); END_PROGRAM "; let sources = add_std!(src, "num_conversion.st", "numerical_functions.st"); @@ -1229,27 +1229,27 @@ fn dint_to_uint_conversion() { #[test] fn dint_to_usint_conversion() { let src = r" - TYPE myType : STRUCT - zero : USINT; negative : USINT; positive : USINT; - max_minus_one : USINT; min_plus_one : USINT; max_overflow : USINT; min_overflow : USINT; - END_STRUCT END_TYPE + TYPE myType : STRUCT + zero : USINT; negative : USINT; positive : USINT; + max_minus_one : USINT; min_plus_one : USINT; max_overflow : USINT; min_overflow : USINT; + END_STRUCT END_TYPE - VAR_GLOBAL - MAX : DINT := 255; - MIN : DINT := 0; - END_VAR + VAR_GLOBAL + MAX : DINT := 255; + MIN : DINT := 0; + END_VAR - PROGRAM main - VAR - ret : myType; - END_VAR - ret.zero := DINT_to_USINT(DINT#0); - ret.negative := DINT_to_USINT(DINT#-1); - ret.positive := DINT_to_USINT(DINT#22); - ret.max_minus_one := DINT_to_USINT(MAX-1); - ret.min_plus_one := DINT_to_USINT(MIN+1); - ret.max_overflow := DINT_to_USINT(MAX+1); - ret.min_overflow := DINT_to_USINT(MIN-1); + PROGRAM main + VAR + ret : myType; + END_VAR + ret.zero := DINT_to_USINT(DINT#0); + ret.negative := DINT_to_USINT(DINT#-1); + ret.positive := DINT_to_USINT(DINT#22); + ret.max_minus_one := DINT_to_USINT(MAX-1); + ret.min_plus_one := DINT_to_USINT(MIN+1); + ret.max_overflow := DINT_to_USINT(MAX+1); + ret.min_overflow := DINT_to_USINT(MIN-1); END_PROGRAM "; let sources = add_std!(src, "num_conversion.st", "numerical_functions.st"); @@ -1267,27 +1267,27 @@ fn dint_to_usint_conversion() { #[test] fn int_to_lreal_conversion() { let src = r" - TYPE myType : STRUCT - zero : LREAL; negative : LREAL; positive : LREAL; - max_minus_one : LREAL; min_plus_one : LREAL; max_overflow : LREAL; min_overflow : LREAL; - END_STRUCT END_TYPE + TYPE myType : STRUCT + zero : LREAL; negative : LREAL; positive : LREAL; + max_minus_one : LREAL; min_plus_one : LREAL; max_overflow : LREAL; min_overflow : LREAL; + END_STRUCT END_TYPE - VAR_GLOBAL - MAX : INT := 32767; - MIN : INT := -32768; - END_VAR + VAR_GLOBAL + MAX : INT := 32767; + MIN : INT := -32768; + END_VAR - PROGRAM main - VAR - ret : myType; - END_VAR - ret.zero := INT_to_LREAL(INT#0); - ret.negative := INT_to_LREAL(INT#-11); - ret.positive := INT_to_LREAL(INT#22); - ret.max_minus_one := INT_to_LREAL(MAX-1); - ret.min_plus_one := INT_to_LREAL(MIN+1); - ret.max_overflow := INT_to_LREAL(MAX+1); - ret.min_overflow := INT_to_LREAL(MIN-1); + PROGRAM main + VAR + ret : myType; + END_VAR + ret.zero := INT_to_LREAL(INT#0); + ret.negative := INT_to_LREAL(INT#-11); + ret.positive := INT_to_LREAL(INT#22); + ret.max_minus_one := INT_to_LREAL(MAX-1); + ret.min_plus_one := INT_to_LREAL(MIN+1); + ret.max_overflow := INT_to_LREAL(MAX+1); + ret.min_overflow := INT_to_LREAL(MIN-1); END_PROGRAM "; let sources = add_std!(src, "num_conversion.st", "numerical_functions.st"); @@ -1305,27 +1305,27 @@ fn int_to_lreal_conversion() { #[test] fn int_to_real_conversion() { let src = r" - TYPE myType : STRUCT - zero : REAL; negative : REAL; positive : REAL; - max_minus_one : REAL; min_plus_one : REAL; max_overflow : REAL; min_overflow : REAL; - END_STRUCT END_TYPE + TYPE myType : STRUCT + zero : REAL; negative : REAL; positive : REAL; + max_minus_one : REAL; min_plus_one : REAL; max_overflow : REAL; min_overflow : REAL; + END_STRUCT END_TYPE - VAR_GLOBAL - MAX : INT := 32767; - MIN : INT := -32768; - END_VAR + VAR_GLOBAL + MAX : INT := 32767; + MIN : INT := -32768; + END_VAR - PROGRAM main - VAR - ret : myType; - END_VAR - ret.zero := INT_to_REAL(INT#0); - ret.negative := INT_to_REAL(INT#-11); - ret.positive := INT_to_REAL(INT#22); - ret.max_minus_one := INT_to_REAL(MAX-1); - ret.min_plus_one := INT_to_REAL(MIN+1); - ret.max_overflow := INT_to_REAL(MAX+1); - ret.min_overflow := INT_to_REAL(MIN-1); + PROGRAM main + VAR + ret : myType; + END_VAR + ret.zero := INT_to_REAL(INT#0); + ret.negative := INT_to_REAL(INT#-11); + ret.positive := INT_to_REAL(INT#22); + ret.max_minus_one := INT_to_REAL(MAX-1); + ret.min_plus_one := INT_to_REAL(MIN+1); + ret.max_overflow := INT_to_REAL(MAX+1); + ret.min_overflow := INT_to_REAL(MIN-1); END_PROGRAM "; let sources = add_std!(src, "num_conversion.st", "numerical_functions.st"); @@ -1343,27 +1343,27 @@ fn int_to_real_conversion() { #[test] fn int_to_lint_conversion() { let src = r" - TYPE myType : STRUCT - zero : LINT; negative : LINT; positive : LINT; - max_minus_one : LINT; min_plus_one : LINT; max_overflow : LINT; min_overflow : LINT; - END_STRUCT END_TYPE + TYPE myType : STRUCT + zero : LINT; negative : LINT; positive : LINT; + max_minus_one : LINT; min_plus_one : LINT; max_overflow : LINT; min_overflow : LINT; + END_STRUCT END_TYPE - VAR_GLOBAL - MAX : INT := 32767; - MIN : INT := -32768; - END_VAR + VAR_GLOBAL + MAX : INT := 32767; + MIN : INT := -32768; + END_VAR - PROGRAM main - VAR - ret : myType; - END_VAR - ret.zero := INT_to_LINT(INT#0); - ret.negative := INT_to_LINT(INT#-11); - ret.positive := INT_to_LINT(INT#22); - ret.max_minus_one := INT_to_LINT(MAX-1); - ret.min_plus_one := INT_to_LINT(MIN+1); - ret.max_overflow := INT_to_LINT(MAX+1); - ret.min_overflow := INT_to_LINT(MIN-1); + PROGRAM main + VAR + ret : myType; + END_VAR + ret.zero := INT_to_LINT(INT#0); + ret.negative := INT_to_LINT(INT#-11); + ret.positive := INT_to_LINT(INT#22); + ret.max_minus_one := INT_to_LINT(MAX-1); + ret.min_plus_one := INT_to_LINT(MIN+1); + ret.max_overflow := INT_to_LINT(MAX+1); + ret.min_overflow := INT_to_LINT(MIN-1); END_PROGRAM "; let sources = add_std!(src, "num_conversion.st", "numerical_functions.st"); @@ -1381,27 +1381,27 @@ fn int_to_lint_conversion() { #[test] fn int_to_dint_conversion() { let src = r" - TYPE myType : STRUCT - zero : DINT; negative : DINT; positive : DINT; - max_minus_one : DINT; min_plus_one : DINT; max_overflow : DINT; min_overflow : DINT; - END_STRUCT END_TYPE + TYPE myType : STRUCT + zero : DINT; negative : DINT; positive : DINT; + max_minus_one : DINT; min_plus_one : DINT; max_overflow : DINT; min_overflow : DINT; + END_STRUCT END_TYPE - VAR_GLOBAL - MAX : INT := 32767; - MIN : INT := -32768; - END_VAR + VAR_GLOBAL + MAX : INT := 32767; + MIN : INT := -32768; + END_VAR - PROGRAM main - VAR - ret : myType; - END_VAR - ret.zero := INT_to_DINT(INT#0); - ret.negative := INT_to_DINT(INT#-11); - ret.positive := INT_to_DINT(INT#22); - ret.max_minus_one := INT_to_DINT(MAX-1); - ret.min_plus_one := INT_to_DINT(MIN+1); - ret.max_overflow := INT_to_DINT(MAX+1); - ret.min_overflow := INT_to_DINT(MIN-1); + PROGRAM main + VAR + ret : myType; + END_VAR + ret.zero := INT_to_DINT(INT#0); + ret.negative := INT_to_DINT(INT#-11); + ret.positive := INT_to_DINT(INT#22); + ret.max_minus_one := INT_to_DINT(MAX-1); + ret.min_plus_one := INT_to_DINT(MIN+1); + ret.max_overflow := INT_to_DINT(MAX+1); + ret.min_overflow := INT_to_DINT(MIN-1); END_PROGRAM "; let sources = add_std!(src, "num_conversion.st", "numerical_functions.st"); @@ -1419,27 +1419,27 @@ fn int_to_dint_conversion() { #[test] fn int_to_sint_conversion() { let src = r" - TYPE myType : STRUCT - zero : SINT; negative : SINT; positive : SINT; - max_minus_one : SINT; min_plus_one : SINT; max_overflow : SINT; min_overflow : SINT; - END_STRUCT END_TYPE + TYPE myType : STRUCT + zero : SINT; negative : SINT; positive : SINT; + max_minus_one : SINT; min_plus_one : SINT; max_overflow : SINT; min_overflow : SINT; + END_STRUCT END_TYPE - VAR_GLOBAL - MAX : INT := 127; - MIN : INT := -128; - END_VAR + VAR_GLOBAL + MAX : INT := 127; + MIN : INT := -128; + END_VAR - PROGRAM main - VAR - ret : myType; - END_VAR - ret.zero := INT_to_SINT(INT#0); - ret.negative := INT_to_SINT(INT#-11); - ret.positive := INT_to_SINT(INT#22); - ret.max_minus_one := INT_to_SINT(MAX-1); - ret.min_plus_one := INT_to_SINT(MIN+1); - ret.max_overflow := INT_to_SINT(MAX+1); - ret.min_overflow := INT_to_SINT(MIN-1); + PROGRAM main + VAR + ret : myType; + END_VAR + ret.zero := INT_to_SINT(INT#0); + ret.negative := INT_to_SINT(INT#-11); + ret.positive := INT_to_SINT(INT#22); + ret.max_minus_one := INT_to_SINT(MAX-1); + ret.min_plus_one := INT_to_SINT(MIN+1); + ret.max_overflow := INT_to_SINT(MAX+1); + ret.min_overflow := INT_to_SINT(MIN-1); END_PROGRAM "; let sources = add_std!(src, "num_conversion.st", "numerical_functions.st"); @@ -1457,27 +1457,27 @@ fn int_to_sint_conversion() { #[test] fn int_to_ulint_conversion() { let src = r" - TYPE myType : STRUCT - zero : ULINT; negative : ULINT; positive : ULINT; - max_minus_one : ULINT; min_plus_one : ULINT; max_overflow : ULINT; min_overflow : ULINT; - END_STRUCT END_TYPE + TYPE myType : STRUCT + zero : ULINT; negative : ULINT; positive : ULINT; + max_minus_one : ULINT; min_plus_one : ULINT; max_overflow : ULINT; min_overflow : ULINT; + END_STRUCT END_TYPE - VAR_GLOBAL - MAX : INT := 32767; - MIN : INT := -32768; - END_VAR + VAR_GLOBAL + MAX : INT := 32767; + MIN : INT := -32768; + END_VAR - PROGRAM main - VAR - ret : myType; - END_VAR - ret.zero := INT_to_ULINT(INT#0); - ret.negative := INT_to_ULINT(INT#-1); - ret.positive := INT_to_ULINT(INT#22); - ret.max_minus_one := INT_to_ULINT(MAX-1); - ret.min_plus_one := INT_to_ULINT(MIN+1); - ret.max_overflow := INT_to_ULINT(MAX+1); - ret.min_overflow := INT_to_ULINT(MIN-1); + PROGRAM main + VAR + ret : myType; + END_VAR + ret.zero := INT_to_ULINT(INT#0); + ret.negative := INT_to_ULINT(INT#-1); + ret.positive := INT_to_ULINT(INT#22); + ret.max_minus_one := INT_to_ULINT(MAX-1); + ret.min_plus_one := INT_to_ULINT(MIN+1); + ret.max_overflow := INT_to_ULINT(MAX+1); + ret.min_overflow := INT_to_ULINT(MIN-1); END_PROGRAM "; let sources = add_std!(src, "num_conversion.st", "numerical_functions.st"); @@ -1495,27 +1495,27 @@ fn int_to_ulint_conversion() { #[test] fn int_to_udint_conversion() { let src = r" - TYPE myType : STRUCT - zero : UDINT; negative : UDINT; positive : UDINT; - max_minus_one : UDINT; min_plus_one : UDINT; max_overflow : UDINT; min_overflow : UDINT; - END_STRUCT END_TYPE + TYPE myType : STRUCT + zero : UDINT; negative : UDINT; positive : UDINT; + max_minus_one : UDINT; min_plus_one : UDINT; max_overflow : UDINT; min_overflow : UDINT; + END_STRUCT END_TYPE - VAR_GLOBAL - MAX : INT := 32767; - MIN : INT := -32768; - END_VAR + VAR_GLOBAL + MAX : INT := 32767; + MIN : INT := -32768; + END_VAR - PROGRAM main - VAR - ret : myType; - END_VAR - ret.zero := INT_to_UDINT(INT#0); - ret.negative := INT_to_UDINT(INT#-1); - ret.positive := INT_to_UDINT(INT#22); - ret.max_minus_one := INT_to_UDINT(MAX-1); - ret.min_plus_one := INT_to_UDINT(MIN+1); - ret.max_overflow := INT_to_UDINT(MAX+1); - ret.min_overflow := INT_to_UDINT(MIN-1); + PROGRAM main + VAR + ret : myType; + END_VAR + ret.zero := INT_to_UDINT(INT#0); + ret.negative := INT_to_UDINT(INT#-1); + ret.positive := INT_to_UDINT(INT#22); + ret.max_minus_one := INT_to_UDINT(MAX-1); + ret.min_plus_one := INT_to_UDINT(MIN+1); + ret.max_overflow := INT_to_UDINT(MAX+1); + ret.min_overflow := INT_to_UDINT(MIN-1); END_PROGRAM "; let sources = add_std!(src, "num_conversion.st", "numerical_functions.st"); @@ -1533,27 +1533,27 @@ fn int_to_udint_conversion() { #[test] fn int_to_uint_conversion() { let src = r" - TYPE myType : STRUCT - zero : UINT; negative : UINT; positive : UINT; - max_minus_one : UINT; min_plus_one : UINT; max_overflow : UINT; min_overflow : UINT; - END_STRUCT END_TYPE + TYPE myType : STRUCT + zero : UINT; negative : UINT; positive : UINT; + max_minus_one : UINT; min_plus_one : UINT; max_overflow : UINT; min_overflow : UINT; + END_STRUCT END_TYPE - VAR_GLOBAL - MAX : INT := 32767; - MIN : INT := -32768; - END_VAR + VAR_GLOBAL + MAX : INT := 32767; + MIN : INT := -32768; + END_VAR - PROGRAM main - VAR - ret : myType; - END_VAR - ret.zero := INT_to_UINT(INT#0); - ret.negative := INT_to_UINT(INT#-1); - ret.positive := INT_to_UINT(INT#22); - ret.max_minus_one := INT_to_UINT(MAX-1); - ret.min_plus_one := INT_to_UINT(MIN+1); - ret.max_overflow := INT_to_UINT(MAX+1); - ret.min_overflow := INT_to_UINT(MIN-1); + PROGRAM main + VAR + ret : myType; + END_VAR + ret.zero := INT_to_UINT(INT#0); + ret.negative := INT_to_UINT(INT#-1); + ret.positive := INT_to_UINT(INT#22); + ret.max_minus_one := INT_to_UINT(MAX-1); + ret.min_plus_one := INT_to_UINT(MIN+1); + ret.max_overflow := INT_to_UINT(MAX+1); + ret.min_overflow := INT_to_UINT(MIN-1); END_PROGRAM "; let sources = add_std!(src, "num_conversion.st", "numerical_functions.st"); @@ -1571,27 +1571,27 @@ fn int_to_uint_conversion() { #[test] fn int_to_usint_conversion() { let src = r" - TYPE myType : STRUCT - zero : USINT; negative : USINT; positive : USINT; - max_minus_one : USINT; min_plus_one : USINT; max_overflow : USINT; min_overflow : USINT; - END_STRUCT END_TYPE + TYPE myType : STRUCT + zero : USINT; negative : USINT; positive : USINT; + max_minus_one : USINT; min_plus_one : USINT; max_overflow : USINT; min_overflow : USINT; + END_STRUCT END_TYPE - VAR_GLOBAL - MAX : INT := 255; - MIN : INT := 0; - END_VAR + VAR_GLOBAL + MAX : INT := 255; + MIN : INT := 0; + END_VAR - PROGRAM main - VAR - ret : myType; - END_VAR - ret.zero := INT_to_USINT(INT#0); - ret.negative := INT_to_USINT(INT#-1); - ret.positive := INT_to_USINT(INT#22); - ret.max_minus_one := INT_to_USINT(MAX-1); - ret.min_plus_one := INT_to_USINT(MIN+1); - ret.max_overflow := INT_to_USINT(MAX+1); - ret.min_overflow := INT_to_USINT(MIN-1); + PROGRAM main + VAR + ret : myType; + END_VAR + ret.zero := INT_to_USINT(INT#0); + ret.negative := INT_to_USINT(INT#-1); + ret.positive := INT_to_USINT(INT#22); + ret.max_minus_one := INT_to_USINT(MAX-1); + ret.min_plus_one := INT_to_USINT(MIN+1); + ret.max_overflow := INT_to_USINT(MAX+1); + ret.min_overflow := INT_to_USINT(MIN-1); END_PROGRAM "; let sources = add_std!(src, "num_conversion.st", "numerical_functions.st"); @@ -1609,27 +1609,27 @@ fn int_to_usint_conversion() { #[test] fn sint_to_lreal_conversion() { let src = r" - TYPE myType : STRUCT - zero : LREAL; negative : LREAL; positive : LREAL; - max_minus_one : LREAL; min_plus_one : LREAL; max_overflow : LREAL; min_overflow : LREAL; - END_STRUCT END_TYPE + TYPE myType : STRUCT + zero : LREAL; negative : LREAL; positive : LREAL; + max_minus_one : LREAL; min_plus_one : LREAL; max_overflow : LREAL; min_overflow : LREAL; + END_STRUCT END_TYPE - VAR_GLOBAL - MAX : SINT := 127; - MIN : SINT := -128; - END_VAR + VAR_GLOBAL + MAX : SINT := 127; + MIN : SINT := -128; + END_VAR - PROGRAM main - VAR - ret : myType; - END_VAR - ret.zero := SINT_to_LREAL(SINT#0); - ret.negative := SINT_to_LREAL(SINT#-11); - ret.positive := SINT_to_LREAL(SINT#22); - ret.max_minus_one := SINT_to_LREAL(MAX-1); - ret.min_plus_one := SINT_to_LREAL(MIN+1); - ret.max_overflow := SINT_to_LREAL(MAX+1); - ret.min_overflow := SINT_to_LREAL(MIN-1); + PROGRAM main + VAR + ret : myType; + END_VAR + ret.zero := SINT_to_LREAL(SINT#0); + ret.negative := SINT_to_LREAL(SINT#-11); + ret.positive := SINT_to_LREAL(SINT#22); + ret.max_minus_one := SINT_to_LREAL(MAX-1); + ret.min_plus_one := SINT_to_LREAL(MIN+1); + ret.max_overflow := SINT_to_LREAL(MAX+1); + ret.min_overflow := SINT_to_LREAL(MIN-1); END_PROGRAM "; let sources = add_std!(src, "num_conversion.st", "numerical_functions.st"); @@ -1647,27 +1647,27 @@ fn sint_to_lreal_conversion() { #[test] fn sint_to_real_conversion() { let src = r" - TYPE myType : STRUCT - zero : REAL; negative : REAL; positive : REAL; - max_minus_one : REAL; min_plus_one : REAL; max_overflow : REAL; min_overflow : REAL; - END_STRUCT END_TYPE + TYPE myType : STRUCT + zero : REAL; negative : REAL; positive : REAL; + max_minus_one : REAL; min_plus_one : REAL; max_overflow : REAL; min_overflow : REAL; + END_STRUCT END_TYPE - VAR_GLOBAL - MAX : SINT := 127; - MIN : SINT := -128; - END_VAR + VAR_GLOBAL + MAX : SINT := 127; + MIN : SINT := -128; + END_VAR - PROGRAM main - VAR - ret : myType; - END_VAR - ret.zero := SINT_to_REAL(SINT#0); - ret.negative := SINT_to_REAL(SINT#-11); - ret.positive := SINT_to_REAL(SINT#22); - ret.max_minus_one := SINT_to_REAL(MAX-1); - ret.min_plus_one := SINT_to_REAL(MIN+1); - ret.max_overflow := SINT_to_REAL(MAX+1); - ret.min_overflow := SINT_to_REAL(MIN-1); + PROGRAM main + VAR + ret : myType; + END_VAR + ret.zero := SINT_to_REAL(SINT#0); + ret.negative := SINT_to_REAL(SINT#-11); + ret.positive := SINT_to_REAL(SINT#22); + ret.max_minus_one := SINT_to_REAL(MAX-1); + ret.min_plus_one := SINT_to_REAL(MIN+1); + ret.max_overflow := SINT_to_REAL(MAX+1); + ret.min_overflow := SINT_to_REAL(MIN-1); END_PROGRAM "; let sources = add_std!(src, "num_conversion.st", "numerical_functions.st"); @@ -1685,27 +1685,27 @@ fn sint_to_real_conversion() { #[test] fn sint_to_lint_conversion() { let src = r" - TYPE myType : STRUCT - zero : LINT; negative : LINT; positive : LINT; - max_minus_one : LINT; min_plus_one : LINT; max_overflow : LINT; min_overflow : LINT; - END_STRUCT END_TYPE + TYPE myType : STRUCT + zero : LINT; negative : LINT; positive : LINT; + max_minus_one : LINT; min_plus_one : LINT; max_overflow : LINT; min_overflow : LINT; + END_STRUCT END_TYPE - VAR_GLOBAL - MAX : SINT := 127; - MIN : SINT := -128; - END_VAR + VAR_GLOBAL + MAX : SINT := 127; + MIN : SINT := -128; + END_VAR - PROGRAM main - VAR - ret : myType; - END_VAR - ret.zero := SINT_to_LINT(SINT#0); - ret.negative := SINT_to_LINT(SINT#-11); - ret.positive := SINT_to_LINT(SINT#22); - ret.max_minus_one := SINT_to_LINT(MAX-1); - ret.min_plus_one := SINT_to_LINT(MIN+1); - ret.max_overflow := SINT_to_LINT(MAX+1); - ret.min_overflow := SINT_to_LINT(MIN-1); + PROGRAM main + VAR + ret : myType; + END_VAR + ret.zero := SINT_to_LINT(SINT#0); + ret.negative := SINT_to_LINT(SINT#-11); + ret.positive := SINT_to_LINT(SINT#22); + ret.max_minus_one := SINT_to_LINT(MAX-1); + ret.min_plus_one := SINT_to_LINT(MIN+1); + ret.max_overflow := SINT_to_LINT(MAX+1); + ret.min_overflow := SINT_to_LINT(MIN-1); END_PROGRAM "; let sources = add_std!(src, "num_conversion.st", "numerical_functions.st"); @@ -1723,27 +1723,27 @@ fn sint_to_lint_conversion() { #[test] fn sint_to_dint_conversion() { let src = r" - TYPE myType : STRUCT - zero : DINT; negative : DINT; positive : DINT; - max_minus_one : DINT; min_plus_one : DINT; max_overflow : DINT; min_overflow : DINT; - END_STRUCT END_TYPE + TYPE myType : STRUCT + zero : DINT; negative : DINT; positive : DINT; + max_minus_one : DINT; min_plus_one : DINT; max_overflow : DINT; min_overflow : DINT; + END_STRUCT END_TYPE - VAR_GLOBAL - MAX : SINT := 127; - MIN : SINT := -128; - END_VAR + VAR_GLOBAL + MAX : SINT := 127; + MIN : SINT := -128; + END_VAR - PROGRAM main - VAR - ret : myType; - END_VAR - ret.zero := SINT_to_DINT(SINT#0); - ret.negative := SINT_to_DINT(SINT#-11); - ret.positive := SINT_to_DINT(SINT#22); - ret.max_minus_one := SINT_to_DINT(MAX-1); - ret.min_plus_one := SINT_to_DINT(MIN+1); - ret.max_overflow := SINT_to_DINT(MAX+1); - ret.min_overflow := SINT_to_DINT(MIN-1); + PROGRAM main + VAR + ret : myType; + END_VAR + ret.zero := SINT_to_DINT(SINT#0); + ret.negative := SINT_to_DINT(SINT#-11); + ret.positive := SINT_to_DINT(SINT#22); + ret.max_minus_one := SINT_to_DINT(MAX-1); + ret.min_plus_one := SINT_to_DINT(MIN+1); + ret.max_overflow := SINT_to_DINT(MAX+1); + ret.min_overflow := SINT_to_DINT(MIN-1); END_PROGRAM "; let sources = add_std!(src, "num_conversion.st", "numerical_functions.st"); @@ -1761,27 +1761,27 @@ fn sint_to_dint_conversion() { #[test] fn sint_to_int_conversion() { let src = r" - TYPE myType : STRUCT - zero : INT; negative : INT; positive : INT; - max_minus_one : INT; min_plus_one : INT; max_overflow : INT; min_overflow : INT; - END_STRUCT END_TYPE + TYPE myType : STRUCT + zero : INT; negative : INT; positive : INT; + max_minus_one : INT; min_plus_one : INT; max_overflow : INT; min_overflow : INT; + END_STRUCT END_TYPE - VAR_GLOBAL - MAX : SINT := 127; - MIN : SINT := -128; - END_VAR + VAR_GLOBAL + MAX : SINT := 127; + MIN : SINT := -128; + END_VAR - PROGRAM main - VAR - ret : myType; - END_VAR - ret.zero := SINT_to_INT(SINT#0); - ret.negative := SINT_to_INT(SINT#-11); - ret.positive := SINT_to_INT(SINT#22); - ret.max_minus_one := SINT_to_INT(MAX-1); - ret.min_plus_one := SINT_to_INT(MIN+1); - ret.max_overflow := SINT_to_INT(MAX+1); - ret.min_overflow := SINT_to_INT(MIN-1); + PROGRAM main + VAR + ret : myType; + END_VAR + ret.zero := SINT_to_INT(SINT#0); + ret.negative := SINT_to_INT(SINT#-11); + ret.positive := SINT_to_INT(SINT#22); + ret.max_minus_one := SINT_to_INT(MAX-1); + ret.min_plus_one := SINT_to_INT(MIN+1); + ret.max_overflow := SINT_to_INT(MAX+1); + ret.min_overflow := SINT_to_INT(MIN-1); END_PROGRAM "; let sources = add_std!(src, "num_conversion.st", "numerical_functions.st"); @@ -1799,27 +1799,27 @@ fn sint_to_int_conversion() { #[test] fn sint_to_ulint_conversion() { let src = r" - TYPE myType : STRUCT - zero : ULINT; negative : ULINT; positive : ULINT; - max_minus_one : ULINT; min_plus_one : ULINT; max_overflow : ULINT; min_overflow : ULINT; - END_STRUCT END_TYPE + TYPE myType : STRUCT + zero : ULINT; negative : ULINT; positive : ULINT; + max_minus_one : ULINT; min_plus_one : ULINT; max_overflow : ULINT; min_overflow : ULINT; + END_STRUCT END_TYPE - VAR_GLOBAL - MAX : SINT := 127; - MIN : SINT := -128; - END_VAR + VAR_GLOBAL + MAX : SINT := 127; + MIN : SINT := -128; + END_VAR - PROGRAM main - VAR - ret : myType; - END_VAR - ret.zero := SINT_to_ULINT(SINT#0); - ret.negative := SINT_to_ULINT(SINT#-1); - ret.positive := SINT_to_ULINT(SINT#22); - ret.max_minus_one := SINT_to_ULINT(MAX-1); - ret.min_plus_one := SINT_to_ULINT(MIN+1); - ret.max_overflow := SINT_to_ULINT(MAX+1); - ret.min_overflow := SINT_to_ULINT(MIN-1); + PROGRAM main + VAR + ret : myType; + END_VAR + ret.zero := SINT_to_ULINT(SINT#0); + ret.negative := SINT_to_ULINT(SINT#-1); + ret.positive := SINT_to_ULINT(SINT#22); + ret.max_minus_one := SINT_to_ULINT(MAX-1); + ret.min_plus_one := SINT_to_ULINT(MIN+1); + ret.max_overflow := SINT_to_ULINT(MAX+1); + ret.min_overflow := SINT_to_ULINT(MIN-1); END_PROGRAM "; let sources = add_std!(src, "num_conversion.st", "numerical_functions.st"); @@ -1837,27 +1837,27 @@ fn sint_to_ulint_conversion() { #[test] fn sint_to_udint_conversion() { let src = r" - TYPE myType : STRUCT - zero : UDINT; negative : UDINT; positive : UDINT; - max_minus_one : UDINT; min_plus_one : UDINT; max_overflow : UDINT; min_overflow : UDINT; - END_STRUCT END_TYPE + TYPE myType : STRUCT + zero : UDINT; negative : UDINT; positive : UDINT; + max_minus_one : UDINT; min_plus_one : UDINT; max_overflow : UDINT; min_overflow : UDINT; + END_STRUCT END_TYPE - VAR_GLOBAL - MAX : SINT := 127; - MIN : SINT := -128; - END_VAR + VAR_GLOBAL + MAX : SINT := 127; + MIN : SINT := -128; + END_VAR - PROGRAM main - VAR - ret : myType; - END_VAR - ret.zero := SINT_to_UDINT(SINT#0); - ret.negative := SINT_to_UDINT(SINT#-1); - ret.positive := SINT_to_UDINT(SINT#22); - ret.max_minus_one := SINT_to_UDINT(MAX-1); - ret.min_plus_one := SINT_to_UDINT(MIN+1); - ret.max_overflow := SINT_to_UDINT(MAX+1); - ret.min_overflow := SINT_to_UDINT(MIN-1); + PROGRAM main + VAR + ret : myType; + END_VAR + ret.zero := SINT_to_UDINT(SINT#0); + ret.negative := SINT_to_UDINT(SINT#-1); + ret.positive := SINT_to_UDINT(SINT#22); + ret.max_minus_one := SINT_to_UDINT(MAX-1); + ret.min_plus_one := SINT_to_UDINT(MIN+1); + ret.max_overflow := SINT_to_UDINT(MAX+1); + ret.min_overflow := SINT_to_UDINT(MIN-1); END_PROGRAM "; let sources = add_std!(src, "num_conversion.st", "numerical_functions.st"); @@ -1875,27 +1875,27 @@ fn sint_to_udint_conversion() { #[test] fn sint_to_uint_conversion() { let src = r" - TYPE myType : STRUCT - zero : UINT; negative : UINT; positive : UINT; - max_minus_one : UINT; min_plus_one : UINT; max_overflow : UINT; min_overflow : UINT; - END_STRUCT END_TYPE + TYPE myType : STRUCT + zero : UINT; negative : UINT; positive : UINT; + max_minus_one : UINT; min_plus_one : UINT; max_overflow : UINT; min_overflow : UINT; + END_STRUCT END_TYPE - VAR_GLOBAL - MAX : SINT := 127; - MIN : SINT := -128; - END_VAR + VAR_GLOBAL + MAX : SINT := 127; + MIN : SINT := -128; + END_VAR - PROGRAM main - VAR - ret : myType; - END_VAR - ret.zero := SINT_to_UINT(SINT#0); - ret.negative := SINT_to_UINT(SINT#-1); - ret.positive := SINT_to_UINT(SINT#22); - ret.max_minus_one := SINT_to_UINT(MAX-1); - ret.min_plus_one := SINT_to_UINT(MIN+1); - ret.max_overflow := SINT_to_UINT(MAX+1); - ret.min_overflow := SINT_to_UINT(MIN-1); + PROGRAM main + VAR + ret : myType; + END_VAR + ret.zero := SINT_to_UINT(SINT#0); + ret.negative := SINT_to_UINT(SINT#-1); + ret.positive := SINT_to_UINT(SINT#22); + ret.max_minus_one := SINT_to_UINT(MAX-1); + ret.min_plus_one := SINT_to_UINT(MIN+1); + ret.max_overflow := SINT_to_UINT(MAX+1); + ret.min_overflow := SINT_to_UINT(MIN-1); END_PROGRAM "; let sources = add_std!(src, "num_conversion.st", "numerical_functions.st"); @@ -1913,27 +1913,27 @@ fn sint_to_uint_conversion() { #[test] fn sint_to_usint_conversion() { let src = r" - TYPE myType : STRUCT - zero : USINT; negative : USINT; positive : USINT; - max_minus_one : USINT; min_plus_one : USINT; max_overflow : USINT; min_overflow : USINT; - END_STRUCT END_TYPE + TYPE myType : STRUCT + zero : USINT; negative : USINT; positive : USINT; + max_minus_one : USINT; min_plus_one : USINT; max_overflow : USINT; min_overflow : USINT; + END_STRUCT END_TYPE - VAR_GLOBAL - MAX : SINT := 127; - MIN : SINT := -128; - END_VAR + VAR_GLOBAL + MAX : SINT := 127; + MIN : SINT := -128; + END_VAR - PROGRAM main - VAR - ret : myType; - END_VAR - ret.zero := SINT_to_USINT(SINT#0); - ret.negative := SINT_to_USINT(SINT#-1); - ret.positive := SINT_to_USINT(SINT#22); - ret.max_minus_one := SINT_to_USINT(MAX-1); - ret.min_plus_one := SINT_to_USINT(MIN+1); - ret.max_overflow := SINT_to_USINT(MAX+1); - ret.min_overflow := SINT_to_USINT(MIN-1); + PROGRAM main + VAR + ret : myType; + END_VAR + ret.zero := SINT_to_USINT(SINT#0); + ret.negative := SINT_to_USINT(SINT#-1); + ret.positive := SINT_to_USINT(SINT#22); + ret.max_minus_one := SINT_to_USINT(MAX-1); + ret.min_plus_one := SINT_to_USINT(MIN+1); + ret.max_overflow := SINT_to_USINT(MAX+1); + ret.min_overflow := SINT_to_USINT(MIN-1); END_PROGRAM "; let sources = add_std!(src, "num_conversion.st", "numerical_functions.st"); @@ -1951,27 +1951,27 @@ fn sint_to_usint_conversion() { #[test] fn ulint_to_lreal_conversion() { let src = r" - TYPE myType : STRUCT - zero : LREAL; negative : LREAL; positive : LREAL; - max_minus_one : LREAL; min_plus_one : LREAL; max_overflow : LREAL; min_overflow : LREAL; - END_STRUCT END_TYPE + TYPE myType : STRUCT + zero : LREAL; negative : LREAL; positive : LREAL; + max_minus_one : LREAL; min_plus_one : LREAL; max_overflow : LREAL; min_overflow : LREAL; + END_STRUCT END_TYPE - VAR_GLOBAL - MAX : ULINT := 18446744073709551615; - MIN : ULINT := 0; - END_VAR + VAR_GLOBAL + MAX : ULINT := 18446744073709551615; + MIN : ULINT := 0; + END_VAR - PROGRAM main - VAR - ret : myType; - END_VAR - ret.zero := ULINT_to_LREAL(ULINT#0); - ret.negative := ULINT_to_LREAL(-2); - ret.positive := ULINT_to_LREAL(ULINT#22); - ret.max_minus_one := ULINT_to_LREAL(MAX-1); - ret.min_plus_one := ULINT_to_LREAL(MIN+1); - ret.max_overflow := ULINT_to_LREAL(MAX+1); - ret.min_overflow := ULINT_to_LREAL(MIN-1); + PROGRAM main + VAR + ret : myType; + END_VAR + ret.zero := ULINT_to_LREAL(ULINT#0); + ret.negative := ULINT_to_LREAL(-2); + ret.positive := ULINT_to_LREAL(ULINT#22); + ret.max_minus_one := ULINT_to_LREAL(MAX-1); + ret.min_plus_one := ULINT_to_LREAL(MIN+1); + ret.max_overflow := ULINT_to_LREAL(MAX+1); + ret.min_overflow := ULINT_to_LREAL(MIN-1); END_PROGRAM "; let sources = add_std!(src, "num_conversion.st", "numerical_functions.st"); @@ -1989,27 +1989,27 @@ fn ulint_to_lreal_conversion() { #[test] fn ulint_to_real_conversion() { let src = r" - TYPE myType : STRUCT - zero : REAL; negative : REAL; positive : REAL; - max_minus_one : REAL; min_plus_one : REAL; max_overflow : REAL; min_overflow : REAL; - END_STRUCT END_TYPE + TYPE myType : STRUCT + zero : REAL; negative : REAL; positive : REAL; + max_minus_one : REAL; min_plus_one : REAL; max_overflow : REAL; min_overflow : REAL; + END_STRUCT END_TYPE - VAR_GLOBAL - MAX : ULINT := 18446744073709551615; - MIN : ULINT := 0; - END_VAR + VAR_GLOBAL + MAX : ULINT := 18446744073709551615; + MIN : ULINT := 0; + END_VAR - PROGRAM main - VAR - ret : myType; - END_VAR - ret.zero := ULINT_to_REAL(ULINT#0); - ret.negative := ULINT_to_REAL(-2); - ret.positive := ULINT_to_REAL(ULINT#22); - ret.max_minus_one := ULINT_to_REAL(MAX-1); - ret.min_plus_one := ULINT_to_REAL(MIN+1); - ret.max_overflow := ULINT_to_REAL(MAX+1); - ret.min_overflow := ULINT_to_REAL(MIN-1); + PROGRAM main + VAR + ret : myType; + END_VAR + ret.zero := ULINT_to_REAL(ULINT#0); + ret.negative := ULINT_to_REAL(-2); + ret.positive := ULINT_to_REAL(ULINT#22); + ret.max_minus_one := ULINT_to_REAL(MAX-1); + ret.min_plus_one := ULINT_to_REAL(MIN+1); + ret.max_overflow := ULINT_to_REAL(MAX+1); + ret.min_overflow := ULINT_to_REAL(MIN-1); END_PROGRAM "; let sources = add_std!(src, "num_conversion.st", "numerical_functions.st"); @@ -2027,25 +2027,25 @@ fn ulint_to_real_conversion() { #[test] fn ulint_to_lint_conversion() { let src = r" - TYPE myType : STRUCT - zero : LINT; negative : LINT; positive : LINT; - max_minus_one : LINT; min_plus_one : LINT; max_overflow : LINT; min_overflow : LINT; - END_STRUCT END_TYPE + TYPE myType : STRUCT + zero : LINT; negative : LINT; positive : LINT; + max_minus_one : LINT; min_plus_one : LINT; max_overflow : LINT; min_overflow : LINT; + END_STRUCT END_TYPE - VAR_GLOBAL - MAX : ULINT := 9223372036854775807; - MIN : ULINT := 0; - END_VAR + VAR_GLOBAL + MAX : ULINT := 9223372036854775807; + MIN : ULINT := 0; + END_VAR - PROGRAM main - VAR - ret : myType; - END_VAR - ret.zero := ULINT_to_LINT(ULINT#0); - ret.positive := ULINT_to_LINT(ULINT#22); - ret.max_minus_one := ULINT_to_LINT(MAX-1); - ret.min_plus_one := ULINT_to_LINT(MIN+1); - ret.max_overflow := ULINT_to_LINT(MAX+1); + PROGRAM main + VAR + ret : myType; + END_VAR + ret.zero := ULINT_to_LINT(ULINT#0); + ret.positive := ULINT_to_LINT(ULINT#22); + ret.max_minus_one := ULINT_to_LINT(MAX-1); + ret.min_plus_one := ULINT_to_LINT(MIN+1); + ret.max_overflow := ULINT_to_LINT(MAX+1); END_PROGRAM "; let sources = add_std!(src, "num_conversion.st", "numerical_functions.st"); @@ -2061,25 +2061,25 @@ fn ulint_to_lint_conversion() { #[test] fn ulint_to_dint_conversion() { let src = r" - TYPE myType : STRUCT - zero : DINT; negative : DINT; positive : DINT; - max_minus_one : DINT; min_plus_one : DINT; max_overflow : DINT; min_overflow : DINT; - END_STRUCT END_TYPE + TYPE myType : STRUCT + zero : DINT; negative : DINT; positive : DINT; + max_minus_one : DINT; min_plus_one : DINT; max_overflow : DINT; min_overflow : DINT; + END_STRUCT END_TYPE - VAR_GLOBAL - MAX : ULINT := 2147483647; - MIN : ULINT := 0; - END_VAR + VAR_GLOBAL + MAX : ULINT := 2147483647; + MIN : ULINT := 0; + END_VAR - PROGRAM main - VAR - ret : myType; - END_VAR - ret.zero := ULINT_to_DINT(ULINT#0); - ret.positive := ULINT_to_DINT(ULINT#22); - ret.max_minus_one := ULINT_to_DINT(MAX-1); - ret.min_plus_one := ULINT_to_DINT(MIN+1); - ret.max_overflow := ULINT_to_DINT(MAX+1); + PROGRAM main + VAR + ret : myType; + END_VAR + ret.zero := ULINT_to_DINT(ULINT#0); + ret.positive := ULINT_to_DINT(ULINT#22); + ret.max_minus_one := ULINT_to_DINT(MAX-1); + ret.min_plus_one := ULINT_to_DINT(MIN+1); + ret.max_overflow := ULINT_to_DINT(MAX+1); END_PROGRAM "; let sources = add_std!(src, "num_conversion.st", "numerical_functions.st"); @@ -2095,25 +2095,25 @@ fn ulint_to_dint_conversion() { #[test] fn ulint_to_int_conversion() { let src = r" - TYPE myType : STRUCT - zero : INT; negative : INT; positive : INT; - max_minus_one : INT; min_plus_one : INT; max_overflow : INT; min_overflow : INT; - END_STRUCT END_TYPE + TYPE myType : STRUCT + zero : INT; negative : INT; positive : INT; + max_minus_one : INT; min_plus_one : INT; max_overflow : INT; min_overflow : INT; + END_STRUCT END_TYPE - VAR_GLOBAL - MAX : ULINT := 32767; - MIN : ULINT := 0; - END_VAR + VAR_GLOBAL + MAX : ULINT := 32767; + MIN : ULINT := 0; + END_VAR - PROGRAM main - VAR - ret : myType; - END_VAR - ret.zero := ULINT_to_INT(ULINT#0); - ret.positive := ULINT_to_INT(ULINT#22); - ret.max_minus_one := ULINT_to_INT(MAX-1); - ret.min_plus_one := ULINT_to_INT(MIN+1); - ret.max_overflow := ULINT_to_INT(MAX+1); + PROGRAM main + VAR + ret : myType; + END_VAR + ret.zero := ULINT_to_INT(ULINT#0); + ret.positive := ULINT_to_INT(ULINT#22); + ret.max_minus_one := ULINT_to_INT(MAX-1); + ret.min_plus_one := ULINT_to_INT(MIN+1); + ret.max_overflow := ULINT_to_INT(MAX+1); END_PROGRAM "; let sources = add_std!(src, "num_conversion.st", "numerical_functions.st"); @@ -2129,25 +2129,25 @@ fn ulint_to_int_conversion() { #[test] fn ulint_to_sint_conversion() { let src = r" - TYPE myType : STRUCT - zero : SINT; negative : SINT; positive : SINT; - max_minus_one : SINT; min_plus_one : SINT; max_overflow : SINT; min_overflow : SINT; - END_STRUCT END_TYPE + TYPE myType : STRUCT + zero : SINT; negative : SINT; positive : SINT; + max_minus_one : SINT; min_plus_one : SINT; max_overflow : SINT; min_overflow : SINT; + END_STRUCT END_TYPE - VAR_GLOBAL - MAX : ULINT := 127; - MIN : ULINT := 0; - END_VAR + VAR_GLOBAL + MAX : ULINT := 127; + MIN : ULINT := 0; + END_VAR - PROGRAM main - VAR - ret : myType; - END_VAR - ret.zero := ULINT_to_SINT(ULINT#0); - ret.positive := ULINT_to_SINT(ULINT#22); - ret.max_minus_one := ULINT_to_SINT(MAX-1); - ret.min_plus_one := ULINT_to_SINT(MIN+1); - ret.max_overflow := ULINT_to_SINT(MAX+1); + PROGRAM main + VAR + ret : myType; + END_VAR + ret.zero := ULINT_to_SINT(ULINT#0); + ret.positive := ULINT_to_SINT(ULINT#22); + ret.max_minus_one := ULINT_to_SINT(MAX-1); + ret.min_plus_one := ULINT_to_SINT(MIN+1); + ret.max_overflow := ULINT_to_SINT(MAX+1); END_PROGRAM "; let sources = add_std!(src, "num_conversion.st", "numerical_functions.st"); @@ -2163,27 +2163,27 @@ fn ulint_to_sint_conversion() { #[test] fn ulint_to_udint_conversion() { let src = r" - TYPE myType : STRUCT - zero : UDINT; negative : UDINT; positive : UDINT; - max_minus_one : UDINT; min_plus_one : UDINT; max_overflow : UDINT; min_overflow : UDINT; - END_STRUCT END_TYPE + TYPE myType : STRUCT + zero : UDINT; negative : UDINT; positive : UDINT; + max_minus_one : UDINT; min_plus_one : UDINT; max_overflow : UDINT; min_overflow : UDINT; + END_STRUCT END_TYPE - VAR_GLOBAL - MAX : ULINT := 4294967295; - MIN : ULINT := 0; - END_VAR + VAR_GLOBAL + MAX : ULINT := 4294967295; + MIN : ULINT := 0; + END_VAR - PROGRAM main - VAR - ret : myType; - END_VAR - ret.zero := ULINT_to_UDINT(ULINT#0); - ret.negative := ULINT_to_UDINT(-1); - ret.positive := ULINT_to_UDINT(ULINT#22); - ret.max_minus_one := ULINT_to_UDINT(MAX-1); - ret.min_plus_one := ULINT_to_UDINT(MIN+1); - ret.max_overflow := ULINT_to_UDINT(MAX+1); - ret.min_overflow := ULINT_to_UDINT(MIN-1); + PROGRAM main + VAR + ret : myType; + END_VAR + ret.zero := ULINT_to_UDINT(ULINT#0); + ret.negative := ULINT_to_UDINT(-1); + ret.positive := ULINT_to_UDINT(ULINT#22); + ret.max_minus_one := ULINT_to_UDINT(MAX-1); + ret.min_plus_one := ULINT_to_UDINT(MIN+1); + ret.max_overflow := ULINT_to_UDINT(MAX+1); + ret.min_overflow := ULINT_to_UDINT(MIN-1); END_PROGRAM "; let sources = add_std!(src, "num_conversion.st", "numerical_functions.st"); @@ -2201,27 +2201,27 @@ fn ulint_to_udint_conversion() { #[test] fn ulint_to_uint_conversion() { let src = r" - TYPE myType : STRUCT - zero : UINT; negative : UINT; positive : UINT; - max_minus_one : UINT; min_plus_one : UINT; max_overflow : UINT; min_overflow : UINT; - END_STRUCT END_TYPE + TYPE myType : STRUCT + zero : UINT; negative : UINT; positive : UINT; + max_minus_one : UINT; min_plus_one : UINT; max_overflow : UINT; min_overflow : UINT; + END_STRUCT END_TYPE - VAR_GLOBAL - MAX : ULINT := 65535; - MIN : ULINT := 0; - END_VAR + VAR_GLOBAL + MAX : ULINT := 65535; + MIN : ULINT := 0; + END_VAR - PROGRAM main - VAR - ret : myType; - END_VAR - ret.zero := ULINT_to_UINT(ULINT#0); - ret.negative := ULINT_to_UINT(-1); - ret.positive := ULINT_to_UINT(ULINT#22); - ret.max_minus_one := ULINT_to_UINT(MAX-1); - ret.min_plus_one := ULINT_to_UINT(MIN+1); - ret.max_overflow := ULINT_to_UINT(MAX+1); - ret.min_overflow := ULINT_to_UINT(MIN-1); + PROGRAM main + VAR + ret : myType; + END_VAR + ret.zero := ULINT_to_UINT(ULINT#0); + ret.negative := ULINT_to_UINT(-1); + ret.positive := ULINT_to_UINT(ULINT#22); + ret.max_minus_one := ULINT_to_UINT(MAX-1); + ret.min_plus_one := ULINT_to_UINT(MIN+1); + ret.max_overflow := ULINT_to_UINT(MAX+1); + ret.min_overflow := ULINT_to_UINT(MIN-1); END_PROGRAM "; let sources = add_std!(src, "num_conversion.st", "numerical_functions.st"); @@ -2239,27 +2239,27 @@ fn ulint_to_uint_conversion() { #[test] fn ulint_to_usint_conversion() { let src = r" - TYPE myType : STRUCT - zero : USINT; negative : USINT; positive : USINT; - max_minus_one : USINT; min_plus_one : USINT; max_overflow : USINT; min_overflow : USINT; - END_STRUCT END_TYPE + TYPE myType : STRUCT + zero : USINT; negative : USINT; positive : USINT; + max_minus_one : USINT; min_plus_one : USINT; max_overflow : USINT; min_overflow : USINT; + END_STRUCT END_TYPE - VAR_GLOBAL - MAX : ULINT := 255; - MIN : ULINT := 0; - END_VAR + VAR_GLOBAL + MAX : ULINT := 255; + MIN : ULINT := 0; + END_VAR - PROGRAM main - VAR - ret : myType; - END_VAR - ret.zero := ULINT_to_USINT(ULINT#0); - ret.negative := ULINT_to_USINT(-1); - ret.positive := ULINT_to_USINT(ULINT#22); - ret.max_minus_one := ULINT_to_USINT(MAX-1); - ret.min_plus_one := ULINT_to_USINT(MIN+1); - ret.max_overflow := ULINT_to_USINT(MAX+1); - ret.min_overflow := ULINT_to_USINT(MIN-1); + PROGRAM main + VAR + ret : myType; + END_VAR + ret.zero := ULINT_to_USINT(ULINT#0); + ret.negative := ULINT_to_USINT(-1); + ret.positive := ULINT_to_USINT(ULINT#22); + ret.max_minus_one := ULINT_to_USINT(MAX-1); + ret.min_plus_one := ULINT_to_USINT(MIN+1); + ret.max_overflow := ULINT_to_USINT(MAX+1); + ret.min_overflow := ULINT_to_USINT(MIN-1); END_PROGRAM "; let sources = add_std!(src, "num_conversion.st", "numerical_functions.st"); @@ -2277,27 +2277,27 @@ fn ulint_to_usint_conversion() { #[test] fn udint_to_lreal_conversion() { let src = r" - TYPE myType : STRUCT - zero : LREAL; negative : LREAL; positive : LREAL; - max_minus_one : LREAL; min_plus_one : LREAL; max_overflow : LREAL; min_overflow : LREAL; - END_STRUCT END_TYPE + TYPE myType : STRUCT + zero : LREAL; negative : LREAL; positive : LREAL; + max_minus_one : LREAL; min_plus_one : LREAL; max_overflow : LREAL; min_overflow : LREAL; + END_STRUCT END_TYPE - VAR_GLOBAL - MAX : UDINT := 4294967295; - MIN : UDINT := 0; - END_VAR + VAR_GLOBAL + MAX : UDINT := 4294967295; + MIN : UDINT := 0; + END_VAR - PROGRAM main - VAR - ret : myType; - END_VAR - ret.zero := UDINT_to_LREAL(UDINT#0); - ret.negative := UDINT_to_LREAL(-2); - ret.positive := UDINT_to_LREAL(UDINT#22); - ret.max_minus_one := UDINT_to_LREAL(MAX-1); - ret.min_plus_one := UDINT_to_LREAL(MIN+1); - ret.max_overflow := UDINT_to_LREAL(MAX+1); - ret.min_overflow := UDINT_to_LREAL(MIN-1); + PROGRAM main + VAR + ret : myType; + END_VAR + ret.zero := UDINT_to_LREAL(UDINT#0); + ret.negative := UDINT_to_LREAL(-2); + ret.positive := UDINT_to_LREAL(UDINT#22); + ret.max_minus_one := UDINT_to_LREAL(MAX-1); + ret.min_plus_one := UDINT_to_LREAL(MIN+1); + ret.max_overflow := UDINT_to_LREAL(MAX+1); + ret.min_overflow := UDINT_to_LREAL(MIN-1); END_PROGRAM "; let sources = add_std!(src, "num_conversion.st", "numerical_functions.st"); @@ -2315,27 +2315,27 @@ fn udint_to_lreal_conversion() { #[test] fn udint_to_real_conversion() { let src = r" - TYPE myType : STRUCT - zero : REAL; negative : REAL; positive : REAL; - max_minus_one : REAL; min_plus_one : REAL; max_overflow : REAL; min_overflow : REAL; - END_STRUCT END_TYPE + TYPE myType : STRUCT + zero : REAL; negative : REAL; positive : REAL; + max_minus_one : REAL; min_plus_one : REAL; max_overflow : REAL; min_overflow : REAL; + END_STRUCT END_TYPE - VAR_GLOBAL - MAX : UDINT := 4294967295; - MIN : UDINT := 0; - END_VAR + VAR_GLOBAL + MAX : UDINT := 4294967295; + MIN : UDINT := 0; + END_VAR - PROGRAM main - VAR - ret : myType; - END_VAR - ret.zero := UDINT_to_REAL(UDINT#0); - ret.negative := UDINT_to_REAL(-2); - ret.positive := UDINT_to_REAL(UDINT#22); - ret.max_minus_one := UDINT_to_REAL(MAX-1); - ret.min_plus_one := UDINT_to_REAL(MIN+1); - ret.max_overflow := UDINT_to_REAL(MAX+1); - ret.min_overflow := UDINT_to_REAL(MIN-1); + PROGRAM main + VAR + ret : myType; + END_VAR + ret.zero := UDINT_to_REAL(UDINT#0); + ret.negative := UDINT_to_REAL(-2); + ret.positive := UDINT_to_REAL(UDINT#22); + ret.max_minus_one := UDINT_to_REAL(MAX-1); + ret.min_plus_one := UDINT_to_REAL(MIN+1); + ret.max_overflow := UDINT_to_REAL(MAX+1); + ret.min_overflow := UDINT_to_REAL(MIN-1); END_PROGRAM "; let sources = add_std!(src, "num_conversion.st", "numerical_functions.st"); @@ -2353,27 +2353,27 @@ fn udint_to_real_conversion() { #[test] fn udint_to_lint_conversion() { let src = r" - TYPE myType : STRUCT - zero : LINT; negative : LINT; positive : LINT; - max_minus_one : LINT; min_plus_one : LINT; max_overflow : LINT; min_overflow : LINT; - END_STRUCT END_TYPE + TYPE myType : STRUCT + zero : LINT; negative : LINT; positive : LINT; + max_minus_one : LINT; min_plus_one : LINT; max_overflow : LINT; min_overflow : LINT; + END_STRUCT END_TYPE - VAR_GLOBAL - MAX : UDINT := 4294967295; - MIN : UDINT := 0; - END_VAR + VAR_GLOBAL + MAX : UDINT := 4294967295; + MIN : UDINT := 0; + END_VAR - PROGRAM main - VAR - ret : myType; - END_VAR - ret.zero := UDINT_to_LINT(UDINT#0); - ret.negative := UDINT_to_LINT(-1); - ret.positive := UDINT_to_LINT(UDINT#22); - ret.max_minus_one := UDINT_to_LINT(MAX-1); - ret.min_plus_one := UDINT_to_LINT(MIN+1); - ret.max_overflow := UDINT_to_LINT(MAX+1); - ret.min_overflow := UDINT_to_LINT(MIN-1); + PROGRAM main + VAR + ret : myType; + END_VAR + ret.zero := UDINT_to_LINT(UDINT#0); + ret.negative := UDINT_to_LINT(-1); + ret.positive := UDINT_to_LINT(UDINT#22); + ret.max_minus_one := UDINT_to_LINT(MAX-1); + ret.min_plus_one := UDINT_to_LINT(MIN+1); + ret.max_overflow := UDINT_to_LINT(MAX+1); + ret.min_overflow := UDINT_to_LINT(MIN-1); END_PROGRAM "; let sources = add_std!(src, "num_conversion.st", "numerical_functions.st"); @@ -2391,25 +2391,25 @@ fn udint_to_lint_conversion() { #[test] fn udint_to_dint_conversion() { let src = r" - TYPE myType : STRUCT - zero : DINT; negative : DINT; positive : DINT; - max_minus_one : DINT; min_plus_one : DINT; max_overflow : DINT; min_overflow : DINT; - END_STRUCT END_TYPE + TYPE myType : STRUCT + zero : DINT; negative : DINT; positive : DINT; + max_minus_one : DINT; min_plus_one : DINT; max_overflow : DINT; min_overflow : DINT; + END_STRUCT END_TYPE - VAR_GLOBAL - MAX : UDINT := 2147483647; - MIN : UDINT := 0; - END_VAR + VAR_GLOBAL + MAX : UDINT := 2147483647; + MIN : UDINT := 0; + END_VAR - PROGRAM main - VAR - ret : myType; - END_VAR - ret.zero := UDINT_to_DINT(UDINT#0); - ret.positive := UDINT_to_DINT(UDINT#22); - ret.max_minus_one := UDINT_to_DINT(MAX-1); - ret.min_plus_one := UDINT_to_DINT(MIN+1); - ret.max_overflow := UDINT_to_DINT(MAX+1); + PROGRAM main + VAR + ret : myType; + END_VAR + ret.zero := UDINT_to_DINT(UDINT#0); + ret.positive := UDINT_to_DINT(UDINT#22); + ret.max_minus_one := UDINT_to_DINT(MAX-1); + ret.min_plus_one := UDINT_to_DINT(MIN+1); + ret.max_overflow := UDINT_to_DINT(MAX+1); END_PROGRAM "; let sources = add_std!(src, "num_conversion.st", "numerical_functions.st"); @@ -2425,25 +2425,25 @@ fn udint_to_dint_conversion() { #[test] fn udint_to_int_conversion() { let src = r" - TYPE myType : STRUCT - zero : INT; negative : INT; positive : INT; - max_minus_one : INT; min_plus_one : INT; max_overflow : INT; min_overflow : INT; - END_STRUCT END_TYPE + TYPE myType : STRUCT + zero : INT; negative : INT; positive : INT; + max_minus_one : INT; min_plus_one : INT; max_overflow : INT; min_overflow : INT; + END_STRUCT END_TYPE - VAR_GLOBAL - MAX : UDINT := 32767; - MIN : UDINT := 0; - END_VAR + VAR_GLOBAL + MAX : UDINT := 32767; + MIN : UDINT := 0; + END_VAR - PROGRAM main - VAR - ret : myType; - END_VAR - ret.zero := UDINT_to_INT(UDINT#0); - ret.positive := UDINT_to_INT(UDINT#22); - ret.max_minus_one := UDINT_to_INT(MAX-1); - ret.min_plus_one := UDINT_to_INT(MIN+1); - ret.max_overflow := UDINT_to_INT(MAX+1); + PROGRAM main + VAR + ret : myType; + END_VAR + ret.zero := UDINT_to_INT(UDINT#0); + ret.positive := UDINT_to_INT(UDINT#22); + ret.max_minus_one := UDINT_to_INT(MAX-1); + ret.min_plus_one := UDINT_to_INT(MIN+1); + ret.max_overflow := UDINT_to_INT(MAX+1); END_PROGRAM "; let sources = add_std!(src, "num_conversion.st", "numerical_functions.st"); @@ -2459,25 +2459,25 @@ fn udint_to_int_conversion() { #[test] fn udint_to_sint_conversion() { let src = r" - TYPE myType : STRUCT - zero : SINT; negative : SINT; positive : SINT; - max_minus_one : SINT; min_plus_one : SINT; max_overflow : SINT; min_overflow : SINT; - END_STRUCT END_TYPE + TYPE myType : STRUCT + zero : SINT; negative : SINT; positive : SINT; + max_minus_one : SINT; min_plus_one : SINT; max_overflow : SINT; min_overflow : SINT; + END_STRUCT END_TYPE - VAR_GLOBAL - MAX : UDINT := 127; - MIN : UDINT := 0; - END_VAR + VAR_GLOBAL + MAX : UDINT := 127; + MIN : UDINT := 0; + END_VAR - PROGRAM main - VAR - ret : myType; - END_VAR - ret.zero := UDINT_to_SINT(UDINT#0); - ret.positive := UDINT_to_SINT(UDINT#22); - ret.max_minus_one := UDINT_to_SINT(MAX-1); - ret.min_plus_one := UDINT_to_SINT(MIN+1); - ret.max_overflow := UDINT_to_SINT(MAX+1); + PROGRAM main + VAR + ret : myType; + END_VAR + ret.zero := UDINT_to_SINT(UDINT#0); + ret.positive := UDINT_to_SINT(UDINT#22); + ret.max_minus_one := UDINT_to_SINT(MAX-1); + ret.min_plus_one := UDINT_to_SINT(MIN+1); + ret.max_overflow := UDINT_to_SINT(MAX+1); END_PROGRAM "; let sources = add_std!(src, "num_conversion.st", "numerical_functions.st"); @@ -2493,27 +2493,27 @@ fn udint_to_sint_conversion() { #[test] fn udint_to_ulint_conversion() { let src = r" - TYPE myType : STRUCT - zero : ULINT; negative : ULINT; positive : ULINT; - max_minus_one : ULINT; min_plus_one : ULINT; max_overflow : ULINT; min_overflow : ULINT; - END_STRUCT END_TYPE + TYPE myType : STRUCT + zero : ULINT; negative : ULINT; positive : ULINT; + max_minus_one : ULINT; min_plus_one : ULINT; max_overflow : ULINT; min_overflow : ULINT; + END_STRUCT END_TYPE - VAR_GLOBAL - MAX : UDINT := 4294967295; - MIN : UDINT := 0; - END_VAR + VAR_GLOBAL + MAX : UDINT := 4294967295; + MIN : UDINT := 0; + END_VAR - PROGRAM main - VAR - ret : myType; - END_VAR - ret.zero := UDINT_to_ULINT(UDINT#0); - ret.negative := UDINT_to_ULINT(-1); - ret.positive := UDINT_to_ULINT(UDINT#22); - ret.max_minus_one := UDINT_to_ULINT(MAX-1); - ret.min_plus_one := UDINT_to_ULINT(MIN+1); - ret.max_overflow := UDINT_to_ULINT(MAX+1); - ret.min_overflow := UDINT_to_ULINT(MIN-1); + PROGRAM main + VAR + ret : myType; + END_VAR + ret.zero := UDINT_to_ULINT(UDINT#0); + ret.negative := UDINT_to_ULINT(-1); + ret.positive := UDINT_to_ULINT(UDINT#22); + ret.max_minus_one := UDINT_to_ULINT(MAX-1); + ret.min_plus_one := UDINT_to_ULINT(MIN+1); + ret.max_overflow := UDINT_to_ULINT(MAX+1); + ret.min_overflow := UDINT_to_ULINT(MIN-1); END_PROGRAM "; let sources = add_std!(src, "num_conversion.st", "numerical_functions.st"); @@ -2531,27 +2531,27 @@ fn udint_to_ulint_conversion() { #[test] fn udint_to_uint_conversion() { let src = r" - TYPE myType : STRUCT - zero : UINT; negative : UINT; positive : UINT; - max_minus_one : UINT; min_plus_one : UINT; max_overflow : UINT; min_overflow : UINT; - END_STRUCT END_TYPE + TYPE myType : STRUCT + zero : UINT; negative : UINT; positive : UINT; + max_minus_one : UINT; min_plus_one : UINT; max_overflow : UINT; min_overflow : UINT; + END_STRUCT END_TYPE - VAR_GLOBAL - MAX : UDINT := 65535; - MIN : UDINT := 0; - END_VAR + VAR_GLOBAL + MAX : UDINT := 65535; + MIN : UDINT := 0; + END_VAR - PROGRAM main - VAR - ret : myType; - END_VAR - ret.zero := UDINT_to_UINT(UDINT#0); - ret.negative := UDINT_to_UINT(-1); - ret.positive := UDINT_to_UINT(UDINT#22); - ret.max_minus_one := UDINT_to_UINT(MAX-1); - ret.min_plus_one := UDINT_to_UINT(MIN+1); - ret.max_overflow := UDINT_to_UINT(MAX+1); - ret.min_overflow := UDINT_to_UINT(MIN-1); + PROGRAM main + VAR + ret : myType; + END_VAR + ret.zero := UDINT_to_UINT(UDINT#0); + ret.negative := UDINT_to_UINT(-1); + ret.positive := UDINT_to_UINT(UDINT#22); + ret.max_minus_one := UDINT_to_UINT(MAX-1); + ret.min_plus_one := UDINT_to_UINT(MIN+1); + ret.max_overflow := UDINT_to_UINT(MAX+1); + ret.min_overflow := UDINT_to_UINT(MIN-1); END_PROGRAM "; let sources = add_std!(src, "num_conversion.st", "numerical_functions.st"); @@ -2569,27 +2569,27 @@ fn udint_to_uint_conversion() { #[test] fn udint_to_usint_conversion() { let src = r" - TYPE myType : STRUCT - zero : USINT; negative : USINT; positive : USINT; - max_minus_one : USINT; min_plus_one : USINT; max_overflow : USINT; min_overflow : USINT; - END_STRUCT END_TYPE + TYPE myType : STRUCT + zero : USINT; negative : USINT; positive : USINT; + max_minus_one : USINT; min_plus_one : USINT; max_overflow : USINT; min_overflow : USINT; + END_STRUCT END_TYPE - VAR_GLOBAL - MAX : UDINT := 255; - MIN : UDINT := 0; - END_VAR + VAR_GLOBAL + MAX : UDINT := 255; + MIN : UDINT := 0; + END_VAR - PROGRAM main - VAR - ret : myType; - END_VAR - ret.zero := UDINT_to_USINT(UDINT#0); - ret.negative := UDINT_to_USINT(-1); - ret.positive := UDINT_to_USINT(UDINT#22); - ret.max_minus_one := UDINT_to_USINT(MAX-1); - ret.min_plus_one := UDINT_to_USINT(MIN+1); - ret.max_overflow := UDINT_to_USINT(MAX+1); - ret.min_overflow := UDINT_to_USINT(MIN-1); + PROGRAM main + VAR + ret : myType; + END_VAR + ret.zero := UDINT_to_USINT(UDINT#0); + ret.negative := UDINT_to_USINT(-1); + ret.positive := UDINT_to_USINT(UDINT#22); + ret.max_minus_one := UDINT_to_USINT(MAX-1); + ret.min_plus_one := UDINT_to_USINT(MIN+1); + ret.max_overflow := UDINT_to_USINT(MAX+1); + ret.min_overflow := UDINT_to_USINT(MIN-1); END_PROGRAM "; let sources = add_std!(src, "num_conversion.st", "numerical_functions.st"); @@ -2607,27 +2607,27 @@ fn udint_to_usint_conversion() { #[test] fn uint_to_lreal_conversion() { let src = r" - TYPE myType : STRUCT - zero : LREAL; negative : LREAL; positive : LREAL; - max_minus_one : LREAL; min_plus_one : LREAL; max_overflow : LREAL; min_overflow : LREAL; - END_STRUCT END_TYPE + TYPE myType : STRUCT + zero : LREAL; negative : LREAL; positive : LREAL; + max_minus_one : LREAL; min_plus_one : LREAL; max_overflow : LREAL; min_overflow : LREAL; + END_STRUCT END_TYPE - VAR_GLOBAL - MAX : UINT := 65535; - MIN : UINT := 0; - END_VAR + VAR_GLOBAL + MAX : UINT := 65535; + MIN : UINT := 0; + END_VAR - PROGRAM main - VAR - ret : myType; - END_VAR - ret.zero := UINT_to_LREAL(UINT#0); - ret.negative := UINT_to_LREAL(-2); - ret.positive := UINT_to_LREAL(UINT#22); - ret.max_minus_one := UINT_to_LREAL(MAX-1); - ret.min_plus_one := UINT_to_LREAL(MIN+1); - ret.max_overflow := UINT_to_LREAL(MAX+1); - ret.min_overflow := UINT_to_LREAL(MIN-1); + PROGRAM main + VAR + ret : myType; + END_VAR + ret.zero := UINT_to_LREAL(UINT#0); + ret.negative := UINT_to_LREAL(-2); + ret.positive := UINT_to_LREAL(UINT#22); + ret.max_minus_one := UINT_to_LREAL(MAX-1); + ret.min_plus_one := UINT_to_LREAL(MIN+1); + ret.max_overflow := UINT_to_LREAL(MAX+1); + ret.min_overflow := UINT_to_LREAL(MIN-1); END_PROGRAM "; let sources = add_std!(src, "num_conversion.st", "numerical_functions.st"); @@ -2645,27 +2645,27 @@ fn uint_to_lreal_conversion() { #[test] fn uint_to_real_conversion() { let src = r" - TYPE myType : STRUCT - zero : REAL; negative : REAL; positive : REAL; - max_minus_one : REAL; min_plus_one : REAL; max_overflow : REAL; min_overflow : REAL; - END_STRUCT END_TYPE + TYPE myType : STRUCT + zero : REAL; negative : REAL; positive : REAL; + max_minus_one : REAL; min_plus_one : REAL; max_overflow : REAL; min_overflow : REAL; + END_STRUCT END_TYPE - VAR_GLOBAL - MAX : UINT := 65535; - MIN : UINT := 0; - END_VAR + VAR_GLOBAL + MAX : UINT := 65535; + MIN : UINT := 0; + END_VAR - PROGRAM main - VAR - ret : myType; - END_VAR - ret.zero := UINT_to_REAL(UINT#0); - ret.negative := UINT_to_REAL(-2); - ret.positive := UINT_to_REAL(UINT#22); - ret.max_minus_one := UINT_to_REAL(MAX-1); - ret.min_plus_one := UINT_to_REAL(MIN+1); - ret.max_overflow := UINT_to_REAL(MAX+1); - ret.min_overflow := UINT_to_REAL(MIN-1); + PROGRAM main + VAR + ret : myType; + END_VAR + ret.zero := UINT_to_REAL(UINT#0); + ret.negative := UINT_to_REAL(-2); + ret.positive := UINT_to_REAL(UINT#22); + ret.max_minus_one := UINT_to_REAL(MAX-1); + ret.min_plus_one := UINT_to_REAL(MIN+1); + ret.max_overflow := UINT_to_REAL(MAX+1); + ret.min_overflow := UINT_to_REAL(MIN-1); END_PROGRAM "; let sources = add_std!(src, "num_conversion.st", "numerical_functions.st"); @@ -2683,27 +2683,27 @@ fn uint_to_real_conversion() { #[test] fn uint_to_lint_conversion() { let src = r" - TYPE myType : STRUCT - zero : LINT; negative : LINT; positive : LINT; - max_minus_one : LINT; min_plus_one : LINT; max_overflow : LINT; min_overflow : LINT; - END_STRUCT END_TYPE + TYPE myType : STRUCT + zero : LINT; negative : LINT; positive : LINT; + max_minus_one : LINT; min_plus_one : LINT; max_overflow : LINT; min_overflow : LINT; + END_STRUCT END_TYPE - VAR_GLOBAL - MAX : UINT := 65535; - MIN : UINT := 0; - END_VAR + VAR_GLOBAL + MAX : UINT := 65535; + MIN : UINT := 0; + END_VAR - PROGRAM main - VAR - ret : myType; - END_VAR - ret.zero := UINT_to_LINT(UINT#0); - ret.negative := UINT_to_LINT(-1); - ret.positive := UINT_to_LINT(UINT#22); - ret.max_minus_one := UINT_to_LINT(MAX-1); - ret.min_plus_one := UINT_to_LINT(MIN+1); - ret.max_overflow := UINT_to_LINT(MAX+1); - ret.min_overflow := UINT_to_LINT(MIN-1); + PROGRAM main + VAR + ret : myType; + END_VAR + ret.zero := UINT_to_LINT(UINT#0); + ret.negative := UINT_to_LINT(-1); + ret.positive := UINT_to_LINT(UINT#22); + ret.max_minus_one := UINT_to_LINT(MAX-1); + ret.min_plus_one := UINT_to_LINT(MIN+1); + ret.max_overflow := UINT_to_LINT(MAX+1); + ret.min_overflow := UINT_to_LINT(MIN-1); END_PROGRAM "; let sources = add_std!(src, "num_conversion.st", "numerical_functions.st"); @@ -2721,27 +2721,27 @@ fn uint_to_lint_conversion() { #[test] fn uint_to_dint_conversion() { let src = r" - TYPE myType : STRUCT - zero : DINT; negative : DINT; positive : DINT; - max_minus_one : DINT; min_plus_one : DINT; max_overflow : DINT; min_overflow : DINT; - END_STRUCT END_TYPE + TYPE myType : STRUCT + zero : DINT; negative : DINT; positive : DINT; + max_minus_one : DINT; min_plus_one : DINT; max_overflow : DINT; min_overflow : DINT; + END_STRUCT END_TYPE - VAR_GLOBAL - MAX : UINT := 65535; - MIN : UINT := 0; - END_VAR + VAR_GLOBAL + MAX : UINT := 65535; + MIN : UINT := 0; + END_VAR - PROGRAM main - VAR - ret : myType; - END_VAR - ret.zero := UINT_to_DINT(UINT#0); - ret.negative := UINT_to_DINT(-1); - ret.positive := UINT_to_DINT(UINT#22); - ret.max_minus_one := UINT_to_DINT(MAX-1); - ret.min_plus_one := UINT_to_DINT(MIN+1); - ret.max_overflow := UINT_to_DINT(MAX+1); - ret.min_overflow := UINT_to_DINT(MIN-1); + PROGRAM main + VAR + ret : myType; + END_VAR + ret.zero := UINT_to_DINT(UINT#0); + ret.negative := UINT_to_DINT(-1); + ret.positive := UINT_to_DINT(UINT#22); + ret.max_minus_one := UINT_to_DINT(MAX-1); + ret.min_plus_one := UINT_to_DINT(MIN+1); + ret.max_overflow := UINT_to_DINT(MAX+1); + ret.min_overflow := UINT_to_DINT(MIN-1); END_PROGRAM "; let sources = add_std!(src, "num_conversion.st", "numerical_functions.st"); @@ -2759,25 +2759,25 @@ fn uint_to_dint_conversion() { #[test] fn uint_to_int_conversion() { let src = r" - TYPE myType : STRUCT - zero : INT; negative : INT; positive : INT; - max_minus_one : INT; min_plus_one : INT; max_overflow : INT; min_overflow : INT; - END_STRUCT END_TYPE + TYPE myType : STRUCT + zero : INT; negative : INT; positive : INT; + max_minus_one : INT; min_plus_one : INT; max_overflow : INT; min_overflow : INT; + END_STRUCT END_TYPE - VAR_GLOBAL - MAX : UINT := 32767; - MIN : UINT := 0; - END_VAR + VAR_GLOBAL + MAX : UINT := 32767; + MIN : UINT := 0; + END_VAR - PROGRAM main - VAR - ret : myType; - END_VAR - ret.zero := UINT_to_INT(UINT#0); - ret.positive := UINT_to_INT(UINT#22); - ret.max_minus_one := UINT_to_INT(MAX-1); - ret.min_plus_one := UINT_to_INT(MIN+1); - ret.max_overflow := UINT_to_INT(MAX+1); + PROGRAM main + VAR + ret : myType; + END_VAR + ret.zero := UINT_to_INT(UINT#0); + ret.positive := UINT_to_INT(UINT#22); + ret.max_minus_one := UINT_to_INT(MAX-1); + ret.min_plus_one := UINT_to_INT(MIN+1); + ret.max_overflow := UINT_to_INT(MAX+1); END_PROGRAM "; let sources = add_std!(src, "num_conversion.st", "numerical_functions.st"); @@ -2793,25 +2793,25 @@ fn uint_to_int_conversion() { #[test] fn uint_to_sint_conversion() { let src = r" - TYPE myType : STRUCT - zero : SINT; negative : SINT; positive : SINT; - max_minus_one : SINT; min_plus_one : SINT; max_overflow : SINT; min_overflow : SINT; - END_STRUCT END_TYPE + TYPE myType : STRUCT + zero : SINT; negative : SINT; positive : SINT; + max_minus_one : SINT; min_plus_one : SINT; max_overflow : SINT; min_overflow : SINT; + END_STRUCT END_TYPE - VAR_GLOBAL - MAX : UINT := 127; - MIN : UINT := 0; - END_VAR + VAR_GLOBAL + MAX : UINT := 127; + MIN : UINT := 0; + END_VAR - PROGRAM main - VAR - ret : myType; - END_VAR - ret.zero := UINT_to_SINT(UINT#0); - ret.positive := UINT_to_SINT(UINT#22); - ret.max_minus_one := UINT_to_SINT(MAX-1); - ret.min_plus_one := UINT_to_SINT(MIN+1); - ret.max_overflow := UINT_to_SINT(MAX+1); + PROGRAM main + VAR + ret : myType; + END_VAR + ret.zero := UINT_to_SINT(UINT#0); + ret.positive := UINT_to_SINT(UINT#22); + ret.max_minus_one := UINT_to_SINT(MAX-1); + ret.min_plus_one := UINT_to_SINT(MIN+1); + ret.max_overflow := UINT_to_SINT(MAX+1); END_PROGRAM "; let sources = add_std!(src, "num_conversion.st", "numerical_functions.st"); @@ -2827,27 +2827,27 @@ fn uint_to_sint_conversion() { #[test] fn uint_to_ulint_conversion() { let src = r" - TYPE myType : STRUCT - zero : ULINT; negative : ULINT; positive : ULINT; - max_minus_one : ULINT; min_plus_one : ULINT; max_overflow : ULINT; min_overflow : ULINT; - END_STRUCT END_TYPE + TYPE myType : STRUCT + zero : ULINT; negative : ULINT; positive : ULINT; + max_minus_one : ULINT; min_plus_one : ULINT; max_overflow : ULINT; min_overflow : ULINT; + END_STRUCT END_TYPE - VAR_GLOBAL - MAX : UINT := 65535; - MIN : UINT := 0; - END_VAR + VAR_GLOBAL + MAX : UINT := 65535; + MIN : UINT := 0; + END_VAR - PROGRAM main - VAR - ret : myType; - END_VAR - ret.zero := UINT_to_ULINT(UINT#0); - ret.negative := UINT_to_ULINT(-1); - ret.positive := UINT_to_ULINT(UINT#22); - ret.max_minus_one := UINT_to_ULINT(MAX-1); - ret.min_plus_one := UINT_to_ULINT(MIN+1); - ret.max_overflow := UINT_to_ULINT(MAX+1); - ret.min_overflow := UINT_to_ULINT(MIN-1); + PROGRAM main + VAR + ret : myType; + END_VAR + ret.zero := UINT_to_ULINT(UINT#0); + ret.negative := UINT_to_ULINT(-1); + ret.positive := UINT_to_ULINT(UINT#22); + ret.max_minus_one := UINT_to_ULINT(MAX-1); + ret.min_plus_one := UINT_to_ULINT(MIN+1); + ret.max_overflow := UINT_to_ULINT(MAX+1); + ret.min_overflow := UINT_to_ULINT(MIN-1); END_PROGRAM "; let sources = add_std!(src, "num_conversion.st", "numerical_functions.st"); @@ -2865,27 +2865,27 @@ fn uint_to_ulint_conversion() { #[test] fn uint_to_udint_conversion() { let src = r" - TYPE myType : STRUCT - zero : UDINT; negative : UDINT; positive : UDINT; - max_minus_one : UDINT; min_plus_one : UDINT; max_overflow : UDINT; min_overflow : UDINT; - END_STRUCT END_TYPE + TYPE myType : STRUCT + zero : UDINT; negative : UDINT; positive : UDINT; + max_minus_one : UDINT; min_plus_one : UDINT; max_overflow : UDINT; min_overflow : UDINT; + END_STRUCT END_TYPE - VAR_GLOBAL - MAX : UINT := 65535; - MIN : UINT := 0; - END_VAR + VAR_GLOBAL + MAX : UINT := 65535; + MIN : UINT := 0; + END_VAR - PROGRAM main - VAR - ret : myType; - END_VAR - ret.zero := UINT_to_UDINT(UINT#0); - ret.negative := UINT_to_UDINT(-1); - ret.positive := UINT_to_UDINT(UINT#22); - ret.max_minus_one := UINT_to_UDINT(MAX-1); - ret.min_plus_one := UINT_to_UDINT(MIN+1); - ret.max_overflow := UINT_to_UDINT(MAX+1); - ret.min_overflow := UINT_to_UDINT(MIN-1); + PROGRAM main + VAR + ret : myType; + END_VAR + ret.zero := UINT_to_UDINT(UINT#0); + ret.negative := UINT_to_UDINT(-1); + ret.positive := UINT_to_UDINT(UINT#22); + ret.max_minus_one := UINT_to_UDINT(MAX-1); + ret.min_plus_one := UINT_to_UDINT(MIN+1); + ret.max_overflow := UINT_to_UDINT(MAX+1); + ret.min_overflow := UINT_to_UDINT(MIN-1); END_PROGRAM "; let sources = add_std!(src, "num_conversion.st", "numerical_functions.st"); @@ -2903,27 +2903,27 @@ fn uint_to_udint_conversion() { #[test] fn uint_to_usint_conversion() { let src = r" - TYPE myType : STRUCT - zero : USINT; negative : USINT; positive : USINT; - max_minus_one : USINT; min_plus_one : USINT; max_overflow : USINT; min_overflow : USINT; - END_STRUCT END_TYPE + TYPE myType : STRUCT + zero : USINT; negative : USINT; positive : USINT; + max_minus_one : USINT; min_plus_one : USINT; max_overflow : USINT; min_overflow : USINT; + END_STRUCT END_TYPE - VAR_GLOBAL - MAX : UINT := 255; - MIN : UINT := 0; - END_VAR + VAR_GLOBAL + MAX : UINT := 255; + MIN : UINT := 0; + END_VAR - PROGRAM main - VAR - ret : myType; - END_VAR - ret.zero := UINT_to_USINT(UINT#0); - ret.negative := UINT_to_USINT(-1); - ret.positive := UINT_to_USINT(UINT#22); - ret.max_minus_one := UINT_to_USINT(MAX-1); - ret.min_plus_one := UINT_to_USINT(MIN+1); - ret.max_overflow := UINT_to_USINT(MAX+1); - ret.min_overflow := UINT_to_USINT(MIN-1); + PROGRAM main + VAR + ret : myType; + END_VAR + ret.zero := UINT_to_USINT(UINT#0); + ret.negative := UINT_to_USINT(-1); + ret.positive := UINT_to_USINT(UINT#22); + ret.max_minus_one := UINT_to_USINT(MAX-1); + ret.min_plus_one := UINT_to_USINT(MIN+1); + ret.max_overflow := UINT_to_USINT(MAX+1); + ret.min_overflow := UINT_to_USINT(MIN-1); END_PROGRAM "; let sources = add_std!(src, "num_conversion.st", "numerical_functions.st"); @@ -2941,27 +2941,27 @@ fn uint_to_usint_conversion() { #[test] fn usint_to_lreal_conversion() { let src = r" - TYPE myType : STRUCT - zero : LREAL; negative : LREAL; positive : LREAL; - max_minus_one : LREAL; min_plus_one : LREAL; max_overflow : LREAL; min_overflow : LREAL; - END_STRUCT END_TYPE + TYPE myType : STRUCT + zero : LREAL; negative : LREAL; positive : LREAL; + max_minus_one : LREAL; min_plus_one : LREAL; max_overflow : LREAL; min_overflow : LREAL; + END_STRUCT END_TYPE - VAR_GLOBAL - MAX : USINT := 255; - MIN : USINT := 0; - END_VAR + VAR_GLOBAL + MAX : USINT := 255; + MIN : USINT := 0; + END_VAR - PROGRAM main - VAR - ret : myType; - END_VAR - ret.zero := USINT_to_LREAL(USINT#0); - ret.negative := USINT_to_LREAL(-2); - ret.positive := USINT_to_LREAL(USINT#22); - ret.max_minus_one := USINT_to_LREAL(MAX-1); - ret.min_plus_one := USINT_to_LREAL(MIN+1); - ret.max_overflow := USINT_to_LREAL(MAX+1); - ret.min_overflow := USINT_to_LREAL(MIN-1); + PROGRAM main + VAR + ret : myType; + END_VAR + ret.zero := USINT_to_LREAL(USINT#0); + ret.negative := USINT_to_LREAL(-2); + ret.positive := USINT_to_LREAL(USINT#22); + ret.max_minus_one := USINT_to_LREAL(MAX-1); + ret.min_plus_one := USINT_to_LREAL(MIN+1); + ret.max_overflow := USINT_to_LREAL(MAX+1); + ret.min_overflow := USINT_to_LREAL(MIN-1); END_PROGRAM "; let sources = add_std!(src, "num_conversion.st", "numerical_functions.st"); @@ -2979,27 +2979,27 @@ fn usint_to_lreal_conversion() { #[test] fn usint_to_real_conversion() { let src = r" - TYPE myType : STRUCT - zero : REAL; negative : REAL; positive : REAL; - max_minus_one : REAL; min_plus_one : REAL; max_overflow : REAL; min_overflow : REAL; - END_STRUCT END_TYPE + TYPE myType : STRUCT + zero : REAL; negative : REAL; positive : REAL; + max_minus_one : REAL; min_plus_one : REAL; max_overflow : REAL; min_overflow : REAL; + END_STRUCT END_TYPE - VAR_GLOBAL - MAX : USINT := 255; - MIN : USINT := 0; - END_VAR + VAR_GLOBAL + MAX : USINT := 255; + MIN : USINT := 0; + END_VAR - PROGRAM main - VAR - ret : myType; - END_VAR - ret.zero := USINT_to_REAL(USINT#0); - ret.negative := USINT_to_REAL(-2); - ret.positive := USINT_to_REAL(USINT#22); - ret.max_minus_one := USINT_to_REAL(MAX-1); - ret.min_plus_one := USINT_to_REAL(MIN+1); - ret.max_overflow := USINT_to_REAL(MAX+1); - ret.min_overflow := USINT_to_REAL(MIN-1); + PROGRAM main + VAR + ret : myType; + END_VAR + ret.zero := USINT_to_REAL(USINT#0); + ret.negative := USINT_to_REAL(-2); + ret.positive := USINT_to_REAL(USINT#22); + ret.max_minus_one := USINT_to_REAL(MAX-1); + ret.min_plus_one := USINT_to_REAL(MIN+1); + ret.max_overflow := USINT_to_REAL(MAX+1); + ret.min_overflow := USINT_to_REAL(MIN-1); END_PROGRAM "; let sources = add_std!(src, "num_conversion.st", "numerical_functions.st"); @@ -3017,27 +3017,27 @@ fn usint_to_real_conversion() { #[test] fn usint_to_lint_conversion() { let src = r" - TYPE myType : STRUCT - zero : LINT; negative : LINT; positive : LINT; - max_minus_one : LINT; min_plus_one : LINT; max_overflow : LINT; min_overflow : LINT; - END_STRUCT END_TYPE + TYPE myType : STRUCT + zero : LINT; negative : LINT; positive : LINT; + max_minus_one : LINT; min_plus_one : LINT; max_overflow : LINT; min_overflow : LINT; + END_STRUCT END_TYPE - VAR_GLOBAL - MAX : USINT := 255; - MIN : USINT := 0; - END_VAR + VAR_GLOBAL + MAX : USINT := 255; + MIN : USINT := 0; + END_VAR - PROGRAM main - VAR - ret : myType; - END_VAR - ret.zero := USINT_to_LINT(USINT#0); - ret.negative := USINT_to_LINT(-1); - ret.positive := USINT_to_LINT(USINT#22); - ret.max_minus_one := USINT_to_LINT(MAX-1); - ret.min_plus_one := USINT_to_LINT(MIN+1); - ret.max_overflow := USINT_to_LINT(MAX+1); - ret.min_overflow := USINT_to_LINT(MIN-1); + PROGRAM main + VAR + ret : myType; + END_VAR + ret.zero := USINT_to_LINT(USINT#0); + ret.negative := USINT_to_LINT(-1); + ret.positive := USINT_to_LINT(USINT#22); + ret.max_minus_one := USINT_to_LINT(MAX-1); + ret.min_plus_one := USINT_to_LINT(MIN+1); + ret.max_overflow := USINT_to_LINT(MAX+1); + ret.min_overflow := USINT_to_LINT(MIN-1); END_PROGRAM "; let sources = add_std!(src, "num_conversion.st", "numerical_functions.st"); @@ -3055,27 +3055,27 @@ fn usint_to_lint_conversion() { #[test] fn usint_to_dint_conversion() { let src = r" - TYPE myType : STRUCT - zero : DINT; negative : DINT; positive : DINT; - max_minus_one : DINT; min_plus_one : DINT; max_overflow : DINT; min_overflow : DINT; - END_STRUCT END_TYPE + TYPE myType : STRUCT + zero : DINT; negative : DINT; positive : DINT; + max_minus_one : DINT; min_plus_one : DINT; max_overflow : DINT; min_overflow : DINT; + END_STRUCT END_TYPE - VAR_GLOBAL - MAX : USINT := 255; - MIN : USINT := 0; - END_VAR + VAR_GLOBAL + MAX : USINT := 255; + MIN : USINT := 0; + END_VAR - PROGRAM main - VAR - ret : myType; - END_VAR - ret.zero := USINT_to_DINT(USINT#0); - ret.negative := USINT_to_DINT(-1); - ret.positive := USINT_to_DINT(USINT#22); - ret.max_minus_one := USINT_to_DINT(MAX-1); - ret.min_plus_one := USINT_to_DINT(MIN+1); - ret.max_overflow := USINT_to_DINT(MAX+1); - ret.min_overflow := USINT_to_DINT(MIN-1); + PROGRAM main + VAR + ret : myType; + END_VAR + ret.zero := USINT_to_DINT(USINT#0); + ret.negative := USINT_to_DINT(-1); + ret.positive := USINT_to_DINT(USINT#22); + ret.max_minus_one := USINT_to_DINT(MAX-1); + ret.min_plus_one := USINT_to_DINT(MIN+1); + ret.max_overflow := USINT_to_DINT(MAX+1); + ret.min_overflow := USINT_to_DINT(MIN-1); END_PROGRAM "; let sources = add_std!(src, "num_conversion.st", "numerical_functions.st"); @@ -3093,27 +3093,27 @@ fn usint_to_dint_conversion() { #[test] fn usint_to_int_conversion() { let src = r" - TYPE myType : STRUCT - zero : INT; negative : INT; positive : INT; - max_minus_one : INT; min_plus_one : INT; max_overflow : INT; min_overflow : INT; - END_STRUCT END_TYPE + TYPE myType : STRUCT + zero : INT; negative : INT; positive : INT; + max_minus_one : INT; min_plus_one : INT; max_overflow : INT; min_overflow : INT; + END_STRUCT END_TYPE - VAR_GLOBAL - MAX : USINT := 255; - MIN : USINT := 0; - END_VAR + VAR_GLOBAL + MAX : USINT := 255; + MIN : USINT := 0; + END_VAR - PROGRAM main - VAR - ret : myType; - END_VAR - ret.zero := USINT_to_INT(USINT#0); - ret.negative := USINT_to_INT(-1); - ret.positive := USINT_to_INT(USINT#22); - ret.max_minus_one := USINT_to_INT(MAX-1); - ret.min_plus_one := USINT_to_INT(MIN+1); - ret.max_overflow := USINT_to_INT(MAX+1); - ret.min_overflow := USINT_to_INT(MIN-1); + PROGRAM main + VAR + ret : myType; + END_VAR + ret.zero := USINT_to_INT(USINT#0); + ret.negative := USINT_to_INT(-1); + ret.positive := USINT_to_INT(USINT#22); + ret.max_minus_one := USINT_to_INT(MAX-1); + ret.min_plus_one := USINT_to_INT(MIN+1); + ret.max_overflow := USINT_to_INT(MAX+1); + ret.min_overflow := USINT_to_INT(MIN-1); END_PROGRAM "; let sources = add_std!(src, "num_conversion.st", "numerical_functions.st"); @@ -3131,25 +3131,25 @@ fn usint_to_int_conversion() { #[test] fn usint_to_sint_conversion() { let src = r" - TYPE myType : STRUCT - zero : SINT; negative : SINT; positive : SINT; - max_minus_one : SINT; min_plus_one : SINT; max_overflow : SINT; min_overflow : SINT; - END_STRUCT END_TYPE + TYPE myType : STRUCT + zero : SINT; negative : SINT; positive : SINT; + max_minus_one : SINT; min_plus_one : SINT; max_overflow : SINT; min_overflow : SINT; + END_STRUCT END_TYPE - VAR_GLOBAL - MAX : USINT := 127; - MIN : USINT := 0; - END_VAR + VAR_GLOBAL + MAX : USINT := 127; + MIN : USINT := 0; + END_VAR - PROGRAM main - VAR - ret : myType; - END_VAR - ret.zero := USINT_to_SINT(USINT#0); - ret.positive := USINT_to_SINT(USINT#22); - ret.max_minus_one := USINT_to_SINT(MAX-1); - ret.min_plus_one := USINT_to_SINT(MIN+1); - ret.max_overflow := USINT_to_SINT(MAX+1); + PROGRAM main + VAR + ret : myType; + END_VAR + ret.zero := USINT_to_SINT(USINT#0); + ret.positive := USINT_to_SINT(USINT#22); + ret.max_minus_one := USINT_to_SINT(MAX-1); + ret.min_plus_one := USINT_to_SINT(MIN+1); + ret.max_overflow := USINT_to_SINT(MAX+1); END_PROGRAM "; let sources = add_std!(src, "num_conversion.st", "numerical_functions.st"); @@ -3165,27 +3165,27 @@ fn usint_to_sint_conversion() { #[test] fn usint_to_ulint_conversion() { let src = r" - TYPE myType : STRUCT - zero : ULINT; negative : ULINT; positive : ULINT; - max_minus_one : ULINT; min_plus_one : ULINT; max_overflow : ULINT; min_overflow : ULINT; - END_STRUCT END_TYPE + TYPE myType : STRUCT + zero : ULINT; negative : ULINT; positive : ULINT; + max_minus_one : ULINT; min_plus_one : ULINT; max_overflow : ULINT; min_overflow : ULINT; + END_STRUCT END_TYPE - VAR_GLOBAL - MAX : USINT := 255; - MIN : USINT := 0; - END_VAR + VAR_GLOBAL + MAX : USINT := 255; + MIN : USINT := 0; + END_VAR - PROGRAM main - VAR - ret : myType; - END_VAR - ret.zero := USINT_to_ULINT(USINT#0); - ret.negative := USINT_to_ULINT(-1); - ret.positive := USINT_to_ULINT(USINT#22); - ret.max_minus_one := USINT_to_ULINT(MAX-1); - ret.min_plus_one := USINT_to_ULINT(MIN+1); - ret.max_overflow := USINT_to_ULINT(MAX+1); - ret.min_overflow := USINT_to_ULINT(MIN-1); + PROGRAM main + VAR + ret : myType; + END_VAR + ret.zero := USINT_to_ULINT(USINT#0); + ret.negative := USINT_to_ULINT(-1); + ret.positive := USINT_to_ULINT(USINT#22); + ret.max_minus_one := USINT_to_ULINT(MAX-1); + ret.min_plus_one := USINT_to_ULINT(MIN+1); + ret.max_overflow := USINT_to_ULINT(MAX+1); + ret.min_overflow := USINT_to_ULINT(MIN-1); END_PROGRAM "; let sources = add_std!(src, "num_conversion.st", "numerical_functions.st"); @@ -3203,27 +3203,27 @@ fn usint_to_ulint_conversion() { #[test] fn usint_to_udint_conversion() { let src = r" - TYPE myType : STRUCT - zero : UDINT; negative : UDINT; positive : UDINT; - max_minus_one : UDINT; min_plus_one : UDINT; max_overflow : UDINT; min_overflow : UDINT; - END_STRUCT END_TYPE + TYPE myType : STRUCT + zero : UDINT; negative : UDINT; positive : UDINT; + max_minus_one : UDINT; min_plus_one : UDINT; max_overflow : UDINT; min_overflow : UDINT; + END_STRUCT END_TYPE - VAR_GLOBAL - MAX : USINT := 255; - MIN : USINT := 0; - END_VAR + VAR_GLOBAL + MAX : USINT := 255; + MIN : USINT := 0; + END_VAR - PROGRAM main - VAR - ret : myType; - END_VAR - ret.zero := USINT_to_UDINT(USINT#0); - ret.negative := USINT_to_UDINT(-1); - ret.positive := USINT_to_UDINT(USINT#22); - ret.max_minus_one := USINT_to_UDINT(MAX-1); - ret.min_plus_one := USINT_to_UDINT(MIN+1); - ret.max_overflow := USINT_to_UDINT(MAX+1); - ret.min_overflow := USINT_to_UDINT(MIN-1); + PROGRAM main + VAR + ret : myType; + END_VAR + ret.zero := USINT_to_UDINT(USINT#0); + ret.negative := USINT_to_UDINT(-1); + ret.positive := USINT_to_UDINT(USINT#22); + ret.max_minus_one := USINT_to_UDINT(MAX-1); + ret.min_plus_one := USINT_to_UDINT(MIN+1); + ret.max_overflow := USINT_to_UDINT(MAX+1); + ret.min_overflow := USINT_to_UDINT(MIN-1); END_PROGRAM "; let sources = add_std!(src, "num_conversion.st", "numerical_functions.st"); @@ -3241,27 +3241,27 @@ fn usint_to_udint_conversion() { #[test] fn usint_to_uint_conversion() { let src = r" - TYPE myType : STRUCT - zero : UINT; negative : UINT; positive : UINT; - max_minus_one : UINT; min_plus_one : UINT; max_overflow : UINT; min_overflow : UINT; - END_STRUCT END_TYPE - - VAR_GLOBAL - MAX : USINT := 255; - MIN : USINT := 0; - END_VAR - - PROGRAM main - VAR - ret : myType; - END_VAR - ret.zero := USINT_to_UINT(USINT#0); - ret.negative := USINT_to_UINT(-1); - ret.positive := USINT_to_UINT(USINT#22); - ret.max_minus_one := USINT_to_UINT(MAX-1); - ret.min_plus_one := USINT_to_UINT(MIN+1); - ret.max_overflow := USINT_to_UINT(MAX+1); - ret.min_overflow := USINT_to_UINT(MIN-1); + TYPE myType : STRUCT + zero : UINT; negative : UINT; positive : UINT; + max_minus_one : UINT; min_plus_one : UINT; max_overflow : UINT; min_overflow : UINT; + END_STRUCT END_TYPE + + VAR_GLOBAL + MAX : USINT := 255; + MIN : USINT := 0; + END_VAR + + PROGRAM main + VAR + ret : myType; + END_VAR + ret.zero := USINT_to_UINT(USINT#0); + ret.negative := USINT_to_UINT(-1); + ret.positive := USINT_to_UINT(USINT#22); + ret.max_minus_one := USINT_to_UINT(MAX-1); + ret.min_plus_one := USINT_to_UINT(MIN+1); + ret.max_overflow := USINT_to_UINT(MAX+1); + ret.min_overflow := USINT_to_UINT(MIN-1); END_PROGRAM "; let sources = add_std!(src, "num_conversion.st", "numerical_functions.st"); diff --git a/libs/stdlib/tests/string_conversion_tests.rs b/libs/stdlib/tests/string_conversion_tests.rs index 6217d28fec..696e19caf8 100644 --- a/libs/stdlib/tests/string_conversion_tests.rs +++ b/libs/stdlib/tests/string_conversion_tests.rs @@ -13,12 +13,12 @@ fn wstring_to_string_conversion() { } let src = r#" - PROGRAM main - VAR - res : STRING; - ptr : REF_TO STRING; - END_VAR - res := WSTRING_TO_STRING(WSTRING#"hello"); + PROGRAM main + VAR + res : STRING; + ptr : REF_TO STRING; + END_VAR + res := WSTRING_TO_STRING(WSTRING#"hello"); END_PROGRAM "#; let sources = add_std!(src, "string_conversion.st", "string_functions.st"); @@ -35,12 +35,12 @@ fn empty_wstring_to_string_conversion() { } let src = r#" - PROGRAM main - VAR - res : STRING; - ptr : REF_TO STRING; - END_VAR - res := WSTRING_TO_STRING(""); + PROGRAM main + VAR + res : STRING; + ptr : REF_TO STRING; + END_VAR + res := WSTRING_TO_STRING(""); END_PROGRAM "#; let sources = add_std!(src, "string_conversion.st", "string_functions.st"); @@ -57,12 +57,12 @@ fn wstring_to_string_extra_conversion() { } let src = r#" - PROGRAM main - VAR - res : STRING; - ptr : REF_TO STRING; - END_VAR - res := WSTRING_TO_STRING(WSTRING#"hèßlo👽️"); + PROGRAM main + VAR + res : STRING; + ptr : REF_TO STRING; + END_VAR + res := WSTRING_TO_STRING(WSTRING#"hèßlo👽️"); END_PROGRAM "#; let sources = add_std!(src, "string_conversion.st", "string_functions.st"); @@ -80,12 +80,12 @@ fn wstring_to_string_conversion_long() { } let src = r#" - PROGRAM main - VAR - res : STRING; - ptr : REF_TO STRING; - END_VAR - res := WSTRING_TO_STRING("111111111122222222223333333333444444444455555555556666666666777777777788888888889999999999"); + PROGRAM main + VAR + res : STRING; + ptr : REF_TO STRING; + END_VAR + res := WSTRING_TO_STRING("111111111122222222223333333333444444444455555555556666666666777777777788888888889999999999"); END_PROGRAM "#; let sources = add_std!(src, "string_conversion.st", "string_functions.st"); @@ -109,11 +109,11 @@ fn wstring_to_wchar_conversion() { } let src = r#" - PROGRAM main - VAR - res : WCHAR; - END_VAR - res := WSTRING_TO_WCHAR(WSTRING#"ABC"); + PROGRAM main + VAR + res : WCHAR; + END_VAR + res := WSTRING_TO_WCHAR(WSTRING#"ABC"); END_PROGRAM "#; let sources = add_std!(src, "string_conversion.st", "string_functions.st"); @@ -130,11 +130,11 @@ fn string_to_wstring_conversion() { } let src = r#" - PROGRAM main - VAR - res : WSTRING; - END_VAR - res := STRING_TO_WSTRING(STRING#'Hello'); + PROGRAM main + VAR + res : WSTRING; + END_VAR + res := STRING_TO_WSTRING(STRING#'Hello'); END_PROGRAM "#; let sources = add_std!(src, "string_conversion.st", "string_functions.st"); @@ -151,11 +151,11 @@ fn empty_string_to_wstring_conversion() { } let src = r#" - PROGRAM main - VAR - res : WSTRING; - END_VAR - res := STRING_TO_WSTRING(''); + PROGRAM main + VAR + res : WSTRING; + END_VAR + res := STRING_TO_WSTRING(''); END_PROGRAM "#; let sources = add_std!(src, "string_conversion.st", "string_functions.st"); @@ -170,11 +170,11 @@ fn string_to_wstring_extra_conversion() { res: [u16; 8], } let src = r#" - PROGRAM main - VAR - res : WSTRING; - END_VAR - res := STRING_TO_WSTRING('Hèßlo😀'); + PROGRAM main + VAR + res : WSTRING; + END_VAR + res := STRING_TO_WSTRING('Hèßlo😀'); END_PROGRAM "#; @@ -195,11 +195,11 @@ fn string_to_wstring_long_conversion() { res: [u16; 81], } let src = r#" - PROGRAM main - VAR - res : WSTRING; - END_VAR - res := STRING_TO_WSTRING('111111111122222222223333333333444444444455555555556666666666777777777788888888889999999999'); + PROGRAM main + VAR + res : WSTRING; + END_VAR + res := STRING_TO_WSTRING('111111111122222222223333333333444444444455555555556666666666777777777788888888889999999999'); END_PROGRAM "#; @@ -228,11 +228,11 @@ fn string_to_char_conversion() { } let src = r#" - PROGRAM main - VAR - res : CHAR; - END_VAR - res := STRING_TO_CHAR(STRING#'BCD'); + PROGRAM main + VAR + res : CHAR; + END_VAR + res := STRING_TO_CHAR(STRING#'BCD'); END_PROGRAM "#; let sources = add_std!(src, "string_conversion.st", "string_functions.st"); @@ -249,11 +249,11 @@ fn wchar_to_wstring_conversion() { } let src = r#" - PROGRAM main - VAR - res : WSTRING[1]; - END_VAR - res := WCHAR_TO_WSTRING(WCHAR#"A"); + PROGRAM main + VAR + res : WSTRING[1]; + END_VAR + res := WCHAR_TO_WSTRING(WCHAR#"A"); END_PROGRAM "#; let sources = add_std!(src, "string_conversion.st", "string_functions.st"); @@ -270,11 +270,11 @@ fn wchar_to_char_conversion() { } let src = r#" - PROGRAM main - VAR - res : CHAR; - END_VAR - res := WCHAR_TO_CHAR(WCHAR#"A"); + PROGRAM main + VAR + res : CHAR; + END_VAR + res := WCHAR_TO_CHAR(WCHAR#"A"); END_PROGRAM "#; let sources = add_std!(src, "string_conversion.st", "string_functions.st"); @@ -291,11 +291,11 @@ fn char_to_string_conversion() { } let src = r#" - PROGRAM main - VAR - res : STRING[1]; - END_VAR - res := CHAR_TO_STRING(CHAR#'B'); + PROGRAM main + VAR + res : STRING[1]; + END_VAR + res := CHAR_TO_STRING(CHAR#'B'); END_PROGRAM "#; let sources = add_std!(src, "string_conversion.st", "string_functions.st"); @@ -312,11 +312,11 @@ fn char_to_wchar_conversion() { } let src = r#" - PROGRAM main - VAR - res : WCHAR; - END_VAR - res := CHAR_TO_WCHAR(CHAR#'B'); + PROGRAM main + VAR + res : WCHAR; + END_VAR + res := CHAR_TO_WCHAR(CHAR#'B'); END_PROGRAM "#; let sources = add_std!(src, "string_conversion.st", "string_functions.st"); diff --git a/libs/stdlib/tests/string_function_tests.rs b/libs/stdlib/tests/string_function_tests.rs index e2c576b54b..1ca3159086 100644 --- a/libs/stdlib/tests/string_function_tests.rs +++ b/libs/stdlib/tests/string_function_tests.rs @@ -23,12 +23,12 @@ fn string_from_utf16(src: &[u16]) -> Result { #[test] fn len_string() { let src = r#" - FUNCTION main : DINT + FUNCTION main : DINT VAR variable: STRING; END_VAR variable := ' this is a very long sentence with plenty of characters.'; - main := LEN(variable); + main := LEN(variable); END_FUNCTION "#; let sources = add_std!(src, "string_functions.st"); @@ -39,8 +39,8 @@ fn len_string() { #[test] fn len_string_long_string() { let src = r#" - FUNCTION main : DINT - main := LEN(' this is a very long sentence with plenty of characters and weird spacing.'); + FUNCTION main : DINT + main := LEN(' this is a very long sentence with plenty of characters and weird spacing.'); END_FUNCTION "#; let sources = add_std!(src, "string_functions.st"); @@ -51,8 +51,8 @@ fn len_string_long_string() { #[test] fn len_string_no_variable() { let src = r#" - FUNCTION main : DINT - main := LEN(STRING#'hello'); + FUNCTION main : DINT + main := LEN(STRING#'hello'); END_FUNCTION "#; let sources = add_std!(src, "string_functions.st"); @@ -63,12 +63,12 @@ fn len_string_no_variable() { #[test] fn len_string_empty() { let src = r#" - FUNCTION main : DINT + FUNCTION main : DINT VAR_TEMP in : STRING[1024]; END_VAR in := ''; - main := LEN(in); + main := LEN(in); END_FUNCTION "#; let sources = add_std!(src, "string_functions.st"); @@ -79,12 +79,12 @@ fn len_string_empty() { #[test] fn left_string() { let src = r#" - FUNCTION main : STRING + FUNCTION main : STRING VAR_TEMP in : STRING; END_VAR in := 'hello'; - main := LEFT(in, DINT#3); + main := LEFT(in, DINT#3); END_FUNCTION "#; @@ -101,12 +101,12 @@ fn left_string() { #[test] fn left_string_long_string() { let src = r#" - FUNCTION main : STRING[2048] + FUNCTION main : STRING[2048] VAR_TEMP in : STRING[100]; END_VAR in := ' this is a very long sentence with plenty of characters and weird spacing.'; - main := LEFT(in, DINT#85); + main := LEFT(in, DINT#85); END_FUNCTION "#; @@ -126,14 +126,14 @@ fn left_string_long_string() { #[test] fn left_string_lint() { let src = r#" - FUNCTION main : STRING + FUNCTION main : STRING VAR_TEMP in : STRING; l : LINT; END_VAR in := 'lets see if long int is handled correctly'; l := 31; - main := LEFT(in, l); + main := LEFT(in, l); END_FUNCTION "#; @@ -150,7 +150,7 @@ fn left_string_lint() { #[test] fn left_ext_string() { let src = r#" - FUNCTION main : STRING + FUNCTION main : STRING VAR_TEMP in : STRING; out : STRING; @@ -159,7 +159,7 @@ fn left_ext_string() { in := 'extended'; l := 6; LEFT_EXT(in, l, out); - main := out; + main := out; END_FUNCTION "#; @@ -176,12 +176,12 @@ fn left_ext_string() { #[test] fn right_string_usint() { let src = r#" - FUNCTION main : STRING + FUNCTION main : STRING VAR_TEMP in : STRING; END_VAR in := 'sample text'; - main := RIGHT(in, USINT#7); + main := RIGHT(in, USINT#7); END_FUNCTION "#; @@ -201,12 +201,12 @@ fn right_string_usint() { #[should_panic(expected = "Requested substring length exceeds string length.")] fn right_string_substring_too_long() { let src = r#" - FUNCTION main : STRING + FUNCTION main : STRING VAR_TEMP in : STRING; END_VAR in := 'sample text'; - main := RIGHT(in, 12); + main := RIGHT(in, 12); END_FUNCTION "#; @@ -217,14 +217,14 @@ fn right_string_substring_too_long() { #[test] fn right_ext_string() { let src = r#" - FUNCTION main : STRING + FUNCTION main : STRING VAR_TEMP in : STRING; out : STRING; END_VAR in := 'extended'; RIGHT_EXT(in, 3, out); - main := out; + main := out; END_FUNCTION "#; @@ -241,7 +241,7 @@ fn right_ext_string() { #[test] fn right_string_long_string() { let src = r#" - FUNCTION main : STRING[2048] + FUNCTION main : STRING[2048] VAR_TEMP in : STRING[100]; l : DINT; @@ -268,16 +268,16 @@ fn right_string_long_string() { #[test] fn right_ext_string_long_string() { let src = r#" - FUNCTION main : STRING[2048] + FUNCTION main : STRING[2048] VAR_TEMP in : STRING[128]; out : STRING[128]; l : DINT; - END_VAR + END_VAR in := '7gAN5pmmSXqHJ3zZCXnBwika9N8RPXpTAdX4LdwHbLjwv9g3mU3dtpCT2MHVPxwtMw6jMQkip3HDy8Ruw42pVi56fiVhYn8faPLUKRghytQcBFgZhMXGhpBW'; l := 99; RIGHT_EXT(in, l, out); - main := out; + main := out; END_FUNCTION "#; @@ -297,7 +297,7 @@ fn right_ext_string_long_string() { #[test] fn mid_string() { let src = r#" - FUNCTION main : STRING + FUNCTION main : STRING VAR_TEMP in : STRING; l : DINT; @@ -306,7 +306,7 @@ fn mid_string() { in := 'sample text'; l := 7; p := 2; - main := MID(in, l, p); + main := MID(in, l, p); END_FUNCTION "#; @@ -323,16 +323,16 @@ fn mid_string() { #[test] fn mid_string_long_literal() { let src = r#" - FUNCTION main : STRING + FUNCTION main : STRING VAR_TEMP l : DINT; p : DINT; END_VAR l := 4; p := 6; - main := MID( + main := MID( ' this is a very long sentence with plenty of characters and weird spacing.the same is true for this string.', - l, + l, p ); END_FUNCTION @@ -351,7 +351,7 @@ fn mid_string_long_literal() { #[test] fn mid_ext_string() { let src = r#" - FUNCTION main : STRING + FUNCTION main : STRING VAR_TEMP in : STRING; out : STRING; @@ -362,7 +362,7 @@ fn mid_ext_string() { l := 7; p := 2; MID_EXT(in, l, p, out); - main := out; + main := out; END_FUNCTION "#; @@ -379,7 +379,7 @@ fn mid_ext_string() { #[test] fn mid_string_long_string() { let src = r#" - FUNCTION main : STRING[2048] + FUNCTION main : STRING[2048] VAR_TEMP in : STRING[128]; l : DINT; @@ -388,7 +388,7 @@ fn mid_string_long_string() { in := '7gAN5pmmSXqHJ3zZCXnBwika9N8RPXpTAdX4LdwHbLjwv9g3mU3dtpCT2MHVPxwtMw6jMQkip3HDy8Ruw42pVi56fiVhYn8faPLUKRghytQcBFgZhMXGhpBW'; l := 99; p := 10; - main := MID(in, l, p); + main := MID(in, l, p); END_FUNCTION "#; @@ -408,13 +408,13 @@ fn mid_string_long_string() { #[test] fn mid_ext_string_long_string() { let src = r#" - FUNCTION main : STRING[2048] + FUNCTION main : STRING[2048] VAR_TEMP in : STRING[128]; out : STRING[128]; l : DINT; p : DINT; - END_VAR + END_VAR in := '7gAN5pmmSXqHJ3zZCXnBwika9N8RPXpTAdX4LdwHbLjwv9g3mU3dtpCT2MHVPxwtMw6jMQkip3HDy8Ruw42pVi56fiVhYn8faPLUKRghytQcBFgZhMXGhpBW'; l := 99; p := 10; @@ -438,7 +438,7 @@ fn mid_ext_string_long_string() { #[test] fn insert_string() { let src = r#" - FUNCTION main : STRING + FUNCTION main : STRING VAR_TEMP in1 : STRING; in2 : STRING; @@ -447,7 +447,7 @@ fn insert_string() { in1 := 'stuck with you'; in2 := 'in the middle '; p := 6; - main := INSERT(in1, in2, p); + main := INSERT(in1, in2, p); END_FUNCTION "#; @@ -464,7 +464,7 @@ fn insert_string() { #[test] fn insert_ext_string_at_start_and_end() { let src = r#" - FUNCTION main : STRING + FUNCTION main : STRING VAR_TEMP in1 : STRING; in2 : STRING; @@ -472,10 +472,10 @@ fn insert_ext_string_at_start_and_end() { END_VAR in1 := '2'; in2 := '1'; - INSERT_EXT(in1, in2, 0, out); + INSERT_EXT(in1, in2, 0, out); in1 := out; in2 := '3'; - INSERT_EXT(in1, in2, 2, out); + INSERT_EXT(in1, in2, 2, out); main := out; END_FUNCTION "#; @@ -493,7 +493,7 @@ fn insert_ext_string_at_start_and_end() { #[test] fn delete_string_with_escape_sequence() { let src = r#" - FUNCTION main : STRING + FUNCTION main : STRING VAR_TEMP in : STRING; l : UINT; @@ -502,7 +502,7 @@ fn delete_string_with_escape_sequence() { in := 'the$$e are escape sequences $'𝄞$''; l := 21; p := 6; - main := DELETE(in, l, p); + main := DELETE(in, l, p); END_FUNCTION "#; @@ -516,7 +516,7 @@ fn delete_string_with_escape_sequence() { #[test] fn delete_ext_string() { let src = r#" - FUNCTION main : STRING + FUNCTION main : STRING VAR_TEMP in : STRING; out : STRING; @@ -526,7 +526,7 @@ fn delete_ext_string() { in := '𝄞typoasdf'; l := 4; p := 6; - DELETE_EXT(in, l, p, out); + DELETE_EXT(in, l, p, out); main := out; END_FUNCTION "#; @@ -544,7 +544,7 @@ fn delete_ext_string() { #[test] fn delete_ext_string_with_escape_sequence() { let src = r#" - FUNCTION main : STRING + FUNCTION main : STRING VAR_TEMP in : STRING; out : STRING; @@ -554,7 +554,7 @@ fn delete_ext_string_with_escape_sequence() { in := 'the$$e are escape sequences $'𝄞$''; l := 21; p := 6; - DELETE_EXT(in, l, p, out); + DELETE_EXT(in, l, p, out); main := out; END_FUNCTION "#; @@ -569,7 +569,7 @@ fn delete_ext_string_with_escape_sequence() { #[test] fn replace_string() { let src = r#" - FUNCTION main : STRING + FUNCTION main : STRING VAR_TEMP in1 : STRING; in2 : STRING; @@ -580,7 +580,7 @@ fn replace_string() { in2 := 'gret𝄞'; l := 8; p := 3; - main := REPLACE(in1, in2, l, p); + main := REPLACE(in1, in2, l, p); END_FUNCTION "#; @@ -597,7 +597,7 @@ fn replace_string() { #[test] fn replace_ext_string() { let src = r#" - FUNCTION main : STRING + FUNCTION main : STRING VAR_TEMP in1 : STRING; in2 : STRING; @@ -609,7 +609,7 @@ fn replace_ext_string() { in2 := 'st𝄞red'; l := 8; p := 3; - REPLACE_EXT(in1, in2, l, p, out); + REPLACE_EXT(in1, in2, l, p, out); main := out; END_FUNCTION "#; @@ -634,7 +634,7 @@ fn find_string() { END_VAR in1 := 'Where is Waldo?'; in2 := 'Waldo'; - main := FIND(in1, in2); + main := FIND(in1, in2); END_FUNCTION "#; @@ -654,7 +654,7 @@ fn test_double_quotes_on_strings() { END_VAR in1 := "Where is Waldo?"; in2 := "Waldo"; - main := FIND(in1, in2); + main := FIND(in1, in2); END_FUNCTION "#; @@ -671,7 +671,7 @@ fn test_concat_string() { b : STRING := ', '; c : STRING := 'World'; d : STRING := '!'; - END_VAR + END_VAR main := CONCAT(a, b, c, d); END_FUNCTION "#; @@ -696,7 +696,7 @@ fn test_concat_ext_string() { b : STRING := ', '; c : STRING := 'World'; d : STRING := '!'; - END_VAR + END_VAR CONCAT_EXT(main, a, b, c, d); END_FUNCTION "#; @@ -766,12 +766,12 @@ the same is true for t #[test] fn len_wstring() { let src = r#" - FUNCTION main : DINT + FUNCTION main : DINT VAR_TEMP in : WSTRING; END_VAR in := "Hèßlo😀𝄞"; - main := LEN(in); + main := LEN(in); END_FUNCTION "#; let sources = add_std!(src, "string_functions.st"); @@ -782,8 +782,8 @@ fn len_wstring() { #[test] fn len_wstring_no_variable() { let src = r#" - FUNCTION main : DINT - main := LEN(WSTRING#'Hèßlo😀𝄞'); + FUNCTION main : DINT + main := LEN(WSTRING#'Hèßlo😀𝄞'); END_FUNCTION "#; let sources = add_std!(src, "string_functions.st"); @@ -794,12 +794,12 @@ fn len_wstring_no_variable() { #[test] fn len_wstring_empty() { let src = r#" - FUNCTION main : DINT + FUNCTION main : DINT VAR_TEMP in : WSTRING[1024]; END_VAR in := ""; - main := LEN(in); + main := LEN(in); END_FUNCTION "#; let sources = add_std!(src, "string_functions.st"); @@ -810,12 +810,12 @@ fn len_wstring_empty() { #[test] fn left_wstring() { let src = r#" - FUNCTION main : WSTRING + FUNCTION main : WSTRING VAR_TEMP in : WSTRING; END_VAR in := "𝄞music"; - main := LEFT(in, DINT#2); + main := LEFT(in, DINT#2); END_FUNCTION "#; @@ -832,14 +832,14 @@ fn left_wstring() { #[test] fn left_wstring_lint() { let src = r#" - FUNCTION main : WSTRING + FUNCTION main : WSTRING VAR_TEMP in : WSTRING; l : LINT; END_VAR in := "lets see 𝄞f long 𝄞nt is handled correctly"; l := 31; - main := LEFT(in, l); + main := LEFT(in, l); END_FUNCTION "#; @@ -856,7 +856,7 @@ fn left_wstring_lint() { #[test] fn left_ext_wstring() { let src = r#" - FUNCTION main : WSTRING + FUNCTION main : WSTRING VAR_TEMP in : WSTRING; out : WSTRING; @@ -865,7 +865,7 @@ fn left_ext_wstring() { in := "e𝄞tended"; l := 6; LEFT_EXT(in, l, out); - main := out; + main := out; END_FUNCTION "#; @@ -882,12 +882,12 @@ fn left_ext_wstring() { #[test] fn right_wstring_usint() { let src = r#" - FUNCTION main : WSTRING + FUNCTION main : WSTRING VAR_TEMP in : WSTRING; END_VAR in := "samp𝄞e text"; - main := RIGHT(in, USINT#7); + main := RIGHT(in, USINT#7); END_FUNCTION "#; @@ -907,12 +907,12 @@ fn right_wstring_usint() { #[should_panic(expected = "Requested substring length exceeds string length.")] fn right_wstring_substring_too_long() { let src = r#" - FUNCTION main : WSTRING + FUNCTION main : WSTRING VAR_TEMP in : WSTRING; END_VAR in := "sa𝄞ple text"; - main := RIGHT(in, 12); + main := RIGHT(in, 12); END_FUNCTION "#; @@ -923,14 +923,14 @@ fn right_wstring_substring_too_long() { #[test] fn right_ext_wstring() { let src = r#" - FUNCTION main : WSTRING + FUNCTION main : WSTRING VAR_TEMP in : WSTRING; out : WSTRING; END_VAR in := "exten𝄞ed𝄞"; RIGHT_EXT(in, 4, out); - main := out; + main := out; END_FUNCTION "#; @@ -947,7 +947,7 @@ fn right_ext_wstring() { #[test] fn right_string_long_wstring() { let src = r#" - FUNCTION main : WSTRING[128] + FUNCTION main : WSTRING[128] VAR_TEMP in : WSTRING[128]; l : DINT; @@ -971,12 +971,12 @@ fn right_string_long_wstring() { #[test] fn right_ext_string_long_wstring() { let src = r#" - FUNCTION main : WSTRING[128] + FUNCTION main : WSTRING[128] VAR_TEMP in : WSTRING[128]; out : WSTRING[128]; l : DINT; - END_VAR + END_VAR in := "7gAN5pmmSXqHJ3zZCXnBwi𝄞𝄞9N8RPXpTAdX4LdwHbLjwv9g3mU3dtpCT2MHVPxwtMw6jMQkip3HDy8Ruw42pVi56fiVhYn8faPLUKRghytQcBFgZhMXGhpBW"; l := 99; RIGHT_EXT(in, l, main); @@ -996,7 +996,7 @@ fn right_ext_string_long_wstring() { #[test] fn mid_wstring() { let src = r#" - FUNCTION main : WSTRING + FUNCTION main : WSTRING VAR_TEMP in : WSTRING; l : DINT; @@ -1005,7 +1005,7 @@ fn mid_wstring() { in := "sample 𝄞muϗ😀 text"; l := 7; p := 2; - main := MID(in, l, p); + main := MID(in, l, p); END_FUNCTION "#; @@ -1022,7 +1022,7 @@ fn mid_wstring() { #[test] fn mid_ext_wstring() { let src = r#" - FUNCTION main : WSTRING + FUNCTION main : WSTRING VAR_TEMP in : WSTRING; out : WSTRING; @@ -1033,7 +1033,7 @@ fn mid_ext_wstring() { l := 7; p := 2; MID_EXT(in, l, p, out); - main := out; + main := out; END_FUNCTION "#; @@ -1050,7 +1050,7 @@ fn mid_ext_wstring() { #[test] fn mid_string_long_wstring() { let src = r#" - FUNCTION main : WSTRING[128] + FUNCTION main : WSTRING[128] VAR_TEMP in : WSTRING[128]; l : DINT; @@ -1059,7 +1059,7 @@ fn mid_string_long_wstring() { in := "𝄞muϗ😀pmmSXqHJ3zZCXnBwika9N8RPXpTAdX4LdwHbLjwv9g3mU3dtpCT2MHVPxwtMw6jMQkip3HDy8Ruw42pVi56fiVhYn8faPLUKRghytQcBFgZhMXGhpBW"; l := 99; p := 10; - main := MID(in, l, p); + main := MID(in, l, p); END_FUNCTION "#; @@ -1076,12 +1076,12 @@ fn mid_string_long_wstring() { #[test] fn mid_ext_string_long_wstring() { let src = r#" - FUNCTION main : WSTRING[128] + FUNCTION main : WSTRING[128] VAR_TEMP in : WSTRING[128]; l : DINT; p : DINT; - END_VAR + END_VAR in := "𝄞muϗ😀pmmSXqHJ3zZCXnBwika9N8RPXpTAdX4LdwHbLjwv9g3mU3dtpCT2MHVPxwtMw6jMQkip3HDy8Ruw42pVi56fiVhYn8faPLUKRghytQcBFgZhMXGhpBW"; l := 99; p := 10; @@ -1102,7 +1102,7 @@ fn mid_ext_string_long_wstring() { #[test] fn insert_wstring() { let src = r#" - FUNCTION main : WSTRING + FUNCTION main : WSTRING VAR_TEMP in1 : WSTRING; in2 : WSTRING; @@ -1111,7 +1111,7 @@ fn insert_wstring() { in1 := "stuck with you"; in2 := "in the middle "; p := 6; - main := INSERT(in1, in2, p); + main := INSERT(in1, in2, p); END_FUNCTION "#; @@ -1122,7 +1122,7 @@ fn insert_wstring() { assert_eq!(res, "stuck in the middle with you"); } else { panic!( - "Given string is not + "Given string is not -encoded" ) } @@ -1131,7 +1131,7 @@ fn insert_wstring() { #[test] fn insert_ext_wstring_at_start_and_end() { let src = r#" - FUNCTION main : WSTRING + FUNCTION main : WSTRING VAR_TEMP in1 : WSTRING; in2 : WSTRING; @@ -1139,10 +1139,10 @@ fn insert_ext_wstring_at_start_and_end() { END_VAR in1 := "2"; in2 := "1"; - INSERT_EXT(in1, in2, 0, out); + INSERT_EXT(in1, in2, 0, out); in1 := out; in2 := "3"; - INSERT_EXT(in1, in2, 2, out); + INSERT_EXT(in1, in2, 2, out); main := out; END_FUNCTION "#; @@ -1160,7 +1160,7 @@ fn insert_ext_wstring_at_start_and_end() { #[test] fn delete_wstring() { let src = r#" - FUNCTION main : WSTRING + FUNCTION main : WSTRING VAR_TEMP in : WSTRING; l : UINT; @@ -1169,7 +1169,7 @@ fn delete_wstring() { in := "this will be deleted"; l := 13; p := 1; - main := DELETE(in, l, p); + main := DELETE(in, l, p); END_FUNCTION "#; @@ -1186,7 +1186,7 @@ fn delete_wstring() { #[test] fn delete_ext_wstring() { let src = r#" - FUNCTION main : WSTRING + FUNCTION main : WSTRING VAR_TEMP in : WSTRING; out : WSTRING; @@ -1196,7 +1196,7 @@ fn delete_ext_wstring() { in := "typoasdf"; l := 4; p := 5; - DELETE_EXT(in, l, p, out); + DELETE_EXT(in, l, p, out); main := out; END_FUNCTION "#; @@ -1215,7 +1215,7 @@ fn delete_ext_wstring() { #[test] fn replace_wstring() { let src = r#" - FUNCTION main : WSTRING + FUNCTION main : WSTRING VAR_TEMP in1 : WSTRING; in2 : WSTRING; @@ -1226,7 +1226,7 @@ fn replace_wstring() { in2 := "gret"; l := 8; p := 3; - main := REPLACE(in1, in2, l, p); + main := REPLACE(in1, in2, l, p); END_FUNCTION "#; @@ -1243,7 +1243,7 @@ fn replace_wstring() { #[test] fn replace_ext_wstring() { let src = r#" - FUNCTION main : WSTRING + FUNCTION main : WSTRING VAR_TEMP in1 : WSTRING; in2 : WSTRING; @@ -1255,7 +1255,7 @@ fn replace_ext_wstring() { in2 := "stored"; l := 8; p := 3; - REPLACE_EXT(in1, in2, l, p, out); + REPLACE_EXT(in1, in2, l, p, out); main := out; END_FUNCTION "#; @@ -1280,7 +1280,7 @@ fn find_wstring() { END_VAR in1 := "Where is Waldo?"; in2 := "Waldo"; - main := FIND(in1, in2); + main := FIND(in1, in2); END_FUNCTION "#; @@ -1292,7 +1292,7 @@ fn find_wstring() { #[test] fn delete_wstring_with_escape_sequence() { let src = r#" - FUNCTION main : WSTRING + FUNCTION main : WSTRING VAR_TEMP in : WSTRING; l : UINT; @@ -1301,7 +1301,7 @@ fn delete_wstring_with_escape_sequence() { in := "the$$e are escape sequences $"𝄞$""; l := 21; p := 6; - main := DELETE(in, l, p); + main := DELETE(in, l, p); END_FUNCTION "#; @@ -1324,7 +1324,7 @@ fn test_concat_wstring() { b : WSTRING := ", "; c : WSTRING := "World"; d : WSTRING := "!"; - END_VAR + END_VAR main := CONCAT(a, b, c, d); END_FUNCTION "#; @@ -1348,7 +1348,7 @@ fn test_concat_ext_wstring() { b : WSTRING := ", "; c : WSTRING := "World"; d : WSTRING := "!"; - END_VAR + END_VAR CONCAT_EXT(main, a, b, c, d); END_FUNCTION "#; @@ -1372,7 +1372,7 @@ fn test_gt_string() { a : STRING := 'z'; b : STRING := 'y '; c : STRING := 'x'; - END_VAR + END_VAR main := GT(a, b, c); END_FUNCTION "#; @@ -1391,7 +1391,7 @@ fn test_ge_string() { b : STRING := 'z'; c : STRING := 'y'; d : STRING := 'x'; - END_VAR + END_VAR main := GE(a, b, c, d); END_FUNCTION "#; @@ -1409,7 +1409,7 @@ fn test_eq_string() { a : STRING := 'same'; b : STRING := 'same'; c : STRING := 'same'; - END_VAR + END_VAR main := EQ(a, b, c); END_FUNCTION "#; @@ -1428,7 +1428,7 @@ fn test_lt_string() { b : STRING := 'z'; c : STRING := 'y'; d : STRING := 'x'; - END_VAR + END_VAR main := LT(d, c, b, a); END_FUNCTION "#; @@ -1447,7 +1447,7 @@ fn test_le_string() { b : STRING := 'z'; c : STRING := 'y'; d : STRING := 'x'; - END_VAR + END_VAR main := LE(d, c, b, a); END_FUNCTION "#; @@ -1464,7 +1464,7 @@ fn test_ne_string() { VAR_TEMP a : STRING := 'z'; b : STRING := 'y'; - END_VAR + END_VAR main := NE(a, b); END_FUNCTION "#; @@ -1482,7 +1482,7 @@ fn test_gt_wstring() { a : WSTRING := "z"; b : WSTRING := "y"; c : WSTRING := "x"; - END_VAR + END_VAR main := GT(a, b, c); END_FUNCTION "#; @@ -1501,7 +1501,7 @@ fn test_ge_wstring() { b : WSTRING := "z"; c : WSTRING := "y"; d : WSTRING := "x"; - END_VAR + END_VAR main := GE(a, b, c, d); END_FUNCTION "#; @@ -1519,7 +1519,7 @@ fn test_eq_wstring() { a : WSTRING := "same"; b : WSTRING := "same"; c : WSTRING := "same"; - END_VAR + END_VAR main := EQ(a, b, c); END_FUNCTION "#; @@ -1538,7 +1538,7 @@ fn test_lt_wstring() { b : WSTRING := "z"; c : WSTRING := "y"; d : WSTRING := "x"; - END_VAR + END_VAR main := LT(d, c, b, a); END_FUNCTION "#; @@ -1557,7 +1557,7 @@ fn test_le_wstring() { b : WSTRING := "z"; c : WSTRING := "y"; d : WSTRING := "x"; - END_VAR + END_VAR main := LE(d, c, b, a); END_FUNCTION "#; @@ -1589,7 +1589,7 @@ fn test_string_greater_operator_works_if_result_is_true() { VAR_TEMP a : STRING := 'zyx'; b : STRING := 'yx'; - END_VAR + END_VAR main := a > b; END_FUNCTION "#; @@ -1621,7 +1621,7 @@ fn test_string_binary_operator_wrapper_functions_work_if_expressions_evaluate_to b : STRING := 'abc'; c : STRING := 'bcd'; d : STRING := 'cba'; - END_VAR + END_VAR lt := a < c AND b < c AND c < d; le := a <= b AND a <= c; eq := a = b; @@ -1650,7 +1650,7 @@ fn test_wstring_binary_operator_wrapper_functions_work() { b : WSTRING := "abc"; c : WSTRING := "bcd"; d : WSTRING := "cba"; - END_VAR + END_VAR lt := a < c AND b < c AND c < d; le := a <= b AND a <= c; eq := a = b; @@ -1679,7 +1679,7 @@ fn test_string_binary_operator_wrapper_functions_work_if_expressions_evaluate_to b : STRING := 'abc'; c : STRING := 'bcd'; d : STRING := 'cba'; - END_VAR + END_VAR lt := c < a OR c < b OR d < c; le := c <= a OR d <= c; eq := a = d OR a = c OR c = d; @@ -1703,7 +1703,7 @@ fn test_string_equality_operator_works_for_long_strings() { VAR_TEMP a : STRING := 'this very long unimaginative sentence consists of the same characters in the same sequence twice'; b : STRING := 'this very long unimaginative sentence consists of the same characters in the same sequence twice'; - END_VAR + END_VAR main := a = b; END_FUNCTION "#; @@ -1720,7 +1720,7 @@ fn test_string_not_equal_operator_works_for_long_strings() { VAR_TEMP a : STRING := 'this very long unimaginative sentence consists of the same characters in the same sequence twice'; b : STRING := 'this very long unimaginative sentence claims the previous string is dishonest'; - END_VAR + END_VAR main := a <> b; END_FUNCTION "#; diff --git a/libs/stdlib/tests/validation_functions_tests.rs b/libs/stdlib/tests/validation_functions_tests.rs index bd489ec36d..a7e58d92a0 100644 --- a/libs/stdlib/tests/validation_functions_tests.rs +++ b/libs/stdlib/tests/validation_functions_tests.rs @@ -17,27 +17,27 @@ struct MainType { #[test] fn is_valid_real() { let src = " - VAR_GLOBAL - MAX : REAL := 3.4028235e38; - MIN : REAL := -3.4028235e38; - INF : REAL := 1.0 / 0.0; - NaN : REAL := 0.0 / 0.0; - END_VAR - - PROGRAM main - VAR - max_ : BOOL; - min_ : BOOL; - zero : BOOL; - inf_ : BOOL; - nan_ : BOOL; - END_VAR - max_ := IS_VALID(MAX); - min_ := IS_VALID(MIN); - zero := IS_VALID(REAL#0.0); - inf_ := IS_VALID(INF); - nan_ := IS_VALID(NaN); - END_PROGRAM"; + VAR_GLOBAL + MAX : REAL := 3.4028235e38; + MIN : REAL := -3.4028235e38; + INF : REAL := 1.0 / 0.0; + NaN : REAL := 0.0 / 0.0; + END_VAR + + PROGRAM main + VAR + max_ : BOOL; + min_ : BOOL; + zero : BOOL; + inf_ : BOOL; + nan_ : BOOL; + END_VAR + max_ := IS_VALID(MAX); + min_ := IS_VALID(MIN); + zero := IS_VALID(REAL#0.0); + inf_ := IS_VALID(INF); + nan_ := IS_VALID(NaN); + END_PROGRAM"; let sources = add_std!(src, "validation_functions.st"); let mut maintype = MainType::default(); let _: i64 = compile_and_run(sources, &mut maintype); @@ -56,27 +56,27 @@ fn is_valid_real() { #[test] fn is_valid_lreal() { let src = " - VAR_GLOBAL - MAX : LREAL := 1.7976931348623157e308; - MIN : LREAL := LREAL#-1.7976931348623157e308; - INF : LREAL := 1.0 / 0.0; - NaN : LREAL := 0.0 / 0.0; - END_VAR - - PROGRAM main - VAR - max_ : BOOL; - min_ : BOOL; - zero : BOOL; - inf_ : BOOL; - nan_ : BOOL; - END_VAR - max_ := IS_VALID(MAX); - min_ := IS_VALID(MIN); - zero := IS_VALID(LREAL#0.0); - inf_ := IS_VALID(INF); - nan_ := IS_VALID(NaN); - END_PROGRAM"; + VAR_GLOBAL + MAX : LREAL := 1.7976931348623157e308; + MIN : LREAL := LREAL#-1.7976931348623157e308; + INF : LREAL := 1.0 / 0.0; + NaN : LREAL := 0.0 / 0.0; + END_VAR + + PROGRAM main + VAR + max_ : BOOL; + min_ : BOOL; + zero : BOOL; + inf_ : BOOL; + nan_ : BOOL; + END_VAR + max_ := IS_VALID(MAX); + min_ := IS_VALID(MIN); + zero := IS_VALID(LREAL#0.0); + inf_ := IS_VALID(INF); + nan_ := IS_VALID(NaN); + END_PROGRAM"; let sources = add_std!(src, "validation_functions.st"); let mut maintype = MainType::default(); let _: i64 = compile_and_run(sources, &mut maintype); @@ -109,21 +109,21 @@ struct StructBCD { #[test] fn is_valid_byte() { let src = " - PROGRAM main - VAR - valid : BOOL; - invalid : BOOL; - END_VAR - VAR_TEMP - v_valid : BYTE; - v_invalid : BYTE; - END_VAR - v_valid := 2#0011_0010; // in BCD 3_2 => VALID - valid := IS_VALID_BCD(v_valid); - - v_invalid := 2#0010_1100; // in BCD 2_[12] => INVALID - invalid := IS_VALID_BCD(v_invalid); - END_PROGRAM"; + PROGRAM main + VAR + valid : BOOL; + invalid : BOOL; + END_VAR + VAR_TEMP + v_valid : BYTE; + v_invalid : BYTE; + END_VAR + v_valid := 2#0011_0010; // in BCD 3_2 => VALID + valid := IS_VALID_BCD(v_valid); + + v_invalid := 2#0010_1100; // in BCD 2_[12] => INVALID + invalid := IS_VALID_BCD(v_invalid); + END_PROGRAM"; let sources = add_std!(src, "validation_functions.st"); let mut maintype = StructBCD::default(); let _: i64 = compile_and_run(sources, &mut maintype); @@ -134,21 +134,21 @@ fn is_valid_byte() { #[test] fn is_valid_word() { let src = " - PROGRAM main - VAR - valid : BOOL; - invalid : BOOL; - END_VAR - VAR_TEMP - v_valid : WORD; - v_invalid : WORD; - END_VAR - v_valid := 2#0100_1000_0111_0001; // in BCD 4_8_7_1 => VALID - valid := IS_VALID_BCD(v_valid); - - v_invalid := 2#0100_1011_0111_0001; // in BCD 4_[11]_7_1 => INVALID - invalid := IS_VALID_BCD(v_invalid); - END_PROGRAM"; + PROGRAM main + VAR + valid : BOOL; + invalid : BOOL; + END_VAR + VAR_TEMP + v_valid : WORD; + v_invalid : WORD; + END_VAR + v_valid := 2#0100_1000_0111_0001; // in BCD 4_8_7_1 => VALID + valid := IS_VALID_BCD(v_valid); + + v_invalid := 2#0100_1011_0111_0001; // in BCD 4_[11]_7_1 => INVALID + invalid := IS_VALID_BCD(v_invalid); + END_PROGRAM"; let sources = add_std!(src, "validation_functions.st"); let mut maintype = StructBCD::default(); let _: i64 = compile_and_run(sources, &mut maintype); @@ -159,21 +159,21 @@ fn is_valid_word() { #[test] fn is_valid_dword() { let src = " - PROGRAM main - VAR - valid : BOOL; - invalid : BOOL; - END_VAR - VAR_TEMP - v_valid : DWORD; - v_invalid : DWORD; - END_VAR - v_valid := 2#0100_1000_0111_0001_0100_1000_0111_0001; // in BCD 4_8_7_1_4_8_7_1 => VALID - valid := IS_VALID_BCD(v_valid); - - v_invalid := 2#0100_1011_0111_0001_0100_1011_0111_0001; // in BCD 4_[11]_7_1_4_11_7_1 => INVALID - invalid := IS_VALID_BCD(v_invalid); - END_PROGRAM"; + PROGRAM main + VAR + valid : BOOL; + invalid : BOOL; + END_VAR + VAR_TEMP + v_valid : DWORD; + v_invalid : DWORD; + END_VAR + v_valid := 2#0100_1000_0111_0001_0100_1000_0111_0001; // in BCD 4_8_7_1_4_8_7_1 => VALID + valid := IS_VALID_BCD(v_valid); + + v_invalid := 2#0100_1011_0111_0001_0100_1011_0111_0001; // in BCD 4_[11]_7_1_4_11_7_1 => INVALID + invalid := IS_VALID_BCD(v_invalid); + END_PROGRAM"; let sources = add_std!(src, "validation_functions.st"); let mut maintype = StructBCD::default(); let _: i64 = compile_and_run(sources, &mut maintype); @@ -184,21 +184,21 @@ fn is_valid_dword() { #[test] fn is_valid_lword() { let src = " - PROGRAM main - VAR - valid : BOOL; - invalid : BOOL; - END_VAR - VAR_TEMP - v_valid : LWORD; - v_invalid : LWORD; - END_VAR - v_valid := 2#0100_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000; // in BCD 4_0_0_0_0_0_0_0_0_0_0_0_0_0_0_0 => VALID - valid := IS_VALID_BCD(v_valid); - - v_invalid := 2#0100_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_1111; // in BCD 4_0_0_0_0_0_0_0_0_0_0_0_0_0_0_[15] => INVALID - invalid := IS_VALID_BCD(v_invalid); - END_PROGRAM"; + PROGRAM main + VAR + valid : BOOL; + invalid : BOOL; + END_VAR + VAR_TEMP + v_valid : LWORD; + v_invalid : LWORD; + END_VAR + v_valid := 2#0100_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000; // in BCD 4_0_0_0_0_0_0_0_0_0_0_0_0_0_0_0 => VALID + valid := IS_VALID_BCD(v_valid); + + v_invalid := 2#0100_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_1111; // in BCD 4_0_0_0_0_0_0_0_0_0_0_0_0_0_0_[15] => INVALID + invalid := IS_VALID_BCD(v_invalid); + END_PROGRAM"; let sources = add_std!(src, "validation_functions.st"); let mut maintype = StructBCD::default(); let _: i64 = compile_and_run(sources, &mut maintype); diff --git a/libs/stdlib/utils/code_gen.py b/libs/stdlib/utils/code_gen.py index b061dc09c3..b73c8368a8 100644 --- a/libs/stdlib/utils/code_gen.py +++ b/libs/stdlib/utils/code_gen.py @@ -2,8 +2,18 @@ f = open("gen.txt", "w") # list of data types -types = ["LREAL", "REAL", "LINT", "DINT", "INT", - "SINT", "ULINT", "UDINT", "UINT", "USINT"] +types = [ + "LREAL", + "REAL", + "LINT", + "DINT", + "INT", + "SINT", + "ULINT", + "UDINT", + "UINT", + "USINT", +] src = """(******************** * @@ -12,9 +22,9 @@ *********************) FUNCTION {0}_TO_{1} : {1} VAR_INPUT - in : {0}; + in : {0}; END_VAR - {0}_TO_{1} := in; + {0}_TO_{1} := in; END_FUNCTION """ diff --git a/scripts/build.sh b/scripts/build.sh index 536c838940..13ec075cb9 100755 --- a/scripts/build.sh +++ b/scripts/build.sh @@ -22,316 +22,316 @@ CONTAINER_NAME='rust-llvm' source "${BASH_SOURCE%/*}/common.sh" function set_cargo_options() { - CARGO_OPTIONS="" - if [[ $debug -ne 0 ]]; then - CARGO_OPTIONS="$CARGO_OPTIONS --verbose" - fi - if [[ $release -ne 0 ]]; then - CARGO_OPTIONS="$CARGO_OPTIONS --release" - fi - if [[ $offline -ne 0 ]]; then - CARGO_OPTIONS="$CARGO_OPTIONS --frozen" - fi - echo "$CARGO_OPTIONS" + CARGO_OPTIONS="" + if [[ $debug -ne 0 ]]; then + CARGO_OPTIONS="$CARGO_OPTIONS --verbose" + fi + if [[ $release -ne 0 ]]; then + CARGO_OPTIONS="$CARGO_OPTIONS --release" + fi + if [[ $offline -ne 0 ]]; then + CARGO_OPTIONS="$CARGO_OPTIONS --frozen" + fi + echo "$CARGO_OPTIONS" } function run_coverage() { - log "Exporting Flags" - export RUSTFLAGS="-C instrument-coverage" - export LLVM_PROFILE_FILE="rusty-%p-%m.profraw" - - log "Cleaning before build" - cargo clean - log "Building coverage" - cargo build --workspace - log "Running coverage tests" - cargo test --workspace - log "Collecting coverage results" - grcov . --binary-path ./target/debug/ -s . -t lcov --branch \ - --ignore "/*" \ - --ignore "src/main.rs" \ - --ignore "src/*/tests.rs" \ - --ignore "src/*/tests/*" \ - --ignore "tests/*" \ - --ignore "src/lexer/tokens.rs" \ - --ignore-not-existing -o lcov.info + log "Exporting Flags" + export RUSTFLAGS="-C instrument-coverage" + export LLVM_PROFILE_FILE="rusty-%p-%m.profraw" + + log "Cleaning before build" + cargo clean + log "Building coverage" + cargo build --workspace + log "Running coverage tests" + cargo test --workspace + log "Collecting coverage results" + grcov . --binary-path ./target/debug/ -s . -t lcov --branch \ + --ignore "/*" \ + --ignore "src/main.rs" \ + --ignore "src/*/tests.rs" \ + --ignore "src/*/tests/*" \ + --ignore "tests/*" \ + --ignore "src/lexer/tokens.rs" \ + --ignore-not-existing -o lcov.info } function run_build() { - CARGO_OPTIONS=$(set_cargo_options) - - # Run cargo build with release or debug flags - echo "Build starting" - echo "-----------------------------------" - cmd="cargo build $CARGO_OPTIONS " - log "Running $cmd" - eval "$cmd" - echo "-----------------------------------" - if [[ ${PIPESTATUS[0]} -ne 0 ]]; then - echo "Build failed" - exit 1 - else - echo "Build done" - fi + CARGO_OPTIONS=$(set_cargo_options) + + # Run cargo build with release or debug flags + echo "Build starting" + echo "-----------------------------------" + cmd="cargo build $CARGO_OPTIONS " + log "Running $cmd" + eval "$cmd" + echo "-----------------------------------" + if [[ ${PIPESTATUS[0]} -ne 0 ]]; then + echo "Build failed" + exit 1 + else + echo "Build done" + fi } # Builds with set targets, useful for standard functions function run_std_build() { - CARGO_OPTIONS=$(set_cargo_options) - - # if the targets are set, we will build once per target - - # Run cargo build with release or debug flags - echo "Build starting" - echo "-----------------------------------" - cmd="cargo build $CARGO_OPTIONS -p iec61131std" - if [[ ! -z $target ]]; then - for val in ${target//,/ } - do - new_cmd="$cmd --target=$val" - log "Running $new_cmd" - eval "$new_cmd" - echo "-----------------------------------" - if [[ ${PIPESTATUS[0]} -ne 0 ]]; then - echo "Build $val failed" - exit 1 - else - echo "Build $val done" - fi - done - else - log "Running $cmd" - eval "$cmd" - echo "-----------------------------------" - if [[ ${PIPESTATUS[0]} -ne 0 ]]; then - echo "Build failed" - exit 1 - else - echo "Build done" - fi - fi + CARGO_OPTIONS=$(set_cargo_options) + + # if the targets are set, we will build once per target + + # Run cargo build with release or debug flags + echo "Build starting" + echo "-----------------------------------" + cmd="cargo build $CARGO_OPTIONS -p iec61131std" + if [[ ! -z $target ]]; then + for val in ${target//,/ } + do + new_cmd="$cmd --target=$val" + log "Running $new_cmd" + eval "$new_cmd" + echo "-----------------------------------" + if [[ ${PIPESTATUS[0]} -ne 0 ]]; then + echo "Build $val failed" + exit 1 + else + echo "Build $val done" + fi + done + else + log "Running $cmd" + eval "$cmd" + echo "-----------------------------------" + if [[ ${PIPESTATUS[0]} -ne 0 ]]; then + echo "Build failed" + exit 1 + else + echo "Build done" + fi + fi } function run_check() { - CARGO_OPTIONS=$(set_cargo_options) - log "Running cargo check" + CARGO_OPTIONS=$(set_cargo_options) + log "Running cargo check" - cargo check $CARGO_OPTIONS --workspace + cargo check $CARGO_OPTIONS --workspace } function run_doc() { - CARGO_OPTIONS=$(set_cargo_options) - log "Running cargo doc --workspace $CARGO_OPTIONS" - cargo doc --workspace $CARGO_OPTIONS - log "Building book" - cd book && mdbook build && mdbook test + CARGO_OPTIONS=$(set_cargo_options) + log "Running cargo doc --workspace $CARGO_OPTIONS" + cargo doc --workspace $CARGO_OPTIONS + log "Building book" + cd book && mdbook build && mdbook test } function run_check_style() { - CARGO_OPTIONS=$(set_cargo_options) - log "Running cargo clippy" - cargo clippy $CARGO_OPTIONS --workspace -- -Dwarnings - log "Running cargo fmt check" - cargo fmt -- --check + CARGO_OPTIONS=$(set_cargo_options) + log "Running cargo clippy" + cargo clippy $CARGO_OPTIONS --workspace -- -Dwarnings + log "Running cargo fmt check" + cargo fmt -- --check } function run_test() { - CARGO_OPTIONS=$(set_cargo_options) - log "Running cargo test" - if [[ $junit -ne 0 ]]; then - #Delete the test results if they exist - rm -rf "$project_location/test_results" - make_dir "$project_location/test_results" - # JUnit test should run on nightly - log "cargo +nightly test $CARGO_OPTIONS --lib -- --format=junit \ - -Zunstable-options \ - | split -l1 - "$project_location"/test_results/unit_tests \ - -d --additional-suffix=.xml - " - cargo +nightly test $CARGO_OPTIONS --lib -- --format=junit \ - -Zunstable-options \ - | split -l1 - "$project_location"/test_results/unit_tests \ - -d --additional-suffix=.xml - - # Run only the integration tests - #https://stackoverflow.com/questions/62447864/how-can-i-run-only-integration-tests - log "cargo +nightly test $CARGO_OPTIONS --test '*' -- --format=junit \ - -Zunstable-options \ - | split -l1 - "$project_location"/test_results/integration_tests \ - -d --additional-suffix=.xml" - cargo +nightly test $CARGO_OPTIONS --test '*' -- --format=junit \ - -Zunstable-options \ - | split -l1 - "$project_location"/test_results/integration_tests \ - -d --additional-suffix=.xml - - # Run the std integration - log "cargo +nightly test $CARGO_OPTIONS -p iec61131std --test '*' -- --format=junit \ - -Zunstable-options \ - | split -l1 - "$project_location"/test_results/std_integration_tests \ - -d --additional-suffix=.xml" - cargo +nightly test $CARGO_OPTIONS -p iec61131std --test '*' -- --format=junit \ - -Zunstable-options \ - | split -l1 - "$project_location"/test_results/std_integration_tests \ - -d --additional-suffix=.xml - else - cargo test $CARGO_OPTIONS --workspace - fi + CARGO_OPTIONS=$(set_cargo_options) + log "Running cargo test" + if [[ $junit -ne 0 ]]; then + #Delete the test results if they exist + rm -rf "$project_location/test_results" + make_dir "$project_location/test_results" + # JUnit test should run on nightly + log "cargo +nightly test $CARGO_OPTIONS --lib -- --format=junit \ + -Zunstable-options \ + | split -l1 - "$project_location"/test_results/unit_tests \ + -d --additional-suffix=.xml + " + cargo +nightly test $CARGO_OPTIONS --lib -- --format=junit \ + -Zunstable-options \ + | split -l1 - "$project_location"/test_results/unit_tests \ + -d --additional-suffix=.xml + + # Run only the integration tests + #https://stackoverflow.com/questions/62447864/how-can-i-run-only-integration-tests + log "cargo +nightly test $CARGO_OPTIONS --test '*' -- --format=junit \ + -Zunstable-options \ + | split -l1 - "$project_location"/test_results/integration_tests \ + -d --additional-suffix=.xml" + cargo +nightly test $CARGO_OPTIONS --test '*' -- --format=junit \ + -Zunstable-options \ + | split -l1 - "$project_location"/test_results/integration_tests \ + -d --additional-suffix=.xml + + # Run the std integration + log "cargo +nightly test $CARGO_OPTIONS -p iec61131std --test '*' -- --format=junit \ + -Zunstable-options \ + | split -l1 - "$project_location"/test_results/std_integration_tests \ + -d --additional-suffix=.xml" + cargo +nightly test $CARGO_OPTIONS -p iec61131std --test '*' -- --format=junit \ + -Zunstable-options \ + | split -l1 - "$project_location"/test_results/std_integration_tests \ + -d --additional-suffix=.xml + else + cargo test $CARGO_OPTIONS --workspace + fi } function generate_sources() { - log "Collecting 3rd party sources" - cargo vendor 3rd-party --versioned-dirs - log "Packaging all sources into sources.zip" - zip -r sources.zip ./ -x "output/*" -x "target/*" -x ".git/*" -q + log "Collecting 3rd party sources" + cargo vendor 3rd-party --versioned-dirs + log "Packaging all sources into sources.zip" + zip -r sources.zip ./ -x "output/*" -x "target/*" -x ".git/*" -q } function set_offline() { - log "Vendor location set, using offline build" - log "Copy the offline.toml config to build/.cargo/config.toml" - make_dir "$BUILD_DIR"/.cargo - cp "$project_location"/scripts/data/offline.toml "$BUILD_DIR"/.cargo/config.toml - if [[ ! -d $project_location/3rd-party ]]; then - echo "Offline sources not found at $project_location/3rd-party" - exit 1 - fi + log "Vendor location set, using offline build" + log "Copy the offline.toml config to build/.cargo/config.toml" + make_dir "$BUILD_DIR"/.cargo + cp "$project_location"/scripts/data/offline.toml "$BUILD_DIR"/.cargo/config.toml + if [[ ! -d $project_location/3rd-party ]]; then + echo "Offline sources not found at $project_location/3rd-party" + exit 1 + fi } function run_package_std() { - cc=$(get_compiler) - log "Packaging Standard functions" - log "Removing previous output folder" - rm -rf $OUTPUT_DIR - target_dir="$project_location/target" - include_dir=$OUTPUT_DIR/include - make_dir $include_dir - #Copy the iec61131-st folder - cp -r "$project_location"/libs/stdlib/iec61131-st/*.st "$include_dir" - - if [[ ! -z $target ]]; then - for val in ${target//,/ } - do - lib_dir=$OUTPUT_DIR/$val/lib - make_dir $lib_dir - rel_dir="$target_dir/$val" - if [[ $release -ne 0 ]]; then - rel_dir="$rel_dir/release" - else - rel_dir="$rel_dir/debug" - fi - if [[ ! -d "$rel_dir" ]]; then - echo "Compilation directory $rel_dir not found" - exit 1 - fi - cp "$rel_dir/"*.a "$lib_dir" 2>/dev/null || log "$rel_dir does not contain *.a files" - # Create an SO file from the copied a file - log "Creating a shared library from the compiled static library" - log "Running : $cc --shared -L$lib_dir \ - -Wl,--whole-archive -liec61131std \ - -o $lib_dir/out.so -Wl,--no-whole-archive \ - -lm \ - -fuse-ld=lld \ - --target=$val" - $cc --shared -L"$lib_dir" \ - -Wl,--whole-archive -liec61131std \ - -o "$lib_dir/out.so" -Wl,--no-whole-archive \ - -lm \ - -fuse-ld=lld \ - --target="$val" - - mv "$lib_dir/out.so" "$lib_dir/libiec61131std.so" - done - else - lib_dir=$OUTPUT_DIR/lib - make_dir $lib_dir - if [[ $release -ne 0 ]]; then - rel_dir="$target_dir/release" - else - rel_dir="$target_dir/debug" - fi - cp "$rel_dir/"*.a "$lib_dir" 2>/dev/null || log "$rel_dir does not contain *.a files" - # Create an SO file from the copied a file - log "Creating a shared library from the compiled static library" - log "Running : $cc --shared -L"$lib_dir" \ - -Wl,--whole-archive -liec61131std \ - -o "$lib_dir/out.so" -Wl,--no-whole-archive \ - -lm \ - -fuse-ld=lld " - $cc --shared -L"$lib_dir" \ - -Wl,--whole-archive -liec61131std \ - -o "$lib_dir/out.so" -Wl,--no-whole-archive \ - -lm \ - -fuse-ld=lld - mv "$lib_dir/out.so" "$lib_dir/libiec61131std.so" - fi - - log "Enabling read/write on the output folder" - chmod a+rw $OUTPUT_DIR -R + cc=$(get_compiler) + log "Packaging Standard functions" + log "Removing previous output folder" + rm -rf $OUTPUT_DIR + target_dir="$project_location/target" + include_dir=$OUTPUT_DIR/include + make_dir $include_dir + #Copy the iec61131-st folder + cp -r "$project_location"/libs/stdlib/iec61131-st/*.st "$include_dir" + + if [[ ! -z $target ]]; then + for val in ${target//,/ } + do + lib_dir=$OUTPUT_DIR/$val/lib + make_dir $lib_dir + rel_dir="$target_dir/$val" + if [[ $release -ne 0 ]]; then + rel_dir="$rel_dir/release" + else + rel_dir="$rel_dir/debug" + fi + if [[ ! -d "$rel_dir" ]]; then + echo "Compilation directory $rel_dir not found" + exit 1 + fi + cp "$rel_dir/"*.a "$lib_dir" 2>/dev/null || log "$rel_dir does not contain *.a files" + # Create an SO file from the copied a file + log "Creating a shared library from the compiled static library" + log "Running : $cc --shared -L$lib_dir \ + -Wl,--whole-archive -liec61131std \ + -o $lib_dir/out.so -Wl,--no-whole-archive \ + -lm \ + -fuse-ld=lld \ + --target=$val" + $cc --shared -L"$lib_dir" \ + -Wl,--whole-archive -liec61131std \ + -o "$lib_dir/out.so" -Wl,--no-whole-archive \ + -lm \ + -fuse-ld=lld \ + --target="$val" + + mv "$lib_dir/out.so" "$lib_dir/libiec61131std.so" + done + else + lib_dir=$OUTPUT_DIR/lib + make_dir $lib_dir + if [[ $release -ne 0 ]]; then + rel_dir="$target_dir/release" + else + rel_dir="$target_dir/debug" + fi + cp "$rel_dir/"*.a "$lib_dir" 2>/dev/null || log "$rel_dir does not contain *.a files" + # Create an SO file from the copied a file + log "Creating a shared library from the compiled static library" + log "Running : $cc --shared -L"$lib_dir" \ + -Wl,--whole-archive -liec61131std \ + -o "$lib_dir/out.so" -Wl,--no-whole-archive \ + -lm \ + -fuse-ld=lld " + $cc --shared -L"$lib_dir" \ + -Wl,--whole-archive -liec61131std \ + -o "$lib_dir/out.so" -Wl,--no-whole-archive \ + -lm \ + -fuse-ld=lld + mv "$lib_dir/out.so" "$lib_dir/libiec61131std.so" + fi + + log "Enabling read/write on the output folder" + chmod a+rw $OUTPUT_DIR -R } function run_in_container() { - container_engine=$(get_container_engine) - params="" - options="" - - if [[ $offline -ne 0 ]]; then - params="$params --offline" - fi - if [[ $debug -ne 0 ]]; then - params="$params --verbose" - fi - if [[ $check -ne 0 ]]; then - params="$params --check" - fi - if [[ $check_style -ne 0 ]]; then - params="$params --check-style" - fi - if [[ $build -ne 0 ]]; then - params="$params --build" - fi - if [[ $release -ne 0 ]]; then - params="$params --release" - fi - if [[ $coverage -ne 0 ]]; then - params="$params --coverage" - fi - if [[ $test -ne 0 ]]; then - params="$params --test" - fi - if [[ $junit -ne 0 ]]; then - params="$params --junit" - fi - if [[ $doc -ne 0 ]]; then - params="$params --doc" - fi - if [[ $package -ne 0 ]]; then - params="$params --package" - fi - if [[ ! -z $target ]]; then - params="$params --target $target" - fi - - volume_target="/build" - unameOut="$(uname -s)" - case "${unameOut}" in - Linux*) - volume_target="/build" - ;; - MINGW* | cygwin*) - volume_target="C:\\\\build" - ;; - *) - echo "Unsupported os $unameOut" - exit 1 - esac - - build_location=$(sanitize_path "$project_location") - log "Sanitized Project location : $project_location" - - command_to_run="$container_engine run $options -v $build_location:$volume_target $CONTAINER_NAME scripts/build.sh $params" - log "Running command : $command_to_run" - eval "$command_to_run" + container_engine=$(get_container_engine) + params="" + options="" + + if [[ $offline -ne 0 ]]; then + params="$params --offline" + fi + if [[ $debug -ne 0 ]]; then + params="$params --verbose" + fi + if [[ $check -ne 0 ]]; then + params="$params --check" + fi + if [[ $check_style -ne 0 ]]; then + params="$params --check-style" + fi + if [[ $build -ne 0 ]]; then + params="$params --build" + fi + if [[ $release -ne 0 ]]; then + params="$params --release" + fi + if [[ $coverage -ne 0 ]]; then + params="$params --coverage" + fi + if [[ $test -ne 0 ]]; then + params="$params --test" + fi + if [[ $junit -ne 0 ]]; then + params="$params --junit" + fi + if [[ $doc -ne 0 ]]; then + params="$params --doc" + fi + if [[ $package -ne 0 ]]; then + params="$params --package" + fi + if [[ ! -z $target ]]; then + params="$params --target $target" + fi + + volume_target="/build" + unameOut="$(uname -s)" + case "${unameOut}" in + Linux*) + volume_target="/build" + ;; + MINGW* | cygwin*) + volume_target="C:\\\\build" + ;; + *) + echo "Unsupported os $unameOut" + exit 1 + esac + + build_location=$(sanitize_path "$project_location") + log "Sanitized Project location : $project_location" + + command_to_run="$container_engine run $options -v $build_location:$volume_target $CONTAINER_NAME scripts/build.sh $params" + log "Running command : $command_to_run" + eval "$command_to_run" } # More safety, by turning some bugs into errors. @@ -340,79 +340,79 @@ set -o errexit -o pipefail -o noclobber -o nounset OPTIONS=sorbvc LONGOPTS=sources,offline,release,check,check-style,build,doc,test,junit,verbose,container,linux,container-name:,coverage,package,target: -check_env +check_env # -activate quoting/enhanced mode (e.g. by writing out “--options”) # -pass arguments only via -- "$@" to separate them correctly ! PARSED=$(getopt --options="$OPTIONS" --longoptions="$LONGOPTS" --name "$0" -- "$@") if [[ ${PIPESTATUS[0]} -ne 0 ]]; then - exit 2 + exit 2 fi # read getopt’s output this way to handle the quoting right: eval set -- "$PARSED" while true; do - case "$1" in - -s|--sources) - vendor=1 - ;; - -o|--offline) - offline=1 - ;; - -r|--release) - release=1 - ;; - -v|--verbose) - debug=1 - ;; - -c|--container) - container=1 - ;; - --container-name) - shift; - CONTAINER_NAME=$1 - ;; - --linux) - assume_linux=1 - ;; - --check-style) - check_style=1 - ;; - --doc) - doc=1 - ;; - --check) - check=1 - ;; - -b|--build) - build=1 - ;; - --test) - test=1 - ;; - --junit) - junit=1 - ;; - --coverage) - coverage=1 - ;; - --package) - package=1 - ;; - --target) - shift - target=$1 - ;; - --) - shift - break - ;; - *) - echo "Programming error" - exit 3 - ;; - esac - shift + case "$1" in + -s|--sources) + vendor=1 + ;; + -o|--offline) + offline=1 + ;; + -r|--release) + release=1 + ;; + -v|--verbose) + debug=1 + ;; + -c|--container) + container=1 + ;; + --container-name) + shift; + CONTAINER_NAME=$1 + ;; + --linux) + assume_linux=1 + ;; + --check-style) + check_style=1 + ;; + --doc) + doc=1 + ;; + --check) + check=1 + ;; + -b|--build) + build=1 + ;; + --test) + test=1 + ;; + --junit) + junit=1 + ;; + --coverage) + coverage=1 + ;; + --package) + package=1 + ;; + --target) + shift + target=$1 + ;; + --) + shift + break + ;; + *) + echo "Programming error" + exit 3 + ;; + esac + shift done project_location=$(find_project_root) @@ -420,67 +420,67 @@ log "Moving to project level directory $project_location" cd "$project_location" if [[ $container -ne 0 ]]; then - log "Container Build" - run_in_container - exit 0 + log "Container Build" + run_in_container + exit 0 fi if [[ $package -ne 0 ]]; then - OUTPUT_DIR=$project_location/output - make_dir "$OUTPUT_DIR" + OUTPUT_DIR=$project_location/output + make_dir "$OUTPUT_DIR" fi if [[ $vendor -ne 0 ]]; then - generate_sources - exit 0 + generate_sources + exit 0 fi if [[ $offline -ne 0 ]]; then - BUILD_DIR=$project_location/build - make_dir "$BUILD_DIR" - set_offline - log "Moving into $BUILD_DIR" - cd "$BUILD_DIR" + BUILD_DIR=$project_location/build + make_dir "$BUILD_DIR" + set_offline + log "Moving into $BUILD_DIR" + cd "$BUILD_DIR" fi if [[ $check -ne 0 ]]; then - run_check + run_check fi if [[ $check_style -ne 0 ]]; then - run_check_style + run_check_style fi if [[ $build -ne 0 ]]; then - run_build - #Build the standard functions - run_std_build + run_build + #Build the standard functions + run_std_build fi if [[ $package -ne 0 ]]; then - run_package_std + run_package_std fi if [[ $test -ne 0 ]]; then - run_test + run_test fi if [[ $doc -ne 0 ]]; then - run_doc + run_doc fi if [[ $coverage -ne 0 ]]; then - run_coverage + run_coverage fi if [[ -d $project_location/target/ ]]; then - log "Allow access to target folders" - chmod a+rw -R $project_location/target/ + log "Allow access to target folders" + chmod a+rw -R $project_location/target/ fi if [[ $offline -ne 0 ]]; then - log "Removing temporary build directory : $BUILD_DIR" - rm -rf "$BUILD_DIR" + log "Removing temporary build directory : $BUILD_DIR" + rm -rf "$BUILD_DIR" fi echo "Done" diff --git a/scripts/cargo_watch.sh b/scripts/cargo_watch.sh index 2d3f76b6f7..929d1a5d13 100755 --- a/scripts/cargo_watch.sh +++ b/scripts/cargo_watch.sh @@ -1,9 +1,9 @@ #!/bin/bash -if [ ! -z "$1" ] && [ $1 == '--container' ] +if [ ! -z "$1" ] && [ $1 == '--container' ] then cargo watch -x 'test --target-dir /tmp/target' else cargo watch -x test -fi \ No newline at end of file +fi diff --git a/scripts/common.sh b/scripts/common.sh index ec6abae1fc..6fd6d01e2d 100755 --- a/scripts/common.sh +++ b/scripts/common.sh @@ -2,89 +2,89 @@ debug=0 function log() { - if [[ $debug -ne 0 ]]; then - >&2 echo "$1" - fi + if [[ $debug -ne 0 ]]; then + >&2 echo "$1" + fi } function make_dir() { if [[ ! -d $1 ]]; then - log "Creating a target build directory at $1" - mkdir -p "$1" + log "Creating a target build directory at $1" + mkdir -p "$1" fi } function check_env() { - # -allow a command to fail with !’s side effect on errexit - # -use return value from ${PIPESTATUS[0]}, because ! hosed $? + # -allow a command to fail with !’s side effect on errexit + # -use return value from ${PIPESTATUS[0]}, because ! hosed $? - ! getopt --test > /dev/null - if [[ ${PIPESTATUS[0]} -ne 4 ]]; then - echo 'Error: extended getopts needed' - exit 1 - fi + ! getopt --test > /dev/null + if [[ ${PIPESTATUS[0]} -ne 4 ]]; then + echo 'Error: extended getopts needed' + exit 1 + fi } function get_compiler() { - log "Trying clang" - res= - if command -v clang &> /dev/null - then - log "Found clang, using as default" - res=clang - else - log "Trying clang-14" - if command -v clang-14 &> /dev/null - then - log "Found clang, using as default" - res=clang-14 - else - echo 'Error : clang / clang-14 not found' - exit 1 - fi - fi - log "Compiler found : $res" - echo $res + log "Trying clang" + res= + if command -v clang &> /dev/null + then + log "Found clang, using as default" + res=clang + else + log "Trying clang-14" + if command -v clang-14 &> /dev/null + then + log "Found clang, using as default" + res=clang-14 + else + echo 'Error : clang / clang-14 not found' + exit 1 + fi + fi + log "Compiler found : $res" + echo $res } function get_container_engine() { - log "Trying docker" - if command -v docker &> /dev/null - then - container_engine=docker - else - >&2 log "Docker not found, trying podman" - if command -v podman &> /dev/null - then - container_engine=podman - else - echo "Docker or podman not found" - exit 1 - fi - fi - log "container engine found : $container_engine" - echo $container_engine + log "Trying docker" + if command -v docker &> /dev/null + then + container_engine=docker + else + >&2 log "Docker not found, trying podman" + if command -v podman &> /dev/null + then + container_engine=podman + else + echo "Docker or podman not found" + exit 1 + fi + fi + log "container engine found : $container_engine" + echo $container_engine } function find_project_root() { - log "Locating project root" - if command -v cargo &> /dev/null - then - log "Using cargo" - project_location=$(cargo locate-project --message-format plain) - project_location=$(dirname "$project_location") - else - log "Cargo not found, using script location" - project_location="${BASH_SOURCE%/*/..}" - project_location=$(dirname $(readlink -f "$project_location")) - fi - log "Found project location at $project_location" - # echo $project_location | tr -t "\\" "\\\\" - echo $project_location + log "Locating project root" + if command -v cargo &> /dev/null + then + log "Using cargo" + project_location=$(cargo locate-project --message-format plain) + project_location=$(dirname "$project_location") + else + log "Cargo not found, using script location" + project_location="${BASH_SOURCE%/*/..}" + project_location=$(dirname $(readlink -f "$project_location")) + fi + log "Found project location at $project_location" + # echo $project_location | tr -t "\\" "\\\\" + echo $project_location } function sanitize_path() { - target=$1 - echo "${target//\\/\\\\}" -} \ No newline at end of file + target=$1 + echo "${target//\\/\\\\}" +} diff --git a/src/codegen/generators/llvm.rs b/src/codegen/generators/llvm.rs index e1a9b84587..6023dc3b15 100644 --- a/src/codegen/generators/llvm.rs +++ b/src/codegen/generators/llvm.rs @@ -67,7 +67,7 @@ impl<'a> Llvm<'a> { /// - `module` the compilation module to add the variable /// - `name` the name of the global variable /// - `data_type` the variable's datatype - /// - `initial_value` an optional initial value of the global variable + /// - `initial_value` an optional initial value of the global variable pub fn create_global_variable( &self, module: &Module<'a>, diff --git a/src/codegen/generators/pou_generator.rs b/src/codegen/generators/pou_generator.rs index e977f45ace..fd12513cc1 100644 --- a/src/codegen/generators/pou_generator.rs +++ b/src/codegen/generators/pou_generator.rs @@ -167,8 +167,8 @@ impl<'ink, 'cg> PouGenerator<'ink, 'cg> { .map(|(i, p)| match declared_parameters.get(i) { Some(v) if v.is_in_parameter_by_ref() && - // parameters by ref will always be a pointer - p.into_pointer_type().get_element_type().is_array_type() => + // parameters by ref will always be a pointer + p.into_pointer_type().get_element_type().is_array_type() => { // for array types we will generate a pointer to the arrays element type // not a pointer to array diff --git a/src/codegen/tests/code_gen_tests.rs b/src/codegen/tests/code_gen_tests.rs index 5e6ce9b51d..c33f22b07d 100644 --- a/src/codegen/tests/code_gen_tests.rs +++ b/src/codegen/tests/code_gen_tests.rs @@ -38,7 +38,7 @@ fn empty_statements_dont_generate_anything() { fn external_program_global_var_is_external() { let result = codegen( r#" - @EXTERNAL + @EXTERNAL PROGRAM prg VAR x : DINT; y : DINT; END_VAR x; @@ -179,7 +179,7 @@ END_VAR // to result in an DINT (i32) and then truncated back // to i16 again - z := x + INT#7; + z := x + INT#7; END_PROGRAM "#, @@ -195,8 +195,8 @@ VAR x : DINT; END_VAR - x := INT#16#FFFF; - x := WORD#16#FFFF; + x := INT#16#FFFF; + x := WORD#16#FFFF; END_PROGRAM "#, @@ -214,7 +214,7 @@ z : REAL; END_VAR // the LREAL# should fource a double addition - z := x + LREAL#7.7; + z := x + LREAL#7.7; END_PROGRAM "#, @@ -232,10 +232,10 @@ z : REAL; END_VAR // the REAL# should prevent this addition - // to result in an DINT (i32) and then result + // to result in an DINT (i32) and then result // in an i32 devision - z := x / REAL#7; + z := x / REAL#7; END_PROGRAM "#, @@ -253,10 +253,10 @@ z : INT; END_VAR // the INT# should prevent this addition - // to result in an DINT (i32) and then + // to result in an DINT (i32) and then // truncated back to i16 - z := x + INT#16#D; + z := x + INT#16#D; END_PROGRAM "#, @@ -293,10 +293,10 @@ VAR z : BOOL; END_VAR - z := BOOL#TRUE; - z := BOOL#FALSE; - z := BOOL#1; - z := BOOL#0; + z := BOOL#TRUE; + z := BOOL#FALSE; + z := BOOL#1; + z := BOOL#0; END_PROGRAM "#, @@ -717,7 +717,7 @@ fn program_with_xor_statement() { VAR x : BOOL; y : BOOL; -z : BOOL; +z : BOOL; END_VAR z := x XOR y; END_PROGRAM @@ -780,7 +780,7 @@ fn program_with_signed_combined_expressions() { fn if_elsif_else_generator_test() { let result = codegen( " - PROGRAM prg + PROGRAM prg VAR x : DINT; y : DINT; @@ -809,7 +809,7 @@ fn if_elsif_else_generator_test() { fn if_generator_test() { let result = codegen( " - PROGRAM prg + PROGRAM prg VAR x : DINT; b1 : BOOL; @@ -827,7 +827,7 @@ fn if_generator_test() { fn if_with_expression_generator_test() { let result = codegen( " - PROGRAM prg + PROGRAM prg VAR x : DINT; b1 : BOOL; @@ -845,11 +845,11 @@ fn if_with_expression_generator_test() { fn for_statement_with_steps_test() { let result = codegen( " - PROGRAM prg + PROGRAM prg VAR x : DINT; END_VAR - FOR x := 3 TO 10 BY 7 DO + FOR x := 3 TO 10 BY 7 DO x; END_FOR END_PROGRAM @@ -863,7 +863,7 @@ fn for_statement_with_steps_test() { fn for_statement_with_continue() { let result = codegen( " - PROGRAM prg + PROGRAM prg VAR x : DINT; END_VAR @@ -882,11 +882,11 @@ fn for_statement_with_continue() { fn for_statement_with_exit() { let result = codegen( " - PROGRAM prg + PROGRAM prg VAR x : DINT; END_VAR - FOR x := 3 TO 10 BY 7 DO + FOR x := 3 TO 10 BY 7 DO x := x + 2; EXIT; x := x + 5; @@ -906,11 +906,11 @@ fn class_method_in_pou() { VAR x, y : INT; END_VAR - + METHOD testMethod VAR_INPUT myMethodArg : INT; END_VAR VAR myMethodLocalVar : INT; END_VAR - + x := myMethodArg; y := x; myMethodLocalVar = y; @@ -940,11 +940,11 @@ fn fb_method_in_pou() { VAR x, y : INT; END_VAR - + METHOD testMethod VAR_INPUT myMethodArg : INT; END_VAR VAR myMethodLocalVar : INT; END_VAR - + x := myMethodArg; y := x; myMethodLocalVar = y; @@ -1008,11 +1008,11 @@ fn class_member_access_from_method() { VAR x, y : INT; END_VAR - + METHOD testMethod VAR_INPUT myMethodArg : INT; END_VAR VAR myMethodLocalVar : INT; END_VAR - + x := myMethodArg; y := x; myMethodLocalVar = y; @@ -1028,7 +1028,7 @@ fn class_member_access_from_method() { fn while_loop_with_if_exit() { let result = codegen( " - PROGRAM prg + PROGRAM prg VAR x : DINT; END_VAR @@ -1048,11 +1048,11 @@ fn while_loop_with_if_exit() { fn for_statement_without_steps_test() { let result = codegen( " - PROGRAM prg + PROGRAM prg VAR x : DINT; END_VAR - FOR x := 3 TO 10 DO + FOR x := 3 TO 10 DO x; END_FOR END_PROGRAM @@ -1066,11 +1066,11 @@ fn for_statement_without_steps_test() { fn for_statement_sint() { let result = codegen( " - PROGRAM prg + PROGRAM prg VAR x : SINT; END_VAR - FOR x := 3 TO 10 DO + FOR x := 3 TO 10 DO x; END_FOR END_PROGRAM @@ -1084,11 +1084,11 @@ fn for_statement_sint() { fn for_statement_int() { let result = codegen( " - PROGRAM prg + PROGRAM prg VAR x : INT; END_VAR - FOR x := 3 TO 10 DO + FOR x := 3 TO 10 DO x; END_FOR END_PROGRAM @@ -1102,11 +1102,11 @@ fn for_statement_int() { fn for_statement_lint() { let result = codegen( " - PROGRAM prg + PROGRAM prg VAR x : LINT; END_VAR - FOR x := 3 TO 10 DO + FOR x := 3 TO 10 DO x; END_FOR END_PROGRAM @@ -1120,11 +1120,11 @@ fn for_statement_lint() { fn for_statement_continue() { let result = codegen( " - PROGRAM prg + PROGRAM prg VAR x : DINT; END_VAR - FOR x := 3 TO 10 DO + FOR x := 3 TO 10 DO END_FOR x; END_PROGRAM @@ -1138,14 +1138,14 @@ fn for_statement_continue() { fn for_statement_with_references_steps_test() { let result = codegen( " - PROGRAM prg + PROGRAM prg VAR step: DINT; x : DINT; y : DINT; z : DINT; END_VAR - FOR x := y TO z BY step DO + FOR x := y TO z BY step DO x; END_FOR END_PROGRAM @@ -1159,7 +1159,7 @@ fn for_statement_with_references_steps_test() { fn while_statement() { let result = codegen( " - PROGRAM prg + PROGRAM prg VAR x : BOOL; END_VAR @@ -1177,7 +1177,7 @@ fn while_statement() { fn while_with_expression_statement() { let result = codegen( " - PROGRAM prg + PROGRAM prg VAR x : BOOL; END_VAR @@ -1194,13 +1194,13 @@ fn while_with_expression_statement() { fn repeat_statement() { let result = codegen( " - PROGRAM prg + PROGRAM prg VAR x : BOOL; END_VAR REPEAT x; - UNTIL x + UNTIL x END_REPEAT END_PROGRAM ", @@ -1213,7 +1213,7 @@ fn repeat_statement() { fn simple_case_statement() { let result = codegen( " - PROGRAM prg + PROGRAM prg VAR x : DINT; y : DINT; @@ -1236,7 +1236,7 @@ fn simple_case_statement() { fn simple_case_i8_statement() { let result = codegen( " - PROGRAM prg + PROGRAM prg VAR x : BYTE; y : BYTE; @@ -1259,7 +1259,7 @@ fn simple_case_i8_statement() { fn case_with_multiple_labels_statement() { let result = codegen( " - PROGRAM prg + PROGRAM prg VAR x : DINT; y : DINT; @@ -1281,7 +1281,7 @@ fn case_with_multiple_labels_statement() { fn case_with_ranges_statement() { let result = codegen( " - PROGRAM prg + PROGRAM prg VAR x : DINT; y : DINT; @@ -1301,9 +1301,9 @@ fn case_with_constant_expressions_in_case_selectors() { let result = codegen( r##" VAR_GLOBAL CONSTANT - FORWARD : DINT := 7; - UP : DINT := FORWARD + 1; - DOWN : DINT := FORWARD + UP; + FORWARD : DINT := 7; + UP : DINT := FORWARD + 1; + DOWN : DINT := FORWARD + UP; END_VAR FUNCTION drive : DINT @@ -1312,17 +1312,17 @@ FUNCTION drive : DINT horiz, depth : DINT; END_VAR - CASE input OF - FORWARD : - horiz := horiz + 1; + CASE input OF + FORWARD : + horiz := horiz + 1; FORWARD*2: horiz := horiz + 2; - UP : - depth := depth - 1; - DOWN : - depth := depth + 1; + UP : + depth := depth - 1; + DOWN : + depth := depth + 1; - END_CASE + END_CASE END_FUNCTION "##, @@ -1353,17 +1353,17 @@ FUNCTION drive : DINT horiz, depth : DINT; END_VAR - CASE input OF - FORWARD : + CASE input OF + FORWARD : horiz := horiz + 1; FORWARD*2: horiz := horiz + 2; - UP : + UP : depth := depth - 1; - DOWN : - depth := depth + 1; + DOWN : + depth := depth + 1; - END_CASE + END_CASE END_FUNCTION "##, @@ -1382,7 +1382,7 @@ fn function_called_in_program() { foo := 1; END_FUNCTION - PROGRAM prg + PROGRAM prg VAR x : DINT; END_VAR @@ -1402,7 +1402,7 @@ fn real_function_called_in_program() { foo := 1.0; END_FUNCTION - PROGRAM prg + PROGRAM prg VAR x : DINT; END_VAR @@ -1421,7 +1421,7 @@ fn external_function_called_in_program() { @EXTERNAL FUNCTION foo : DINT END_FUNCTION - PROGRAM prg + PROGRAM prg foo(); END_PROGRAM ", @@ -1446,7 +1446,7 @@ fn nested_function_called_in_program() { foo := 1; END_FUNCTION - PROGRAM prg + PROGRAM prg VAR x : DINT; END_VAR @@ -1469,7 +1469,7 @@ fn function_with_parameters_called_in_program() { foo := 1; END_FUNCTION - PROGRAM prg + PROGRAM prg VAR x : DINT; END_VAR @@ -1493,7 +1493,7 @@ fn function_with_two_parameters_called_in_program() { foo := 1; END_FUNCTION - PROGRAM prg + PROGRAM prg VAR x : DINT; END_VAR @@ -1583,7 +1583,7 @@ fn program_called_in_program() { PROGRAM foo END_PROGRAM - PROGRAM prg + PROGRAM prg foo(); END_PROGRAM ", @@ -1596,7 +1596,7 @@ fn program_called_in_program() { fn action_called_in_program() { let result = codegen( " - PROGRAM prg + PROGRAM prg VAR x : DINT; END_VAR @@ -1616,7 +1616,7 @@ fn action_called_in_program() { fn qualified_local_action_called_in_program() { let result = codegen( " - PROGRAM prg + PROGRAM prg VAR x : DINT; END_VAR @@ -1639,7 +1639,7 @@ fn qualified_foreign_action_called_in_program() { PROGRAM bar prg.foo(); END_PROGRAM - PROGRAM prg + PROGRAM prg VAR x : DINT; END_VAR @@ -1666,7 +1666,7 @@ fn qualified_action_from_fb_called_in_program() { fb_inst.foo(); END_PROGRAM - FUNCTION_BLOCK fb + FUNCTION_BLOCK fb VAR x : DINT; END_VAR @@ -1686,14 +1686,14 @@ fn qualified_action_from_fb_called_in_program() { fn program_with_two_parameters_called_in_program() { let result = codegen( " - PROGRAM foo + PROGRAM foo VAR_INPUT bar : DINT; buz : BOOL; END_VAR END_PROGRAM - PROGRAM prg + PROGRAM prg foo(2, TRUE); END_PROGRAM ", @@ -1706,14 +1706,14 @@ fn program_with_two_parameters_called_in_program() { fn program_with_two_explicit_parameters_called_in_program() { let result = codegen( " - PROGRAM foo + PROGRAM foo VAR_INPUT bar : DINT; buz : BOOL; END_VAR END_PROGRAM - PROGRAM prg + PROGRAM prg foo(buz := TRUE, bar := 2); END_PROGRAM ", @@ -1726,7 +1726,7 @@ fn program_with_two_explicit_parameters_called_in_program() { fn program_with_var_out_called_in_program() { let result = codegen( " - PROGRAM foo + PROGRAM foo VAR_INPUT bar : DINT; END_VAR @@ -1735,7 +1735,7 @@ fn program_with_var_out_called_in_program() { END_VAR END_PROGRAM - PROGRAM prg + PROGRAM prg VAR baz : BOOL; END_VAR @@ -1751,14 +1751,14 @@ fn program_with_var_out_called_in_program() { fn program_with_var_inout_called_in_program() { let result = codegen( " - PROGRAM foo + PROGRAM foo VAR_IN_OUT inout : DINT; END_VAR inout := inout + 1; END_PROGRAM - PROGRAM prg + PROGRAM prg VAR baz : DINT; END_VAR @@ -1779,19 +1779,19 @@ fn pass_inout_to_inout() { VAR_IN_OUT inout : DINT; END_VAR - VAR_INPUT + VAR_INPUT in : DINT; END_VAR END_PROGRAM - PROGRAM foo + PROGRAM foo VAR_IN_OUT inout : DINT; END_VAR foo2(inout := inout, in := inout); END_PROGRAM - PROGRAM prg + PROGRAM prg VAR baz : DINT; END_VAR @@ -1807,27 +1807,27 @@ fn pass_inout_to_inout() { fn pointers_generated() { let result = codegen( " - PROGRAM prg + PROGRAM prg VAR X : BOOL; pX : POINTER TO BOOL; rX : REF_TO BOOL; END_VAR - + //Assign address pX := NULL; rX := NULL; pX := &X; rX := &X; - //Read from pointer + //Read from pointer X := pX^; X := rX^; - //Write in pointer + //Write in pointer pX^ := X; rX^ := X; - + END_PROGRAM ", ); @@ -1839,7 +1839,7 @@ fn pointers_generated() { fn complex_pointers() { let result = codegen( " - PROGRAM prg + PROGRAM prg VAR X : INT; arrX : ARRAY[1..10] OF INT; @@ -1852,14 +1852,14 @@ fn complex_pointers() { arrrX[2] := &arrX[3]; rarrX := &arrX; - //Read from pointer + //Read from pointer X := arrrX[4]^; X := rarrX^[5]; - //Write in pointer + //Write in pointer arrrX[6]^ := X; rarrX^[7] := arrrX[8]^; - + END_PROGRAM ", ); @@ -1871,7 +1871,7 @@ fn complex_pointers() { fn pointer_and_array_access_to_in_out() { let result = codegen( " - FUNCTION main : INT + FUNCTION main : INT VAR_IN_OUT a : REF_TO INT; b : ARRAY[0..1] OF INT; @@ -1892,7 +1892,7 @@ fn pointer_and_array_access_to_in_out() { fn program_with_var_out_called_mixed_in_program() { let result = codegen( " - PROGRAM foo + PROGRAM foo VAR_INPUT bar : DINT; END_VAR @@ -1901,7 +1901,7 @@ fn program_with_var_out_called_mixed_in_program() { END_VAR END_PROGRAM - PROGRAM prg + PROGRAM prg VAR baz : BOOL; END_VAR @@ -1917,11 +1917,11 @@ fn program_with_var_out_called_mixed_in_program() { fn program_called_before_decalaration() { codegen( " - PROGRAM foo + PROGRAM foo bar(); END_PROGRAM - PROGRAM bar + PROGRAM bar END_PROGRAM ", ); @@ -1952,7 +1952,7 @@ fn function_called_when_shadowed() { foo := 1; END_FUNCTION - PROGRAM prg + PROGRAM prg VAR froo : DINT; END_VAR @@ -1975,7 +1975,7 @@ fn function_block_instance_call() { END_VAR END_FUNCTION_BLOCK - PROGRAM prg + PROGRAM prg VAR fb_inst : foo; END_VAR @@ -2028,13 +2028,13 @@ fn reference_qualified_name() { baz : fb; END_VAR END_PROGRAM - PROGRAM prg + PROGRAM prg VAR x : DINT; END_VAR x := foo.x; x := foo.y; - x := foo.baz.x; + x := foo.baz.x; END_PROGRAM ", ); @@ -2086,7 +2086,7 @@ fn arrays_with_global_const_size_are_generated() { let result = codegen( " VAR_GLOBAL CONSTANT - THREE : INT := 3; + THREE : INT := 3; ZERO : INT := 0; LEN : INT := THREE * THREE; END_VAR @@ -2116,9 +2116,9 @@ fn structs_members_can_be_referenced() { END_STRUCT END_TYPE - PROGRAM MainProg + PROGRAM MainProg VAR - Cord: MyStruct; + Cord: MyStruct; END_VAR Cord.a := 0; END_PROGRAM @@ -2153,7 +2153,7 @@ fn typed_enums_are_generated() { TYPE MyEnum2: UINT(red, yellow, green); END_TYPE - + TYPE MyEnum3: DINT(red, yellow, green); END_TYPE @@ -2177,12 +2177,12 @@ fn typed_enums_are_used_properly() { TYPE MyEnum2: UINT(red := 15, yellow, green); END_TYPE - + TYPE MyEnum3: DINT(red := 25, yellow, green); END_TYPE PROGRAM prg - VAR + VAR x: BYTE; y: UINT; z: DINT; @@ -2208,7 +2208,7 @@ fn typed_enums_with_initializers_are_generated() { TYPE MyEnum2: UINT(red := 10, yellow := 11, green := 12); END_TYPE - + TYPE MyEnum3: DINT(red := 22, yellow := 33, green := 44); END_TYPE @@ -2256,7 +2256,7 @@ fn enums_custom_type_are_generated() { PROGRAM main VAR - tf1 : TrafficLight; + tf1 : TrafficLight; END_VAR END_PROGRAM ", @@ -2290,7 +2290,7 @@ fn enum_members_can_be_used_in_asignments() { fn inline_structs_are_generated() { let result = codegen( " - + VAR_GLOBAL x: STRUCT a: DINT; @@ -2308,19 +2308,19 @@ fn accessing_nested_structs() { let result = codegen( " TYPE InnerStruct: - STRUCT + STRUCT inner1 : INT; inner2 : INT; END_STRUCT END_TYPE - + TYPE OuterStruct: - STRUCT + STRUCT out1 : InnerStruct; out2 : InnerStruct; END_STRUCT END_TYPE - + PROGRAM Main VAR m : OuterStruct; @@ -2376,7 +2376,7 @@ fn basic_datatypes_generated() { fn array_of_int_type_generated() { let result = codegen( " - PROGRAM prg + PROGRAM prg VAR x : ARRAY[0..10] OF INT; END_VAR @@ -2391,7 +2391,7 @@ fn array_of_int_type_generated() { fn array_of_cast_int_type_generated() { let result = codegen( " - PROGRAM prg + PROGRAM prg VAR x : ARRAY[0..INT#16#A] OF INT; END_VAR @@ -2406,7 +2406,7 @@ fn array_of_cast_int_type_generated() { fn array_of_int_type_used() { let result = codegen( " - PROGRAM prg + PROGRAM prg VAR x : ARRAY[0..3] OF DINT; END_VAR @@ -2423,7 +2423,7 @@ fn array_of_int_type_used() { fn array_of_int_non_zero_type_generated() { let result = codegen( " - PROGRAM prg + PROGRAM prg VAR x : ARRAY[10..20] OF INT; END_VAR @@ -2438,7 +2438,7 @@ fn array_of_int_non_zero_type_generated() { fn array_of_int_type_with_non_zero_start_used() { let result = codegen( " - PROGRAM prg + PROGRAM prg VAR x : ARRAY[1..3] OF DINT; END_VAR @@ -2455,7 +2455,7 @@ fn array_of_int_type_with_non_zero_start_used() { fn array_of_int_non_zero_negative_type_generated() { let result = codegen( " - PROGRAM prg + PROGRAM prg VAR x : ARRAY[-10..20] OF INT; END_VAR @@ -2470,7 +2470,7 @@ fn array_of_int_non_zero_negative_type_generated() { fn array_of_int_type_with_non_zero_negative_start_used() { let result = codegen( " - PROGRAM prg + PROGRAM prg VAR x : ARRAY[-2..3] OF DINT; END_VAR @@ -2487,7 +2487,7 @@ fn array_of_int_type_with_non_zero_negative_start_used() { fn multidim_array_declaration() { let result = codegen( " - PROGRAM prg + PROGRAM prg VAR x : ARRAY[0..1, 2..4] OF INT; END_VAR @@ -2502,7 +2502,7 @@ fn multidim_array_declaration() { fn multidim_array_access() { let result = codegen( " - PROGRAM prg + PROGRAM prg VAR x : ARRAY[0..3, 1..2] OF DINT; END_VAR @@ -2519,7 +2519,7 @@ fn multidim_array_access() { fn nested_array_declaration() { let result = codegen( " - PROGRAM prg + PROGRAM prg VAR x : ARRAY[2..4] OF ARRAY[0..1] OF INT; END_VAR @@ -2534,7 +2534,7 @@ fn nested_array_declaration() { fn nested_array_access() { let result = codegen( " - PROGRAM prg + PROGRAM prg VAR x : ARRAY[0..3] OF ARRAY[1..2] OF DINT; END_VAR @@ -2624,11 +2624,11 @@ fn accessing_nested_array_in_struct() { let result = codegen( " TYPE MyStruct: - STRUCT + STRUCT field1 : ARRAY[0..4] OF INT; END_STRUCT END_TYPE - + PROGRAM Main VAR m : MyStruct; @@ -2655,11 +2655,11 @@ fn sub_range_type_calls_check_function_missing() { END_VAR Check_XX_RangeSigned := value; END_FUNCTION - + PROGRAM Main VAR x : MyInt; - END_VAR + END_VAR x := 7; END_PROGRAM @@ -2683,11 +2683,11 @@ fn sub_range_type_calls_check_function_on_assigment() { END_VAR CheckRangeSigned := value; END_FUNCTION - + PROGRAM Main VAR x : MyInt; - END_VAR + END_VAR x := 7; END_PROGRAM @@ -2707,7 +2707,7 @@ fn using_global_consts_in_expressions() { cA : INT := 1; cB : INT := 2; cC : INT := cA + cB; - END_VAR + END_VAR PROGRAM prg VAR @@ -2746,9 +2746,9 @@ fn using_const_expression_in_range_type() { r#" VAR_GLOBAL CONST MIN : INT := 7; - END_VAR + END_VAR - FUNCTION CheckRangeSigned: INT + FUNCTION CheckRangeSigned: INT VAR_INPUT value : INT; lower : INT; @@ -2786,7 +2786,7 @@ fn inlined_array_size_from_local_scoped_constants() { VAR CONSTANT a : INT := 3; b : INT := 7; - END_VAR + END_VAR VAR arr : ARRAY[a..b] OF BYTE; @@ -2805,20 +2805,20 @@ fn inlined_array_size_from_local_scoped_constants() { fn program_with_chars() { let result = codegen( r#" - PROGRAM mainPROG - VAR - x : CHAR; - y : WCHAR; - END_VAR - x := 'a'; - x := ' '; + PROGRAM mainPROG + VAR + x : CHAR; + y : WCHAR; + END_VAR + x := 'a'; + x := ' '; - y := "A"; - y := " "; - y := "'"; - y := "$""; - END_PROGRAM - "#, + y := "A"; + y := " "; + y := "'"; + y := "$""; + END_PROGRAM + "#, ); insta::assert_snapshot!(result); } @@ -2827,15 +2827,15 @@ fn program_with_chars() { fn program_with_casted_chars_assignment() { let result = codegen( r#" - PROGRAM mainPROG - VAR - x : CHAR; - y : WCHAR; - END_VAR - x := CHAR#"A"; - y := WCHAR#'B'; - END_PROGRAM - "#, + PROGRAM mainPROG + VAR + x : CHAR; + y : WCHAR; + END_VAR + x := CHAR#"A"; + y := WCHAR#'B'; + END_PROGRAM + "#, ); insta::assert_snapshot!(result); } @@ -2844,15 +2844,15 @@ fn program_with_casted_chars_assignment() { fn function_call_with_same_name_as_return_type() { let result = codegen( " - FUNCTION TIME : TIME - END_FUNCTION + FUNCTION TIME : TIME + END_FUNCTION - PROGRAM prg - VAR - END_VAR - TIME(); - END_PROGRAM - ", + PROGRAM prg + VAR + END_VAR + TIME(); + END_PROGRAM + ", ); insta::assert_snapshot!(result); } @@ -2861,18 +2861,18 @@ fn function_call_with_same_name_as_return_type() { fn variable_with_same_name_as_data_type() { let result = codegen( " - FUNCTION func : TIME - VAR - TIME : TIME; - END_VAR - END_FUNCTION + FUNCTION func : TIME + VAR + TIME : TIME; + END_VAR + END_FUNCTION - PROGRAM prog - VAR - TIME : TIME; - END_VAR - END_PROGRAM - ", + PROGRAM prog + VAR + TIME : TIME; + END_VAR + END_PROGRAM + ", ); insta::assert_snapshot!(result); } @@ -2886,12 +2886,12 @@ fn variable_with_same_name_as_data_type() { fn variable_with_same_name_as_function() { let result = codegen( " - FUNCTION TIME : TIME - VAR - TIME : TIME; - END_VAR - END_FUNCTION - ", + FUNCTION TIME : TIME + VAR + TIME : TIME; + END_VAR + END_FUNCTION + ", ); insta::assert_snapshot!(result); } @@ -2900,12 +2900,12 @@ fn variable_with_same_name_as_function() { fn expression_list_as_array_initilization() { let result = codegen( " - VAR_GLOBAL - arr : ARRAY[0..3] OF INT := 1, 2, 3; - b_exp : ARRAY[0..4] OF DINT := 1+3, 2*3, 7-1, 10; - str : ARRAY[0..2] OF STRING := 'first', 'second'; - END_VAR - ", + VAR_GLOBAL + arr : ARRAY[0..3] OF INT := 1, 2, 3; + b_exp : ARRAY[0..4] OF DINT := 1+3, 2*3, 7-1, 10; + str : ARRAY[0..2] OF STRING := 'first', 'second'; + END_VAR + ", ); insta::assert_snapshot!(result); } @@ -2914,15 +2914,15 @@ fn expression_list_as_array_initilization() { fn default_values_for_not_initialized_function_vars() { let result = codegen( " - FUNCTION func : INT - VAR - int_var : INT; - arr_var : ARRAY[0..2] OF DINT; - ptr_var : REF_TO DINT; - float_var : REAL; - END_VAR - END_FUNCTION - ", + FUNCTION func : INT + VAR + int_var : INT; + arr_var : ARRAY[0..2] OF DINT; + ptr_var : REF_TO DINT; + float_var : REAL; + END_VAR + END_FUNCTION + ", ); insta::assert_snapshot!(result); } @@ -2932,15 +2932,15 @@ fn order_var_and_var_temp_block() { // GIVEN a program with defined VAR_TEMP before VAR block let result = codegen( " - PROGRAM main - VAR_TEMP - temp : INT; - END_VAR - VAR - var1 : INT; - END_VAR - END_PROGRAM - ", + PROGRAM main + VAR_TEMP + temp : INT; + END_VAR + VAR + var1 : INT; + END_VAR + END_PROGRAM + ", ); // codegen should be successful insta::assert_snapshot!(result); @@ -2951,12 +2951,12 @@ fn constant_expressions_in_ranged_type_declaration_are_propagated() { //GIVEN a ranged type from 0 .. MIN+1 where MIN is a global constant //WHEN the code is generated let result = codegen( - " + " VAR_GLOBAL CONSTANT MIN : INT := 7; - END_VAR + END_VAR - FUNCTION CheckRangeSigned: INT + FUNCTION CheckRangeSigned: INT VAR_INPUT value : INT; lower : INT; @@ -2985,8 +2985,8 @@ fn constant_expression_in_function_blocks_are_propagated() { //GIVEN a constant in a function block //WHEN the code is generated let result = codegen( - " - FUNCTION_BLOCK fbWithConstant + " + FUNCTION_BLOCK fbWithConstant VAR x : INT; END_VAR @@ -3009,7 +3009,7 @@ fn date_and_time_addition_in_var_output() { //GIVEN a date and time and a time addition on output variables //WHEN the code is generated let result = codegen( - " + " FUNCTION func : DINT VAR_OUTPUT d_and_t : DT; @@ -3049,18 +3049,18 @@ fn date_and_time_global_constants_initialize() { PROGRAM main VAR_TEMP - t1 : TIME; - t2 : TIME; - lt1 : LTIME; - lt2 : LTIME; - d1 : DATE; - d2 : DATE; - ld1 : LDATE; - ld2 : LDATE; - tod1 : TIME_OF_DAY; - tod2 : TOD; - ltod1 : LTOD; - ltod2 : LTOD; + t1 : TIME; + t2 : TIME; + lt1 : LTIME; + lt2 : LTIME; + d1 : DATE; + d2 : DATE; + ld1 : LDATE; + ld2 : LDATE; + tod1 : TIME_OF_DAY; + tod2 : TOD; + ltod1 : LTOD; + ltod2 : LTOD; dt1 : DATE_AND_TIME; dt2 : DT; ldt1 : LDT; @@ -3071,16 +3071,16 @@ fn date_and_time_global_constants_initialize() { t2 := cT_SHORT; lt1 := cLT; lt2 := cLT_SHORT; - d1 := cD; - d2 := cD_SHORT; + d1 := cD; + d2 := cD_SHORT; ld1 := cLD; ld2 := cLD_SHORT; tod1 := cTOD; tod2 := cTOD_SHORT; - ltod1 := cLTOD; - ltod2 := cLTOD_SHORT; - dt1 := cDT; - dt2 := cDT_SHORT; + ltod1 := cLTOD; + ltod2 := cLTOD_SHORT; + dt1 := cDT; + dt2 := cDT_SHORT; ldt1 := cLDT; ldt2 := cLDT_SHORT; END_PROGRAM"#; @@ -3093,7 +3093,7 @@ fn date_and_time_global_constants_initialize() { #[test] fn contants_in_case_statements_resolved() { let result = codegen( - " + " PROGRAM main VAR DAYS_IN_MONTH : DINT; @@ -3102,12 +3102,12 @@ fn contants_in_case_statements_resolved() { SIXTY : DINT := 60; END_VAR CASE DAYS_IN_MONTH OF - 32..SIXTY : DAYS_IN_MONTH := 29; - (SIXTY + 2)..70 : DAYS_IN_MONTH := 30; + 32..SIXTY : DAYS_IN_MONTH := 29; + (SIXTY + 2)..70 : DAYS_IN_MONTH := 30; ELSE DAYS_IN_MONTH := 31; END_CASE; - END_PROGRAM + END_PROGRAM ", ); @@ -3121,43 +3121,43 @@ fn sub_range_check_functions() { // GIVEN let result = codegen( " - FUNCTION CheckRangeSigned : DINT - VAR_INPUT v: DINT; low: DINT; up: DINT; END_VAR - CheckRangeSigned := -7; - END_FUNCTION - - FUNCTION CheckRangeUnsigned : UDINT - VAR_INPUT v: UDINT; low: UDINT; up: UDINT; END_VAR - CheckRangeUnsigned := 7; - END_FUNCTION - - FUNCTION CheckLRangeSigned : LINT - VAR_INPUT v: LINT; low: LINT; up: LINT; END_VAR - CheckLRangeSigned := -77; - END_FUNCTION - - FUNCTION CheckLRangeUnsigned : ULINT - VAR_INPUT v: ULINT; low: ULINT; up: ULINT; END_VAR - CheckLRangeUnsigned := 77; - END_FUNCTION - - PROGRAM main - VAR - a : BYTE(0 .. 100); - b : SINT(-100 .. 100); - c : USINT(0 .. 100); - d : WORD(0 .. 100); - e : INT(-100 .. 100); - f : UINT(0 .. 100); - g : DINT(-100 .. 100); - h : UDINT(0 .. 100); - i : LINT(-100 .. 100); - j : ULINT(0 .. 100); - END_VAR - a := 1; b := 1; c := 1; d := 1; e := 1; - f := 1; g := 1; h := 1; i := 1; j := 1; - END_PROGRAM - ", + FUNCTION CheckRangeSigned : DINT + VAR_INPUT v: DINT; low: DINT; up: DINT; END_VAR + CheckRangeSigned := -7; + END_FUNCTION + + FUNCTION CheckRangeUnsigned : UDINT + VAR_INPUT v: UDINT; low: UDINT; up: UDINT; END_VAR + CheckRangeUnsigned := 7; + END_FUNCTION + + FUNCTION CheckLRangeSigned : LINT + VAR_INPUT v: LINT; low: LINT; up: LINT; END_VAR + CheckLRangeSigned := -77; + END_FUNCTION + + FUNCTION CheckLRangeUnsigned : ULINT + VAR_INPUT v: ULINT; low: ULINT; up: ULINT; END_VAR + CheckLRangeUnsigned := 77; + END_FUNCTION + + PROGRAM main + VAR + a : BYTE(0 .. 100); + b : SINT(-100 .. 100); + c : USINT(0 .. 100); + d : WORD(0 .. 100); + e : INT(-100 .. 100); + f : UINT(0 .. 100); + g : DINT(-100 .. 100); + h : UDINT(0 .. 100); + i : LINT(-100 .. 100); + j : ULINT(0 .. 100); + END_VAR + a := 1; b := 1; c := 1; d := 1; e := 1; + f := 1; g := 1; h := 1; i := 1; j := 1; + END_PROGRAM + ", ); // THEN for every assignment a check function should be called @@ -3202,7 +3202,7 @@ fn reference_to_reference_assignments_in_function_arguments() { input2 := REF(global2), input3 := &global3 ); - + prog( // These are not valid but we want to see if there's a cast involved input1 := ADR(global4), @@ -3219,7 +3219,7 @@ fn reference_to_reference_assignments_in_function_arguments() { #[test] fn sizeof_works_in_binary_expression_with_different_size() { let result = codegen( - r#" + r#" FUNCTION main : DINT VAR i : DINT; diff --git a/src/codegen/tests/codegen_error_messages_tests.rs b/src/codegen/tests/codegen_error_messages_tests.rs index f2b1418274..39b6395e77 100644 --- a/src/codegen/tests/codegen_error_messages_tests.rs +++ b/src/codegen/tests/codegen_error_messages_tests.rs @@ -6,7 +6,7 @@ use insta::assert_snapshot; fn unknown_reference_should_be_reported_with_line_number() { let result = codegen_without_unwrap( " - PROGRAM prg + PROGRAM prg VAR x : INT; END_VAR @@ -25,7 +25,7 @@ fn unknown_reference_should_be_reported_with_line_number() { fn exit_not_in_loop() { let result = codegen_without_unwrap( " - PROGRAM prg + PROGRAM prg VAR x : INT; END_VAR @@ -44,7 +44,7 @@ fn exit_not_in_loop() { fn continue_not_in_loop() { let result = codegen_without_unwrap( " - PROGRAM prg + PROGRAM prg VAR x : INT; END_VAR @@ -65,13 +65,13 @@ fn unknown_struct_field_should_be_reported_with_line_number() { let result = codegen_without_unwrap( " TYPE MyStruct: - STRUCT + STRUCT a : INT; b : INT; END_STRUCT END_TYPE - PROGRAM prg + PROGRAM prg VAR x : MyStruct; END_VAR @@ -92,7 +92,7 @@ fn unknown_struct_field_should_be_reported_with_line_number() { fn invalid_array_access_should_be_reported_with_line_number() { let result = codegen_without_unwrap( " - PROGRAM prg + PROGRAM prg VAR x : INT; END_VAR @@ -114,13 +114,13 @@ fn invalid_array_access_in_struct_should_be_reported_with_line_number() { let result = codegen_without_unwrap( " TYPE MyStruct: - STRUCT + STRUCT a : INT; b : INT; END_STRUCT END_TYPE - PROGRAM prg + PROGRAM prg VAR x : MyStruct; END_VAR @@ -139,7 +139,7 @@ fn invalid_array_access_in_struct_should_be_reported_with_line_number() { #[test] fn invalid_struct_access_in_array_should_be_reported_with_line_number() { let src = " - PROGRAM prg + PROGRAM prg VAR x : ARRAY[0..1] OF INT; END_VAR @@ -160,7 +160,7 @@ fn invalid_struct_access_in_array_should_be_reported_with_line_number() { #[test] fn invalid_struct_access_in_array_access_should_be_reported_with_line_number() { let src = " - PROGRAM prg + PROGRAM prg VAR x : ARRAY[0..1] OF INT; y : INT; @@ -189,13 +189,13 @@ fn invalid_initial_constant_values_in_pou_variables() { VAR_GLOBAL LEN : DINT := MAX_LEN - 2; END_VAR - + PROGRAM prg - VAR_INPUT + VAR_INPUT my_len: INT := LEN + 4; //cannot be evaluated at compile time! END_VAR END_PROGRAM - + "#, crate::DebugLevel::None, ) @@ -227,12 +227,12 @@ fn assigning_string_literal_to_int_variable_results_in_casting_error() { // WHEN codegen let result = codegen_without_unwrap( r#" - PROGRAM mainProg - VAR - x : INT; - END_VAR - x := 'A'; - END_PROGRAM"#, + PROGRAM mainProg + VAR + x : INT; + END_VAR + x := 'A'; + END_PROGRAM"#, ); // THEN result shoud be a casting error if let Err(msg) = result { @@ -248,12 +248,12 @@ fn assigning_empty_string_literal_to_char_results_in_error() { // WHEN codegen let result = codegen_without_unwrap( r#" - PROGRAM mainProg - VAR - x : CHAR; - END_VAR - x := ''; - END_PROGRAM"#, + PROGRAM mainProg + VAR + x : CHAR; + END_VAR + x := ''; + END_PROGRAM"#, ); // THEN result shoud be an error if let Err(msg) = result { @@ -269,12 +269,12 @@ fn assigning_empty_string_literal_to_wide_char_results_in_error() { // WHEN codegen let result = codegen_without_unwrap( r#" - PROGRAM mainProg - VAR - x : WCHAR; - END_VAR - x := ""; - END_PROGRAM"#, + PROGRAM mainProg + VAR + x : WCHAR; + END_VAR + x := ""; + END_PROGRAM"#, ); // THEN result shoud be an error if let Err(msg) = result { @@ -288,14 +288,14 @@ fn assigning_empty_string_literal_to_wide_char_results_in_error() { fn pointer_binary_expression_adding_two_pointers() { let result = codegen_without_unwrap( r#" - PROGRAM mainProg - VAR - x : INT; - ptr : REF_TO INT; - END_VAR - ptr := &(x); - ptr := ptr + ptr; - END_PROGRAM"#, + PROGRAM mainProg + VAR + x : INT; + ptr : REF_TO INT; + END_VAR + ptr := &(x); + ptr := ptr + ptr; + END_PROGRAM"#, ); if let Err(msg) = result { assert_snapshot!(msg) @@ -308,14 +308,14 @@ fn pointer_binary_expression_adding_two_pointers() { fn pointer_binary_expression_multiplication() { let result = codegen_without_unwrap( r#" - PROGRAM mainProg - VAR - x : INT; - ptr : REF_TO INT; - END_VAR - ptr := &(x); - ptr := ptr * ptr; - END_PROGRAM"#, + PROGRAM mainProg + VAR + x : INT; + ptr : REF_TO INT; + END_VAR + ptr := &(x); + ptr := ptr * ptr; + END_PROGRAM"#, ); if let Err(msg) = result { assert_snapshot!(msg) @@ -328,14 +328,14 @@ fn pointer_binary_expression_multiplication() { fn pointer_binary_expression_division() { let result = codegen_without_unwrap( r#" - PROGRAM mainProg - VAR - x : INT; - ptr : REF_TO INT; - END_VAR - ptr := &(x); - ptr := ptr / ptr; - END_PROGRAM"#, + PROGRAM mainProg + VAR + x : INT; + ptr : REF_TO INT; + END_VAR + ptr := &(x); + ptr := ptr / ptr; + END_PROGRAM"#, ); if let Err(msg) = result { assert_snapshot!(msg) @@ -348,14 +348,14 @@ fn pointer_binary_expression_division() { fn pointer_binary_expression_modulo() { let result = codegen_without_unwrap( r#" - PROGRAM mainProg - VAR - x : INT; - ptr : REF_TO INT; - END_VAR - ptr := &(x); - ptr := ptr MOD ptr; - END_PROGRAM"#, + PROGRAM mainProg + VAR + x : INT; + ptr : REF_TO INT; + END_VAR + ptr := &(x); + ptr := ptr MOD ptr; + END_PROGRAM"#, ); if let Err(msg) = result { assert_snapshot!(msg) @@ -373,7 +373,7 @@ fn assigning_to_rvalue() { x : INT; END_VAR END_FUNCTION - + PROGRAM main func(1 := 1); END_PROGRAM diff --git a/src/codegen/tests/compare_instructions_tests.rs b/src/codegen/tests/compare_instructions_tests.rs index 0c63a53c0b..1e9cdba24c 100644 --- a/src/codegen/tests/compare_instructions_tests.rs +++ b/src/codegen/tests/compare_instructions_tests.rs @@ -211,24 +211,24 @@ fn pointer_compare_instructions() { // codegen should be successful for binary expression for pointer<->int / int<->pointer / pointer<->pointer let result = codegen( " - PROGRAM main - VAR - x : INT := 10; - y : INT := 20; - pt : REF_TO INT; - comp : BOOL; - END_VAR - pt := &(x); - - (* compare pointer-pointer / pointer-int *) - comp := pt = pt; - comp := pt <> y; - comp := pt < pt; - comp := pt > y; - comp := pt <= pt; - comp := y >= pt; - END_PROGRAM - ", + PROGRAM main + VAR + x : INT := 10; + y : INT := 20; + pt : REF_TO INT; + comp : BOOL; + END_VAR + pt := &(x); + + (* compare pointer-pointer / pointer-int *) + comp := pt = pt; + comp := pt <> y; + comp := pt < pt; + comp := pt > y; + comp := pt <= pt; + comp := y >= pt; + END_PROGRAM + ", ); insta::assert_snapshot!(result); } @@ -241,23 +241,23 @@ fn pointer_function_call_compare_instructions() { FUNCTION foo : LINT END_FUNCTION - PROGRAM main - VAR - pt : REF_TO INT; + PROGRAM main + VAR + pt : REF_TO INT; x : INT; - comp : BOOL; - END_VAR - pt := &(x); - - (* compare pointer-pointer / pointer-int *) - comp := pt = foo(); - comp := pt <> foo(); - comp := pt < foo(); - comp := pt > foo(); - comp := pt <= foo(); - comp := pt >= foo(); - END_PROGRAM - ", + comp : BOOL; + END_VAR + pt := &(x); + + (* compare pointer-pointer / pointer-int *) + comp := pt = foo(); + comp := pt <> foo(); + comp := pt < foo(); + comp := pt > foo(); + comp := pt <= foo(); + comp := pt >= foo(); + END_PROGRAM + ", ); insta::assert_snapshot!(result); } @@ -266,56 +266,56 @@ fn pointer_function_call_compare_instructions() { fn compare_instructions_with_different_types() { let result = codegen( " - TYPE MySubRangeInt: INT(0..500); END_TYPE - TYPE MyDint: DINT; END_TYPE + TYPE MySubRangeInt: INT(0..500); END_TYPE + TYPE MyDint: DINT; END_TYPE FUNCTION foo : LINT END_FUNCTION - PROGRAM main - VAR - ptr_int : REF_TO INT; + PROGRAM main + VAR + ptr_int : REF_TO INT; - a : MySubRangeInt; - b : MyDint; + a : MySubRangeInt; + b : MyDint; - var_sint : SINT; + var_sint : SINT; var_int : INT; - var_dint : DINT; - var_lint : LINT; - - var_usint : USINT; + var_dint : DINT; + var_lint : LINT; + + var_usint : USINT; var_uint : UINT; - var_udint : UDINT; - var_ulint : ULINT; - END_VAR - ptr_int := &(var_int); - - var_sint = var_dint; - var_int < 30; - 10 > var_lint; - - var_usint <> var_udint; - var_uint <= UDINT#40; - UDINT#10 >= var_ulint; - - var_sint = var_usint; - var_uint <= var_lint; - var_dint >= var_ulint; - - var_lint < a; - a > var_sint; - b < var_lint; - SINT#5 <> b; - - ptr_int <= var_usint; - a = ptr_int; - - foo() <> 40; - var_udint <= foo(); - foo() = var_lint; - END_PROGRAM - ", + var_udint : UDINT; + var_ulint : ULINT; + END_VAR + ptr_int := &(var_int); + + var_sint = var_dint; + var_int < 30; + 10 > var_lint; + + var_usint <> var_udint; + var_uint <= UDINT#40; + UDINT#10 >= var_ulint; + + var_sint = var_usint; + var_uint <= var_lint; + var_dint >= var_ulint; + + var_lint < a; + a > var_sint; + b < var_lint; + SINT#5 <> b; + + ptr_int <= var_usint; + a = ptr_int; + + foo() <> 40; + var_udint <= foo(); + foo() = var_lint; + END_PROGRAM + ", ); insta::assert_snapshot!(result); } diff --git a/src/codegen/tests/constants_tests.rs b/src/codegen/tests/constants_tests.rs index e7f827f168..18e2012eeb 100644 --- a/src/codegen/tests/constants_tests.rs +++ b/src/codegen/tests/constants_tests.rs @@ -6,15 +6,15 @@ fn assigning_const_string_variable() { let result = codegen( r#" PROGRAM main - VAR - str : STRING; - END_VAR - str := const_str; - END_PROGRAM + VAR + str : STRING; + END_VAR + str := const_str; + END_PROGRAM - VAR_GLOBAL CONSTANT - const_str : STRING := 'global constant string'; - END_VAR + VAR_GLOBAL CONSTANT + const_str : STRING := 'global constant string'; + END_VAR "#, ); // THEN we expect a memcopy for the assignment @@ -27,15 +27,15 @@ fn assigning_const_array_variable() { let result = codegen( r#" PROGRAM main - VAR - arr : ARRAY[0..3] OF INT; - END_VAR - arr := const_arr; - END_PROGRAM + VAR + arr : ARRAY[0..3] OF INT; + END_VAR + arr := const_arr; + END_PROGRAM - VAR_GLOBAL CONSTANT - const_arr : ARRAY[0..3] OF INT := (1,2,3,4); - END_VAR + VAR_GLOBAL CONSTANT + const_arr : ARRAY[0..3] OF INT := (1,2,3,4); + END_VAR "#, ); // THEN we expect a memcopy for the assignment @@ -48,21 +48,21 @@ fn assigning_const_struct_variable() { let result = codegen( r#" TYPE Point : - STRUCT - x,y : INT; - END_STRUCT + STRUCT + x,y : INT; + END_STRUCT END_TYPE PROGRAM main - VAR - strct : Point; - END_VAR - strct := const_strct; - END_PROGRAM + VAR + strct : Point; + END_VAR + strct := const_strct; + END_PROGRAM - VAR_GLOBAL CONSTANT - const_strct : Point := (x := 1, y := 2); - END_VAR + VAR_GLOBAL CONSTANT + const_strct : Point := (x := 1, y := 2); + END_VAR "#, ); // THEN we expect a memcopy for the assignment diff --git a/src/codegen/tests/debug_tests.rs b/src/codegen/tests/debug_tests.rs index 111fd1257f..8d67b0e472 100644 --- a/src/codegen/tests/debug_tests.rs +++ b/src/codegen/tests/debug_tests.rs @@ -61,8 +61,8 @@ fn test_global_var_float_added_to_debug_info() { let codegen = codegen( r#" VAR_GLOBAL - a : REAL; - b : LREAL; + a : REAL; + b : LREAL; END_VAR "#, ); @@ -75,9 +75,9 @@ fn test_global_var_array_added_to_debug_info() { let codegen = codegen( r#" VAR_GLOBAL - a : ARRAY[0..10] OF DINT; - b : ARRAY[0..10, 11..20] OF DINT; - c : ARRAY[0..10] OF ARRAY[11..20] OF DINT; + a : ARRAY[0..10] OF DINT; + b : ARRAY[0..10, 11..20] OF DINT; + c : ARRAY[0..10] OF ARRAY[11..20] OF DINT; END_VAR "#, ); @@ -89,8 +89,8 @@ fn test_global_var_pointer_added_to_debug_info() { let codegen = codegen( r#" VAR_GLOBAL - a : REF_TO DINT; - b : REF_TO ARRAY[0..10] DINT; + a : REF_TO DINT; + b : REF_TO ARRAY[0..10] DINT; END_VAR "#, ); diff --git a/src/codegen/tests/debug_tests/expression_debugging.rs b/src/codegen/tests/debug_tests/expression_debugging.rs index d6494b5dd9..14a7e9b5ce 100644 --- a/src/codegen/tests/debug_tests/expression_debugging.rs +++ b/src/codegen/tests/debug_tests/expression_debugging.rs @@ -227,7 +227,7 @@ fn if_conditions_location_marked() { myFunc := 1; ELSIF FALSE THEN myFunc := 1; - ELSE + ELSE myFunc := 1; END_IF myFunc := 1; @@ -249,7 +249,7 @@ fn case_conditions_location_marked() { myFunc := 1; 2: myFunc := 1; - ELSE + ELSE myFunc := 1; END_CASE myFunc := 1; diff --git a/src/codegen/tests/expression_tests.rs b/src/codegen/tests/expression_tests.rs index e56c93fd81..d02831c8ae 100644 --- a/src/codegen/tests/expression_tests.rs +++ b/src/codegen/tests/expression_tests.rs @@ -50,7 +50,7 @@ fn calling_strings_in_function_return() { FUNCTION func : STRING func := 'hello'; END_FUNCTION - + PROGRAM main VAR x : STRING; @@ -102,9 +102,9 @@ fn cast_pointer_to_lword() { let result = codegen( r#" FUNCTION baz : INT - VAR - ptr_x : POINTER TO INT; - y : LWORD; + VAR + ptr_x : POINTER TO INT; + y : LWORD; END_VAR; y := ptr_x; @@ -121,8 +121,8 @@ fn cast_lword_to_pointer() { let result = codegen( r#" FUNCTION baz : INT - VAR - ptr_x : POINTER TO INT; + VAR + ptr_x : POINTER TO INT; y : LWORD; END_VAR; @@ -140,8 +140,8 @@ fn cast_between_pointer_types() { let result = codegen( r#" PROGRAM baz - VAR - ptr_x : POINTER TO BYTE; + VAR + ptr_x : POINTER TO BYTE; y : WORD; END_VAR; @@ -159,10 +159,10 @@ fn unnecessary_casts_between_pointer_types() { let result = codegen( r#" TYPE MyByte : BYTE; END_TYPE - + PROGRAM baz - VAR - ptr : POINTER TO BYTE; + VAR + ptr : POINTER TO BYTE; b : BYTE; si : SINT; mb : MyByte; @@ -184,11 +184,11 @@ fn access_string_via_byte_array() { let result = codegen( r#" TYPE MyByte : BYTE; END_TYPE - + PROGRAM baz - VAR + VAR str: STRING[10]; - ptr : POINTER TO BYTE; + ptr : POINTER TO BYTE; bytes : POINTER TO ARRAY[0..9] OF BYTE; END_VAR; @@ -207,26 +207,26 @@ fn pointer_arithmetics() { // codegen should be successful for binary expression for pointer<->int / int<->pointer / pointer<->pointer let result = codegen( " - PROGRAM main - VAR - x : INT := 10; - y : INT := 20; - pt : REF_TO INT; - END_VAR - pt := &(x); - - (* +/- *) - pt := pt + 1; - pt := pt + 1 + 1; - pt := 1 + pt; - pt := pt - y; - pt := 1 + pt + 1; - pt := pt - y - 1; - pt := 1 + 1 + pt ; - pt := y + pt - y ; - pt := y + y + pt ; - END_PROGRAM - ", + PROGRAM main + VAR + x : INT := 10; + y : INT := 20; + pt : REF_TO INT; + END_VAR + pt := &(x); + + (* +/- *) + pt := pt + 1; + pt := pt + 1 + 1; + pt := 1 + pt; + pt := pt - y; + pt := 1 + pt + 1; + pt := pt - y - 1; + pt := 1 + 1 + pt ; + pt := y + pt - y ; + pt := y + y + pt ; + END_PROGRAM + ", ); insta::assert_snapshot!(result); } @@ -239,17 +239,17 @@ fn pointer_arithmetics_function_call() { FUNCTION foo : LINT END_FUNCTION - PROGRAM main - VAR - pt : REF_TO INT; + PROGRAM main + VAR + pt : REF_TO INT; x : INT; - END_VAR - pt := &(x); + END_VAR + pt := &(x); - (* +/- *) - pt := pt + foo(); - END_PROGRAM - ", + (* +/- *) + pt := pt + foo(); + END_PROGRAM + ", ); insta::assert_snapshot!(result); } @@ -265,10 +265,10 @@ fn nested_call_statements() { END_VAR END_FUNCTION - PROGRAM main + PROGRAM main foo(foo(2)); - END_PROGRAM - ", + END_PROGRAM + ", ); // WHEN compiled // WE expect a flat sequence of calls, no regions and branching @@ -280,14 +280,14 @@ fn builtin_function_call_adr() { // GIVEN some nested call statements let result = codegen( " - PROGRAM main + PROGRAM main VAR a : REF_TO DINT; b : DINT; END_VAR a := ADR(b); - END_PROGRAM - ", + END_PROGRAM + ", ); // WHEN compiled // We expect a direct conversion to lword and subsequent assignment (no call) @@ -299,14 +299,14 @@ fn builtin_function_call_ref() { // GIVEN some nested call statements let result = codegen( " - PROGRAM main + PROGRAM main VAR a : REF_TO DINT; b : DINT; END_VAR a := REF(b); - END_PROGRAM - ", + END_PROGRAM + ", ); // WHEN compiled // We expect a direct conversion and subsequent assignment to pointer(no call) @@ -394,7 +394,7 @@ fn builtin_function_call_lower_bound() { END_VAR b := foo(a); END_PROGRAM - + FUNCTION foo : DINT VAR_IN_OUT vla: ARRAY[*] OF DINT; @@ -418,7 +418,7 @@ fn builtin_function_call_upper_bound() { END_VAR b := foo(a); END_PROGRAM - + FUNCTION foo : DINT VAR_IN_OUT vla: ARRAY[*] OF DINT; @@ -446,13 +446,13 @@ fn builtin_function_call_upper_bound_expr() { END_VAR b := foo(a); END_PROGRAM - + FUNCTION foo : DINT VAR_IN_OUT vla: ARRAY[*] OF DINT; END_VAR // upper bound of 4th dimension => 8th element in dimension array - foo := UPPER_BOUND(vla, MY_CONST - (2 * 3)); + foo := UPPER_BOUND(vla, MY_CONST - (2 * 3)); END_VAR END_FUNCTION ", @@ -469,7 +469,7 @@ fn test_max_int() { FUNCTION MAX : U VAR_INPUT in : {sized} U...; END_VAR END_FUNCTION - + FUNCTION main : INT main := MAX(INT#5,INT#2,INT#1,INT#3,INT#4,INT#7,INT#-1); END_FUNCTION", @@ -486,17 +486,17 @@ fn compare_date_time_literals() { VAR_TEMP cmp1, cmp2, cmp3, cmp4, cmp5, cmp6, cmp7, cmp8 : BOOL; END_VAR - cmp1 := TIME#2d4h6m8s10ms11us300ns < TIME#1d8h43m23s55ms; - cmp2 := LTIME#2d4h6m8s10ms11us300ns > LTIME#1d8h43m23s55ms; + cmp1 := TIME#2d4h6m8s10ms11us300ns < TIME#1d8h43m23s55ms; + cmp2 := LTIME#2d4h6m8s10ms11us300ns > LTIME#1d8h43m23s55ms; - cmp3 := TOD#23:59:59.999 < TOD#10:32:59; - cmp4 := LTOD#23:59:59.999 > LTOD#10:32:59; + cmp3 := TOD#23:59:59.999 < TOD#10:32:59; + cmp4 := LTOD#23:59:59.999 > LTOD#10:32:59; - cmp5 := DATE#2022-10-20 < DATE#1999-01-01; - cmp6 := LDATE#2022-10-20 > LDATE#1999-01-01; + cmp5 := DATE#2022-10-20 < DATE#1999-01-01; + cmp6 := LDATE#2022-10-20 > LDATE#1999-01-01; - cmp7 := DT#2022-10-20-23:59:59.999 < DT#1999-01-01-10:32; - cmp8 := LDT#2022-10-20-23:59:59.999 > LDT#1999-01-01-10:32; + cmp7 := DT#2022-10-20-23:59:59.999 < DT#1999-01-01-10:32; + cmp8 := LDT#2022-10-20-23:59:59.999 > LDT#1999-01-01-10:32; END_PROGRAM ", ); diff --git a/src/codegen/tests/function_tests.rs b/src/codegen/tests/function_tests.rs index 32831c5add..a01d117879 100644 --- a/src/codegen/tests/function_tests.rs +++ b/src/codegen/tests/function_tests.rs @@ -62,7 +62,7 @@ fn member_variables_in_body() { VAR_OUTPUT o : LINT; END_VAR VAR v : INT := 1; END_VAR VAR_TEMP vt : INT := 2; END_VAR - + func := i * io - o + v * vt; END_FUNCTION "#, @@ -170,7 +170,7 @@ fn autocast_argument_literals_for_function_call() { PROGRAM main // Check if up- and downcasting works; the IR should not need additional instructions other // than a `alloca` and `store` instruction for their actual types, i.e. no casting needed - func(DINT#1, DINT#2, SINT#3, DINT#4, LREAL#5.0, REAL#6.0); + func(DINT#1, DINT#2, SINT#3, DINT#4, LREAL#5.0, REAL#6.0); END_PROGRAM "#, ); @@ -198,7 +198,7 @@ fn bitcast_argument_references_for_function_call() { in_out : LINT; END_VAR END_FUNCTION - + FUNCTION fn_real : LINT VAR_INPUT {ref} in_ref : REAL; @@ -207,7 +207,7 @@ fn bitcast_argument_references_for_function_call() { in_out : REAL; END_VAR END_FUNCTION - + FUNCTION fn_lreal : LINT VAR_INPUT {ref} in_ref : LREAL; @@ -216,7 +216,7 @@ fn bitcast_argument_references_for_function_call() { in_out : LREAL; END_VAR END_FUNCTION - + PROGRAM main VAR var1_sint, var2_sint : SINT := 1; @@ -232,7 +232,7 @@ fn bitcast_argument_references_for_function_call() { fn_sint(var1_int, var2_int); fn_sint(var1_dint, var2_dint); fn_sint(var1_lint, var2_lint); - + fn_lint(var1_sint, var2_sint); fn_lint(var1_int, var2_int); fn_lint(var1_dint, var2_dint); @@ -284,7 +284,7 @@ fn function_with_varargs_called_in_program() { END_VAR END_FUNCTION - PROGRAM prg + PROGRAM prg VAR x : DINT; END_VAR @@ -307,7 +307,7 @@ fn function_with_sized_varargs_called_in_program() { END_VAR END_FUNCTION - PROGRAM prg + PROGRAM prg VAR x : DINT; END_VAR @@ -333,7 +333,7 @@ fn function_with_ref_sized_string_varargs_called_in_program() { END_VAR END_FUNCTION - PROGRAM prg + PROGRAM prg VAR x : DINT; END_VAR diff --git a/src/codegen/tests/generics_test.rs b/src/codegen/tests/generics_test.rs index 846b210d27..dde712dc0a 100644 --- a/src/codegen/tests/generics_test.rs +++ b/src/codegen/tests/generics_test.rs @@ -18,7 +18,7 @@ fn generic_function_call_generates_real_type_call() { @EXTERNAL FUNCTION MAX : T VAR_INPUT in1, in2 : T END_VAR END_FUNCTION FUNCTION MAX__DINT : DINT VAR_INPUT in1, in2 : DINT END_VAR END_FUNCTION - PROGRAM prg + PROGRAM prg VAR a, b : INT; END_VAR @@ -36,7 +36,7 @@ fn generic_function_call_generates_real_type_call() { fn generic_output_parameter() { // GIVEN ... (see comments in st-code) let src = r" - // ... a generic function FOO with a T, defined by a VAR_OUT + // ... a generic function FOO with a T, defined by a VAR_OUT // parameter (which will be interally treated as a pointer) FUNCTION foo : T VAR_INPUT in1 : DATE; END_VAR @@ -51,8 +51,8 @@ fn generic_output_parameter() { // ... AND a program calling foo with an INT-parameter PROGRAM prg - VAR - theInt, iResult : INT; + VAR + theInt, iResult : INT; data : DATE; END_VAR @@ -67,14 +67,14 @@ fn generic_output_parameter() { #[test] fn generic_call_gets_cast_to_biggest_type() { let src = r" - + {external} FUNCTION MAX : T VAR_INPUT args : {sized} T...; END_VAR END_FUNCTION - + FUNCTION main : LREAL main := MAX(SINT#5,DINT#1,LREAL#1.5,1.2); END_FUNCTION"; @@ -86,38 +86,38 @@ fn generic_call_gets_cast_to_biggest_type() { #[test] fn any_real_function_called_with_ints() { let src = r" - FUNCTION foo : T - VAR_INPUT in1 : T; END_VAR - END_FUNCTION - - FUNCTION foo__REAL : REAL - VAR_INPUT in1 : REAL; END_VAR - END_FUNCTION - - PROGRAM prg - VAR - res_sint : REAL; - res_int : REAL; - res_dint : REAL; - res_lint : LREAL; - res_usint : REAL; - res_uint : REAL; - res_udint : REAL; - res_ulint : LREAL; - END_VAR - VAR_TEMP - v_dint : DINT := 1; - v_udint : DINT := 1; - END_VAR - res_sint := foo(SINT#1); - res_int := foo(INT#1); - res_dint := foo(v_dint); - res_lint := foo(LINT#1); - res_usint := foo(USINT#1); - res_uint := foo(UINT#1); - res_udint := foo(v_udint); - res_ulint := foo(ULINT#1); - END_PROGRAM"; + FUNCTION foo : T + VAR_INPUT in1 : T; END_VAR + END_FUNCTION + + FUNCTION foo__REAL : REAL + VAR_INPUT in1 : REAL; END_VAR + END_FUNCTION + + PROGRAM prg + VAR + res_sint : REAL; + res_int : REAL; + res_dint : REAL; + res_lint : LREAL; + res_usint : REAL; + res_uint : REAL; + res_udint : REAL; + res_ulint : LREAL; + END_VAR + VAR_TEMP + v_dint : DINT := 1; + v_udint : DINT := 1; + END_VAR + res_sint := foo(SINT#1); + res_int := foo(INT#1); + res_dint := foo(v_dint); + res_lint := foo(LINT#1); + res_usint := foo(USINT#1); + res_uint := foo(UINT#1); + res_udint := foo(v_udint); + res_ulint := foo(ULINT#1); + END_PROGRAM"; //Expecting to REAL/LREAL conversion for every call insta::assert_snapshot!(codegen(src)); } diff --git a/src/codegen/tests/initialization_test/global_initializers.rs b/src/codegen/tests/initialization_test/global_initializers.rs index e8694382da..d534b130b4 100644 --- a/src/codegen/tests/initialization_test/global_initializers.rs +++ b/src/codegen/tests/initialization_test/global_initializers.rs @@ -7,7 +7,7 @@ fn initial_values_in_global_constant_variables() { VAR_GLOBAL CONSTANT c_INT : INT := 7; c_3c : INT := 3 * c_INT; - + c_BOOL : BOOL := TRUE; c_not : BOOL := NOT c_BOOL; c_str : STRING[10] := 'Hello'; @@ -60,17 +60,17 @@ fn initial_values_in_global_variables_out_of_order() { VAR_GLOBAL x : MyFB; END_VAR - + PROGRAM prg VAR - x : MyFB; + x : MyFB; END_VAR END_PROGRAM //if this fb is moved to the top, the initializer works FUNCTION_BLOCK MyFB VAR - x : INT := 77; + x : INT := 77; END_VAR END_FUNCTION_BLOCK ", @@ -83,8 +83,8 @@ fn initial_values_in_global_variables_out_of_order() { fn uninitialized_global_array() { let result = codegen( " - VAR_GLOBAL - a : ARRAY[0..1] OF BYTE; + VAR_GLOBAL + a : ARRAY[0..1] OF BYTE; END_VAR ", ); @@ -99,19 +99,19 @@ fn global_constant_without_initializer_gets_default_initializer() { " FUNCTION main : DINT VAR CONSTANT - cmd1 : commands; - myStr1 : STRING; - myArr1 : MyArr; + cmd1 : commands; + myStr1 : STRING; + myArr1 : MyArr; END_VAR VAR_TEMP CONSTANT - cmd2 : commands; - //myStr2 : MyStr; - myArr2 : MyArr; + cmd2 : commands; + //myStr2 : MyStr; + myArr2 : MyArr; END_VAR END_FUNCTION TYPE MyArr: ARRAY[0..3] OF INT; END_TYPE - + TYPE commands : STRUCT ReInit : BOOL; @@ -132,11 +132,11 @@ fn global_constant_without_initializer_gets_declared_initializer() { " FUNCTION main : DINT VAR CONSTANT - cmd1 : commands; + cmd1 : commands; var1 : INT; END_VAR VAR CONSTANT - cmd2 : commands; + cmd2 : commands; var2 : INT; END_VAR END_FUNCTION diff --git a/src/codegen/tests/initialization_test/pou_initializers.rs b/src/codegen/tests/initialization_test/pou_initializers.rs index 8f40458d26..c21e63100c 100644 --- a/src/codegen/tests/initialization_test/pou_initializers.rs +++ b/src/codegen/tests/initialization_test/pou_initializers.rs @@ -9,14 +9,14 @@ fn initial_constant_values_in_pou_variables() { MIN_LEN : INT := 10; LEN : INT := MIN_LEN + 10; END_VAR - + PROGRAM prg - VAR_INPUT + VAR_INPUT my_len: INT := LEN + 4; my_size: INT := MAX_LEN - MIN_LEN; END_VAR END_PROGRAM - + "#, ); @@ -72,8 +72,8 @@ fn initial_values_in_function_block_pou() { fn initial_values_in_array_of_array_variable() { let result = codegen( " - VAR_GLOBAL - a : ARRAY[0..1] OF ARRAY[0..1] OF BYTE := [[1,2],[3,4]]; + VAR_GLOBAL + a : ARRAY[0..1] OF ARRAY[0..1] OF BYTE := [[1,2],[3,4]]; END_VAR ", ); @@ -85,15 +85,15 @@ fn initial_values_in_array_of_array_variable() { fn default_values_for_not_initialized_function_vars() { let result = codegen( " - FUNCTION func : INT - VAR - int_var : INT; - arr_var : ARRAY[-1..2] OF DINT; - ptr_var : REF_TO DINT; - float_var : REAL; - END_VAR - END_FUNCTION - ", + FUNCTION func : INT + VAR + int_var : INT; + arr_var : ARRAY[-1..2] OF DINT; + ptr_var : REF_TO DINT; + float_var : REAL; + END_VAR + END_FUNCTION + ", ); insta::assert_snapshot!(result); } @@ -102,12 +102,12 @@ fn default_values_for_not_initialized_function_vars() { fn initialized_array_in_function() { let result = codegen( " - FUNCTION func : INT - VAR - arr_var : ARRAY[-1..2] OF DINT := [1,2,3,4]; - END_VAR - END_FUNCTION - ", + FUNCTION func : INT + VAR + arr_var : ARRAY[-1..2] OF DINT := [1,2,3,4]; + END_VAR + END_FUNCTION + ", ); insta::assert_snapshot!(result); } @@ -117,12 +117,12 @@ fn initialized_array_type_in_function() { let result = codegen( " TYPE arr : ARRAY[-1..2] OF DINT := [1,2,3,4]; END_TYPE - FUNCTION func : INT - VAR - arr_var : arr; - END_VAR - END_FUNCTION - ", + FUNCTION func : INT + VAR + arr_var : arr; + END_VAR + END_FUNCTION + ", ); insta::assert_snapshot!(result); } @@ -131,12 +131,12 @@ fn initialized_array_type_in_function() { fn memcpy_for_struct_initialization_in_function() { let result = codegen( " - FUNCTION func : INT - VAR - a : STRUCT x : INT := 0; END_STRUCT - END_VAR - END_FUNCTION - ", + FUNCTION func : INT + VAR + a : STRUCT x : INT := 0; END_STRUCT + END_VAR + END_FUNCTION + ", ); insta::assert_snapshot!(result); } @@ -145,12 +145,12 @@ fn memcpy_for_struct_initialization_in_function() { fn no_memcpy_for_struct_initialization_in_program() { let result = codegen( " - PROGRAM prog - VAR - a : STRUCT x : INT := 0; END_STRUCT - END_VAR - END_PROGRAM - ", + PROGRAM prog + VAR + a : STRUCT x : INT := 0; END_STRUCT + END_VAR + END_PROGRAM + ", ); insta::assert_snapshot!(result); } diff --git a/src/codegen/tests/initialization_test/snapshots/rusty__codegen__tests__initialization_test__type_initializers__unresolvable_types_validation.snap b/src/codegen/tests/initialization_test/snapshots/rusty__codegen__tests__initialization_test__type_initializers__unresolvable_types_validation.snap index 23c5f7c70b..7e9aedd6c4 100644 --- a/src/codegen/tests/initialization_test/snapshots/rusty__codegen__tests__initialization_test__type_initializers__unresolvable_types_validation.snap +++ b/src/codegen/tests/initialization_test/snapshots/rusty__codegen__tests__initialization_test__type_initializers__unresolvable_types_validation.snap @@ -9,8 +9,8 @@ error: Cannot generate literal initializer for 'MyStruct2.b': Value cannot be de │ 7 │ TYPE MyStruct2: STRUCT │ --------- see also -8 │ a : MyStruct := (a:=5, b:=3); -9 │ b : MyStruct := (c:=7); +8 │ a : MyStruct := (a:=5, b:=3); +9 │ b : MyStruct := (c:=7); │ ^^^^ Cannot generate literal initializer for 'MyStruct2.b': Value cannot be derived diff --git a/src/codegen/tests/initialization_test/type_initializers.rs b/src/codegen/tests/initialization_test/type_initializers.rs index beffef7d12..1ee022b89f 100644 --- a/src/codegen/tests/initialization_test/type_initializers.rs +++ b/src/codegen/tests/initialization_test/type_initializers.rs @@ -60,7 +60,7 @@ fn struct_initial_values_different_data_types() { fn initial_values_in_type_alias() { let result = codegen( " - TYPE MyInt: INT := 7; END_TYPE + TYPE MyInt: INT := 7; END_TYPE VAR_GLOBAL x : MyInt; END_VAR ", ); @@ -72,7 +72,7 @@ fn initial_values_in_type_alias() { fn initial_values_in_sub_range_type() { let result = codegen( " - TYPE MyInt: INT(0..1000) := 7; END_TYPE + TYPE MyInt: INT(0..1000) := 7; END_TYPE VAR_GLOBAL x : MyInt; END_VAR ", ); @@ -84,12 +84,12 @@ fn initial_values_in_sub_range_type() { fn expression_list_as_array_initilization() { let result = codegen( " - VAR_GLOBAL - arr : ARRAY[-1..3] OF INT := 1, 2, 3; - b_exp : ARRAY[-1..4] OF DINT := 1+3, 2*3, 7-1, 10; - str : ARRAY[-1..2] OF STRING := 'first', 'second'; - END_VAR - ", + VAR_GLOBAL + arr : ARRAY[-1..3] OF INT := 1, 2, 3; + b_exp : ARRAY[-1..4] OF DINT := 1+3, 2*3, 7-1, 10; + str : ARRAY[-1..2] OF STRING := 'first', 'second'; + END_VAR + ", ); insta::assert_snapshot!(result); } @@ -98,10 +98,10 @@ fn expression_list_as_array_initilization() { fn incomplete_array_initialization() { let result = codegen( " - VAR_GLOBAL - arr : ARRAY[0..5] OF INT := 0, 1, 2; - END_VAR - ", + VAR_GLOBAL + arr : ARRAY[0..5] OF INT := 0, 1, 2; + END_VAR + ", ); insta::assert_snapshot!(result); } @@ -112,10 +112,10 @@ fn incomplete_array_initialization_with_custom_init_value() { " TYPE MyInt : INT := 7; END_TYPE - VAR_GLOBAL - arr : ARRAY[0..5] OF MyInt := 0, 1, 2; - END_VAR - ", + VAR_GLOBAL + arr : ARRAY[0..5] OF MyInt := 0, 1, 2; + END_VAR + ", ); insta::assert_snapshot!(result); } @@ -124,12 +124,12 @@ fn incomplete_array_initialization_with_custom_init_value() { fn alias_chain_with_lots_of_initializers() { let result = codegen( " - TYPE MyInt: MyOtherInt1; END_TYPE - VAR_GLOBAL - x0 : MyInt; - x1 : MyOtherInt1; - x2 : MyOtherInt2; - x3 : MyOtherInt3; + TYPE MyInt: MyOtherInt1; END_TYPE + VAR_GLOBAL + x0 : MyInt; + x1 : MyOtherInt1; + x2 : MyOtherInt2; + x3 : MyOtherInt3; END_VAR TYPE MyOtherInt3 : DINT := 3; END_TYPE TYPE MyOtherInt1 : MyOtherInt2 := 1; END_TYPE @@ -144,15 +144,15 @@ fn alias_chain_with_lots_of_initializers() { fn initial_values_in_single_dimension_array_variable() { let result = codegen( " - VAR_GLOBAL - a : ARRAY[0..2] OF SINT := [1, 2, 3]; - b : ARRAY[0..2] OF INT := [1, 2, 3]; - c : ARRAY[0..2] OF DINT := [1, 2, 3]; - d : ARRAY[0..2] OF LINT := [1, 2, 3]; - e : ARRAY[0..2] OF USINT := [1, 2, 3]; - f : ARRAY[0..2] OF UINT := [1, 2, 3]; - g : ARRAY[0..2] OF ULINT := [1, 2, 3]; - h : ARRAY[0..2] OF BOOL := [TRUE, FALSE, TRUE]; + VAR_GLOBAL + a : ARRAY[0..2] OF SINT := [1, 2, 3]; + b : ARRAY[0..2] OF INT := [1, 2, 3]; + c : ARRAY[0..2] OF DINT := [1, 2, 3]; + d : ARRAY[0..2] OF LINT := [1, 2, 3]; + e : ARRAY[0..2] OF USINT := [1, 2, 3]; + f : ARRAY[0..2] OF UINT := [1, 2, 3]; + g : ARRAY[0..2] OF ULINT := [1, 2, 3]; + h : ARRAY[0..2] OF BOOL := [TRUE, FALSE, TRUE]; END_VAR ", ); @@ -176,8 +176,8 @@ fn initial_values_in_single_dimension_array_type() { fn initial_values_in_multi_dimension_array_variable() { let result = codegen( " - VAR_GLOBAL - a : ARRAY[0..1, 0..1] OF BYTE := [1,2,3,4]; + VAR_GLOBAL + a : ARRAY[0..1, 0..1] OF BYTE := [1,2,3,4]; END_VAR ", ); @@ -189,11 +189,11 @@ fn initial_values_in_multi_dimension_array_variable() { fn initial_values_in_array_variable_using_multiplied_statement() { let result = codegen( " - VAR_GLOBAL - a : ARRAY[0..3] OF BYTE := [4(7)]; - b : ARRAY[0..3] OF BYTE := [2, 2(7), 3]; - c : ARRAY[0..9] OF BYTE := [5(0,1)]; - d : ARRAY[0..9] OF BYTE := [2(2(0), 2(1), 2)]; + VAR_GLOBAL + a : ARRAY[0..3] OF BYTE := [4(7)]; + b : ARRAY[0..3] OF BYTE := [2, 2(7), 3]; + c : ARRAY[0..9] OF BYTE := [5(0,1)]; + d : ARRAY[0..9] OF BYTE := [2(2(0), 2(1), 2)]; END_VAR ", ); @@ -211,9 +211,9 @@ fn initial_values_in_struct_variable() { END_STRUCT END_TYPE - VAR_GLOBAL - a : MyStruct := (a:=3, b:=5); - b : MyStruct := (b:=3, a:=5); + VAR_GLOBAL + a : MyStruct := (a:=3, b:=5); + b : MyStruct := (b:=3, a:=5); END_VAR ", ); @@ -232,9 +232,9 @@ fn initial_values_in_struct_variable_missing_init() { END_STRUCT END_TYPE - VAR_GLOBAL - a : MyStruct := (a:=5, c := 10); - b : MyStruct := (b:=3, c := 10); + VAR_GLOBAL + a : MyStruct := (a:=5, c := 10); + b : MyStruct := (b:=3, c := 10); END_VAR ", ); @@ -246,14 +246,14 @@ fn initial_values_in_struct_variable_missing_init() { fn unresolvable_types_validation() { let msg = codegen_debug_without_unwrap( " - VAR_GLOBAL - a : MyStruct2 := (a := (c:=5, b:= 7), b := (a:=3, b:=2)); - b : MyStruct2 := (b := (a:= 9)); + VAR_GLOBAL + a : MyStruct2 := (a := (c:=5, b:= 7), b := (a:=3, b:=2)); + b : MyStruct2 := (b := (a:= 9)); END_VAR TYPE MyStruct2: STRUCT - a : MyStruct := (a:=5, b:=3); - b : MyStruct := (c:=7); + a : MyStruct := (a:=5, b:=3); + b : MyStruct := (c:=7); END_STRUCT END_TYPE @@ -273,14 +273,14 @@ fn unresolvable_types_validation() { fn initial_nested_struct_delayed_init() { let result = codegen( " - VAR_GLOBAL - a : MyStruct2 := (a := (a:=5, b:= 7), b := (a:=3, b:=2)); - b : MyStruct2 := (b := (a:= 9)); + VAR_GLOBAL + a : MyStruct2 := (a := (a:=5, b:= 7), b := (a:=3, b:=2)); + b : MyStruct2 := (b := (a:= 9)); END_VAR TYPE MyStruct2: STRUCT - a : MyStruct := (a:=5, b:=3); - b : MyStruct := (b:=7); + a : MyStruct := (a:=5, b:=3); + b : MyStruct := (b:=7); END_STRUCT END_TYPE @@ -329,7 +329,7 @@ fn initial_values_in_fb_variable() { END_VAR END_FUNCTION_BLOCK - PROGRAM main + PROGRAM main VAR CONSTANT TEN : INT := 10; @@ -353,7 +353,7 @@ fn complex_initial_values_in_struct_variable_using_multiplied_statement() { y: DINT; END_STRUCT END_TYPE - + TYPE MyStruct: STRUCT point: MyPoint; my_array: ARRAY[0..3] OF INT; @@ -361,12 +361,12 @@ fn complex_initial_values_in_struct_variable_using_multiplied_statement() { END_STRUCT END_TYPE - VAR_GLOBAL + VAR_GLOBAL a : MyStruct := ( point := (x := 1, y:= 2), my_array := [0,1,2,3], f := 7 - ); + ); END_VAR ", ); @@ -382,8 +382,8 @@ fn struct_with_one_field_can_be_initialized() { x: DINT; END_STRUCT END_TYPE - - VAR_GLOBAL + + VAR_GLOBAL a : MyPoint := ( x := 7); END_VAR ", @@ -400,7 +400,7 @@ fn struct_initializer_needs_assignments() { y: DINT; END_STRUCT END_TYPE - + VAR_GLOBAL x : Point := (x := 1, 2); END_VAR @@ -423,7 +423,7 @@ fn struct_initialization_uses_types_default_if_not_provided() { z: MyDINT; END_STRUCT END_TYPE - + VAR_GLOBAL x : Point := (x := 1, y := 2); END_VAR @@ -448,7 +448,7 @@ fn struct_initializer_uses_fallback_to_field_default() { z: DINT := 3; END_STRUCT END_TYPE - + VAR_GLOBAL x : Point := (x := 1); END_VAR @@ -461,26 +461,26 @@ fn struct_initializer_uses_fallback_to_field_default() { #[test] fn array_of_struct_initialization() { let source = " - TYPE myStruct : STRUCT - a, b : DINT; - c : ARRAY[0..1] OF DINT; - END_STRUCT - END_TYPE - - TYPE AliasMyStruct : myStruct; END_TYPE - - VAR_GLOBAL CONSTANT - str : myStruct := (a := 50, b := 60, c := [70, 80]); - alias_str : AliasMyStruct := (a := 50, b := 60, c := [70, 80]); - global_arr : ARRAY[0..1] OF DINT := [30, 40]; - END_VAR - - PROGRAM main - VAR - arr : ARRAY[0..1] OF myStruct := [(a := 10, b := 20, c := [30, 40]), str]; - alias_arr : ARRAY[0..1] OF AliasMyStruct := [(a := 10, b := 20, c := global_arr), alias_str]; - END_VAR - END_PROGRAM + TYPE myStruct : STRUCT + a, b : DINT; + c : ARRAY[0..1] OF DINT; + END_STRUCT + END_TYPE + + TYPE AliasMyStruct : myStruct; END_TYPE + + VAR_GLOBAL CONSTANT + str : myStruct := (a := 50, b := 60, c := [70, 80]); + alias_str : AliasMyStruct := (a := 50, b := 60, c := [70, 80]); + global_arr : ARRAY[0..1] OF DINT := [30, 40]; + END_VAR + + PROGRAM main + VAR + arr : ARRAY[0..1] OF myStruct := [(a := 10, b := 20, c := [30, 40]), str]; + alias_arr : ARRAY[0..1] OF AliasMyStruct := [(a := 10, b := 20, c := global_arr), alias_str]; + END_VAR + END_PROGRAM "; let result = codegen(source); @@ -525,7 +525,7 @@ fn partly_uninitialized_const_struct_will_get_default_values() { z: DINT := 3; END_STRUCT END_TYPE - + VAR_GLOBAL CONSTANT x : Point := (x := 1); empty: Point; @@ -549,7 +549,7 @@ fn partly_uninitialized_const_struct_will_not_report_errors() { z: DINT := 3; END_STRUCT END_TYPE - + VAR_GLOBAL CONSTANT x : Point := (x := 1); empty: Point; @@ -562,7 +562,7 @@ fn partly_uninitialized_const_struct_will_not_report_errors() { #[test] fn enums_with_inline_initializer_do_not_report_errors() { let diagnostics = parse_and_validate( - r#" + r#" VAR_GLOBAL x : (red, yellow, green) := red; END_VAR @@ -585,7 +585,7 @@ fn enums_with_inline_initializer_do_not_report_errors() { #[test] fn enums_with_inline_initializer_are_initialized() { let res = codegen( - r#" + r#" VAR_GLOBAL x : (red, yellow, green) := 2; END_VAR diff --git a/src/codegen/tests/parameters_tests.rs b/src/codegen/tests/parameters_tests.rs index 6d4978e60b..76530faa8b 100644 --- a/src/codegen/tests/parameters_tests.rs +++ b/src/codegen/tests/parameters_tests.rs @@ -5,27 +5,27 @@ fn function_all_parameters_assigned() { // GIVEN let result = codegen( " - FUNCTION foo : DINT - VAR_INPUT - input1 : DINT; - END_VAR - VAR_OUTPUT - output1 : DINT; - END_VAR - VAR_IN_OUT - inout1 : DINT; - END_VAR - END_FUNCTION - - PROGRAM main - VAR - var1, var2, var3 : DINT; - END_VAR - foo(var1, var2, var3); - foo(input1 := var1, output1 => var2, inout1 := var3); - foo(inout1 := var3, input1 := var1, output1 => var2); - END_PROGRAM - ", + FUNCTION foo : DINT + VAR_INPUT + input1 : DINT; + END_VAR + VAR_OUTPUT + output1 : DINT; + END_VAR + VAR_IN_OUT + inout1 : DINT; + END_VAR + END_FUNCTION + + PROGRAM main + VAR + var1, var2, var3 : DINT; + END_VAR + foo(var1, var2, var3); + foo(input1 := var1, output1 => var2, inout1 := var3); + foo(inout1 := var3, input1 := var1, output1 => var2); + END_PROGRAM + ", ); // THEN insta::assert_snapshot!(result); @@ -36,25 +36,25 @@ fn function_empty_input_assignment() { // GIVEN let result = codegen( " - FUNCTION foo : DINT - VAR_INPUT - input1 : DINT; - END_VAR - VAR_OUTPUT - output1 : DINT; - END_VAR - VAR_IN_OUT - inout1 : DINT; - END_VAR - END_FUNCTION - - PROGRAM main - VAR - var1, var2, var3 : DINT; - END_VAR - foo(input1 := , output1 => var2, inout1 := var3); - END_PROGRAM - ", + FUNCTION foo : DINT + VAR_INPUT + input1 : DINT; + END_VAR + VAR_OUTPUT + output1 : DINT; + END_VAR + VAR_IN_OUT + inout1 : DINT; + END_VAR + END_FUNCTION + + PROGRAM main + VAR + var1, var2, var3 : DINT; + END_VAR + foo(input1 := , output1 => var2, inout1 := var3); + END_PROGRAM + ", ); // THEN insta::assert_snapshot!(result); @@ -65,25 +65,25 @@ fn function_empty_output_assignment() { // GIVEN let result = codegen( " - FUNCTION foo : DINT - VAR_INPUT - input1 : DINT; - END_VAR - VAR_OUTPUT - output1 : DINT; - END_VAR - VAR_IN_OUT - inout1 : DINT; - END_VAR - END_FUNCTION - - PROGRAM main - VAR - var1, var2, var3 : DINT; - END_VAR - foo(input1 := var1, output1 => , inout1 := var3); - END_PROGRAM - ", + FUNCTION foo : DINT + VAR_INPUT + input1 : DINT; + END_VAR + VAR_OUTPUT + output1 : DINT; + END_VAR + VAR_IN_OUT + inout1 : DINT; + END_VAR + END_FUNCTION + + PROGRAM main + VAR + var1, var2, var3 : DINT; + END_VAR + foo(input1 := var1, output1 => , inout1 := var3); + END_PROGRAM + ", ); // THEN insta::assert_snapshot!(result); @@ -94,25 +94,25 @@ fn function_empty_output_default_value_assignment() { // GIVEN let result = codegen( " - FUNCTION foo : DINT - VAR_INPUT - input1 : DINT; - END_VAR - VAR_OUTPUT - output1 : DINT := 3; - END_VAR - VAR_IN_OUT - inout1 : DINT; - END_VAR - END_FUNCTION - - PROGRAM main - VAR - var1, var2, var3 : DINT; - END_VAR - foo(input1 := var1, output1 => , inout1 := var3); - END_PROGRAM - ", + FUNCTION foo : DINT + VAR_INPUT + input1 : DINT; + END_VAR + VAR_OUTPUT + output1 : DINT := 3; + END_VAR + VAR_IN_OUT + inout1 : DINT; + END_VAR + END_FUNCTION + + PROGRAM main + VAR + var1, var2, var3 : DINT; + END_VAR + foo(input1 := var1, output1 => , inout1 := var3); + END_PROGRAM + ", ); // THEN insta::assert_snapshot!(result); @@ -123,25 +123,25 @@ fn function_empty_inout_assignment() { // GIVEN let result = codegen( " - FUNCTION foo : DINT - VAR_INPUT - input1 : DINT; - END_VAR - VAR_OUTPUT - output1 : DINT; - END_VAR - VAR_IN_OUT - inout1 : DINT; - END_VAR - END_FUNCTION - - PROGRAM main - VAR - var1, var2, var3 : DINT; - END_VAR - foo(input1 := var1, output1 => var2, inout1 := ); - END_PROGRAM - ", + FUNCTION foo : DINT + VAR_INPUT + input1 : DINT; + END_VAR + VAR_OUTPUT + output1 : DINT; + END_VAR + VAR_IN_OUT + inout1 : DINT; + END_VAR + END_FUNCTION + + PROGRAM main + VAR + var1, var2, var3 : DINT; + END_VAR + foo(input1 := var1, output1 => var2, inout1 := ); + END_PROGRAM + ", ); // THEN insta::assert_snapshot!(result); @@ -152,25 +152,25 @@ fn function_missing_input_assignment() { // GIVEN let result = codegen( " - FUNCTION foo : DINT - VAR_INPUT - input1 : DINT; - END_VAR - VAR_OUTPUT - output1 : DINT; - END_VAR - VAR_IN_OUT - inout1 : DINT; - END_VAR - END_FUNCTION - - PROGRAM main - VAR - var1, var2, var3 : DINT; - END_VAR - foo(output1 => var2, inout1 := var3); - END_PROGRAM - ", + FUNCTION foo : DINT + VAR_INPUT + input1 : DINT; + END_VAR + VAR_OUTPUT + output1 : DINT; + END_VAR + VAR_IN_OUT + inout1 : DINT; + END_VAR + END_FUNCTION + + PROGRAM main + VAR + var1, var2, var3 : DINT; + END_VAR + foo(output1 => var2, inout1 := var3); + END_PROGRAM + ", ); // THEN insta::assert_snapshot!(result); @@ -181,25 +181,25 @@ fn function_missing_input_default_value_assignment() { // GIVEN let result = codegen( " - FUNCTION foo : DINT - VAR_INPUT - input1 : DINT := 10; - END_VAR - VAR_OUTPUT - output1 : DINT; - END_VAR - VAR_IN_OUT - inout1 : DINT; - END_VAR - END_FUNCTION - - PROGRAM main - VAR - var1, var2, var3 : DINT; - END_VAR - foo(output1 => var2, inout1 := var3); - END_PROGRAM - ", + FUNCTION foo : DINT + VAR_INPUT + input1 : DINT := 10; + END_VAR + VAR_OUTPUT + output1 : DINT; + END_VAR + VAR_IN_OUT + inout1 : DINT; + END_VAR + END_FUNCTION + + PROGRAM main + VAR + var1, var2, var3 : DINT; + END_VAR + foo(output1 => var2, inout1 := var3); + END_PROGRAM + ", ); // THEN insta::assert_snapshot!(result); @@ -210,25 +210,25 @@ fn function_missing_output_assignment() { // GIVEN let result = codegen( " - FUNCTION foo : DINT - VAR_INPUT - input1 : DINT; - END_VAR - VAR_OUTPUT - output1 : DINT; - END_VAR - VAR_IN_OUT - inout1 : DINT; - END_VAR - END_FUNCTION - - PROGRAM main - VAR - var1, var2, var3 : DINT; - END_VAR - foo(input1 := var1, inout1 := var3); - END_PROGRAM - ", + FUNCTION foo : DINT + VAR_INPUT + input1 : DINT; + END_VAR + VAR_OUTPUT + output1 : DINT; + END_VAR + VAR_IN_OUT + inout1 : DINT; + END_VAR + END_FUNCTION + + PROGRAM main + VAR + var1, var2, var3 : DINT; + END_VAR + foo(input1 := var1, inout1 := var3); + END_PROGRAM + ", ); // THEN insta::assert_snapshot!(result); @@ -239,25 +239,25 @@ fn function_missing_output_default_value_assignment() { // GIVEN let result = codegen( " - FUNCTION foo : DINT - VAR_INPUT - input1 : DINT; - END_VAR - VAR_OUTPUT - output1 : DINT := 3; - END_VAR - VAR_IN_OUT - inout1 : DINT; - END_VAR - END_FUNCTION - - PROGRAM main - VAR - var1, var2, var3 : DINT; - END_VAR - foo(input1 := var1, inout1 := var3); - END_PROGRAM - ", + FUNCTION foo : DINT + VAR_INPUT + input1 : DINT; + END_VAR + VAR_OUTPUT + output1 : DINT := 3; + END_VAR + VAR_IN_OUT + inout1 : DINT; + END_VAR + END_FUNCTION + + PROGRAM main + VAR + var1, var2, var3 : DINT; + END_VAR + foo(input1 := var1, inout1 := var3); + END_PROGRAM + ", ); // THEN insta::assert_snapshot!(result); @@ -268,25 +268,25 @@ fn function_missing_inout_assignment() { // GIVEN let result = codegen( " - FUNCTION foo : DINT - VAR_INPUT - input1 : DINT; - END_VAR - VAR_OUTPUT - output1 : DINT; - END_VAR - VAR_IN_OUT - inout1 : DINT; - END_VAR - END_FUNCTION - - PROGRAM main - VAR - var1, var2, var3 : DINT; - END_VAR - foo(input1 := var1, output1 => var2); - END_PROGRAM - ", + FUNCTION foo : DINT + VAR_INPUT + input1 : DINT; + END_VAR + VAR_OUTPUT + output1 : DINT; + END_VAR + VAR_IN_OUT + inout1 : DINT; + END_VAR + END_FUNCTION + + PROGRAM main + VAR + var1, var2, var3 : DINT; + END_VAR + foo(input1 := var1, output1 => var2); + END_PROGRAM + ", ); // THEN insta::assert_snapshot!(result); @@ -297,28 +297,28 @@ fn function_default_value_parameter_type() { // GIVEN let result = codegen( " - TYPE myType : DINT := 20; END_TYPE - - FUNCTION foo : DINT - VAR_INPUT - input1 : myType; - END_VAR - VAR_OUTPUT - output1 : myType; - output2 : myType; - END_VAR - VAR_IN_OUT - inout1 : DINT; - END_VAR - END_FUNCTION - - PROGRAM main - VAR - var1, var2, var3 : DINT; - END_VAR - foo(output2 => , inout1 := var3); - END_PROGRAM - ", + TYPE myType : DINT := 20; END_TYPE + + FUNCTION foo : DINT + VAR_INPUT + input1 : myType; + END_VAR + VAR_OUTPUT + output1 : myType; + output2 : myType; + END_VAR + VAR_IN_OUT + inout1 : DINT; + END_VAR + END_FUNCTION + + PROGRAM main + VAR + var1, var2, var3 : DINT; + END_VAR + foo(output2 => , inout1 := var3); + END_PROGRAM + ", ); // THEN insta::assert_snapshot!(result); @@ -329,26 +329,26 @@ fn program_all_parameters_assigned_explicit() { // GIVEN let result = codegen( " - PROGRAM prog - VAR_INPUT - input1 : DINT; - END_VAR - VAR_OUTPUT - output1 : DINT; - END_VAR - VAR_IN_OUT - inout1 : DINT; - END_VAR - END_PROGRAM - - PROGRAM main - VAR - var1, var2, var3 : DINT; - END_VAR - prog(input1 := var1, output1 => var2, inout1 := var3); - prog(inout1 := var3, input1 := var1, output1 => var2); - END_PROGRAM - ", + PROGRAM prog + VAR_INPUT + input1 : DINT; + END_VAR + VAR_OUTPUT + output1 : DINT; + END_VAR + VAR_IN_OUT + inout1 : DINT; + END_VAR + END_PROGRAM + + PROGRAM main + VAR + var1, var2, var3 : DINT; + END_VAR + prog(input1 := var1, output1 => var2, inout1 := var3); + prog(inout1 := var3, input1 := var1, output1 => var2); + END_PROGRAM + ", ); // THEN insta::assert_snapshot!(result); @@ -359,25 +359,25 @@ fn program_all_parameters_assigned_implicit() { // GIVEN let result = codegen( " - PROGRAM prog - VAR_INPUT - input1 : DINT; - END_VAR - VAR_OUTPUT - output1 : DINT; - END_VAR - VAR_IN_OUT - inout1 : DINT; - END_VAR - END_PROGRAM - - PROGRAM main - VAR - var1, var2, var3 : DINT; - END_VAR - prog(var1, var2, var3); - END_PROGRAM - ", + PROGRAM prog + VAR_INPUT + input1 : DINT; + END_VAR + VAR_OUTPUT + output1 : DINT; + END_VAR + VAR_IN_OUT + inout1 : DINT; + END_VAR + END_PROGRAM + + PROGRAM main + VAR + var1, var2, var3 : DINT; + END_VAR + prog(var1, var2, var3); + END_PROGRAM + ", ); // THEN insta::assert_snapshot!(result); @@ -388,25 +388,25 @@ fn program_empty_inout_assignment() { // GIVEN let result = codegen( " - PROGRAM prog - VAR_INPUT - input1 : DINT; - END_VAR - VAR_OUTPUT - output1 : DINT; - END_VAR - VAR_IN_OUT - inout1 : DINT; - END_VAR - END_PROGRAM - - PROGRAM main - VAR - var1, var2, var3 : DINT; - END_VAR - prog(input1 := var1, output1 => var2, inout1 := ); - END_PROGRAM - ", + PROGRAM prog + VAR_INPUT + input1 : DINT; + END_VAR + VAR_OUTPUT + output1 : DINT; + END_VAR + VAR_IN_OUT + inout1 : DINT; + END_VAR + END_PROGRAM + + PROGRAM main + VAR + var1, var2, var3 : DINT; + END_VAR + prog(input1 := var1, output1 => var2, inout1 := ); + END_PROGRAM + ", ); // THEN insta::assert_snapshot!(result); @@ -417,25 +417,25 @@ fn program_missing_input_assignment() { // GIVEN let result = codegen( " - PROGRAM prog - VAR_INPUT - input1 : DINT; - END_VAR - VAR_OUTPUT - output1 : DINT; - END_VAR - VAR_IN_OUT - inout1 : DINT; - END_VAR - END_PROGRAM - - PROGRAM main - VAR - var1, var2, var3 : DINT; - END_VAR - prog(output1 => var2, inout1 := var3); - END_PROGRAM - ", + PROGRAM prog + VAR_INPUT + input1 : DINT; + END_VAR + VAR_OUTPUT + output1 : DINT; + END_VAR + VAR_IN_OUT + inout1 : DINT; + END_VAR + END_PROGRAM + + PROGRAM main + VAR + var1, var2, var3 : DINT; + END_VAR + prog(output1 => var2, inout1 := var3); + END_PROGRAM + ", ); // THEN insta::assert_snapshot!(result); @@ -446,25 +446,25 @@ fn program_missing_output_assignment() { // GIVEN let result = codegen( " - PROGRAM prog - VAR_INPUT - input1 : DINT; - END_VAR - VAR_OUTPUT - output1 : DINT; - END_VAR - VAR_IN_OUT - inout1 : DINT; - END_VAR - END_PROGRAM - - PROGRAM main - VAR - var1, var2, var3 : DINT; - END_VAR - prog(input1 := var1, inout1 := var3); - END_PROGRAM - ", + PROGRAM prog + VAR_INPUT + input1 : DINT; + END_VAR + VAR_OUTPUT + output1 : DINT; + END_VAR + VAR_IN_OUT + inout1 : DINT; + END_VAR + END_PROGRAM + + PROGRAM main + VAR + var1, var2, var3 : DINT; + END_VAR + prog(input1 := var1, inout1 := var3); + END_PROGRAM + ", ); // THEN insta::assert_snapshot!(result); @@ -475,17 +475,17 @@ fn program_accepts_empty_statement_as_input_param() { // GIVEN let result = codegen( " - PROGRAM prog - VAR_INPUT - in1: DINT; - in2: DINT; - END_VAR - END_PROGRAM - - PROGRAM main - prog(in1 := 1, in2 := ); - END_PROGRAM - ", + PROGRAM prog + VAR_INPUT + in1: DINT; + in2: DINT; + END_VAR + END_PROGRAM + + PROGRAM main + prog(in1 := 1, in2 := ); + END_PROGRAM + ", ); // THEN @@ -497,22 +497,22 @@ fn program_accepts_empty_statement_as_output_param() { // GIVEN let result = codegen( " - PROGRAM prog - VAR_OUTPUT - out1 : DINT; - out2 : DINT; - END_VAR - out1 := 1; - out2 := 2; - END_PROGRAM - - PROGRAM main - VAR - x : DINT; - END_VAR - prog( out1 => x, out2 => ); - END_PROGRAM - ", + PROGRAM prog + VAR_OUTPUT + out1 : DINT; + out2 : DINT; + END_VAR + out1 := 1; + out2 := 2; + END_PROGRAM + + PROGRAM main + VAR + x : DINT; + END_VAR + prog( out1 => x, out2 => ); + END_PROGRAM + ", ); // THEN @@ -524,20 +524,20 @@ fn fb_accepts_empty_statement_as_input_param() { // GIVEN let result = codegen( " - FUNCTION_BLOCK fb_t - VAR_INPUT - in1: DINT; - in2: DINT; - END_VAR - END_FUNCTION_BLOCK - - PROGRAM main - VAR - fb : fb_t; - END_VAR - fb(in1 := 1, in2 := ); - END_PROGRAM - ", + FUNCTION_BLOCK fb_t + VAR_INPUT + in1: DINT; + in2: DINT; + END_VAR + END_FUNCTION_BLOCK + + PROGRAM main + VAR + fb : fb_t; + END_VAR + fb(in1 := 1, in2 := ); + END_PROGRAM + ", ); // THEN @@ -549,21 +549,21 @@ fn fb_accepts_empty_statement_as_output_param() { // GIVEN let result = codegen( " - FUNCTION_BLOCK fb_t - VAR_OUTPUT - out1 : DINT; - out2 : DINT; - END_VAR - END_FUNCTION_BLOCK - - PROGRAM main - VAR - fb : fb_t; - x : DINT; - END_VAR - fb( out1 => x, out2 => ); - END_PROGRAM - ", + FUNCTION_BLOCK fb_t + VAR_OUTPUT + out1 : DINT; + out2 : DINT; + END_VAR + END_FUNCTION_BLOCK + + PROGRAM main + VAR + fb : fb_t; + x : DINT; + END_VAR + fb( out1 => x, out2 => ); + END_PROGRAM + ", ); // THEN @@ -575,17 +575,17 @@ fn function_accepts_empty_statement_as_input_param() { // GIVEN let result = codegen( " - FUNCTION foo - VAR_INPUT - in1: DINT; - in2: DINT; - END_VAR - END_FUNCTION - - PROGRAM main - foo(in1 := 1, in2 := ); - END_PROGRAM - ", + FUNCTION foo + VAR_INPUT + in1: DINT; + in2: DINT; + END_VAR + END_FUNCTION + + PROGRAM main + foo(in1 := 1, in2 := ); + END_PROGRAM + ", ); // THEN @@ -597,20 +597,20 @@ fn function_accepts_empty_statement_as_output_param() { // GIVEN let result = codegen( " - FUNCTION foo - VAR_OUTPUT - out1 : DINT; - out2 : DINT; - END_VAR - END_FUNCTION - - PROGRAM main - VAR - x: DINT; - END_VAR - foo( out1 => x, out2 => ); - END_PROGRAM - ", + FUNCTION foo + VAR_OUTPUT + out1 : DINT; + out2 : DINT; + END_VAR + END_FUNCTION + + PROGRAM main + VAR + x: DINT; + END_VAR + foo( out1 => x, out2 => ); + END_PROGRAM + ", ); // THEN @@ -622,12 +622,12 @@ fn parameters_behind_function_block_pointer_are_assigned_to() { // GIVEN let result = codegen( " - PROGRAM main + PROGRAM main VAR - file : file_t; + file : file_t; FileOpen : REF_TO file_t; END_VAR - FileOpen := &file; + FileOpen := &file; FileOpen^(var2:=TRUE); END_PROGRAM @@ -637,7 +637,7 @@ fn parameters_behind_function_block_pointer_are_assigned_to() { var2 : BOOL; END_VAR END_FUNCTION_BLOCK - ", + ", ); // THEN @@ -658,19 +658,19 @@ fn var_in_out_params_can_be_out_of_order() { fb.foo(myOtherInOut := out2, myInOut := out1); fb.foo(myInOut := out2, myOtherInOut := out1); END_PROGRAM - + FUNCTION_BLOCK fb_t VAR - myVar : BOOL; + myVar : BOOL; END_VAR VAR_INPUT - myInput : USINT; + myInput : USINT; END_VAR VAR_IN_OUT - myInOut : BOOL; + myInOut : BOOL; END_VAR VAR_OUTPUT - myOut : BOOL; + myOut : BOOL; END_VAR VAR_IN_OUT myOtherInOut : BOOL; diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__codegen_error_messages_tests__assigning_empty_string_literal_to_char_results_in_error.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__codegen_error_messages_tests__assigning_empty_string_literal_to_char_results_in_error.snap index b2439583b1..0764b8e51d 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__codegen_error_messages_tests__assigning_empty_string_literal_to_char_results_in_error.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__codegen_error_messages_tests__assigning_empty_string_literal_to_char_results_in_error.snap @@ -3,9 +3,9 @@ source: src/codegen/tests/codegen_error_messages_tests.rs expression: msg --- error: Cannot generate CHAR from empty literal - ┌─ :6:8 + ┌─ :6:14 │ -6 │ x := ''; - │ ^^ Cannot generate CHAR from empty literal +6 │ x := ''; + │ ^^ Cannot generate CHAR from empty literal diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__codegen_error_messages_tests__assigning_empty_string_literal_to_wide_char_results_in_error.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__codegen_error_messages_tests__assigning_empty_string_literal_to_wide_char_results_in_error.snap index 1f2cad2e0e..6140be982a 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__codegen_error_messages_tests__assigning_empty_string_literal_to_wide_char_results_in_error.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__codegen_error_messages_tests__assigning_empty_string_literal_to_wide_char_results_in_error.snap @@ -3,9 +3,9 @@ source: src/codegen/tests/codegen_error_messages_tests.rs expression: msg --- error: Cannot generate WCHAR from empty literal - ┌─ :6:8 + ┌─ :6:14 │ -6 │ x := ""; - │ ^^ Cannot generate WCHAR from empty literal +6 │ x := ""; + │ ^^ Cannot generate WCHAR from empty literal diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__codegen_error_messages_tests__assigning_string_literal_to_int_variable_results_in_casting_error.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__codegen_error_messages_tests__assigning_string_literal_to_int_variable_results_in_casting_error.snap index 151bfa86ac..ab4fd15945 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__codegen_error_messages_tests__assigning_string_literal_to_int_variable_results_in_casting_error.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__codegen_error_messages_tests__assigning_string_literal_to_int_variable_results_in_casting_error.snap @@ -3,9 +3,9 @@ source: src/codegen/tests/codegen_error_messages_tests.rs expression: msg --- error: Cannot generate String-Literal for type INT - ┌─ :6:8 + ┌─ :6:14 │ -6 │ x := 'A'; - │ ^^^ Cannot generate String-Literal for type INT +6 │ x := 'A'; + │ ^^^ Cannot generate String-Literal for type INT diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__codegen_error_messages_tests__pointer_binary_expression_adding_two_pointers.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__codegen_error_messages_tests__pointer_binary_expression_adding_two_pointers.snap index 489c31b3a4..617ae6c7fe 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__codegen_error_messages_tests__pointer_binary_expression_adding_two_pointers.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__codegen_error_messages_tests__pointer_binary_expression_adding_two_pointers.snap @@ -3,9 +3,9 @@ source: src/codegen/tests/codegen_error_messages_tests.rs expression: msg --- error: '+' operation must contain one int type - ┌─ :8:10 + ┌─ :8:16 │ -8 │ ptr := ptr + ptr; - │ ^^^^^^^^^ '+' operation must contain one int type +8 │ ptr := ptr + ptr; + │ ^^^^^^^^^ '+' operation must contain one int type diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__codegen_error_messages_tests__pointer_binary_expression_division.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__codegen_error_messages_tests__pointer_binary_expression_division.snap index e339f4ab2f..820b3f4542 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__codegen_error_messages_tests__pointer_binary_expression_division.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__codegen_error_messages_tests__pointer_binary_expression_division.snap @@ -3,9 +3,9 @@ source: src/codegen/tests/codegen_error_messages_tests.rs expression: msg --- error: Operator '/' unimplemented for pointers - ┌─ :8:10 + ┌─ :8:16 │ -8 │ ptr := ptr / ptr; - │ ^^^^^^^^^ Operator '/' unimplemented for pointers +8 │ ptr := ptr / ptr; + │ ^^^^^^^^^ Operator '/' unimplemented for pointers diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__codegen_error_messages_tests__pointer_binary_expression_modulo.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__codegen_error_messages_tests__pointer_binary_expression_modulo.snap index 49ab53f182..46f1c8f69f 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__codegen_error_messages_tests__pointer_binary_expression_modulo.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__codegen_error_messages_tests__pointer_binary_expression_modulo.snap @@ -3,9 +3,9 @@ source: src/codegen/tests/codegen_error_messages_tests.rs expression: msg --- error: Operator 'MOD' unimplemented for pointers - ┌─ :8:10 + ┌─ :8:16 │ -8 │ ptr := ptr MOD ptr; - │ ^^^^^^^^^^^ Operator 'MOD' unimplemented for pointers +8 │ ptr := ptr MOD ptr; + │ ^^^^^^^^^^^ Operator 'MOD' unimplemented for pointers diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__codegen_error_messages_tests__pointer_binary_expression_multiplication.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__codegen_error_messages_tests__pointer_binary_expression_multiplication.snap index 1d1ade8a01..ed4e41f346 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__codegen_error_messages_tests__pointer_binary_expression_multiplication.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__codegen_error_messages_tests__pointer_binary_expression_multiplication.snap @@ -3,9 +3,9 @@ source: src/codegen/tests/codegen_error_messages_tests.rs expression: msg --- error: Operator '*' unimplemented for pointers - ┌─ :8:10 + ┌─ :8:16 │ -8 │ ptr := ptr * ptr; - │ ^^^^^^^^^ Operator '*' unimplemented for pointers +8 │ ptr := ptr * ptr; + │ ^^^^^^^^^ Operator '*' unimplemented for pointers diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__string_tests__generate_with_invalid_casted_string_assignment.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__string_tests__generate_with_invalid_casted_string_assignment.snap index 70a4b5939b..5971f9e0d2 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__string_tests__generate_with_invalid_casted_string_assignment.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__string_tests__generate_with_invalid_casted_string_assignment.snap @@ -5,7 +5,7 @@ expression: result error: Cannot generate String-Literal for type INT ┌─ :5:10 │ -5 │ y := INT#"seven"; +5 │ y := INT#"seven"; │ ^^^^^^^ Cannot generate String-Literal for type INT diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__string_tests__nested_struct_initialization_of_multi_dim_string_arrays.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__string_tests__nested_struct_initialization_of_multi_dim_string_arrays.snap index 8654b75dae..3a44ecd3b0 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__string_tests__nested_struct_initialization_of_multi_dim_string_arrays.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__string_tests__nested_struct_initialization_of_multi_dim_string_arrays.snap @@ -7,6 +7,6 @@ source_filename = "main" %CONSTANTS_LANGUAGE = type { i16, i16, [21 x [11 x i8]], [21 x [3 x i8]], [36 x [11 x i8]], [36 x [4 x i8]], [48 x [4 x i8]] } -@x = global %CONSTANTS_LANGUAGE { i16 1, i16 3, [21 x [11 x i8]] [[11 x i8] c"Monday\00\00\00\00\00", [11 x i8] c"Tuesday\00\00\00\00", [11 x i8] c"Wednesday\00\00", [11 x i8] c"Thursday\00\00\00", [11 x i8] c"Friday\00\00\00\00\00", [11 x i8] c"Saturday\00\00\00", [11 x i8] c"Sunday\00\00\00\00\00", [11 x i8] c"Montag\00\00\00\00\00", [11 x i8] c"Dienstag\00\00\00", [11 x i8] c"Mittwoch\00\00\00", [11 x i8] c"Donnerstag\00", [11 x i8] c"Freitag\00\00\00\00", [11 x i8] c"Samstag\00\00\00\00", [11 x i8] c"Sonntag\00\00\00\00", [11 x i8] c"Lundi\00\00\00\00\00\00", [11 x i8] c"Mardi\00\00\00\00\00\00", [11 x i8] c"Mercredi\00\00\00", [11 x i8] c"Jeudi\00\00\00\00\00\00", [11 x i8] c"Vendredi\00\00\00", [11 x i8] c"Samedi\00\00\00\00\00", [11 x i8] c"Dimanche\00\00\00"], [21 x [3 x i8]] [[3 x i8] c"Mo\00", [3 x i8] c"Tu\00", [3 x i8] c"We\00", [3 x i8] c"Th\00", [3 x i8] c"Fr\00", [3 x i8] c"Sa\00", [3 x i8] c"Su\00", [3 x i8] c"Mo\00", [3 x i8] c"Di\00", [3 x i8] c"Mi\00", [3 x i8] c"Do\00", [3 x i8] c"Fr\00", [3 x i8] c"Sa\00", [3 x i8] c"So\00", [3 x i8] c"Lu\00", [3 x i8] c"Ma\00", [3 x i8] c"Me\00", [3 x i8] c"Je\00", [3 x i8] c"Ve\00", [3 x i8] c"Sa\00", [3 x i8] c"Di\00"], [36 x [11 x i8]] [[11 x i8] c"January\00\00\00\00", [11 x i8] c"February\00\00\00", [11 x i8] c"March\00\00\00\00\00\00", [11 x i8] c"April\00\00\00\00\00\00", [11 x i8] c"May\00\00\00\00\00\00\00\00", [11 x i8] c"June\00\00\00\00\00\00\00", [11 x i8] c"July\00\00\00\00\00\00\00", [11 x i8] c"August\00\00\00\00\00", [11 x i8] c"September\00\00", [11 x i8] c"October\00\00\00\00", [11 x i8] c"November\00\00\00", [11 x i8] c"December\00\00\00", [11 x i8] c"Januar\00\00\00\00\00", [11 x i8] c"Februar\00\00\00\00", [11 x i8] c"M\EF\BF\BDrz\00\00\00\00\00", [11 x i8] c"April\00\00\00\00\00\00", [11 x i8] c"Mai\00\00\00\00\00\00\00\00", [11 x i8] c"Juni\00\00\00\00\00\00\00", [11 x i8] c"Juli\00\00\00\00\00\00\00", [11 x i8] c"August\00\00\00\00\00", [11 x i8] c"September\00\00", [11 x i8] c"Oktober\00\00\00\00", [11 x i8] c"November\00\00\00", [11 x i8] c"Dezember\00\00\00", [11 x i8] c"Janvier\00\00\00\00", [11 x i8] c"F\EF\BF\BDvrier\00\00", [11 x i8] c"mars\00\00\00\00\00\00\00", [11 x i8] c"Avril\00\00\00\00\00\00", [11 x i8] c"Mai\00\00\00\00\00\00\00\00", [11 x i8] c"Juin\00\00\00\00\00\00\00", [11 x i8] c"Juillet\00\00\00\00", [11 x i8] c"Ao\EF\BF\BDt\00\00\00\00\00", [11 x i8] c"Septembre\00\00", [11 x i8] c"Octobre\00\00\00\00", [11 x i8] c"Novembre\00\00\00", [11 x i8] c"Decembre\00\00\00"], [36 x [4 x i8]] [[4 x i8] c"Jan\00", [4 x i8] c"Feb\00", [4 x i8] c"Mar\00", [4 x i8] c"Apr\00", [4 x i8] c"May\00", [4 x i8] c"Jun\00", [4 x i8] c"Jul\00", [4 x i8] c"Aug\00", [4 x i8] c"Sep\00", [4 x i8] c"Oct\00", [4 x i8] c"Nov\00", [4 x i8] c"Dec\00", [4 x i8] c"Jan\00", [4 x i8] c"Feb\00", [4 x i8] c"Mrz\00", [4 x i8] c"Apr\00", [4 x i8] c"Mai\00", [4 x i8] c"Jun\00", [4 x i8] c"Jul\00", [4 x i8] c"Aug\00", [4 x i8] c"Sep\00", [4 x i8] c"Okt\00", [4 x i8] c"Nov\00", [4 x i8] c"Dez\00", [4 x i8] c"Jan\00", [4 x i8] c"Fev\00", [4 x i8] c"Mar\00", [4 x i8] c"Avr\00", [4 x i8] c"Mai\00", [4 x i8] c"Jun\00", [4 x i8] c"Jul\00", [4 x i8] c"Aou\00", [4 x i8] c"Sep\00", [4 x i8] c"Oct\00", [4 x i8] c"Nov\00", [4 x i8] c"Dec\00"], [48 x [4 x i8]] [[4 x i8] c"N\00\00\00", [4 x i8] c"NNE\00", [4 x i8] c"NE\00\00", [4 x i8] c"ENE\00", [4 x i8] c"E\00\00\00", [4 x i8] c"ESE\00", [4 x i8] c"SE\00\00", [4 x i8] c"SSE\00", [4 x i8] c"S\00\00\00", [4 x i8] c"SSW\00", [4 x i8] c"SW\00\00", [4 x i8] c"WSW\00", [4 x i8] c"W\00\00\00", [4 x i8] c"WNW\00", [4 x i8] c"NW\00\00", [4 x i8] c"NNW\00", [4 x i8] c"N\00\00\00", [4 x i8] c"NNO\00", [4 x i8] c"NO\00\00", [4 x i8] c"ONO\00", [4 x i8] c"O\00\00\00", [4 x i8] c"OSO\00", [4 x i8] c"SO\00\00", [4 x i8] c"SSO\00", [4 x i8] c"S\00\00\00", [4 x i8] c"SSW\00", [4 x i8] c"SW\00\00", [4 x i8] c"WSW\00", [4 x i8] c"W\00\00\00", [4 x i8] c"WNW\00", [4 x i8] c"NW\00\00", [4 x i8] c"NNW\00", [4 x i8] c"N\00\00\00", [4 x i8] c"NNO\00", [4 x i8] c"NO\00\00", [4 x i8] c"ONO\00", [4 x i8] c"O\00\00\00", [4 x i8] c"OSO\00", [4 x i8] c"SO\00\00", [4 x i8] c"SSO\00", [4 x i8] c"S\00\00\00", [4 x i8] c"SSW\00", [4 x i8] c"SW\00\00", [4 x i8] c"WSW\00", [4 x i8] c"W\00\00\00", [4 x i8] c"WNW\00", [4 x i8] c"NW\00\00", [4 x i8] c"NNW\00"] } -@__CONSTANTS_LANGUAGE__init = unnamed_addr constant %CONSTANTS_LANGUAGE { i16 1, i16 3, [21 x [11 x i8]] [[11 x i8] c"Monday\00\00\00\00\00", [11 x i8] c"Tuesday\00\00\00\00", [11 x i8] c"Wednesday\00\00", [11 x i8] c"Thursday\00\00\00", [11 x i8] c"Friday\00\00\00\00\00", [11 x i8] c"Saturday\00\00\00", [11 x i8] c"Sunday\00\00\00\00\00", [11 x i8] c"Montag\00\00\00\00\00", [11 x i8] c"Dienstag\00\00\00", [11 x i8] c"Mittwoch\00\00\00", [11 x i8] c"Donnerstag\00", [11 x i8] c"Freitag\00\00\00\00", [11 x i8] c"Samstag\00\00\00\00", [11 x i8] c"Sonntag\00\00\00\00", [11 x i8] c"Lundi\00\00\00\00\00\00", [11 x i8] c"Mardi\00\00\00\00\00\00", [11 x i8] c"Mercredi\00\00\00", [11 x i8] c"Jeudi\00\00\00\00\00\00", [11 x i8] c"Vendredi\00\00\00", [11 x i8] c"Samedi\00\00\00\00\00", [11 x i8] c"Dimanche\00\00\00"], [21 x [3 x i8]] [[3 x i8] c"Mo\00", [3 x i8] c"Tu\00", [3 x i8] c"We\00", [3 x i8] c"Th\00", [3 x i8] c"Fr\00", [3 x i8] c"Sa\00", [3 x i8] c"Su\00", [3 x i8] c"Mo\00", [3 x i8] c"Di\00", [3 x i8] c"Mi\00", [3 x i8] c"Do\00", [3 x i8] c"Fr\00", [3 x i8] c"Sa\00", [3 x i8] c"So\00", [3 x i8] c"Lu\00", [3 x i8] c"Ma\00", [3 x i8] c"Me\00", [3 x i8] c"Je\00", [3 x i8] c"Ve\00", [3 x i8] c"Sa\00", [3 x i8] c"Di\00"], [36 x [11 x i8]] [[11 x i8] c"January\00\00\00\00", [11 x i8] c"February\00\00\00", [11 x i8] c"March\00\00\00\00\00\00", [11 x i8] c"April\00\00\00\00\00\00", [11 x i8] c"May\00\00\00\00\00\00\00\00", [11 x i8] c"June\00\00\00\00\00\00\00", [11 x i8] c"July\00\00\00\00\00\00\00", [11 x i8] c"August\00\00\00\00\00", [11 x i8] c"September\00\00", [11 x i8] c"October\00\00\00\00", [11 x i8] c"November\00\00\00", [11 x i8] c"December\00\00\00", [11 x i8] c"Januar\00\00\00\00\00", [11 x i8] c"Februar\00\00\00\00", [11 x i8] c"M\EF\BF\BDrz\00\00\00\00\00", [11 x i8] c"April\00\00\00\00\00\00", [11 x i8] c"Mai\00\00\00\00\00\00\00\00", [11 x i8] c"Juni\00\00\00\00\00\00\00", [11 x i8] c"Juli\00\00\00\00\00\00\00", [11 x i8] c"August\00\00\00\00\00", [11 x i8] c"September\00\00", [11 x i8] c"Oktober\00\00\00\00", [11 x i8] c"November\00\00\00", [11 x i8] c"Dezember\00\00\00", [11 x i8] c"Janvier\00\00\00\00", [11 x i8] c"F\EF\BF\BDvrier\00\00", [11 x i8] c"mars\00\00\00\00\00\00\00", [11 x i8] c"Avril\00\00\00\00\00\00", [11 x i8] c"Mai\00\00\00\00\00\00\00\00", [11 x i8] c"Juin\00\00\00\00\00\00\00", [11 x i8] c"Juillet\00\00\00\00", [11 x i8] c"Ao\EF\BF\BDt\00\00\00\00\00", [11 x i8] c"Septembre\00\00", [11 x i8] c"Octobre\00\00\00\00", [11 x i8] c"Novembre\00\00\00", [11 x i8] c"Decembre\00\00\00"], [36 x [4 x i8]] [[4 x i8] c"Jan\00", [4 x i8] c"Feb\00", [4 x i8] c"Mar\00", [4 x i8] c"Apr\00", [4 x i8] c"May\00", [4 x i8] c"Jun\00", [4 x i8] c"Jul\00", [4 x i8] c"Aug\00", [4 x i8] c"Sep\00", [4 x i8] c"Oct\00", [4 x i8] c"Nov\00", [4 x i8] c"Dec\00", [4 x i8] c"Jan\00", [4 x i8] c"Feb\00", [4 x i8] c"Mrz\00", [4 x i8] c"Apr\00", [4 x i8] c"Mai\00", [4 x i8] c"Jun\00", [4 x i8] c"Jul\00", [4 x i8] c"Aug\00", [4 x i8] c"Sep\00", [4 x i8] c"Okt\00", [4 x i8] c"Nov\00", [4 x i8] c"Dez\00", [4 x i8] c"Jan\00", [4 x i8] c"Fev\00", [4 x i8] c"Mar\00", [4 x i8] c"Avr\00", [4 x i8] c"Mai\00", [4 x i8] c"Jun\00", [4 x i8] c"Jul\00", [4 x i8] c"Aou\00", [4 x i8] c"Sep\00", [4 x i8] c"Oct\00", [4 x i8] c"Nov\00", [4 x i8] c"Dec\00"], [48 x [4 x i8]] [[4 x i8] c"N\00\00\00", [4 x i8] c"NNE\00", [4 x i8] c"NE\00\00", [4 x i8] c"ENE\00", [4 x i8] c"E\00\00\00", [4 x i8] c"ESE\00", [4 x i8] c"SE\00\00", [4 x i8] c"SSE\00", [4 x i8] c"S\00\00\00", [4 x i8] c"SSW\00", [4 x i8] c"SW\00\00", [4 x i8] c"WSW\00", [4 x i8] c"W\00\00\00", [4 x i8] c"WNW\00", [4 x i8] c"NW\00\00", [4 x i8] c"NNW\00", [4 x i8] c"N\00\00\00", [4 x i8] c"NNO\00", [4 x i8] c"NO\00\00", [4 x i8] c"ONO\00", [4 x i8] c"O\00\00\00", [4 x i8] c"OSO\00", [4 x i8] c"SO\00\00", [4 x i8] c"SSO\00", [4 x i8] c"S\00\00\00", [4 x i8] c"SSW\00", [4 x i8] c"SW\00\00", [4 x i8] c"WSW\00", [4 x i8] c"W\00\00\00", [4 x i8] c"WNW\00", [4 x i8] c"NW\00\00", [4 x i8] c"NNW\00", [4 x i8] c"N\00\00\00", [4 x i8] c"NNO\00", [4 x i8] c"NO\00\00", [4 x i8] c"ONO\00", [4 x i8] c"O\00\00\00", [4 x i8] c"OSO\00", [4 x i8] c"SO\00\00", [4 x i8] c"SSO\00", [4 x i8] c"S\00\00\00", [4 x i8] c"SSW\00", [4 x i8] c"SW\00\00", [4 x i8] c"WSW\00", [4 x i8] c"W\00\00\00", [4 x i8] c"WNW\00", [4 x i8] c"NW\00\00", [4 x i8] c"NNW\00"] } +@x = global %CONSTANTS_LANGUAGE { i16 1, i16 3, [21 x [11 x i8]] [[11 x i8] c"Monday\00\00\00\00\00", [11 x i8] c"Tuesday\00\00\00\00", [11 x i8] c"Wednesday\00\00", [11 x i8] c"Thursday\00\00\00", [11 x i8] c"Friday\00\00\00\00\00", [11 x i8] c"Saturday\00\00\00", [11 x i8] c"Sunday\00\00\00\00\00", [11 x i8] c"Montag\00\00\00\00\00", [11 x i8] c"Dienstag\00\00\00", [11 x i8] c"Mittwoch\00\00\00", [11 x i8] c"Donnerstag\00", [11 x i8] c"Freitag\00\00\00\00", [11 x i8] c"Samstag\00\00\00\00", [11 x i8] c"Sonntag\00\00\00\00", [11 x i8] c"Lundi\00\00\00\00\00\00", [11 x i8] c"Mardi\00\00\00\00\00\00", [11 x i8] c"Mercredi\00\00\00", [11 x i8] c"Jeudi\00\00\00\00\00\00", [11 x i8] c"Vendredi\00\00\00", [11 x i8] c"Samedi\00\00\00\00\00", [11 x i8] c"Dimanche\00\00\00"], [21 x [3 x i8]] [[3 x i8] c"Mo\00", [3 x i8] c"Tu\00", [3 x i8] c"We\00", [3 x i8] c"Th\00", [3 x i8] c"Fr\00", [3 x i8] c"Sa\00", [3 x i8] c"Su\00", [3 x i8] c"Mo\00", [3 x i8] c"Di\00", [3 x i8] c"Mi\00", [3 x i8] c"Do\00", [3 x i8] c"Fr\00", [3 x i8] c"Sa\00", [3 x i8] c"So\00", [3 x i8] c"Lu\00", [3 x i8] c"Ma\00", [3 x i8] c"Me\00", [3 x i8] c"Je\00", [3 x i8] c"Ve\00", [3 x i8] c"Sa\00", [3 x i8] c"Di\00"], [36 x [11 x i8]] [[11 x i8] c"January\00\00\00\00", [11 x i8] c"February\00\00\00", [11 x i8] c"March\00\00\00\00\00\00", [11 x i8] c"April\00\00\00\00\00\00", [11 x i8] c"May\00\00\00\00\00\00\00\00", [11 x i8] c"June\00\00\00\00\00\00\00", [11 x i8] c"July\00\00\00\00\00\00\00", [11 x i8] c"August\00\00\00\00\00", [11 x i8] c"September\00\00", [11 x i8] c"October\00\00\00\00", [11 x i8] c"November\00\00\00", [11 x i8] c"December\00\00\00", [11 x i8] c"Januar\00\00\00\00\00", [11 x i8] c"Februar\00\00\00\00", [11 x i8] c"M\C3\A4rz\00\00\00\00\00\00", [11 x i8] c"April\00\00\00\00\00\00", [11 x i8] c"Mai\00\00\00\00\00\00\00\00", [11 x i8] c"Juni\00\00\00\00\00\00\00", [11 x i8] c"Juli\00\00\00\00\00\00\00", [11 x i8] c"August\00\00\00\00\00", [11 x i8] c"September\00\00", [11 x i8] c"Oktober\00\00\00\00", [11 x i8] c"November\00\00\00", [11 x i8] c"Dezember\00\00\00", [11 x i8] c"Janvier\00\00\00\00", [11 x i8] c"F\C3\A9vrier\00\00\00", [11 x i8] c"mars\00\00\00\00\00\00\00", [11 x i8] c"Avril\00\00\00\00\00\00", [11 x i8] c"Mai\00\00\00\00\00\00\00\00", [11 x i8] c"Juin\00\00\00\00\00\00\00", [11 x i8] c"Juillet\00\00\00\00", [11 x i8] c"Ao\C3\BBt\00\00\00\00\00\00", [11 x i8] c"Septembre\00\00", [11 x i8] c"Octobre\00\00\00\00", [11 x i8] c"Novembre\00\00\00", [11 x i8] c"Decembre\00\00\00"], [36 x [4 x i8]] [[4 x i8] c"Jan\00", [4 x i8] c"Feb\00", [4 x i8] c"Mar\00", [4 x i8] c"Apr\00", [4 x i8] c"May\00", [4 x i8] c"Jun\00", [4 x i8] c"Jul\00", [4 x i8] c"Aug\00", [4 x i8] c"Sep\00", [4 x i8] c"Oct\00", [4 x i8] c"Nov\00", [4 x i8] c"Dec\00", [4 x i8] c"Jan\00", [4 x i8] c"Feb\00", [4 x i8] c"Mrz\00", [4 x i8] c"Apr\00", [4 x i8] c"Mai\00", [4 x i8] c"Jun\00", [4 x i8] c"Jul\00", [4 x i8] c"Aug\00", [4 x i8] c"Sep\00", [4 x i8] c"Okt\00", [4 x i8] c"Nov\00", [4 x i8] c"Dez\00", [4 x i8] c"Jan\00", [4 x i8] c"Fev\00", [4 x i8] c"Mar\00", [4 x i8] c"Avr\00", [4 x i8] c"Mai\00", [4 x i8] c"Jun\00", [4 x i8] c"Jul\00", [4 x i8] c"Aou\00", [4 x i8] c"Sep\00", [4 x i8] c"Oct\00", [4 x i8] c"Nov\00", [4 x i8] c"Dec\00"], [48 x [4 x i8]] [[4 x i8] c"N\00\00\00", [4 x i8] c"NNE\00", [4 x i8] c"NE\00\00", [4 x i8] c"ENE\00", [4 x i8] c"E\00\00\00", [4 x i8] c"ESE\00", [4 x i8] c"SE\00\00", [4 x i8] c"SSE\00", [4 x i8] c"S\00\00\00", [4 x i8] c"SSW\00", [4 x i8] c"SW\00\00", [4 x i8] c"WSW\00", [4 x i8] c"W\00\00\00", [4 x i8] c"WNW\00", [4 x i8] c"NW\00\00", [4 x i8] c"NNW\00", [4 x i8] c"N\00\00\00", [4 x i8] c"NNO\00", [4 x i8] c"NO\00\00", [4 x i8] c"ONO\00", [4 x i8] c"O\00\00\00", [4 x i8] c"OSO\00", [4 x i8] c"SO\00\00", [4 x i8] c"SSO\00", [4 x i8] c"S\00\00\00", [4 x i8] c"SSW\00", [4 x i8] c"SW\00\00", [4 x i8] c"WSW\00", [4 x i8] c"W\00\00\00", [4 x i8] c"WNW\00", [4 x i8] c"NW\00\00", [4 x i8] c"NNW\00", [4 x i8] c"N\00\00\00", [4 x i8] c"NNO\00", [4 x i8] c"NO\00\00", [4 x i8] c"ONO\00", [4 x i8] c"O\00\00\00", [4 x i8] c"OSO\00", [4 x i8] c"SO\00\00", [4 x i8] c"SSO\00", [4 x i8] c"S\00\00\00", [4 x i8] c"SSW\00", [4 x i8] c"SW\00\00", [4 x i8] c"WSW\00", [4 x i8] c"W\00\00\00", [4 x i8] c"WNW\00", [4 x i8] c"NW\00\00", [4 x i8] c"NNW\00"] } +@__CONSTANTS_LANGUAGE__init = unnamed_addr constant %CONSTANTS_LANGUAGE { i16 1, i16 3, [21 x [11 x i8]] [[11 x i8] c"Monday\00\00\00\00\00", [11 x i8] c"Tuesday\00\00\00\00", [11 x i8] c"Wednesday\00\00", [11 x i8] c"Thursday\00\00\00", [11 x i8] c"Friday\00\00\00\00\00", [11 x i8] c"Saturday\00\00\00", [11 x i8] c"Sunday\00\00\00\00\00", [11 x i8] c"Montag\00\00\00\00\00", [11 x i8] c"Dienstag\00\00\00", [11 x i8] c"Mittwoch\00\00\00", [11 x i8] c"Donnerstag\00", [11 x i8] c"Freitag\00\00\00\00", [11 x i8] c"Samstag\00\00\00\00", [11 x i8] c"Sonntag\00\00\00\00", [11 x i8] c"Lundi\00\00\00\00\00\00", [11 x i8] c"Mardi\00\00\00\00\00\00", [11 x i8] c"Mercredi\00\00\00", [11 x i8] c"Jeudi\00\00\00\00\00\00", [11 x i8] c"Vendredi\00\00\00", [11 x i8] c"Samedi\00\00\00\00\00", [11 x i8] c"Dimanche\00\00\00"], [21 x [3 x i8]] [[3 x i8] c"Mo\00", [3 x i8] c"Tu\00", [3 x i8] c"We\00", [3 x i8] c"Th\00", [3 x i8] c"Fr\00", [3 x i8] c"Sa\00", [3 x i8] c"Su\00", [3 x i8] c"Mo\00", [3 x i8] c"Di\00", [3 x i8] c"Mi\00", [3 x i8] c"Do\00", [3 x i8] c"Fr\00", [3 x i8] c"Sa\00", [3 x i8] c"So\00", [3 x i8] c"Lu\00", [3 x i8] c"Ma\00", [3 x i8] c"Me\00", [3 x i8] c"Je\00", [3 x i8] c"Ve\00", [3 x i8] c"Sa\00", [3 x i8] c"Di\00"], [36 x [11 x i8]] [[11 x i8] c"January\00\00\00\00", [11 x i8] c"February\00\00\00", [11 x i8] c"March\00\00\00\00\00\00", [11 x i8] c"April\00\00\00\00\00\00", [11 x i8] c"May\00\00\00\00\00\00\00\00", [11 x i8] c"June\00\00\00\00\00\00\00", [11 x i8] c"July\00\00\00\00\00\00\00", [11 x i8] c"August\00\00\00\00\00", [11 x i8] c"September\00\00", [11 x i8] c"October\00\00\00\00", [11 x i8] c"November\00\00\00", [11 x i8] c"December\00\00\00", [11 x i8] c"Januar\00\00\00\00\00", [11 x i8] c"Februar\00\00\00\00", [11 x i8] c"M\C3\A4rz\00\00\00\00\00\00", [11 x i8] c"April\00\00\00\00\00\00", [11 x i8] c"Mai\00\00\00\00\00\00\00\00", [11 x i8] c"Juni\00\00\00\00\00\00\00", [11 x i8] c"Juli\00\00\00\00\00\00\00", [11 x i8] c"August\00\00\00\00\00", [11 x i8] c"September\00\00", [11 x i8] c"Oktober\00\00\00\00", [11 x i8] c"November\00\00\00", [11 x i8] c"Dezember\00\00\00", [11 x i8] c"Janvier\00\00\00\00", [11 x i8] c"F\C3\A9vrier\00\00\00", [11 x i8] c"mars\00\00\00\00\00\00\00", [11 x i8] c"Avril\00\00\00\00\00\00", [11 x i8] c"Mai\00\00\00\00\00\00\00\00", [11 x i8] c"Juin\00\00\00\00\00\00\00", [11 x i8] c"Juillet\00\00\00\00", [11 x i8] c"Ao\C3\BBt\00\00\00\00\00\00", [11 x i8] c"Septembre\00\00", [11 x i8] c"Octobre\00\00\00\00", [11 x i8] c"Novembre\00\00\00", [11 x i8] c"Decembre\00\00\00"], [36 x [4 x i8]] [[4 x i8] c"Jan\00", [4 x i8] c"Feb\00", [4 x i8] c"Mar\00", [4 x i8] c"Apr\00", [4 x i8] c"May\00", [4 x i8] c"Jun\00", [4 x i8] c"Jul\00", [4 x i8] c"Aug\00", [4 x i8] c"Sep\00", [4 x i8] c"Oct\00", [4 x i8] c"Nov\00", [4 x i8] c"Dec\00", [4 x i8] c"Jan\00", [4 x i8] c"Feb\00", [4 x i8] c"Mrz\00", [4 x i8] c"Apr\00", [4 x i8] c"Mai\00", [4 x i8] c"Jun\00", [4 x i8] c"Jul\00", [4 x i8] c"Aug\00", [4 x i8] c"Sep\00", [4 x i8] c"Okt\00", [4 x i8] c"Nov\00", [4 x i8] c"Dez\00", [4 x i8] c"Jan\00", [4 x i8] c"Fev\00", [4 x i8] c"Mar\00", [4 x i8] c"Avr\00", [4 x i8] c"Mai\00", [4 x i8] c"Jun\00", [4 x i8] c"Jul\00", [4 x i8] c"Aou\00", [4 x i8] c"Sep\00", [4 x i8] c"Oct\00", [4 x i8] c"Nov\00", [4 x i8] c"Dec\00"], [48 x [4 x i8]] [[4 x i8] c"N\00\00\00", [4 x i8] c"NNE\00", [4 x i8] c"NE\00\00", [4 x i8] c"ENE\00", [4 x i8] c"E\00\00\00", [4 x i8] c"ESE\00", [4 x i8] c"SE\00\00", [4 x i8] c"SSE\00", [4 x i8] c"S\00\00\00", [4 x i8] c"SSW\00", [4 x i8] c"SW\00\00", [4 x i8] c"WSW\00", [4 x i8] c"W\00\00\00", [4 x i8] c"WNW\00", [4 x i8] c"NW\00\00", [4 x i8] c"NNW\00", [4 x i8] c"N\00\00\00", [4 x i8] c"NNO\00", [4 x i8] c"NO\00\00", [4 x i8] c"ONO\00", [4 x i8] c"O\00\00\00", [4 x i8] c"OSO\00", [4 x i8] c"SO\00\00", [4 x i8] c"SSO\00", [4 x i8] c"S\00\00\00", [4 x i8] c"SSW\00", [4 x i8] c"SW\00\00", [4 x i8] c"WSW\00", [4 x i8] c"W\00\00\00", [4 x i8] c"WNW\00", [4 x i8] c"NW\00\00", [4 x i8] c"NNW\00", [4 x i8] c"N\00\00\00", [4 x i8] c"NNO\00", [4 x i8] c"NO\00\00", [4 x i8] c"ONO\00", [4 x i8] c"O\00\00\00", [4 x i8] c"OSO\00", [4 x i8] c"SO\00\00", [4 x i8] c"SSO\00", [4 x i8] c"S\00\00\00", [4 x i8] c"SSW\00", [4 x i8] c"SW\00\00", [4 x i8] c"WSW\00", [4 x i8] c"W\00\00\00", [4 x i8] c"WNW\00", [4 x i8] c"NW\00\00", [4 x i8] c"NNW\00"] } diff --git a/src/codegen/tests/string_tests.rs b/src/codegen/tests/string_tests.rs index e86cc42735..b1361d5a14 100644 --- a/src/codegen/tests/string_tests.rs +++ b/src/codegen/tests/string_tests.rs @@ -13,7 +13,7 @@ PROGRAM prg y : STRING[15]; z : STRING[30] := 'xyz'; END_VAR - + y := z; z := y; END_PROGRAM @@ -58,7 +58,7 @@ PROGRAM prg y : STRING[15]; z : STRING[30] := 'xyz'; END_VAR - + END_PROGRAM ", ); @@ -90,9 +90,9 @@ VAR END_VAR // cast a WSTRING to a STRING -y := STRING#"im a genius"; +y := STRING#"im a genius"; // cast a STRING to a WSTRING -z := WSTRING#'im a utf16 genius'; +z := WSTRING#'im a utf16 genius'; END_PROGRAM "#, ); @@ -106,7 +106,7 @@ fn generate_with_invalid_casted_string_assignment() { VAR y : INT; END_VAR -y := INT#"seven"; +y := INT#"seven"; END_PROGRAM "#, ) @@ -206,10 +206,10 @@ fn variable_length_strings_using_constants_can_be_created() { let result = codegen( r#" VAR_GLOBAL CONSTANT - LONG_STRING : INT := 15; - SHORT_STRING : INT := 3; + LONG_STRING : INT := 15; + SHORT_STRING : INT := 3; END_VAR - + PROGRAM prg VAR y : STRING[LONG_STRING]; @@ -236,19 +236,19 @@ fn nested_struct_initialization_of_multi_dim_string_arrays() { (* Language Setup *) DEFAULT : INT := 1; (* 1=english, 2=german 3=french *) LMAX : INT := 3; - WEEKDAYS : ARRAY[1..3, 1..7] OF STRING[10] := ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday', + WEEKDAYS : ARRAY[1..3, 1..7] OF STRING[10] := ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday', 'Montag', 'Dienstag', 'Mittwoch', 'Donnerstag', 'Freitag', 'Samstag', 'Sonntag', 'Lundi', 'Mardi', 'Mercredi', 'Jeudi', 'Vendredi', 'Samedi', 'Dimanche']; - WEEKDAYS2 : ARRAY[1..3, 1..7] OF STRING[2] := ['Mo', 'Tu', 'We', 'Th', 'Fr', 'Sa', 'Su', + WEEKDAYS2 : ARRAY[1..3, 1..7] OF STRING[2] := ['Mo', 'Tu', 'We', 'Th', 'Fr', 'Sa', 'Su', 'Mo', 'Di', 'Mi', 'Do', 'Fr', 'Sa', 'So', 'Lu', 'Ma', 'Me', 'Je', 'Ve', 'Sa', 'Di']; - MONTHS : ARRAY[1..3, 1..12] OF STRING[10] := ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December', - 'Januar', 'Februar', 'M�rz', 'April', 'Mai', 'Juni', 'Juli', 'August', 'September', 'Oktober', 'November', 'Dezember', - 'Janvier', 'F�vrier', 'mars', 'Avril', 'Mai', 'Juin', 'Juillet', 'Ao�t', 'Septembre', 'Octobre', 'Novembre', 'Decembre']; - MONTHS3 : ARRAY[1..3, 1..12] OF STRING[3] := ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec', + MONTHS : ARRAY[1..3, 1..12] OF STRING[10] := ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December', + 'Januar', 'Februar', 'März', 'April', 'Mai', 'Juni', 'Juli', 'August', 'September', 'Oktober', 'November', 'Dezember', + 'Janvier', 'Février', 'mars', 'Avril', 'Mai', 'Juin', 'Juillet', 'Août', 'Septembre', 'Octobre', 'Novembre', 'Decembre']; + MONTHS3 : ARRAY[1..3, 1..12] OF STRING[3] := ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec', 'Jan', 'Feb', 'Mrz', 'Apr', 'Mai', 'Jun', 'Jul', 'Aug', 'Sep', 'Okt', 'Nov', 'Dez', 'Jan', 'Fev', 'Mar', 'Avr', 'Mai', 'Jun', 'Jul', 'Aou', 'Sep', 'Oct', 'Nov', 'Dec']; - DIRS : ARRAY[1..3,0..15] OF STRING[3] := ['N', 'NNE', 'NE', 'ENE', 'E', 'ESE', 'SE', 'SSE', 'S', 'SSW', 'SW', 'WSW', 'W', 'WNW', 'NW', 'NNW', + DIRS : ARRAY[1..3,0..15] OF STRING[3] := ['N', 'NNE', 'NE', 'ENE', 'E', 'ESE', 'SE', 'SSE', 'S', 'SSW', 'SW', 'WSW', 'W', 'WNW', 'NW', 'NNW', 'N', 'NNO', 'NO', 'ONO', 'O', 'OSO', 'SO', 'SSO', 'S', 'SSW', 'SW', 'WSW', 'W', 'WNW', 'NW', 'NNW', 'N', 'NNO', 'NO', 'ONO', 'O', 'OSO', 'SO', 'SSO', 'S', 'SSW', 'SW', 'WSW', 'W', 'WNW', 'NW', 'NNW']; END_STRUCT @@ -268,7 +268,7 @@ fn string_function_parameters() { VAR_INPUT s : STRING; END_VAR - + RETURN 0; END_PROGRAM @@ -296,21 +296,21 @@ fn program_string_output() { // GIVEN PROGRAM returning strings let result = codegen( r#" - PROGRAM prog - VAR_OUTPUT - output1 : STRING; - output2 : WSTRING; - END_VAR - output1 := 'string'; - output2 := "wstring"; - END_PROGRAM + PROGRAM prog + VAR_OUTPUT + output1 : STRING; + output2 : WSTRING; + END_VAR + output1 := 'string'; + output2 := "wstring"; + END_PROGRAM PROGRAM main - VAR - x : STRING[6]; - y : WSTRING[7]; - END_VAR - prog(x, y); + VAR + x : STRING[6]; + y : WSTRING[7]; + END_VAR + prog(x, y); END_PROGRAM "#, ); diff --git a/src/codegen/tests/switch_case_tests.rs b/src/codegen/tests/switch_case_tests.rs index 86566cf595..8ba6841ca0 100644 --- a/src/codegen/tests/switch_case_tests.rs +++ b/src/codegen/tests/switch_case_tests.rs @@ -25,18 +25,18 @@ For non const variable references we need our own validation tests -> statement_ fn switch_case_duplicate_integer_literal_integer() { let result = codegen_without_unwrap( r#" - PROGRAM mainProg - VAR - input, res : DINT; - END_VAR - CASE input OF - 2: - res := 1; - 2: - res := 2; - END_CASE - END_PROGRAM - "#, + PROGRAM mainProg + VAR + input, res : DINT; + END_VAR + CASE input OF + 2: + res := 1; + 2: + res := 2; + END_CASE + END_PROGRAM + "#, ); if let Err(msg) = result { assert_eq!( @@ -55,22 +55,22 @@ fn switch_case_duplicate_integer_literal_integer() { fn switch_case_duplicate_integer_literal_integer_and_const() { let result = codegen_without_unwrap( r#" - VAR_GLOBAL CONSTANT - GLOB : DINT := 2; - END_VAR + VAR_GLOBAL CONSTANT + GLOB : DINT := 2; + END_VAR - PROGRAM mainProg - VAR - input, res : DINT; - END_VAR - CASE input OF - 2: - res := 1; - GLOB: - res := 2; - END_CASE - END_PROGRAM - "#, + PROGRAM mainProg + VAR + input, res : DINT; + END_VAR + CASE input OF + 2: + res := 1; + GLOB: + res := 2; + END_CASE + END_PROGRAM + "#, ); if let Err(msg) = result { assert_eq!( @@ -89,18 +89,18 @@ fn switch_case_duplicate_integer_literal_integer_and_const() { fn switch_case_duplicate_integer_literal_integer_and_binary_expression() { let result = codegen_without_unwrap( r#" - PROGRAM mainProg - VAR - input, res : DINT; - END_VAR - CASE input OF - 2: - res := 1; - 1*2: - res := 2; - END_CASE - END_PROGRAM - "#, + PROGRAM mainProg + VAR + input, res : DINT; + END_VAR + CASE input OF + 2: + res := 1; + 1*2: + res := 2; + END_CASE + END_PROGRAM + "#, ); if let Err(msg) = result { assert_eq!( @@ -119,24 +119,24 @@ fn switch_case_duplicate_integer_literal_integer_and_binary_expression() { fn switch_case_duplicate_integer_const() { let result = codegen_without_unwrap( r#" - VAR_GLOBAL CONSTANT - GLOB : DINT := 2; - END_VAR + VAR_GLOBAL CONSTANT + GLOB : DINT := 2; + END_VAR - TYPE myType: ( BASE := GLOB ); END_TYPE + TYPE myType: ( BASE := GLOB ); END_TYPE - PROGRAM mainProg - VAR - input, res : DINT; - END_VAR - CASE input OF - GLOB: - res := 1; - BASE: - res := 2; - END_CASE - END_PROGRAM - "#, + PROGRAM mainProg + VAR + input, res : DINT; + END_VAR + CASE input OF + GLOB: + res := 1; + BASE: + res := 2; + END_CASE + END_PROGRAM + "#, ); if let Err(msg) = result { assert_eq!( @@ -155,22 +155,22 @@ fn switch_case_duplicate_integer_const() { fn switch_case_duplicate_integer_const_and_binary_expression() { let result = codegen_without_unwrap( r#" - VAR_GLOBAL CONSTANT - GLOB : DINT := 2; - END_VAR + VAR_GLOBAL CONSTANT + GLOB : DINT := 2; + END_VAR - PROGRAM mainProg - VAR - input, res : DINT; - END_VAR - CASE input OF - GLOB: - res := 1; - 1*2: - res := 2; - END_CASE - END_PROGRAM - "#, + PROGRAM mainProg + VAR + input, res : DINT; + END_VAR + CASE input OF + GLOB: + res := 1; + 1*2: + res := 2; + END_CASE + END_PROGRAM + "#, ); if let Err(msg) = result { assert_eq!( @@ -189,18 +189,18 @@ fn switch_case_duplicate_integer_const_and_binary_expression() { fn switch_case_duplicate_integer_binary_expression() { let result = codegen_without_unwrap( r#" - PROGRAM mainProg - VAR - input, res : DINT; - END_VAR - CASE input OF - 1*2: - res := 1; - 1+1: - res := 2; - END_CASE - END_PROGRAM - "#, + PROGRAM mainProg + VAR + input, res : DINT; + END_VAR + CASE input OF + 1*2: + res := 1; + 1+1: + res := 2; + END_CASE + END_PROGRAM + "#, ); if let Err(msg) = result { assert_eq!( diff --git a/src/codegen/tests/typesystem_test.rs b/src/codegen/tests/typesystem_test.rs index 98b2412693..0f3c62f914 100644 --- a/src/codegen/tests/typesystem_test.rs +++ b/src/codegen/tests/typesystem_test.rs @@ -258,7 +258,7 @@ fn int_bigger_than_byte_promoted_on_compare_statement() { #[test] fn numerical_promotion_for_variadic_functions_without_declaration() { let src = r#" - {external} + {external} FUNCTION printf : DINT VAR_IN_OUT format: STRING; @@ -268,7 +268,7 @@ fn numerical_promotion_for_variadic_functions_without_declaration() { END_VAR END_FUNCTION - PROGRAM main + PROGRAM main VAR_TEMP s: STRING := '$N numbers: %f %f %f %d $N $N'; float: REAL := 3.0; @@ -286,7 +286,7 @@ fn numerical_promotion_for_variadic_functions_without_declaration() { #[test] fn small_int_varargs_get_promoted_while_32bit_and_higher_keep_their_type() { let src = r#" - {external} + {external} FUNCTION printf : DINT VAR_IN_OUT format: STRING; diff --git a/src/index.rs b/src/index.rs index a5db5a43a6..a64a5f2a72 100644 --- a/src/index.rs +++ b/src/index.rs @@ -1248,7 +1248,7 @@ impl Index { self.get_const_expressions().maybe_get_constant_statement(id) } - /// returns type aliased by Alias or SubRange + /// returns type aliased by Alias or SubRange fn get_aliased_target_type(&self, dt: &DataTypeInformation) -> Option<&DataType> { match dt { DataTypeInformation::SubRange { referenced_type, .. } diff --git a/src/index/tests/index_tests.rs b/src/index/tests/index_tests.rs index f1cfbdbd96..fdcdc3fa95 100644 --- a/src/index/tests/index_tests.rs +++ b/src/index/tests/index_tests.rs @@ -25,7 +25,7 @@ fn index_not_case_sensitive() { VAR_GLOBAL a: INT; - x : ST; + x : ST; END_VAR FUNCTION foo : INT END_FUNCTION @@ -246,13 +246,13 @@ fn pous_are_indexed() { r#" PROGRAM myProgram END_PROGRAM - + FUNCTION myFunction : INT END_FUNCTION - + FUNCTION_BLOCK myFunctionBlock : INT END_FUNCTION_BLOCK - + CLASS myClass END_CLASS @@ -411,7 +411,7 @@ fn index_can_be_retrieved_from_qualified_name() { fb2_inst : fb2; END_VAR END_FUNCTION_BLOCK - + FUNCTION_BLOCK fb2 VAR_INPUT fb3_inst : fb3; @@ -448,7 +448,7 @@ fn callable_instances_can_be_retreived() { fb2_inst : fb2; END_VAR END_FUNCTION_BLOCK - + FUNCTION_BLOCK fb2 VAR_INPUT fb3_inst : fb3; @@ -779,11 +779,11 @@ fn pre_processing_generates_array_of_array_type() { fn pre_processing_nested_array_in_struct() { let src = r#" TYPE MyStruct: - STRUCT + STRUCT field1 : ARRAY[0..4] OF INT; END_STRUCT END_TYPE - + PROGRAM Main VAR m : MyStruct; @@ -916,8 +916,8 @@ fn pre_processing_generates_nested_generic_types() { fn sub_range_boundaries_are_registered_at_the_index() { // GIVEN a Subrange INT from 7 to 1000 let src = " - TYPE MyInt: INT(7..1000); END_TYPE - TYPE MyAliasInt: MyInt; END_TYPE + TYPE MyInt: INT(7..1000); END_TYPE + TYPE MyAliasInt: MyInt; END_TYPE "; // WHEN the program is indexed let (_, index) = index(src); @@ -1196,8 +1196,8 @@ fn function_name_equals_return_type() { // WHEN the function is indexed let (_, index) = index( " - FUNCTION TIME : TIME - END_FUNCTION", + FUNCTION TIME : TIME + END_FUNCTION", ); // THEN there should be a indexed pou_type @@ -1214,12 +1214,12 @@ fn global_vars_for_structs() { // WHEN the program is indexed let (_, index) = index( " - PROGRAM main - VAR - x : STRUCT var1 : INT; END_STRUCT - END_VAR - END_PROGRAM - ", + PROGRAM main + VAR + x : STRUCT var1 : INT; END_STRUCT + END_VAR + END_PROGRAM + ", ); // THEN there should be a global variable for the struct @@ -1233,15 +1233,15 @@ fn pointer_and_in_out_pointer_should_not_conflict() { // WHEN the program is indexed let (_, index) = index( " - PROGRAM main - VAR_INPUT - x : REF_TO INT; - END_VAR + PROGRAM main + VAR_INPUT + x : REF_TO INT; + END_VAR VAR_IN_OUT y : INT; END_VAR - END_PROGRAM - ", + END_PROGRAM + ", ); // THEN x and y whould be different pointer types @@ -1277,17 +1277,17 @@ fn pointer_and_in_out_pointer_should_not_conflict_2() { let id_provider = IdProvider::default(); let (result, mut index) = index_with_ids( " - PROGRAM main - VAR_INPUT - x : REF_TO INT; - END_VAR + PROGRAM main + VAR_INPUT + x : REF_TO INT; + END_VAR VAR_IN_OUT y : INT; END_VAR &y; //this will add another pointer_to_int type to the index (autoderef = false) - END_PROGRAM - ", + END_PROGRAM + ", id_provider.clone(), ); @@ -1422,18 +1422,18 @@ fn program_parameters_variable_type() { // WHEN the PROGRAM is indexed let (_, index) = index( " - PROGRAM main - VAR_INPUT - input1 : INT; - END_VAR - VAR_OUTPUT - output1 : INT; - END_VAR - VAR_IN_OUT - inout1 : INT; - END_VAR - END_PROGRAM - ", + PROGRAM main + VAR_INPUT + input1 : INT; + END_VAR + VAR_OUTPUT + output1 : INT; + END_VAR + VAR_IN_OUT + inout1 : INT; + END_VAR + END_PROGRAM + ", ); // THEN the parameters should have the correct VariableType @@ -1452,18 +1452,18 @@ fn fb_parameters_variable_type() { // WHEN the FB is indexed let (_, index) = index( " - FUNCTION_BLOCK fb - VAR_INPUT - input1 : INT; - END_VAR - VAR_OUTPUT - output1 : INT; - END_VAR - VAR_IN_OUT - inout1 : INT; - END_VAR - END_FUNCTION_BLOCK - ", + FUNCTION_BLOCK fb + VAR_INPUT + input1 : INT; + END_VAR + VAR_OUTPUT + output1 : INT; + END_VAR + VAR_IN_OUT + inout1 : INT; + END_VAR + END_FUNCTION_BLOCK + ", ); // THEN the parameters should have the correct VariableType @@ -1482,18 +1482,18 @@ fn function_parameters_variable_type() { // WHEN the FUNCTION is indexed let (_, index) = index( " - FUNCTION foo : INT - VAR_INPUT - input1 : INT; - END_VAR - VAR_OUTPUT - output1 : INT; - END_VAR - VAR_IN_OUT - inout1 : INT; - END_VAR - END_FUNCTION - ", + FUNCTION foo : INT + VAR_INPUT + input1 : INT; + END_VAR + VAR_OUTPUT + output1 : INT; + END_VAR + VAR_IN_OUT + inout1 : INT; + END_VAR + END_FUNCTION + ", ); // THEN the parameters should have the correct VariableType @@ -1513,18 +1513,18 @@ fn pou_duplicates_are_indexed() { // WHEN the code is indexed let (_, index) = index( " - PROGRAM foo - VAR_INPUT - input1 : INT; - END_VAR - END_PROGRAM - - PROGRAM foo - VAR_INPUT - input2 : INT; - END_VAR - END_PROGRAM - ", + PROGRAM foo + VAR_INPUT + input1 : INT; + END_VAR + END_PROGRAM + + PROGRAM foo + VAR_INPUT + input2 : INT; + END_VAR + END_PROGRAM + ", ); //THEN I expect both PouIndexEntries @@ -1543,20 +1543,20 @@ fn type_duplicates_are_indexed() { // WHEN the code is indexed let (_, index) = index( " - TYPE MyStruct: - STRUCT + TYPE MyStruct: + STRUCT field1 : INT; END_STRUCT END_TYPE - - TYPE MyStruct: - STRUCT + + TYPE MyStruct: + STRUCT field2 : INT; END_STRUCT END_TYPE - TYPE MyStruct: - STRUCT + TYPE MyStruct: + STRUCT field3 : INT; END_STRUCT END_TYPE diff --git a/src/index/tests/instance_resolver_tests.rs b/src/index/tests/instance_resolver_tests.rs index 24cef3d0f2..57ad7e907c 100644 --- a/src/index/tests/instance_resolver_tests.rs +++ b/src/index/tests/instance_resolver_tests.rs @@ -63,7 +63,7 @@ fn program_variables_are_retrieved() { fn global_struct_variables_are_retrieved() { let (_, index) = index( " - TYPE str : STRUCT + TYPE str : STRUCT a,b : DINT; END_STRUCT END_TYPE @@ -84,11 +84,11 @@ fn global_struct_variables_are_retrieved() { fn nested_global_struct_variables_are_retrieved() { let (_, index) = index( " - TYPE str : STRUCT + TYPE str : STRUCT a,b : str2; END_STRUCT END_TYPE - TYPE str2 : STRUCT + TYPE str2 : STRUCT c,d : DINT; END_STRUCT END_TYPE @@ -109,7 +109,7 @@ fn nested_global_struct_variables_are_retrieved() { fn global_fb_variables_are_retrieved() { let (_, index) = index( " - FUNCTION_BLOCK fb + FUNCTION_BLOCK fb VAR a,b : DINT; END_VAR @@ -131,7 +131,7 @@ fn global_fb_variables_are_retrieved() { fn array_instances_are_repeated() { let (_, index) = index( " - FUNCTION_BLOCK fb + FUNCTION_BLOCK fb VAR c,b : DINT; END_VAR @@ -152,7 +152,7 @@ fn array_instances_are_repeated() { fn array_with_const_instances_are_repeated() { let (_, index) = index( " - FUNCTION_BLOCK fb + FUNCTION_BLOCK fb VAR c,b : DINT; END_VAR @@ -174,7 +174,7 @@ fn array_with_const_instances_are_repeated() { fn pointer_variables_are_not_retrieved() { let (_, index) = index( " - FUNCTION_BLOCK fb + FUNCTION_BLOCK fb VAR a,b : DINT; END_VAR @@ -193,7 +193,7 @@ fn pointer_variables_are_not_retrieved() { fn filter_on_variables_are_applied() { let (_, index) = index( " - FUNCTION_BLOCK fb + FUNCTION_BLOCK fb VAR a,b : DINT; END_VAR diff --git a/src/index/tests/snapshots/rusty__index__tests__index_tests__fb_parameters_variable_type.snap b/src/index/tests/snapshots/rusty__index__tests__index_tests__fb_parameters_variable_type.snap index 940a676c60..e068ad0b1d 100644 --- a/src/index/tests/snapshots/rusty__index__tests__index_tests__fb_parameters_variable_type.snap +++ b/src/index/tests/snapshots/rusty__index__tests__index_tests__fb_parameters_variable_type.snap @@ -19,12 +19,12 @@ expression: members span: Range( TextLocation { line: 3, - column: 3, - offset: 36, + column: 12, + offset: 57, }..TextLocation { line: 3, - column: 9, - offset: 42, + column: 18, + offset: 63, }, ), }, @@ -46,12 +46,12 @@ expression: members span: Range( TextLocation { line: 6, - column: 3, - offset: 76, + column: 12, + offset: 118, }..TextLocation { line: 6, - column: 10, - offset: 83, + column: 19, + offset: 125, }, ), }, @@ -73,12 +73,12 @@ expression: members span: Range( TextLocation { line: 9, - column: 3, - offset: 117, + column: 12, + offset: 180, }..TextLocation { line: 9, - column: 9, - offset: 123, + column: 18, + offset: 186, }, ), }, diff --git a/src/index/tests/snapshots/rusty__index__tests__index_tests__function_parameters_variable_type.snap b/src/index/tests/snapshots/rusty__index__tests__index_tests__function_parameters_variable_type.snap index 3f40c6b7a4..ff411aff36 100644 --- a/src/index/tests/snapshots/rusty__index__tests__index_tests__function_parameters_variable_type.snap +++ b/src/index/tests/snapshots/rusty__index__tests__index_tests__function_parameters_variable_type.snap @@ -19,12 +19,12 @@ expression: members span: Range( TextLocation { line: 3, - column: 3, - offset: 37, + column: 12, + offset: 58, }..TextLocation { line: 3, - column: 9, - offset: 43, + column: 18, + offset: 64, }, ), }, @@ -46,12 +46,12 @@ expression: members span: Range( TextLocation { line: 6, - column: 3, - offset: 77, + column: 12, + offset: 119, }..TextLocation { line: 6, - column: 10, - offset: 84, + column: 19, + offset: 126, }, ), }, @@ -73,12 +73,12 @@ expression: members span: Range( TextLocation { line: 9, - column: 3, - offset: 118, + column: 12, + offset: 181, }..TextLocation { line: 9, - column: 9, - offset: 124, + column: 18, + offset: 187, }, ), }, @@ -100,12 +100,12 @@ expression: members span: Range( TextLocation { line: 1, - column: 11, - offset: 12, + column: 17, + offset: 18, }..TextLocation { line: 1, - column: 14, - offset: 15, + column: 20, + offset: 21, }, ), }, diff --git a/src/index/tests/snapshots/rusty__index__tests__index_tests__program_parameters_variable_type.snap b/src/index/tests/snapshots/rusty__index__tests__index_tests__program_parameters_variable_type.snap index 04247c5601..f37056b140 100644 --- a/src/index/tests/snapshots/rusty__index__tests__index_tests__program_parameters_variable_type.snap +++ b/src/index/tests/snapshots/rusty__index__tests__index_tests__program_parameters_variable_type.snap @@ -19,12 +19,12 @@ expression: members span: Range( TextLocation { line: 3, - column: 3, - offset: 31, + column: 12, + offset: 52, }..TextLocation { line: 3, - column: 9, - offset: 37, + column: 18, + offset: 58, }, ), }, @@ -46,12 +46,12 @@ expression: members span: Range( TextLocation { line: 6, - column: 3, - offset: 71, + column: 12, + offset: 113, }..TextLocation { line: 6, - column: 10, - offset: 78, + column: 19, + offset: 120, }, ), }, @@ -73,12 +73,12 @@ expression: members span: Range( TextLocation { line: 9, - column: 3, - offset: 112, + column: 12, + offset: 175, }..TextLocation { line: 9, - column: 9, - offset: 118, + column: 18, + offset: 181, }, ), }, diff --git a/src/index/tests/snapshots/rusty__index__tests__instance_resolver_tests__array_instances_are_repeated.snap b/src/index/tests/snapshots/rusty__index__tests__instance_resolver_tests__array_instances_are_repeated.snap index b64e2bf1cc..25f154029f 100644 --- a/src/index/tests/snapshots/rusty__index__tests__instance_resolver_tests__array_instances_are_repeated.snap +++ b/src/index/tests/snapshots/rusty__index__tests__instance_resolver_tests__array_instances_are_repeated.snap @@ -28,11 +28,11 @@ expression: "index.find_instances().collect::>>()" TextLocation { line: 6, column: 12, - offset: 99, + offset: 98, }..TextLocation { line: 6, column: 20, - offset: 107, + offset: 106, }, ), }, @@ -67,11 +67,11 @@ expression: "index.find_instances().collect::>>()" TextLocation { line: 8, column: 8, - offset: 124, + offset: 123, }..TextLocation { line: 8, column: 11, - offset: 127, + offset: 126, }, ), }, @@ -127,11 +127,11 @@ expression: "index.find_instances().collect::>>()" TextLocation { line: 3, column: 8, - offset: 40, + offset: 39, }..TextLocation { line: 3, column: 9, - offset: 41, + offset: 40, }, ), }, @@ -187,11 +187,11 @@ expression: "index.find_instances().collect::>>()" TextLocation { line: 3, column: 10, - offset: 42, + offset: 41, }..TextLocation { line: 3, column: 11, - offset: 43, + offset: 42, }, ), }, @@ -226,11 +226,11 @@ expression: "index.find_instances().collect::>>()" TextLocation { line: 9, column: 8, - offset: 157, + offset: 156, }..TextLocation { line: 9, column: 12, - offset: 161, + offset: 160, }, ), }, @@ -300,11 +300,11 @@ expression: "index.find_instances().collect::>>()" TextLocation { line: 3, column: 8, - offset: 40, + offset: 39, }..TextLocation { line: 3, column: 9, - offset: 41, + offset: 40, }, ), }, @@ -374,11 +374,11 @@ expression: "index.find_instances().collect::>>()" TextLocation { line: 3, column: 10, - offset: 42, + offset: 41, }..TextLocation { line: 3, column: 11, - offset: 43, + offset: 42, }, ), }, @@ -413,11 +413,11 @@ expression: "index.find_instances().collect::>>()" TextLocation { line: 10, column: 8, - offset: 196, + offset: 195, }..TextLocation { line: 10, column: 12, - offset: 200, + offset: 199, }, ), }, diff --git a/src/index/tests/snapshots/rusty__index__tests__instance_resolver_tests__array_with_const_instances_are_repeated.snap b/src/index/tests/snapshots/rusty__index__tests__instance_resolver_tests__array_with_const_instances_are_repeated.snap index 84286a371b..011abfe075 100644 --- a/src/index/tests/snapshots/rusty__index__tests__instance_resolver_tests__array_with_const_instances_are_repeated.snap +++ b/src/index/tests/snapshots/rusty__index__tests__instance_resolver_tests__array_with_const_instances_are_repeated.snap @@ -28,11 +28,11 @@ expression: "index.find_instances().collect::>>()" TextLocation { line: 6, column: 12, - offset: 99, + offset: 98, }..TextLocation { line: 6, column: 20, - offset: 107, + offset: 106, }, ), }, @@ -72,11 +72,11 @@ expression: "index.find_instances().collect::>>()" TextLocation { line: 8, column: 8, - offset: 133, + offset: 132, }..TextLocation { line: 8, column: 12, - offset: 137, + offset: 136, }, ), }, @@ -111,11 +111,11 @@ expression: "index.find_instances().collect::>>()" TextLocation { line: 11, column: 8, - offset: 179, + offset: 178, }..TextLocation { line: 11, column: 11, - offset: 182, + offset: 181, }, ), }, @@ -171,11 +171,11 @@ expression: "index.find_instances().collect::>>()" TextLocation { line: 3, column: 8, - offset: 40, + offset: 39, }..TextLocation { line: 3, column: 9, - offset: 41, + offset: 40, }, ), }, @@ -231,11 +231,11 @@ expression: "index.find_instances().collect::>>()" TextLocation { line: 3, column: 10, - offset: 42, + offset: 41, }..TextLocation { line: 3, column: 11, - offset: 43, + offset: 42, }, ), }, diff --git a/src/index/tests/snapshots/rusty__index__tests__instance_resolver_tests__filter_on_variables_are_applied.snap b/src/index/tests/snapshots/rusty__index__tests__instance_resolver_tests__filter_on_variables_are_applied.snap index becb2ad39c..a2b720aae3 100644 --- a/src/index/tests/snapshots/rusty__index__tests__instance_resolver_tests__filter_on_variables_are_applied.snap +++ b/src/index/tests/snapshots/rusty__index__tests__instance_resolver_tests__filter_on_variables_are_applied.snap @@ -33,11 +33,11 @@ expression: "index.filter_instances(|it, _|\n !it.is_constant()).coll TextLocation { line: 12, column: 8, - offset: 194, + offset: 193, }..TextLocation { line: 12, column: 11, - offset: 197, + offset: 196, }, ), }, @@ -69,11 +69,11 @@ expression: "index.filter_instances(|it, _|\n !it.is_constant()).coll TextLocation { line: 6, column: 12, - offset: 99, + offset: 98, }..TextLocation { line: 6, column: 20, - offset: 107, + offset: 106, }, ), }, @@ -108,11 +108,11 @@ expression: "index.filter_instances(|it, _|\n !it.is_constant()).coll TextLocation { line: 8, column: 8, - offset: 124, + offset: 123, }..TextLocation { line: 8, column: 11, - offset: 127, + offset: 126, }, ), }, @@ -150,11 +150,11 @@ expression: "index.filter_instances(|it, _|\n !it.is_constant()).coll TextLocation { line: 3, column: 8, - offset: 40, + offset: 39, }..TextLocation { line: 3, column: 9, - offset: 41, + offset: 40, }, ), }, @@ -192,11 +192,11 @@ expression: "index.filter_instances(|it, _|\n !it.is_constant()).coll TextLocation { line: 3, column: 10, - offset: 42, + offset: 41, }..TextLocation { line: 3, column: 11, - offset: 43, + offset: 42, }, ), }, diff --git a/src/index/tests/snapshots/rusty__index__tests__instance_resolver_tests__global_fb_variables_are_retrieved.snap b/src/index/tests/snapshots/rusty__index__tests__instance_resolver_tests__global_fb_variables_are_retrieved.snap index 455d6e33df..2c62c3f94c 100644 --- a/src/index/tests/snapshots/rusty__index__tests__instance_resolver_tests__global_fb_variables_are_retrieved.snap +++ b/src/index/tests/snapshots/rusty__index__tests__instance_resolver_tests__global_fb_variables_are_retrieved.snap @@ -28,11 +28,11 @@ expression: "index.find_instances().collect::>>()" TextLocation { line: 7, column: 8, - offset: 110, + offset: 109, }..TextLocation { line: 7, column: 11, - offset: 113, + offset: 112, }, ), }, @@ -67,11 +67,11 @@ expression: "index.find_instances().collect::>>()" TextLocation { line: 3, column: 8, - offset: 40, + offset: 39, }..TextLocation { line: 3, column: 9, - offset: 41, + offset: 40, }, ), }, @@ -106,11 +106,11 @@ expression: "index.find_instances().collect::>>()" TextLocation { line: 3, column: 10, - offset: 42, + offset: 41, }..TextLocation { line: 3, column: 11, - offset: 43, + offset: 42, }, ), }, @@ -142,11 +142,11 @@ expression: "index.find_instances().collect::>>()" TextLocation { line: 9, column: 12, - offset: 144, + offset: 143, }..TextLocation { line: 9, column: 20, - offset: 152, + offset: 151, }, ), }, @@ -181,11 +181,11 @@ expression: "index.find_instances().collect::>>()" TextLocation { line: 11, column: 8, - offset: 169, + offset: 168, }..TextLocation { line: 11, column: 11, - offset: 172, + offset: 171, }, ), }, @@ -223,11 +223,11 @@ expression: "index.find_instances().collect::>>()" TextLocation { line: 3, column: 8, - offset: 40, + offset: 39, }..TextLocation { line: 3, column: 9, - offset: 41, + offset: 40, }, ), }, @@ -265,11 +265,11 @@ expression: "index.find_instances().collect::>>()" TextLocation { line: 3, column: 10, - offset: 42, + offset: 41, }..TextLocation { line: 3, column: 11, - offset: 43, + offset: 42, }, ), }, diff --git a/src/index/tests/snapshots/rusty__index__tests__instance_resolver_tests__global_struct_variables_are_retrieved.snap b/src/index/tests/snapshots/rusty__index__tests__instance_resolver_tests__global_struct_variables_are_retrieved.snap index 3ed489b13d..92adee3445 100644 --- a/src/index/tests/snapshots/rusty__index__tests__instance_resolver_tests__global_struct_variables_are_retrieved.snap +++ b/src/index/tests/snapshots/rusty__index__tests__instance_resolver_tests__global_struct_variables_are_retrieved.snap @@ -28,11 +28,11 @@ expression: "index.find_instances().collect::>>()" TextLocation { line: 6, column: 8, - offset: 95, + offset: 94, }..TextLocation { line: 6, column: 12, - offset: 99, + offset: 98, }, ), }, @@ -67,11 +67,11 @@ expression: "index.find_instances().collect::>>()" TextLocation { line: 2, column: 8, - offset: 32, + offset: 31, }..TextLocation { line: 2, column: 9, - offset: 33, + offset: 32, }, ), }, @@ -106,11 +106,11 @@ expression: "index.find_instances().collect::>>()" TextLocation { line: 2, column: 10, - offset: 34, + offset: 33, }..TextLocation { line: 2, column: 11, - offset: 35, + offset: 34, }, ), }, @@ -142,11 +142,11 @@ expression: "index.find_instances().collect::>>()" TextLocation { line: 8, column: 12, - offset: 131, + offset: 130, }..TextLocation { line: 8, column: 20, - offset: 139, + offset: 138, }, ), }, @@ -181,11 +181,11 @@ expression: "index.find_instances().collect::>>()" TextLocation { line: 10, column: 8, - offset: 156, + offset: 155, }..TextLocation { line: 10, column: 12, - offset: 160, + offset: 159, }, ), }, @@ -223,11 +223,11 @@ expression: "index.find_instances().collect::>>()" TextLocation { line: 2, column: 8, - offset: 32, + offset: 31, }..TextLocation { line: 2, column: 9, - offset: 33, + offset: 32, }, ), }, @@ -265,11 +265,11 @@ expression: "index.find_instances().collect::>>()" TextLocation { line: 2, column: 10, - offset: 34, + offset: 33, }..TextLocation { line: 2, column: 11, - offset: 35, + offset: 34, }, ), }, diff --git a/src/index/tests/snapshots/rusty__index__tests__instance_resolver_tests__nested_global_struct_variables_are_retrieved.snap b/src/index/tests/snapshots/rusty__index__tests__instance_resolver_tests__nested_global_struct_variables_are_retrieved.snap index b51373a644..8f13a244db 100644 --- a/src/index/tests/snapshots/rusty__index__tests__instance_resolver_tests__nested_global_struct_variables_are_retrieved.snap +++ b/src/index/tests/snapshots/rusty__index__tests__instance_resolver_tests__nested_global_struct_variables_are_retrieved.snap @@ -28,11 +28,11 @@ expression: "index.find_instances().collect::>>()" TextLocation { line: 10, column: 8, - offset: 167, + offset: 165, }..TextLocation { line: 10, column: 12, - offset: 171, + offset: 169, }, ), }, @@ -67,11 +67,11 @@ expression: "index.find_instances().collect::>>()" TextLocation { line: 2, column: 8, - offset: 32, + offset: 31, }..TextLocation { line: 2, column: 9, - offset: 33, + offset: 32, }, ), }, @@ -109,11 +109,11 @@ expression: "index.find_instances().collect::>>()" TextLocation { line: 6, column: 8, - offset: 104, + offset: 102, }..TextLocation { line: 6, column: 9, - offset: 105, + offset: 103, }, ), }, @@ -151,11 +151,11 @@ expression: "index.find_instances().collect::>>()" TextLocation { line: 6, column: 10, - offset: 106, + offset: 104, }..TextLocation { line: 6, column: 11, - offset: 107, + offset: 105, }, ), }, @@ -190,11 +190,11 @@ expression: "index.find_instances().collect::>>()" TextLocation { line: 2, column: 10, - offset: 34, + offset: 33, }..TextLocation { line: 2, column: 11, - offset: 35, + offset: 34, }, ), }, @@ -232,11 +232,11 @@ expression: "index.find_instances().collect::>>()" TextLocation { line: 6, column: 8, - offset: 104, + offset: 102, }..TextLocation { line: 6, column: 9, - offset: 105, + offset: 103, }, ), }, @@ -274,11 +274,11 @@ expression: "index.find_instances().collect::>>()" TextLocation { line: 6, column: 10, - offset: 106, + offset: 104, }..TextLocation { line: 6, column: 11, - offset: 107, + offset: 105, }, ), }, @@ -310,11 +310,11 @@ expression: "index.find_instances().collect::>>()" TextLocation { line: 12, column: 12, - offset: 203, + offset: 201, }..TextLocation { line: 12, column: 20, - offset: 211, + offset: 209, }, ), }, @@ -349,11 +349,11 @@ expression: "index.find_instances().collect::>>()" TextLocation { line: 14, column: 8, - offset: 228, + offset: 226, }..TextLocation { line: 14, column: 12, - offset: 232, + offset: 230, }, ), }, @@ -391,11 +391,11 @@ expression: "index.find_instances().collect::>>()" TextLocation { line: 2, column: 8, - offset: 32, + offset: 31, }..TextLocation { line: 2, column: 9, - offset: 33, + offset: 32, }, ), }, @@ -436,11 +436,11 @@ expression: "index.find_instances().collect::>>()" TextLocation { line: 6, column: 8, - offset: 104, + offset: 102, }..TextLocation { line: 6, column: 9, - offset: 105, + offset: 103, }, ), }, @@ -481,11 +481,11 @@ expression: "index.find_instances().collect::>>()" TextLocation { line: 6, column: 10, - offset: 106, + offset: 104, }..TextLocation { line: 6, column: 11, - offset: 107, + offset: 105, }, ), }, @@ -523,11 +523,11 @@ expression: "index.find_instances().collect::>>()" TextLocation { line: 2, column: 10, - offset: 34, + offset: 33, }..TextLocation { line: 2, column: 11, - offset: 35, + offset: 34, }, ), }, @@ -568,11 +568,11 @@ expression: "index.find_instances().collect::>>()" TextLocation { line: 6, column: 8, - offset: 104, + offset: 102, }..TextLocation { line: 6, column: 9, - offset: 105, + offset: 103, }, ), }, @@ -613,11 +613,11 @@ expression: "index.find_instances().collect::>>()" TextLocation { line: 6, column: 10, - offset: 106, + offset: 104, }..TextLocation { line: 6, column: 11, - offset: 107, + offset: 105, }, ), }, diff --git a/src/index/tests/snapshots/rusty__index__tests__instance_resolver_tests__pointer_variables_are_not_retrieved.snap b/src/index/tests/snapshots/rusty__index__tests__instance_resolver_tests__pointer_variables_are_not_retrieved.snap index ae120560f2..33902d0def 100644 --- a/src/index/tests/snapshots/rusty__index__tests__instance_resolver_tests__pointer_variables_are_not_retrieved.snap +++ b/src/index/tests/snapshots/rusty__index__tests__instance_resolver_tests__pointer_variables_are_not_retrieved.snap @@ -28,11 +28,11 @@ expression: "index.find_instances().collect::>>()" TextLocation { line: 6, column: 12, - offset: 99, + offset: 98, }..TextLocation { line: 6, column: 20, - offset: 107, + offset: 106, }, ), }, @@ -67,11 +67,11 @@ expression: "index.find_instances().collect::>>()" TextLocation { line: 8, column: 8, - offset: 124, + offset: 123, }..TextLocation { line: 8, column: 11, - offset: 127, + offset: 126, }, ), }, diff --git a/src/lexer/tests/lexer_tests.rs b/src/lexer/tests/lexer_tests.rs index 7e15621d69..eff07b213e 100644 --- a/src/lexer/tests/lexer_tests.rs +++ b/src/lexer/tests/lexer_tests.rs @@ -22,12 +22,12 @@ fn windows_and_linux_line_separators_ignored() { #[test] fn comments_are_ignored_by_the_lexer() { let mut lexer = lex(r" - PROGRAM (* Some Content *) END_PROGRAM + PROGRAM (* Some Content *) END_PROGRAM /* - * FUNCTION */ + * FUNCTION */ (* Nested (*) Comment *) *) /* Nested /* Comment */ */ - //END_FUNCTION FUNCTION_BLOCK + //END_FUNCTION FUNCTION_BLOCK END_FUNCTION_BLOCK "); assert_eq!(lexer.token, KeywordProgram, "Token : {}", lexer.slice()); @@ -41,7 +41,7 @@ fn comments_are_ignored_by_the_lexer() { #[test] fn undefined_pragmas_are_ignored_by_the_lexer() { let mut lexer = lex(r" - PROGRAM { Some Content } END_PROGRAM + PROGRAM { Some Content } END_PROGRAM { FUNCTION } {END_FUNCTION FUNCTION_BLOCK} @@ -72,12 +72,12 @@ fn registered_pragmas_parsed() { #[test] fn comments_are_not_ignored_in_strings() { let mut lexer = lex(r#" - 'PROGRAM (* Some Content *) END_PROGRAM + 'PROGRAM (* Some Content *) END_PROGRAM /* - * FUNCTION */ + * FUNCTION */ (* Nested (*) Comment *) *) /* Nested /* Comment */ */ - //END_FUNCTION FUNCTION_BLOCK + //END_FUNCTION FUNCTION_BLOCK END_FUNCTION_BLOCK' "#); assert_eq!(lexer.token, LiteralString, "Token : {}", lexer.slice()); @@ -105,12 +105,12 @@ fn string_delimiter_dont_leak_out_of_comments() { #[test] fn unicode_chars_in_comments() { let mut lexer = lex(r" - PROGRAM (* Some Content *) END_PROGRAM + PROGRAM (* Some Content *) END_PROGRAM /* - * FUNCTION */ + * FUNCTION */ (* Nested //2 char utf-8 -> 💖ß (*) //2 char utf-16 --> 💣 Comment *) *) /* Nested /* Comment */ */ - //END_FUNCTION FUNCTION_BLOCK + //END_FUNCTION FUNCTION_BLOCK END_FUNCTION_BLOCK "); assert_eq!(lexer.token, KeywordProgram, "Token : {}", lexer.slice()); @@ -319,7 +319,7 @@ fn date_literals_test() { fn long_date_literals_test() { let mut lexer = lex(r#" LDATE#1984-10-01 LDATE#1-1-1 - LD#1-1-1 + LD#1-1-1 INT#1 "#); for _ in 1..=3 { @@ -347,7 +347,7 @@ fn date_and_time_literals_test() { #[test] fn long_date_and_time_literals_test() { let mut lexer = lex(" - LDT#1984-10-01-20:15:12 LDT#1-1-1-1:1:1 LDT#1984-10-01-20:15 LDT#1984-10-01-20:15:12.123"); + LDT#1984-10-01-20:15:12 LDT#1-1-1-1:1:1 LDT#1984-10-01-20:15 LDT#1984-10-01-20:15:12.123"); for _ in 1..=4 { assert_eq!(lexer.token, LiteralDateAndTime); lexer.advance(); @@ -395,8 +395,8 @@ fn time_literals_test() { fn ltime_literals_test() { let mut lexer = lex(r#" LTIME#12d - LTIME#10M4S - LT#10d + LTIME#10M4S + LT#10d DINT#10 "#); for _ in 1..=3 { @@ -621,9 +621,9 @@ fn type_cast_prefixes_parsing() { #[test] fn wide_string_parsing() { let mut lexer = lex(r#" - WSTRING - "AB C" - "AB$$" + WSTRING + "AB C" + "AB$$" "AB$"" "#); @@ -644,7 +644,7 @@ fn wide_string_parsing() { #[test] fn pointers_and_references_keyword() { let mut lexer = lex(r#" - POINTER TO x + POINTER TO x REF_TO x REFTO x &x @@ -805,18 +805,18 @@ fn multi_named_keywords_without_underscore_test() { fn lowercase_keywords_accepted() { let mut result = lex(r###" program class end_class endclass var_input varinput var_output - varoutput var abstract final method constant retain non_retain + varoutput var abstract final method constant retain non_retain nonretain var_temp vartemp end_method endmethod public private internal protected override var_global varglobal var_in_out varinout end_var endvar end_program endprogram end_function endfunction end_function_block endfunctionblock - type struct end_type endtype end_struct endstruct - actions action end_action endaction end_actions endactions + type struct end_type endtype end_struct endstruct + actions action end_action endaction end_actions endactions if then elsif else endif end_if for to by do end_for endfor while end_while endwhile repeat until endrepeat end_repeat - case return exit continue array string wstring - of endcase end_case mod and or xor not true false + case return exit continue array string wstring + of endcase end_case mod and or xor not true false d#1-2-3 date#1-2-3 dt#1-2-3-1:2:3 date_and_time#1-2-3-1:2:3 tod#1:2:3 time_of_day#1:2:3 time#1s t#1s null refto pointer ref_to "###); diff --git a/src/parser/tests/class_parser_tests.rs b/src/parser/tests/class_parser_tests.rs index 6117cc5529..e585719505 100644 --- a/src/parser/tests/class_parser_tests.rs +++ b/src/parser/tests/class_parser_tests.rs @@ -20,9 +20,9 @@ fn simple_class_with_defaults_can_be_parsed() { #[test] fn extends_can_be_parsed() { let src = " - CLASS MyClass + CLASS MyClass END_CLASS - + CLASS MyClass2 EXTENDS MyClass END_CLASS "; diff --git a/src/parser/tests/control_parser_tests.rs b/src/parser/tests/control_parser_tests.rs index 9179d08d52..b09862b2b1 100644 --- a/src/parser/tests/control_parser_tests.rs +++ b/src/parser/tests/control_parser_tests.rs @@ -11,7 +11,7 @@ use pretty_assertions::*; #[test] fn if_statement() { let src = " - PROGRAM exp + PROGRAM exp IF TRUE THEN END_IF END_PROGRAM @@ -69,7 +69,7 @@ fn test_exit_statement() { #[test] fn if_else_statement_with_expressions() { let src = " - PROGRAM exp + PROGRAM exp IF TRUE THEN x; ELSE @@ -87,7 +87,7 @@ fn if_else_statement_with_expressions() { #[test] fn if_elsif_elsif_else_statement_with_expressions() { let src = " - PROGRAM exp + PROGRAM exp IF TRUE THEN x; ELSIF y THEN @@ -109,7 +109,7 @@ fn if_elsif_elsif_else_statement_with_expressions() { #[test] fn for_with_literals_statement() { let src = " - PROGRAM exp + PROGRAM exp FOR y := x TO 10 DO END_FOR END_PROGRAM @@ -124,8 +124,8 @@ fn for_with_literals_statement() { #[test] fn for_with_step_statement() { let src = " - PROGRAM exp - FOR x := 1 TO 10 BY 7 DO + PROGRAM exp + FOR x := 1 TO 10 BY 7 DO END_FOR END_PROGRAM "; @@ -139,7 +139,7 @@ fn for_with_step_statement() { #[test] fn for_with_reference_statement() { let src = " - PROGRAM exp + PROGRAM exp FOR z := x TO y DO END_FOR END_PROGRAM @@ -154,7 +154,7 @@ fn for_with_reference_statement() { #[test] fn for_with_body_statement() { let src = " - PROGRAM exp + PROGRAM exp FOR z := x TO y DO x; y; @@ -172,7 +172,7 @@ fn for_with_body_statement() { #[test] fn while_with_literal() { let src = " - PROGRAM exp + PROGRAM exp WHILE TRUE DO END_WHILE END_PROGRAM @@ -195,8 +195,8 @@ fn while_with_literal() { #[test] fn while_with_expression() { let src = " - PROGRAM exp - WHILE x < 7 DO + PROGRAM exp + WHILE x < 7 DO END_WHILE END_PROGRAM "; @@ -210,7 +210,7 @@ fn while_with_expression() { #[test] fn while_with_body_statement() { let src = " - PROGRAM exp + PROGRAM exp WHILE TRUE DO x; y; @@ -227,7 +227,7 @@ fn while_with_body_statement() { #[test] fn repeat_with_literal() { let src = " - PROGRAM exp + PROGRAM exp REPEAT UNTIL TRUE END_REPEAT @@ -251,7 +251,7 @@ fn repeat_with_literal() { #[test] fn repeat_with_expression() { let src = " - PROGRAM exp + PROGRAM exp REPEAT UNTIL x > 7 END_REPEAT @@ -267,7 +267,7 @@ fn repeat_with_expression() { #[test] fn repeat_with_body_statement() { let src = " - PROGRAM exp + PROGRAM exp REPEAT x; y; @@ -286,7 +286,7 @@ fn repeat_with_body_statement() { #[test] fn case_statement_with_one_condition() { let src = " - PROGRAM exp + PROGRAM exp CASE StateMachine OF 1: x; END_CASE @@ -303,7 +303,7 @@ fn case_statement_with_one_condition() { #[test] fn case_statement_with_one_condition_with_trailling_comma() { let src = " - PROGRAM exp + PROGRAM exp CASE StateMachine OF 1,: x; END_CASE @@ -321,7 +321,7 @@ fn case_statement_with_one_condition_with_trailling_comma() { #[test] fn case_statement_with_else_and_no_condition() { let src = " - PROGRAM exp + PROGRAM exp CASE StateMachine OF ELSE END_CASE @@ -337,7 +337,7 @@ fn case_statement_with_else_and_no_condition() { #[test] fn case_statement_with_no_conditions() { let src = " - PROGRAM exp + PROGRAM exp CASE StateMachine OF END_CASE END_PROGRAM @@ -352,7 +352,7 @@ fn case_statement_with_no_conditions() { #[test] fn case_statement_with_one_condition_and_an_else() { let src = " - PROGRAM exp + PROGRAM exp CASE StateMachine OF 1: x; ELSE @@ -371,7 +371,7 @@ fn case_statement_with_one_condition_and_an_else() { #[test] fn case_statement_with_one_empty_condition_and_an_else() { let src = " - PROGRAM exp + PROGRAM exp CASE StateMachine OF 1: ELSE @@ -390,7 +390,7 @@ fn case_statement_with_one_empty_condition_and_an_else() { #[test] fn case_statement_with_multiple_conditions() { let src = " - PROGRAM exp + PROGRAM exp CASE StateMachine OF 1: x; 2: y; yy; yyy; @@ -409,7 +409,7 @@ fn case_statement_with_multiple_conditions() { #[test] fn case_statement_with_multiple_expressions_per_condition() { let src = " - PROGRAM exp + PROGRAM exp CASE StateMachine OF 1,2,3: x; 4..5, 6: y; @@ -426,7 +426,7 @@ fn case_statement_with_multiple_expressions_per_condition() { #[test] fn if_stmnt_location_test() { let source = " - PROGRAM prg + PROGRAM prg IF a > 4 THEN a + b; ELSIF x < 2 THEN @@ -462,7 +462,7 @@ fn if_stmnt_location_test() { #[test] fn for_stmnt_location_test() { let source = " - PROGRAM prg + PROGRAM prg FOR x := 3 TO 9 BY 2 DO a + b; END_FOR @@ -504,7 +504,7 @@ fn for_stmnt_location_test() { #[test] fn while_stmnt_location_test() { let source = " - PROGRAM prg + PROGRAM prg WHILE a < 2 DO a := a - 1; END_WHILE @@ -526,7 +526,7 @@ fn while_stmnt_location_test() { #[test] fn case_stmnt_location_test() { let source = " - PROGRAM prg + PROGRAM prg CASE a OF 1: a := a - 1; @@ -554,7 +554,7 @@ fn case_stmnt_location_test() { #[test] fn call_stmnt_location_test() { let source = " - PROGRAM prg + PROGRAM prg foo(a:=3, b:=4); END_PROGRAM"; diff --git a/src/parser/tests/expressions_parser_tests.rs b/src/parser/tests/expressions_parser_tests.rs index 436c847aa2..7bef1c74e8 100644 --- a/src/parser/tests/expressions_parser_tests.rs +++ b/src/parser/tests/expressions_parser_tests.rs @@ -29,13 +29,13 @@ fn qualified_reference_statement_parsed() { #[test] fn bitwise_access_parsed() { - let src = "PROGRAM exp - a.0; - a.%X1; - a.%B1; + let src = "PROGRAM exp + a.0; + a.%X1; + a.%B1; a.%Bb; - a[0].%W1; - a.b.%D1; + a[0].%W1; + a.b.%D1; a.%B1.%X1; END_PROGRAM"; let (result, diagnostics) = parse(src); @@ -121,8 +121,8 @@ fn literal_oct_number_with_underscore_can_be_parsed() { #[test] fn binary_stmts_of_two_variables_parsed() { - let src = "PROGRAM exp - x+y; + let src = "PROGRAM exp + x+y; x.y = y.z; x.y - y.z; &x.y = y.z; @@ -266,8 +266,8 @@ fn equality_expression_test() { #[test] fn comparison_expression_test() { - let src = "PROGRAM exp - a < 3; + let src = "PROGRAM exp + a < 3; b > 0; c <= 7; d >= 4; @@ -304,7 +304,7 @@ fn boolean_expression_param_ast_test() { #[test] fn signed_literal_minus_test() { let src = " - PROGRAM exp + PROGRAM exp -1; END_PROGRAM "; @@ -319,9 +319,9 @@ fn signed_literal_minus_test() { #[test] fn literal_date_test() { let src = " - PROGRAM exp - DATE#1984-10-01; - D#2021-04-20; + PROGRAM exp + DATE#1984-10-01; + D#2021-04-20; END_PROGRAM "; let result = parse(src).0; @@ -344,8 +344,8 @@ fn literal_date_test() { #[test] fn literal_long_date_test() { let src = " - PROGRAM exp - LDATE#1984-10-01; + PROGRAM exp + LDATE#1984-10-01; END_PROGRAM "; let result = parse(src).0; @@ -363,7 +363,7 @@ fn literal_long_date_test() { #[test] fn literal_time_test() { let src = " - PROGRAM exp + PROGRAM exp T#12d; T#12.4d; TIME#-12m; @@ -475,7 +475,7 @@ fn literal_time_test() { #[test] fn literal_long_time_test() { let src = " - PROGRAM exp + PROGRAM exp LTIME#12d; LTIME#12.4d; END_PROGRAM @@ -510,14 +510,14 @@ fn literal_long_time_test() { #[test] fn literal_time_of_day_test() { let src = " - PROGRAM exp + PROGRAM exp TOD#12:00:00; TOD#00:12:00; TOD#00:00:12; TIME_OF_DAY#04:16:22; TIME_OF_DAY#04:16:22.1; TIME_OF_DAY#04:16:22.001002003; - TIME_OF_DAY#04:16; + TIME_OF_DAY#04:16; END_PROGRAM "; let result = parse(src).0; @@ -572,7 +572,7 @@ fn literal_time_of_day_test() { #[test] fn literal_long_time_of_day_test() { let src = " - PROGRAM exp + PROGRAM exp LTOD#12:00:00.123456789; LTOD#00:12:00.99; LTOD#00:00:12; @@ -606,11 +606,11 @@ fn literal_long_time_of_day_test() { #[test] fn literal_date_and_time_test() { let src = " - PROGRAM exp - DATE_AND_TIME#1984-10-01-16:40:22; - DT#2021-04-20-22:33:14; - DT#2021-04-20-22:33:14.999999999; - DATE_AND_TIME#2000-01-01-20:15; + PROGRAM exp + DATE_AND_TIME#1984-10-01-16:40:22; + DT#2021-04-20-22:33:14; + DT#2021-04-20-22:33:14.999999999; + DATE_AND_TIME#2000-01-01-20:15; END_PROGRAM "; let result = parse(src).0; @@ -659,8 +659,8 @@ fn literal_date_and_time_test() { #[test] fn literal_long_date_and_time_test() { let src = " - PROGRAM exp - LDT#1984-10-01-16:40:22.123456789; + PROGRAM exp + LDT#1984-10-01-16:40:22.123456789; LDT#2021-04-20-22:33:14; END_PROGRAM "; @@ -692,7 +692,7 @@ fn literal_long_date_and_time_test() { #[test] fn literal_real_test() { let src = " - PROGRAM exp + PROGRAM exp 1.1; 1.2e3; 1.2e-4; @@ -748,7 +748,7 @@ fn cast(data_type: &str, value: AstNode) -> AstNode { #[test] fn literal_enum_parse_test() { let src = r#" - PROGRAM exp + PROGRAM exp MyEnum#Val7; MyEnum#Val2; MyEnum#Val3; @@ -764,7 +764,7 @@ fn literal_enum_parse_test() { #[test] fn literal_cast_parse_test() { let src = r#" - PROGRAM exp + PROGRAM exp SINT#100; DINT#16#AFFE; BYTE#8#77; @@ -776,8 +776,8 @@ fn literal_cast_parse_test() { BOOL#FALSE; STRING#"abc"; WSTRING#'xyz'; - CHAR#"A"; - WCHAR#'B'; + CHAR#"A"; + WCHAR#'B'; END_PROGRAM "#; let result = parse(src).0; @@ -816,7 +816,7 @@ fn literal_cast_parse_test() { #[test] fn literal_exponents_test() { let src = " - PROGRAM exp + PROGRAM exp 1_2e3; 12e3; 12.0e3; @@ -857,7 +857,7 @@ fn literal_exponents_test() { #[test] fn signed_literal_expression_test() { let src = " - PROGRAM exp + PROGRAM exp 2 +-x; END_PROGRAM "; @@ -872,7 +872,7 @@ fn signed_literal_expression_test() { #[test] fn assignment_to_null() { let src = " - PROGRAM exp + PROGRAM exp x := NULL; END_PROGRAM "; @@ -887,12 +887,12 @@ fn assignment_to_null() { #[test] fn assignment_to_number_with_implicit_and_explicit_plus_sign() { let src = " - PROGRAM exp - VAR - x : INT; - END_VAR - x := 1; - x := +1; + PROGRAM exp + VAR + x : INT; + END_VAR + x := 1; + x := +1; END_PROGRAM "; @@ -905,12 +905,12 @@ fn assignment_to_number_with_implicit_and_explicit_plus_sign() { #[test] fn assignment_to_number_reference_with_explicit_plus_sign() { let src = " - PROGRAM exp - VAR - x : INT; - END_VAR - x := 1; - x := +x; + PROGRAM exp + VAR + x : INT; + END_VAR + x := 1; + x := +x; END_PROGRAM "; @@ -922,7 +922,7 @@ fn assignment_to_number_reference_with_explicit_plus_sign() { #[test] fn pointer_address_test() { let src = " - PROGRAM exp + PROGRAM exp &x; END_PROGRAM "; @@ -936,7 +936,7 @@ fn pointer_address_test() { #[test] fn pointer_dereference_test() { let src = " - PROGRAM exp + PROGRAM exp x^; END_PROGRAM "; @@ -951,7 +951,7 @@ fn pointer_dereference_test() { #[test] fn pointer_dereference_test_nested() { let src = " - PROGRAM exp + PROGRAM exp x^^[0][1]^[2]^^; END_PROGRAM "; @@ -966,7 +966,7 @@ fn pointer_dereference_test_nested() { #[test] fn signed_literal_expression_reversed_test() { let src = " - PROGRAM exp + PROGRAM exp -4 + 5; END_PROGRAM "; @@ -981,7 +981,7 @@ fn signed_literal_expression_reversed_test() { #[test] fn or_compare_expressions_priority_test() { let src = " - PROGRAM exp + PROGRAM exp x > 1 OR b1; END_PROGRAM "; @@ -996,7 +996,7 @@ fn or_compare_expressions_priority_test() { #[test] fn addition_compare_or_priority_test() { let src = " - PROGRAM exp + PROGRAM exp x + 1 > 2 OR b1; END_PROGRAM "; @@ -1054,7 +1054,7 @@ fn amp_as_and_with_address_test() { #[test] fn boolean_priority_test() { let src = " - PROGRAM exp + PROGRAM exp a AND b XOR c OR d; END_PROGRAM "; @@ -1069,7 +1069,7 @@ fn boolean_priority_test() { #[test] fn comparison_priority_test() { let src = " - PROGRAM exp + PROGRAM exp x < 7 = y > 6; END_PROGRAM "; @@ -1084,7 +1084,7 @@ fn comparison_priority_test() { fn expression_list() { //technically this is an illegal state, the parser will accept it though let src = " - PROGRAM exp + PROGRAM exp 1,2,3; END_PROGRAM "; @@ -1100,7 +1100,7 @@ fn expression_list() { fn expression_list_assignments() { //technically this is an illegal state, the parser will accept it though let src = " - PROGRAM exp + PROGRAM exp x := 1, y := 2, z:= 3; END_PROGRAM "; @@ -1115,7 +1115,7 @@ fn expression_list_assignments() { #[test] fn range_expression() { let src = " - PROGRAM exp + PROGRAM exp a..b; 1..2; a..2; @@ -1133,7 +1133,7 @@ fn range_expression() { #[test] fn negative_range_expression() { let src = " - PROGRAM exp + PROGRAM exp -2..-1; END_PROGRAM "; @@ -1158,7 +1158,7 @@ fn negative_range_expression() { #[test] fn negative_range_expression_space() { let src = " - PROGRAM exp + PROGRAM exp -2 ..-1; END_PROGRAM "; @@ -1183,7 +1183,7 @@ fn negative_range_expression_space() { #[test] fn range_expression2() { let src = " - PROGRAM exp + PROGRAM exp 1 .. 2; END_PROGRAM "; @@ -1567,7 +1567,7 @@ fn qualified_reference_location_test() { #[test] fn expressions_location_test() { let source = " - PROGRAM prg + PROGRAM prg a + b; x + z - y + u - v; -x; diff --git a/src/parser/tests/function_parser_tests.rs b/src/parser/tests/function_parser_tests.rs index 73b5e1f25f..232ed75c4b 100644 --- a/src/parser/tests/function_parser_tests.rs +++ b/src/parser/tests/function_parser_tests.rs @@ -412,7 +412,7 @@ fn function_bool_return_supported() { fn function_type_enum_return_supported() { // GIVEN FUNCTION returning a type ENUM let function = "TYPE MyEnum: (green, yellow, red); END_TYPE - FUNCTION foo : MyEnum VAR_INPUT END_VAR END_FUNCTION"; + FUNCTION foo : MyEnum VAR_INPUT END_VAR END_FUNCTION"; //WHEN parsing is done let (_parse_result, diagnostics) = parse(function); //THEN there shouldn't be any diagnostics -> valid return type @@ -423,7 +423,7 @@ fn function_type_enum_return_supported() { fn function_type_struct_return_supported() { // GIVEN FUNCTION returning a type STRUCT let function = "TYPE MyStruct: STRUCT x : INT; y : INT; END_STRUCT END_TYPE - FUNCTION foo : MyStruct VAR_INPUT END_VAR END_FUNCTION"; + FUNCTION foo : MyStruct VAR_INPUT END_VAR END_FUNCTION"; //WHEN parsing is done let (_parse_result, diagnostics) = parse(function); //THEN there shouldn't be any diagnostics -> valid return type diff --git a/src/parser/tests/misc_parser_tests.rs b/src/parser/tests/misc_parser_tests.rs index 1f087f5f01..1e81fe680c 100644 --- a/src/parser/tests/misc_parser_tests.rs +++ b/src/parser/tests/misc_parser_tests.rs @@ -297,7 +297,7 @@ fn ids_are_assigned_to_if_statements() { PROGRAM PRG IF TRUE THEN ; - ELSE + ELSE ; END_IF END_PROGRAM diff --git a/src/parser/tests/parse_errors/parse_error_containers_tests.rs b/src/parser/tests/parse_errors/parse_error_containers_tests.rs index 4c755844a9..ff10d34d77 100644 --- a/src/parser/tests/parse_errors/parse_error_containers_tests.rs +++ b/src/parser/tests/parse_errors/parse_error_containers_tests.rs @@ -15,7 +15,7 @@ use insta::{assert_debug_snapshot, assert_snapshot}; #[test] fn missing_pou_name() { let src = r" - PROGRAM + PROGRAM VAR END_VAR a; END_PROGRAM @@ -34,7 +34,7 @@ fn missing_pou_name() { fn missing_pou_name_2() { // in this case, a becomes the POU's name let src = r" - PROGRAM + PROGRAM a := 2; x; END_PROGRAM diff --git a/src/parser/tests/parse_errors/parse_error_literals_tests.rs b/src/parser/tests/parse_errors/parse_error_literals_tests.rs index 5a562585f3..0d16b5ef8f 100644 --- a/src/parser/tests/parse_errors/parse_error_literals_tests.rs +++ b/src/parser/tests/parse_errors/parse_error_literals_tests.rs @@ -7,7 +7,7 @@ use crate::test_utils::tests::{parse, parse_and_validate_buffered, parse_buffere #[test] fn illegal_literal_time_missing_segments_test() { let src = " - PROGRAM exp + PROGRAM exp T#; END_PROGRAM "; @@ -18,7 +18,7 @@ fn illegal_literal_time_missing_segments_test() { #[test] fn time_literal_problems_can_be_recovered_from_during_parsing() { let src = " - PROGRAM exp + PROGRAM exp T#1d4d2h3m; x; END_PROGRAM @@ -33,7 +33,7 @@ fn time_literal_problems_can_be_recovered_from_during_parsing() { #[test] fn illegal_literal_time_double_segments_test() { let src = " - PROGRAM exp + PROGRAM exp T#1d4d2h3m; END_PROGRAM "; @@ -45,7 +45,7 @@ fn illegal_literal_time_double_segments_test() { #[test] fn illegal_literal_time_out_of_order_segments_test() { let src = " - PROGRAM exp + PROGRAM exp T#1s2h3d; END_PROGRAM "; diff --git a/src/parser/tests/parse_errors/parse_error_messages_test.rs b/src/parser/tests/parse_errors/parse_error_messages_test.rs index 69062d7201..d07548a8a6 100644 --- a/src/parser/tests/parse_errors/parse_error_messages_test.rs +++ b/src/parser/tests/parse_errors/parse_error_messages_test.rs @@ -26,7 +26,7 @@ fn test_unexpected_token_error_message2() { #[test] fn for_with_unexpected_token_1() { let src = " - PROGRAM exp + PROGRAM exp FOR z ALPHA x TO y DO x; y; @@ -40,7 +40,7 @@ fn for_with_unexpected_token_1() { #[test] fn for_with_unexpected_token_2() { let src = " - PROGRAM exp + PROGRAM exp FOR z := x BRAVO y DO x; y; @@ -54,7 +54,7 @@ fn for_with_unexpected_token_2() { #[test] fn if_then_with_unexpected_token() { let src = " - PROGRAM exp + PROGRAM exp IF TRUE CHARLIE x; ELSE @@ -69,7 +69,7 @@ fn if_then_with_unexpected_token() { #[test] fn case_with_unexpected_token() { let src = " - PROGRAM exp + PROGRAM exp CASE StateMachine DELTA 1: x; END_CASE @@ -82,7 +82,7 @@ fn case_with_unexpected_token() { #[test] fn test_unclosed_body_error_message() { let src = " - + PROGRAM My_PRG "; diff --git a/src/parser/tests/parse_errors/parse_error_statements_tests.rs b/src/parser/tests/parse_errors/parse_error_statements_tests.rs index dde698cf17..ca29b7abba 100644 --- a/src/parser/tests/parse_errors/parse_error_statements_tests.rs +++ b/src/parser/tests/parse_errors/parse_error_statements_tests.rs @@ -23,7 +23,7 @@ fn missing_semicolon_after_call() { * parsed correctly */ let src = r" - PROGRAM foo + PROGRAM foo buz() foo(); END_PROGRAM @@ -45,7 +45,7 @@ fn missing_comma_in_call_parameters() { * c will not be parsed as an expression */ let src = r" - PROGRAM foo + PROGRAM foo buz(a,b c); END_PROGRAM "; @@ -79,7 +79,7 @@ fn illegal_semicolon_in_call_parameters() { * _ c will be its own reference with an illegal token ')' */ let src = r" - PROGRAM foo + PROGRAM foo buz(a,b; c); END_PROGRAM "; @@ -113,7 +113,7 @@ fn illegal_semicolon_in_call_parameters() { #[test] fn incomplete_statement_test() { let src = " - PROGRAM exp + PROGRAM exp 1 + 2 +; x; END_PROGRAM @@ -153,7 +153,7 @@ fn incomplete_statement_test() { #[test] fn incomplete_statement_in_parantheses_recovery_test() { let src = " - PROGRAM exp + PROGRAM exp (1 + 2 - ) + 3; x; END_PROGRAM @@ -168,7 +168,7 @@ fn incomplete_statement_in_parantheses_recovery_test() { #[test] fn mismatched_parantheses_recovery_test() { let src = " - PROGRAM exp + PROGRAM exp (1 + 2; x; END_PROGRAM @@ -185,7 +185,7 @@ fn mismatched_parantheses_recovery_test() { fn invalid_variable_name_error_recovery() { let src = " PROGRAM p - VAR + VAR c : INT; 4 : INT; END_VAR @@ -225,7 +225,7 @@ fn invalid_variable_name_error_recovery() { fn invalid_variable_data_type_error_recovery() { let src = " PROGRAM p - VAR + VAR a DINT : ; c : INT; h , , : INT; @@ -365,8 +365,8 @@ fn test_for_with_missing_semicolon_in_body() { fn test_nested_for_with_missing_end_for() { //regress, this used to end in an endless loop let src = "PROGRAM My_PRG - FOR x := 1 TO 2 DO - FOR x := 1 TO 2 DO + FOR x := 1 TO 2 DO + FOR x := 1 TO 2 DO y := x; END_FOR x := y; @@ -464,7 +464,7 @@ fn test_repeat_with_missing_semicolon_in_body() { REPEAT x := 3 UNTIL x = y END_REPEAT - y := x; + y := x; END_PROGRAM "; let (unit, diagnostics) = parse_buffered(src); @@ -542,7 +542,7 @@ fn test_nested_repeat_with_missing_until_end_repeat() { REPEAT ; UNTIL x = y END_REPEAT - y := x; + y := x; END_PROGRAM "; let (unit, diagnostics) = parse_buffered(src); @@ -771,7 +771,7 @@ fn test_while_with_missing_semicolon_in_body() { WHILE x = y DO x := 3 END_WHILE - y := x; + y := x; END_PROGRAM "; let (unit, diagnostics) = parse_buffered(src); @@ -1059,7 +1059,7 @@ fn test_case_body_with_missing_semicolon() { fn test_case_without_condition() { let src = "PROGRAM My_PRG CASE x OF - 1: + 1: : x := 3; END_CASE END_PROGRAM @@ -1117,7 +1117,7 @@ fn pointer_type_without_to_test() { let src = r#" TYPE SamplePointer : POINTER INT; - END_TYPE + END_TYPE "#; let (result, diagnostics) = parse_buffered(src); let pointer_type = &result.user_types[0]; @@ -1143,7 +1143,7 @@ fn pointer_type_with_wrong_keyword_to_test() { let src = r#" TYPE SamplePointer : POINTER tu INT; - END_TYPE + END_TYPE "#; let (result, diagnostics) = parse_buffered(src); let pointer_type = &result.user_types[0]; @@ -1165,7 +1165,7 @@ fn pointer_type_with_wrong_keyword_to_test() { #[test] fn bitwise_access_error_validation() { - let src = "PROGRAM exp + let src = "PROGRAM exp a.1e5; // exponent illegal b.%f6; // f is no valid direct access modifier END_PROGRAM"; diff --git a/src/parser/tests/parse_generics.rs b/src/parser/tests/parse_generics.rs index 344fc7e9e8..3a26b5eed9 100644 --- a/src/parser/tests/parse_generics.rs +++ b/src/parser/tests/parse_generics.rs @@ -6,12 +6,12 @@ use crate::test_utils::tests::parse; #[test] fn generic_markers_on_pou_added() { let src = "FUNCTION test< - A: ANY, - B : ANY_DERIVED, - C : ANY_ELEMENTARY, - D: ANY_MAGNITUDE, - E: ANY_NUM, - F : ANY_REAL, + A: ANY, + B : ANY_DERIVED, + C : ANY_ELEMENTARY, + D: ANY_MAGNITUDE, + E: ANY_NUM, + F : ANY_REAL, G : ANY_INT, H : ANY_SIGNED, I : ANY_UNSIGNED, diff --git a/src/parser/tests/snapshots/rusty__parser__tests__statement_parser_tests__empty_parameter_assignments_in_call_statement.snap b/src/parser/tests/snapshots/rusty__parser__tests__statement_parser_tests__empty_parameter_assignments_in_call_statement.snap index c40e00550a..ff923232fc 100644 --- a/src/parser/tests/snapshots/rusty__parser__tests__statement_parser_tests__empty_parameter_assignments_in_call_statement.snap +++ b/src/parser/tests/snapshots/rusty__parser__tests__statement_parser_tests__empty_parameter_assignments_in_call_statement.snap @@ -93,12 +93,12 @@ CompilationUnit { span: Range( TextLocation { line: 11, - column: 2, - offset: 150, + column: 8, + offset: 219, }..TextLocation { line: 11, - column: 14, - offset: 162, + column: 20, + offset: 231, }, ), }, @@ -179,12 +179,12 @@ CompilationUnit { span: Range( TextLocation { line: 17, - column: 2, - offset: 215, + column: 8, + offset: 317, }..TextLocation { line: 18, - column: 13, - offset: 270, + column: 19, + offset: 378, }, ), }, @@ -192,12 +192,12 @@ CompilationUnit { span: Range( TextLocation { line: 13, - column: 10, - offset: 174, + column: 16, + offset: 249, }..TextLocation { line: 13, - column: 14, - offset: 178, + column: 20, + offset: 253, }, ), }, diff --git a/src/parser/tests/snapshots/rusty__parser__tests__variable_parser_tests__global_var_with_address.snap b/src/parser/tests/snapshots/rusty__parser__tests__variable_parser_tests__global_var_with_address.snap index 869bc4f8b8..62321eb9de 100644 --- a/src/parser/tests/snapshots/rusty__parser__tests__variable_parser_tests__global_var_with_address.snap +++ b/src/parser/tests/snapshots/rusty__parser__tests__variable_parser_tests__global_var_with_address.snap @@ -2,4 +2,4 @@ source: src/parser/tests/variable_parser_tests.rs expression: "format!(\"{result:?}\")" --- -CompilationUnit { global_vars: [VariableBlock { variables: [Variable { name: "a", data_type: DataTypeReference { referenced_type: "INT" }, address: Some(HardwareAccess { direction: Input, access: Template, address: [], location: SourceLocation { span: Range(TextLocation { line: 1, column: 14, offset: 26 }..TextLocation { line: 1, column: 20, offset: 32 }) } }) }, Variable { name: "b", data_type: DataTypeReference { referenced_type: "INT" }, address: Some(HardwareAccess { direction: Output, access: Template, address: [], location: SourceLocation { span: Range(TextLocation { line: 2, column: 14, offset: 55 }..TextLocation { line: 2, column: 20, offset: 61 }) } }) }, Variable { name: "c", data_type: DataTypeReference { referenced_type: "INT" }, address: Some(HardwareAccess { direction: Memory, access: Template, address: [], location: SourceLocation { span: Range(TextLocation { line: 3, column: 14, offset: 84 }..TextLocation { line: 3, column: 20, offset: 90 }) } }) }, Variable { name: "aa", data_type: DataTypeReference { referenced_type: "INT" }, address: Some(HardwareAccess { direction: Input, access: Bit, address: [LiteralInteger { value: 7 }], location: SourceLocation { span: Range(TextLocation { line: 4, column: 15, offset: 114 }..TextLocation { line: 4, column: 22, offset: 121 }) } }) }, Variable { name: "bb", data_type: DataTypeReference { referenced_type: "INT" }, address: Some(HardwareAccess { direction: Output, access: Byte, address: [LiteralInteger { value: 5 }, LiteralInteger { value: 5 }], location: SourceLocation { span: Range(TextLocation { line: 5, column: 15, offset: 145 }..TextLocation { line: 5, column: 24, offset: 154 }) } }) }, Variable { name: "cc", data_type: DataTypeReference { referenced_type: "INT" }, address: Some(HardwareAccess { direction: Memory, access: DWord, address: [LiteralInteger { value: 3 }, LiteralInteger { value: 3 }, LiteralInteger { value: 3 }], location: SourceLocation { span: Range(TextLocation { line: 6, column: 15, offset: 178 }..TextLocation { line: 6, column: 26, offset: 189 }) } }) }, Variable { name: "dd", data_type: DataTypeReference { referenced_type: "INT" }, address: Some(HardwareAccess { direction: Global, access: DWord, address: [LiteralInteger { value: 4 }, LiteralInteger { value: 3 }, LiteralInteger { value: 3 }], location: SourceLocation { span: Range(TextLocation { line: 7, column: 15, offset: 213 }..TextLocation { line: 7, column: 26, offset: 224 }) } }) }], variable_block_type: Global }], units: [], implementations: [], user_types: [], file_name: "test.st" } +CompilationUnit { global_vars: [VariableBlock { variables: [Variable { name: "a", data_type: DataTypeReference { referenced_type: "INT" }, address: Some(HardwareAccess { direction: Input, access: Template, address: [], location: SourceLocation { span: Range(TextLocation { line: 1, column: 14, offset: 25 }..TextLocation { line: 1, column: 20, offset: 31 }) } }) }, Variable { name: "b", data_type: DataTypeReference { referenced_type: "INT" }, address: Some(HardwareAccess { direction: Output, access: Template, address: [], location: SourceLocation { span: Range(TextLocation { line: 2, column: 14, offset: 53 }..TextLocation { line: 2, column: 20, offset: 59 }) } }) }, Variable { name: "c", data_type: DataTypeReference { referenced_type: "INT" }, address: Some(HardwareAccess { direction: Memory, access: Template, address: [], location: SourceLocation { span: Range(TextLocation { line: 3, column: 14, offset: 81 }..TextLocation { line: 3, column: 20, offset: 87 }) } }) }, Variable { name: "aa", data_type: DataTypeReference { referenced_type: "INT" }, address: Some(HardwareAccess { direction: Input, access: Bit, address: [LiteralInteger { value: 7 }], location: SourceLocation { span: Range(TextLocation { line: 4, column: 15, offset: 110 }..TextLocation { line: 4, column: 22, offset: 117 }) } }) }, Variable { name: "bb", data_type: DataTypeReference { referenced_type: "INT" }, address: Some(HardwareAccess { direction: Output, access: Byte, address: [LiteralInteger { value: 5 }, LiteralInteger { value: 5 }], location: SourceLocation { span: Range(TextLocation { line: 5, column: 15, offset: 140 }..TextLocation { line: 5, column: 24, offset: 149 }) } }) }, Variable { name: "cc", data_type: DataTypeReference { referenced_type: "INT" }, address: Some(HardwareAccess { direction: Memory, access: DWord, address: [LiteralInteger { value: 3 }, LiteralInteger { value: 3 }, LiteralInteger { value: 3 }], location: SourceLocation { span: Range(TextLocation { line: 6, column: 15, offset: 172 }..TextLocation { line: 6, column: 26, offset: 183 }) } }) }, Variable { name: "dd", data_type: DataTypeReference { referenced_type: "INT" }, address: Some(HardwareAccess { direction: Global, access: DWord, address: [LiteralInteger { value: 4 }, LiteralInteger { value: 3 }, LiteralInteger { value: 3 }], location: SourceLocation { span: Range(TextLocation { line: 7, column: 15, offset: 206 }..TextLocation { line: 7, column: 26, offset: 217 }) } }) }], variable_block_type: Global }], units: [], implementations: [], user_types: [], file_name: "test.st" } diff --git a/src/parser/tests/snapshots/rusty__parser__tests__variable_parser_tests__pou_var_with_address.snap b/src/parser/tests/snapshots/rusty__parser__tests__variable_parser_tests__pou_var_with_address.snap index 1fda889c0f..ea7b37be94 100644 --- a/src/parser/tests/snapshots/rusty__parser__tests__variable_parser_tests__pou_var_with_address.snap +++ b/src/parser/tests/snapshots/rusty__parser__tests__variable_parser_tests__pou_var_with_address.snap @@ -2,4 +2,4 @@ source: src/parser/tests/variable_parser_tests.rs expression: "format!(\"{result:?}\")" --- -CompilationUnit { global_vars: [], units: [POU { name: "main", variable_blocks: [VariableBlock { variables: [Variable { name: "a", data_type: DataTypeReference { referenced_type: "INT" }, address: Some(HardwareAccess { direction: Input, access: Template, address: [], location: SourceLocation { span: Range(TextLocation { line: 2, column: 14, offset: 36 }..TextLocation { line: 2, column: 20, offset: 42 }) } }) }, Variable { name: "b", data_type: DataTypeReference { referenced_type: "INT" }, address: Some(HardwareAccess { direction: Output, access: Template, address: [], location: SourceLocation { span: Range(TextLocation { line: 3, column: 14, offset: 65 }..TextLocation { line: 3, column: 20, offset: 71 }) } }) }, Variable { name: "c", data_type: DataTypeReference { referenced_type: "INT" }, address: Some(HardwareAccess { direction: Memory, access: Template, address: [], location: SourceLocation { span: Range(TextLocation { line: 4, column: 16, offset: 96 }..TextLocation { line: 4, column: 22, offset: 102 }) } }) }, Variable { name: "d", data_type: DataTypeReference { referenced_type: "INT" }, address: Some(HardwareAccess { direction: Memory, access: Template, address: [], location: SourceLocation { span: Range(TextLocation { line: 4, column: 16, offset: 96 }..TextLocation { line: 4, column: 22, offset: 102 }) } }) }, Variable { name: "aa", data_type: DataTypeReference { referenced_type: "INT" }, address: Some(HardwareAccess { direction: Input, access: Bit, address: [LiteralInteger { value: 7 }], location: SourceLocation { span: Range(TextLocation { line: 5, column: 15, offset: 126 }..TextLocation { line: 5, column: 22, offset: 133 }) } }) }, Variable { name: "bb", data_type: DataTypeReference { referenced_type: "INT" }, address: Some(HardwareAccess { direction: Output, access: Byte, address: [LiteralInteger { value: 5 }, LiteralInteger { value: 5 }], location: SourceLocation { span: Range(TextLocation { line: 6, column: 15, offset: 157 }..TextLocation { line: 6, column: 24, offset: 166 }) } }) }, Variable { name: "cc", data_type: DataTypeReference { referenced_type: "INT" }, address: Some(HardwareAccess { direction: Memory, access: DWord, address: [LiteralInteger { value: 3 }, LiteralInteger { value: 3 }, LiteralInteger { value: 3 }], location: SourceLocation { span: Range(TextLocation { line: 7, column: 15, offset: 190 }..TextLocation { line: 7, column: 26, offset: 201 }) } }) }, Variable { name: "dd", data_type: DataTypeReference { referenced_type: "INT" }, address: Some(HardwareAccess { direction: Global, access: DWord, address: [LiteralInteger { value: 4 }, LiteralInteger { value: 3 }, LiteralInteger { value: 3 }], location: SourceLocation { span: Range(TextLocation { line: 8, column: 15, offset: 225 }..TextLocation { line: 8, column: 26, offset: 236 }) } }) }], variable_block_type: Local }], pou_type: Program, return_type: None }], implementations: [Implementation { name: "main", type_name: "main", linkage: Internal, pou_type: Program, statements: [], location: SourceLocation { span: Range(TextLocation { line: 10, column: 4, offset: 262 }..TextLocation { line: 10, column: 15, offset: 273 }) }, name_location: SourceLocation { span: Range(TextLocation { line: 0, column: 8, offset: 8 }..TextLocation { line: 0, column: 12, offset: 12 }) }, overriding: false, generic: false, access: None }], user_types: [], file_name: "test.st" } +CompilationUnit { global_vars: [], units: [POU { name: "main", variable_blocks: [VariableBlock { variables: [Variable { name: "a", data_type: DataTypeReference { referenced_type: "INT" }, address: Some(HardwareAccess { direction: Input, access: Template, address: [], location: SourceLocation { span: Range(TextLocation { line: 2, column: 14, offset: 35 }..TextLocation { line: 2, column: 20, offset: 41 }) } }) }, Variable { name: "b", data_type: DataTypeReference { referenced_type: "INT" }, address: Some(HardwareAccess { direction: Output, access: Template, address: [], location: SourceLocation { span: Range(TextLocation { line: 3, column: 14, offset: 63 }..TextLocation { line: 3, column: 20, offset: 69 }) } }) }, Variable { name: "c", data_type: DataTypeReference { referenced_type: "INT" }, address: Some(HardwareAccess { direction: Memory, access: Template, address: [], location: SourceLocation { span: Range(TextLocation { line: 4, column: 16, offset: 93 }..TextLocation { line: 4, column: 22, offset: 99 }) } }) }, Variable { name: "d", data_type: DataTypeReference { referenced_type: "INT" }, address: Some(HardwareAccess { direction: Memory, access: Template, address: [], location: SourceLocation { span: Range(TextLocation { line: 4, column: 16, offset: 93 }..TextLocation { line: 4, column: 22, offset: 99 }) } }) }, Variable { name: "aa", data_type: DataTypeReference { referenced_type: "INT" }, address: Some(HardwareAccess { direction: Input, access: Bit, address: [LiteralInteger { value: 7 }], location: SourceLocation { span: Range(TextLocation { line: 5, column: 15, offset: 122 }..TextLocation { line: 5, column: 22, offset: 129 }) } }) }, Variable { name: "bb", data_type: DataTypeReference { referenced_type: "INT" }, address: Some(HardwareAccess { direction: Output, access: Byte, address: [LiteralInteger { value: 5 }, LiteralInteger { value: 5 }], location: SourceLocation { span: Range(TextLocation { line: 6, column: 15, offset: 152 }..TextLocation { line: 6, column: 24, offset: 161 }) } }) }, Variable { name: "cc", data_type: DataTypeReference { referenced_type: "INT" }, address: Some(HardwareAccess { direction: Memory, access: DWord, address: [LiteralInteger { value: 3 }, LiteralInteger { value: 3 }, LiteralInteger { value: 3 }], location: SourceLocation { span: Range(TextLocation { line: 7, column: 15, offset: 184 }..TextLocation { line: 7, column: 26, offset: 195 }) } }) }, Variable { name: "dd", data_type: DataTypeReference { referenced_type: "INT" }, address: Some(HardwareAccess { direction: Global, access: DWord, address: [LiteralInteger { value: 4 }, LiteralInteger { value: 3 }, LiteralInteger { value: 3 }], location: SourceLocation { span: Range(TextLocation { line: 8, column: 15, offset: 218 }..TextLocation { line: 8, column: 26, offset: 229 }) } }) }], variable_block_type: Local }], pou_type: Program, return_type: None }], implementations: [Implementation { name: "main", type_name: "main", linkage: Internal, pou_type: Program, statements: [], location: SourceLocation { span: Range(TextLocation { line: 10, column: 4, offset: 253 }..TextLocation { line: 10, column: 15, offset: 264 }) }, name_location: SourceLocation { span: Range(TextLocation { line: 0, column: 8, offset: 8 }..TextLocation { line: 0, column: 12, offset: 12 }) }, overriding: false, generic: false, access: None }], user_types: [], file_name: "test.st" } diff --git a/src/parser/tests/snapshots/rusty__parser__tests__variable_parser_tests__struct_with_address.snap b/src/parser/tests/snapshots/rusty__parser__tests__variable_parser_tests__struct_with_address.snap index 6b762a6bb2..48935c10ba 100644 --- a/src/parser/tests/snapshots/rusty__parser__tests__variable_parser_tests__struct_with_address.snap +++ b/src/parser/tests/snapshots/rusty__parser__tests__variable_parser_tests__struct_with_address.snap @@ -2,4 +2,4 @@ source: src/parser/tests/variable_parser_tests.rs expression: "format!(\"{result:?}\")" --- -CompilationUnit { global_vars: [], units: [], implementations: [], user_types: [UserTypeDeclaration { data_type: StructType { name: Some("t"), variables: [Variable { name: "a", data_type: DataTypeReference { referenced_type: "INT" }, address: Some(HardwareAccess { direction: Input, access: Template, address: [], location: SourceLocation { span: Range(TextLocation { line: 1, column: 14, offset: 30 }..TextLocation { line: 1, column: 20, offset: 36 }) } }) }, Variable { name: "b", data_type: DataTypeReference { referenced_type: "INT" }, address: Some(HardwareAccess { direction: Output, access: Template, address: [], location: SourceLocation { span: Range(TextLocation { line: 2, column: 14, offset: 59 }..TextLocation { line: 2, column: 20, offset: 65 }) } }) }, Variable { name: "c", data_type: DataTypeReference { referenced_type: "INT" }, address: Some(HardwareAccess { direction: Memory, access: Template, address: [], location: SourceLocation { span: Range(TextLocation { line: 3, column: 14, offset: 88 }..TextLocation { line: 3, column: 20, offset: 94 }) } }) }, Variable { name: "aa", data_type: DataTypeReference { referenced_type: "INT" }, address: Some(HardwareAccess { direction: Input, access: Bit, address: [LiteralInteger { value: 7 }], location: SourceLocation { span: Range(TextLocation { line: 4, column: 15, offset: 118 }..TextLocation { line: 4, column: 22, offset: 125 }) } }) }, Variable { name: "bb", data_type: DataTypeReference { referenced_type: "INT" }, address: Some(HardwareAccess { direction: Output, access: Byte, address: [LiteralInteger { value: 5 }, LiteralInteger { value: 5 }], location: SourceLocation { span: Range(TextLocation { line: 5, column: 15, offset: 149 }..TextLocation { line: 5, column: 24, offset: 158 }) } }) }, Variable { name: "cc", data_type: DataTypeReference { referenced_type: "INT" }, address: Some(HardwareAccess { direction: Memory, access: DWord, address: [LiteralInteger { value: 3 }, LiteralInteger { value: 3 }, LiteralInteger { value: 3 }], location: SourceLocation { span: Range(TextLocation { line: 6, column: 15, offset: 182 }..TextLocation { line: 6, column: 26, offset: 193 }) } }) }, Variable { name: "dd", data_type: DataTypeReference { referenced_type: "INT" }, address: Some(HardwareAccess { direction: Global, access: DWord, address: [LiteralInteger { value: 4 }, LiteralInteger { value: 3 }, LiteralInteger { value: 3 }], location: SourceLocation { span: Range(TextLocation { line: 7, column: 15, offset: 217 }..TextLocation { line: 7, column: 26, offset: 228 }) } }) }] }, initializer: None, scope: None }], file_name: "test.st" } +CompilationUnit { global_vars: [], units: [], implementations: [], user_types: [UserTypeDeclaration { data_type: StructType { name: Some("t"), variables: [Variable { name: "a", data_type: DataTypeReference { referenced_type: "INT" }, address: Some(HardwareAccess { direction: Input, access: Template, address: [], location: SourceLocation { span: Range(TextLocation { line: 1, column: 14, offset: 30 }..TextLocation { line: 1, column: 20, offset: 36 }) } }) }, Variable { name: "b", data_type: DataTypeReference { referenced_type: "INT" }, address: Some(HardwareAccess { direction: Output, access: Template, address: [], location: SourceLocation { span: Range(TextLocation { line: 2, column: 14, offset: 58 }..TextLocation { line: 2, column: 20, offset: 64 }) } }) }, Variable { name: "c", data_type: DataTypeReference { referenced_type: "INT" }, address: Some(HardwareAccess { direction: Memory, access: Template, address: [], location: SourceLocation { span: Range(TextLocation { line: 3, column: 14, offset: 86 }..TextLocation { line: 3, column: 20, offset: 92 }) } }) }, Variable { name: "aa", data_type: DataTypeReference { referenced_type: "INT" }, address: Some(HardwareAccess { direction: Input, access: Bit, address: [LiteralInteger { value: 7 }], location: SourceLocation { span: Range(TextLocation { line: 4, column: 15, offset: 115 }..TextLocation { line: 4, column: 22, offset: 122 }) } }) }, Variable { name: "bb", data_type: DataTypeReference { referenced_type: "INT" }, address: Some(HardwareAccess { direction: Output, access: Byte, address: [LiteralInteger { value: 5 }, LiteralInteger { value: 5 }], location: SourceLocation { span: Range(TextLocation { line: 5, column: 15, offset: 145 }..TextLocation { line: 5, column: 24, offset: 154 }) } }) }, Variable { name: "cc", data_type: DataTypeReference { referenced_type: "INT" }, address: Some(HardwareAccess { direction: Memory, access: DWord, address: [LiteralInteger { value: 3 }, LiteralInteger { value: 3 }, LiteralInteger { value: 3 }], location: SourceLocation { span: Range(TextLocation { line: 6, column: 15, offset: 177 }..TextLocation { line: 6, column: 26, offset: 188 }) } }) }, Variable { name: "dd", data_type: DataTypeReference { referenced_type: "INT" }, address: Some(HardwareAccess { direction: Global, access: DWord, address: [LiteralInteger { value: 4 }, LiteralInteger { value: 3 }, LiteralInteger { value: 3 }], location: SourceLocation { span: Range(TextLocation { line: 7, column: 15, offset: 211 }..TextLocation { line: 7, column: 26, offset: 222 }) } }) }] }, initializer: None, scope: None }], file_name: "test.st" } diff --git a/src/parser/tests/statement_parser_tests.rs b/src/parser/tests/statement_parser_tests.rs index 7c932fe27e..ffddd7578f 100644 --- a/src/parser/tests/statement_parser_tests.rs +++ b/src/parser/tests/statement_parser_tests.rs @@ -237,23 +237,23 @@ fn empty_parameter_assignments_in_call_statement() { let (result, diagnostics) = parse( r#" FUNCTION foo : INT - VAR_INPUT - input1 : INT; - END_VAR - VAR_OUTPUT - output1 : INT; - END_VAR - VAR_IN_OUT - inout1 : INT; - END_VAR - END_FUNCTION + VAR_INPUT + input1 : INT; + END_VAR + VAR_OUTPUT + output1 : INT; + END_VAR + VAR_IN_OUT + inout1 : INT; + END_VAR + END_FUNCTION - PROGRAM main - VAR - a, b, c : INT; - END_VAR - foo(input1 := , output1 => , inout1 => ); - END_PROGRAM + PROGRAM main + VAR + a, b, c : INT; + END_VAR + foo(input1 := , output1 => , inout1 => ); + END_PROGRAM "#, ); diff --git a/src/parser/tests/type_parser_tests.rs b/src/parser/tests/type_parser_tests.rs index 5bb2655a26..dec1de21a6 100644 --- a/src/parser/tests/type_parser_tests.rs +++ b/src/parser/tests/type_parser_tests.rs @@ -31,7 +31,7 @@ fn simple_struct_type_can_be_parsed() { Two:INT; Three:INT; END_STRUCT - END_TYPE + END_TYPE "#, ); @@ -88,7 +88,7 @@ fn simple_enum_type_can_be_parsed() { let (result, ..) = parse( r#" TYPE SampleEnum : (red, yellow, green); - END_TYPE + END_TYPE "#, ); insta::assert_debug_snapshot!(result.user_types[0]); @@ -99,7 +99,7 @@ fn simple_enum_with_numeric_type_can_be_parsed() { let (result, ..) = parse( r#" TYPE SampleEnum : INT (red, yellow, green); - END_TYPE + END_TYPE "#, ); insta::assert_debug_snapshot!(result.user_types[0]); @@ -110,7 +110,7 @@ fn simple_enum_with_one_element_numeric_type_can_be_parsed() { let (result, ..) = parse( r#" TYPE SampleEnum : INT (red); - END_TYPE + END_TYPE "#, ); insta::assert_debug_snapshot!(result.user_types[0]); @@ -121,7 +121,7 @@ fn typed_enum_with_initial_values_can_be_parsed() { let (result, ..) = parse( r#" TYPE SampleEnum : INT (red := 1, yellow := 2, green := 4); - END_TYPE + END_TYPE "#, ); insta::assert_debug_snapshot!(result.user_types[0]); @@ -135,7 +135,7 @@ fn typed_inline_enum_with_initial_values_can_be_parsed() { VAR x : INT (red := 1, yellow := 2, green := 4); END_VAR - END_PROGRAM + END_PROGRAM "#, ); insta::assert_debug_snapshot!(result.units[0]); @@ -145,7 +145,7 @@ fn typed_inline_enum_with_initial_values_can_be_parsed() { fn type_alias_can_be_parsed() { let (result, ..) = parse( r#" - TYPE + TYPE MyInt : INT; END_TYPE "#, @@ -226,7 +226,7 @@ fn struct_with_inline_array_can_be_parsed() { STRUCT One: ARRAY[0..1] OF INT; END_STRUCT - END_TYPE + END_TYPE "#, ); @@ -239,7 +239,7 @@ fn pointer_type_test() { r#" TYPE SamplePointer : POINTER TO INT; - END_TYPE + END_TYPE "#, ); assert_debug_snapshot!(result.user_types[0]); @@ -251,7 +251,7 @@ fn ref_type_test() { r#" TYPE SampleReference : REF_TO INT; - END_TYPE + END_TYPE "#, ); assert_debug_snapshot!(result.user_types[0]); @@ -262,10 +262,10 @@ fn ref_type_test() { fn global_pointer_declaration() { let (result, diagnostics) = parse_buffered( r#" - VAR_GLOBAL + VAR_GLOBAL SampleReference : REF_TO INT; SamplePointer : POINTER TO INT; - END_VAR + END_VAR "#, ); let reference_type = &result.global_vars[0].variables[0]; diff --git a/src/parser/tests/variable_parser_tests.rs b/src/parser/tests/variable_parser_tests.rs index 524e7650db..764ae4a80a 100644 --- a/src/parser/tests/variable_parser_tests.rs +++ b/src/parser/tests/variable_parser_tests.rs @@ -164,14 +164,14 @@ fn two_global_vars_can_be_parsed() { #[test] fn global_var_with_address() { - let src = "VAR_GLOBAL - a AT %I* : INT; - b AT %Q* : INT; - c AT %M* : INT; - aa AT %IX7 : INT; - bb AT %QB5.5 : INT; - cc AT %MD3.3.3 : INT; - dd AT %GD4.3.3 : INT; + let src = "VAR_GLOBAL + a AT %I* : INT; + b AT %Q* : INT; + c AT %M* : INT; + aa AT %IX7 : INT; + bb AT %QB5.5 : INT; + cc AT %MD3.3.3 : INT; + dd AT %GD4.3.3 : INT; END_VAR "; let (result, diag) = parse(src); @@ -183,15 +183,15 @@ fn global_var_with_address() { #[test] fn pou_var_with_address() { let src = "PROGRAM main - VAR - a AT %I* : INT; - b AT %Q* : INT; - c,d AT %M* : INT; - aa AT %IX7 : INT; - bb AT %QB5.5 : INT; - cc AT %MD3.3.3 : INT; - dd AT %GD4.3.3 : INT; - END_VAR + VAR + a AT %I* : INT; + b AT %Q* : INT; + c,d AT %M* : INT; + aa AT %IX7 : INT; + bb AT %QB5.5 : INT; + cc AT %MD3.3.3 : INT; + dd AT %GD4.3.3 : INT; + END_VAR END_PROGRAM "; let (result, diag) = parse(src); @@ -204,13 +204,13 @@ fn pou_var_with_address() { #[test] fn struct_with_address() { let src = "TYPE t : STRUCT - a AT %I* : INT; - b AT %Q* : INT; - c AT %M* : INT; - aa AT %IX7 : INT; - bb AT %QB5.5 : INT; - cc AT %MD3.3.3 : INT; - dd AT %GD4.3.3 : INT; + a AT %I* : INT; + b AT %Q* : INT; + c AT %M* : INT; + aa AT %IX7 : INT; + bb AT %QB5.5 : INT; + cc AT %MD3.3.3 : INT; + dd AT %GD4.3.3 : INT; END_STRUCT END_TYPE "; diff --git a/src/resolver/generics.rs b/src/resolver/generics.rs index 81e0d7103d..2a90620605 100644 --- a/src/resolver/generics.rs +++ b/src/resolver/generics.rs @@ -394,7 +394,7 @@ impl<'i> TypeAnnotator<'i> { .find_effective_type_by_name(current.get_name()) .map(|t| { t.has_nature(*nature, self.index) - // INT parameter for REAL is allowed + // INT parameter for REAL is allowed | (nature.is_real() & t.is_numerical()) }) .unwrap_or_default() diff --git a/src/resolver/tests/const_resolver_tests.rs b/src/resolver/tests/const_resolver_tests.rs index 0eb2d572e9..d5ac99e58d 100644 --- a/src/resolver/tests/const_resolver_tests.rs +++ b/src/resolver/tests/const_resolver_tests.rs @@ -66,7 +66,7 @@ fn const_references_to_int_compile_time_evaluation() { iZ : INT := iY; rZ : LREAL := rY; END_VAR - + VAR_GLOBAL CONSTANT a : INT := iX; b : INT := iY; @@ -115,7 +115,7 @@ fn const_enum_variable_default_value_compile_time_evaluation() { // GIVEN an enum with its first value using a const-initializer let ir = codegen( " - + VAR_GLOBAL CONSTANT me : MyEnum; THREE : INT := 3; @@ -134,7 +134,7 @@ fn local_const_references_to_int_compile_time_evaluation() { // GIVEN some INT index used as initializers let (_, index) = index( " - PROGRAM prg + PROGRAM prg VAR CONSTANT iX : INT := 4; rX : LREAL := 4.2; @@ -171,7 +171,7 @@ fn local_const_references_to_int_compile_time_evaluation_uses_correct_scopes() { h : INT := prg.a; // should be 4 END_VAR - PROGRAM prg + PROGRAM prg VAR CONSTANT a : INT := 4; END_VAR @@ -208,7 +208,7 @@ fn non_const_references_to_int_compile_time_evaluation() { a : INT := 3; b : INT := 4; END_VAR - + VAR_GLOBAL CONSTANT ok : INT := iX; nok_a : INT := iX + a; @@ -283,7 +283,7 @@ fn const_references_to_negative_reference() { iX : INT := 4; rX : LREAL := 4.2; END_VAR - + VAR_GLOBAL CONSTANT a : INT := -iX; b : LREAL := -rX; @@ -314,7 +314,7 @@ fn const_references_to_int_additions_compile_time_evaluation() { iZ : INT := iY + 7; rZ : LREAL := rY + 7.7; END_VAR - + VAR_GLOBAL CONSTANT a : INT := iX; b : INT := iY; @@ -351,7 +351,7 @@ fn const_references_to_int_subtractions_compile_time_evaluation() { iZ : INT := iY - 7; rZ : LREAL := rY - 7.7; END_VAR - + VAR_GLOBAL CONSTANT a : INT := iX; b : INT := iY; @@ -388,7 +388,7 @@ fn const_references_to_int_multiplications_compile_time_evaluation() { iZ : INT := iY * 7; rZ : LREAL := rY * 7.7; END_VAR - + VAR_GLOBAL CONSTANT a : INT := iX; b : INT := iY; @@ -425,7 +425,7 @@ fn const_references_to_int_division_compile_time_evaluation() { iZ : INT := iY / 7; rZ : LREAL := rY / 7.7; END_VAR - + VAR_GLOBAL CONSTANT a : INT := iX; b : INT := iY; @@ -606,7 +606,7 @@ fn const_references_bool_bit_functions_behavior_evaluation() { _true : BOOL := TRUE; _false : BOOL := FALSE; END_VAR - + VAR_GLOBAL CONSTANT a : WORD := _true; b : WORD := a AND _false; @@ -637,7 +637,7 @@ fn const_references_int_bit_functions_behavior_evaluation() { "VAR_GLOBAL CONSTANT _0x00ff : WORD := 16#00FF; END_VAR - + VAR_GLOBAL CONSTANT a : WORD := 16#FFAB; b : WORD := a AND _0x00ff; @@ -692,7 +692,7 @@ fn division_by_0_should_fail() { b : REAL := 5 / zero_real; c : REAL := 5.0 / zero_int; d : REAL := 5.0 / zero_real; - + aa : REAL := 5 MOD zero_int; bb : REAL := 5 MOD zero_real; cc : REAL := 5.0 MOD zero_int; @@ -749,7 +749,7 @@ fn const_references_not_function_with_signed_ints() { "VAR_GLOBAL CONSTANT _0x00ff : INT := 16#00FF; // 255 END_VAR - + VAR_GLOBAL CONSTANT a : INT := INT#16#55; // 85; aa : INT := WORD#16#FFAB; // 65xxx; @@ -784,7 +784,7 @@ fn const_references_to_bool_compile_time_evaluation() { y : BOOL := FALSE; z : BOOL := y; END_VAR - + VAR_GLOBAL CONSTANT a : BOOL := x; b : BOOL := y OR NOT y; @@ -863,7 +863,7 @@ fn const_string_initializers_should_be_converted() { a : STRING := 'Hello'; b : WSTRING := "World"; END_VAR - + VAR_GLOBAL CONSTANT aa : STRING := b; bb : WSTRING := a; @@ -892,7 +892,7 @@ fn const_lreal_initializers_should_be_resolved_correctly() { VAR_GLOBAL CONSTANT clreal : LREAL := 3.1415; END_VAR - + VAR_GLOBAL CONSTANT tau : LREAL := 2 * clreal; END_VAR @@ -931,7 +931,7 @@ fn array_size_from_constant() { VAR CONSTANT a : INT := 3; b : INT := 7; - END_VAR + END_VAR VAR arr : ARRAY[a..b] OF BYTE; @@ -1005,7 +1005,7 @@ fn nested_array_literals_type_resolving() { let (parse_result, mut index) = index_with_ids( r#" VAR_GLOBAL CONSTANT - a : ARRAY[0..1] OF ARRAY[0..1] OF BYTE := [[1,2],[3,4]]; + a : ARRAY[0..1] OF ARRAY[0..1] OF BYTE := [[1,2],[3,4]]; END_VAR "#, id_provider.clone(), @@ -1064,7 +1064,7 @@ fn nested_array_literals_multiplied_statement_type_resolving() { let (parse_result, mut index) = index_with_ids( r#" VAR_GLOBAL CONSTANT - a : ARRAY[0..1] OF ARRAY[0..1] OF BYTE := [[2(2)],[2(3)]]; + a : ARRAY[0..1] OF ARRAY[0..1] OF BYTE := [[2(2)],[2(3)]]; END_VAR "#, id_provider.clone(), @@ -1157,7 +1157,7 @@ fn function_block_initializers_constant_resolved_in_assignment() { END_VAR END_FUNCTION_BLOCK - PROGRAM main + PROGRAM main VAR CONSTANT TEN : INT := 10; @@ -1184,7 +1184,7 @@ fn function_block_initializers_constant_resolved_in_assignment() { fn contants_in_case_statements_resolved() { let id_provider = IdProvider::default(); let (parse_result, mut index) = index_with_ids( - " + " PROGRAM main VAR DAYS_IN_MONTH : DINT; @@ -1193,12 +1193,12 @@ fn contants_in_case_statements_resolved() { SIXTY : DINT := 60; END_VAR CASE DAYS_IN_MONTH OF - 32..SIXTY : DAYS_IN_MONTH := 29; - (SIXTY + 2)..70 : DAYS_IN_MONTH := 30; + 32..SIXTY : DAYS_IN_MONTH := 29; + (SIXTY + 2)..70 : DAYS_IN_MONTH := 30; ELSE DAYS_IN_MONTH := 31; END_CASE; - END_PROGRAM + END_PROGRAM ", id_provider.clone(), ); @@ -1220,7 +1220,7 @@ fn contants_in_case_statements_resolved() { fn default_values_are_transitive_for_range_types() { // GIVEN a range type that inherits the default value from its referenced type let src = codegen( - " + " TYPE MyINT : INT := 7; END_TYPE TYPE MyRange : MyINT(1..10); END_TYPE diff --git a/src/resolver/tests/resolve_control_statments.rs b/src/resolver/tests/resolve_control_statments.rs index c911b37417..a65ba38ebe 100644 --- a/src/resolver/tests/resolve_control_statments.rs +++ b/src/resolver/tests/resolve_control_statments.rs @@ -14,7 +14,7 @@ fn binary_expressions_resolves_types() { let (unit, index) = index_with_ids( "PROGRAM PRG VAR x : INT; END_VAR - FOR x := 3 TO 10 BY 2 DO + FOR x := 3 TO 10 BY 2 DO x; END_FOR END_PROGRAM", diff --git a/src/resolver/tests/resolve_expressions_tests.rs b/src/resolver/tests/resolve_expressions_tests.rs index 4507024011..9e40af983e 100644 --- a/src/resolver/tests/resolve_expressions_tests.rs +++ b/src/resolver/tests/resolve_expressions_tests.rs @@ -94,8 +94,8 @@ fn cast_expression_literals_get_casted_types() { let id_provider = IdProvider::default(); let (unit, mut index) = index_with_ids( "PROGRAM PRG - INT#16#FFFF; - WORD#16#FFFF; + INT#16#FFFF; + WORD#16#FFFF; END_PROGRAM", id_provider.clone(), ); @@ -1430,7 +1430,7 @@ fn alias_and_subrange_expressions_resolve_types() { TYPE MySubrange : INT(0..100); END_TYPE; PROGRAM PRG - VAR + VAR i : INT; a : MyAlias; s : MySubrange; @@ -1756,7 +1756,7 @@ fn actions_are_resolved() { prg.foo; END_PROGRAM ACTIONS prg - ACTION foo + ACTION foo END_ACTION END_ACTIONS @@ -2413,17 +2413,17 @@ fn struct_member_explicit_initialization_test() { let id_provider = IdProvider::default(); let (unit, mut index) = index_with_ids( "FUNCTION main : DINT - VAR - x : myStruct; - END_VAR - x := (var1 := 1, var2 := 7); - END_FUNCTION - - TYPE myStruct : STRUCT - var1 : DINT; - var2 : BYTE; - END_STRUCT - END_TYPE", + VAR + x : myStruct; + END_VAR + x := (var1 := 1, var2 := 7); + END_FUNCTION + + TYPE myStruct : STRUCT + var1 : DINT; + var2 : BYTE; + END_STRUCT + END_TYPE", id_provider.clone(), ); @@ -2475,7 +2475,7 @@ fn program_members_initializers_type_hint_test() { let (unit, mut index) = index_with_ids( " PROGRAM prg - VAR_INPUT + VAR_INPUT i : INT := 7; si : SINT := 7; b : BOOL := 1; @@ -3433,9 +3433,9 @@ fn call_explicit_parameter_name_is_resolved() { END_FUNCTION_BLOCK PROGRAM PRG - VAR - f : fb; - END_VAR + VAR + f : fb; + END_VAR f(b:= 1, a:= 3); END_PROGRAM ", @@ -3495,9 +3495,9 @@ fn call_on_function_block_array() { END_FUNCTION_BLOCK PROGRAM PRG - VAR - fbs : ARRAY[1..2] OF fb; - END_VAR + VAR + fbs : ARRAY[1..2] OF fb; + END_VAR fbs[1](); END_PROGRAM ", @@ -3531,9 +3531,9 @@ fn and_statement_of_bools_results_in_bool() { let (unit, index) = index_with_ids( " PROGRAM PRG - VAR + VAR a,b : BOOL; - END_VAR + END_VAR a AND b; END_PROGRAM @@ -3555,10 +3555,10 @@ fn and_statement_of_dints_results_in_dint() { let (unit, index) = index_with_ids( " PROGRAM PRG - VAR + VAR a,b : DINT; c,d : INT; - END_VAR + END_VAR a AND b; c AND d; @@ -3582,21 +3582,21 @@ fn resolve_recursive_function_call() { let (unit, index) = index_with_ids( " FUNCTION foo : DINT - VAR_INPUT - input1 : DINT; - END_VAR - VAR_IN_OUT - inout1 : DINT; - END_VAR - VAR_OUTPUT - output1 : DINT; - END_VAR - VAR - var1, var2, var3 : DINT; - END_VAR - foo(input1 := var1, inout1 := var2, output1 => var3, ); - foo := var1; - END_FUNCTION + VAR_INPUT + input1 : DINT; + END_VAR + VAR_IN_OUT + inout1 : DINT; + END_VAR + VAR_OUTPUT + output1 : DINT; + END_VAR + VAR + var1, var2, var3 : DINT; + END_VAR + foo(input1 := var1, inout1 := var2, output1 => var3, ); + foo := var1; + END_FUNCTION ", id_provider.clone(), ); @@ -3630,20 +3630,20 @@ fn resolve_recursive_program_call() { let (unit, index) = index_with_ids( " PROGRAM mainProg - VAR_INPUT - input1 : DINT; - END_VAR - VAR_IN_OUT - inout1 : DINT; - END_VAR - VAR_OUTPUT - output1 : DINT; - END_VAR - VAR - var1, var2, var3 : DINT; - END_VAR - mainProg(input1 := var1, inout1 := var2, output1 => var3, ); - END_PROGRAM + VAR_INPUT + input1 : DINT; + END_VAR + VAR_IN_OUT + inout1 : DINT; + END_VAR + VAR_OUTPUT + output1 : DINT; + END_VAR + VAR + var1, var2, var3 : DINT; + END_VAR + mainProg(input1 := var1, inout1 := var2, output1 => var3, ); + END_PROGRAM ", id_provider.clone(), ); @@ -4098,17 +4098,17 @@ fn array_of_struct_with_initial_values_annotated_correctly() { // GIVEN let (unit, mut index) = index_with_ids( " - TYPE myStruct : STRUCT - a, b : DINT; - c : ARRAY[0..1] OF DINT; - END_STRUCT - END_TYPE - - PROGRAM main - VAR - arr : ARRAY[0..1] OF myStruct := [(a := 10, b := 20, c := [30, 40]), (a := 50, b := 60, c := [70, 80])]; - END_VAR - END_PROGRAM", + TYPE myStruct : STRUCT + a, b : DINT; + c : ARRAY[0..1] OF DINT; + END_STRUCT + END_TYPE + + PROGRAM main + VAR + arr : ARRAY[0..1] OF myStruct := [(a := 10, b := 20, c := [30, 40]), (a := 50, b := 60, c := [70, 80])]; + END_VAR + END_PROGRAM", id_provider.clone(), ); @@ -4239,18 +4239,18 @@ fn mux_generic_with_strings_is_annotated_correctly() { // GIVEN let (unit, mut index) = index_with_ids( " - PROGRAM main - VAR - str1 : STRING; - END_VAR - VAR_TEMP - str2 : STRING := 'str2 '; - str3 : STRING := 'str3 '; - str4 : STRING := 'str4 '; - END_VAR - MUX(2, str2, str3, str4); + PROGRAM main + VAR + str1 : STRING; + END_VAR + VAR_TEMP + str2 : STRING := 'str2 '; + str3 : STRING := 'str3 '; + str4 : STRING := 'str4 '; + END_VAR + MUX(2, str2, str3, str4); str2; - END_PROGRAM + END_PROGRAM ", id_provider.clone(), ); @@ -4964,8 +4964,8 @@ fn override_is_resolved() { END_CLASS FUNCTION_BLOCK fb - VAR - myClass : cls2; + VAR + myClass : cls2; END_VAR myClass.foo(); @@ -5023,8 +5023,8 @@ fn override_in_grandparent_is_resolved() { END_CLASS FUNCTION_BLOCK fb - VAR - myClass : cls2; + VAR + myClass : cls2; END_VAR myClass.foo(); @@ -5065,8 +5065,8 @@ fn annotate_variable_in_parent_class() { let (unit, index) = index_with_ids( " CLASS cls1 - VAR - LIGHT: BOOL; + VAR + LIGHT: BOOL; END_VAR END_CLASS @@ -5120,7 +5120,7 @@ fn annotate_variable_in_grandparent_class() { let (unit, index) = index_with_ids( " CLASS cls0 - VAR + VAR LIGHT: BOOL; END_VAR END_CLASS @@ -5158,7 +5158,7 @@ fn annotate_variable_in_field() { let (unit, index) = index_with_ids( " CLASS cls0 - VAR + VAR LIGHT: BOOL; END_VAR END_CLASS @@ -5170,8 +5170,8 @@ fn annotate_variable_in_field() { END_FUNCTION_BLOCK PROGRAM prog - VAR - myClass : cls2; + VAR + myClass : cls2; END_VAR myClass.LIGHT := TRUE; @@ -5203,7 +5203,7 @@ fn annotate_method_in_super() { let (unit, index) = index_with_ids( " CLASS cls0 - VAR + VAR LIGHT: BOOL; END_VAR @@ -5213,7 +5213,7 @@ fn annotate_method_in_super() { END_CLASS CLASS cls1 EXTENDS cls0 - VAR + VAR LIGHT1: BOOL; END_VAR @@ -5224,7 +5224,7 @@ fn annotate_method_in_super() { END_CLASS CLASS cls2 EXTENDS cls1 - VAR + VAR LIGHT2: BOOL; END_VAR METHOD meth2 : DINT diff --git a/src/resolver/tests/resolve_generic_calls.rs b/src/resolver/tests/resolve_generic_calls.rs index 5d1d905722..cda9f0ac68 100644 --- a/src/resolver/tests/resolve_generic_calls.rs +++ b/src/resolver/tests/resolve_generic_calls.rs @@ -512,7 +512,7 @@ fn builtin_generic_functions_do_not_get_specialized_calls() { fn builtin_adr_ref_return_annotated() { let id_provider = IdProvider::default(); let (unit, index) = index_with_ids( - "PROGRAM main + "PROGRAM main VAR_INPUT input1 : REF_TO DINT; param1 : DINT; @@ -573,7 +573,7 @@ fn resolve_variadic_generics() { let id_provider = IdProvider::default(); let (unit, index) = index_with_ids( " - FUNCTION ex : U + FUNCTION ex : U VAR_INPUT ar : {sized}U...; END_VAR @@ -613,14 +613,14 @@ fn generic_call_gets_cast_to_biggest_type() { let id_provider = IdProvider::default(); let (unit, index) = index_with_ids( r" - + {external} FUNCTION MAX : T VAR_INPUT args : {sized} T...; END_VAR END_FUNCTION - + FUNCTION main : LREAL MAX(SINT#5,DINT#1,LREAL#1.5,1.2); END_FUNCTION", @@ -694,13 +694,13 @@ fn auto_pointer_of_generic_resolved() { IN : T; END_VAR END_FUNCTION - + FUNCTION LEFT_EXT : DINT VAR_IN_OUT IN : T; END_VAR END_FUNCTION - + FUNCTION LEFT__DINT : DINT VAR_INPUT IN : DINT; @@ -731,14 +731,14 @@ fn string_ref_as_generic_resolved() { IN : T; END_VAR END_FUNCTION - + FUNCTION LEFT_EXT : DINT VAR_INPUT {ref} IN : T; END_VAR END_FUNCTION - - FUNCTION LEFT__STRING : STRING + + FUNCTION LEFT__STRING : STRING VAR_INPUT IN : STRING; END_VAR @@ -790,18 +790,18 @@ fn resolved_generic_any_real_call_with_ints_added_to_index() { PROGRAM PRG VAR a : INT; - b : UINT; + b : UINT; END_VAR myFunc(REAL#1.0); myFunc(SINT#1); myFunc(a); myFunc(DINT#1); - myFunc(LINT#1); + myFunc(LINT#1); - myFunc(USINT#1); + myFunc(USINT#1); myFunc(b); myFunc(UDINT#1); - myFunc(ULINT#1); + myFunc(ULINT#1); END_PROGRAM", id_provider.clone(), ); @@ -832,7 +832,7 @@ fn generic_string_functions_are_annotated_correctly() { FUNCTION foo : T VAR_INPUT {ref} in : T; - END_VAR + END_VAR END_FUNCTION FUNCTION foo__STRING : STRING @@ -878,7 +878,7 @@ fn generic_string_functions_are_annotated_correctly() { fn generic_string_functions_without_specific_implementation_are_annotated_correctly() { let id_provider = IdProvider::default(); let (unit, mut index) = index_with_ids( - r#" + r#" FUNCTION LEN : DINT VAR_INPUT {ref} IN : T; @@ -943,7 +943,7 @@ fn generic_string_functions_with_non_default_length_are_annotated_correctly() { FUNCTION foo : T VAR_INPUT {ref} in : T; - END_VAR + END_VAR VAR_OUTPUT {ref} out : T; END_VAR diff --git a/src/resolver/tests/resolve_literals_tests.rs b/src/resolver/tests/resolve_literals_tests.rs index 18868548fa..5997737c1e 100644 --- a/src/resolver/tests/resolve_literals_tests.rs +++ b/src/resolver/tests/resolve_literals_tests.rs @@ -114,12 +114,12 @@ fn date_literals_are_annotated() { TIME#-12m; TOD#00:00:12; TIME_OF_DAY#04:16:22; - TIME_OF_DAY#04:16; - DATE_AND_TIME#1984-10-01-16:40:22; - DT#2021-04-20-22:33:14; - DATE_AND_TIME#2000-01-01-20:15; - DATE#1984-10-01; - D#2021-04-20; + TIME_OF_DAY#04:16; + DATE_AND_TIME#1984-10-01-16:40:22; + DT#2021-04-20-22:33:14; + DATE_AND_TIME#2000-01-01-20:15; + DATE#1984-10-01; + D#2021-04-20; END_PROGRAM", id_provider.clone(), ); @@ -149,9 +149,9 @@ fn long_date_literals_are_annotated() { let (unit, index) = index_with_ids( "PROGRAM PRG LTIME#12.4d; - LDATE#1984-10-01; - LDT#1984-10-01-16:40:22; - LTOD#00:00:12; + LDATE#1984-10-01; + LDT#1984-10-01-16:40:22; + LTOD#00:00:12; END_PROGRAM", id_provider.clone(), ); @@ -222,10 +222,10 @@ fn enum_literals_are_annotated() { TYPE Color: (Green, Yellow, Red); END_TYPE TYPE Animal: (Dog, Cat, Horse); END_TYPE - VAR_GLOBAL + VAR_GLOBAL Cat : BOOL; END_VAR - + PROGRAM PRG VAR Yellow: BYTE; END_VAR @@ -462,11 +462,11 @@ fn expression_list_as_array_initilization_is_annotated_correctly() { let id_provider = IdProvider::default(); let (unit, mut index) = index_with_ids( " - VAR_GLOBAL - a : ARRAY[0..2] OF INT := 1+1,2; - b : ARRAY[0..2] OF STRING[3] := 'ABC','D'; - END_VAR - ", + VAR_GLOBAL + a : ARRAY[0..2] OF INT := 1+1,2; + b : ARRAY[0..2] OF STRING[3] := 'ABC','D'; + END_VAR + ", id_provider.clone(), ); diff --git a/src/resolver/tests/resolver_dependency_resolution.rs b/src/resolver/tests/resolver_dependency_resolution.rs index ba9546420f..f8df3a68a1 100644 --- a/src/resolver/tests/resolver_dependency_resolution.rs +++ b/src/resolver/tests/resolver_dependency_resolution.rs @@ -336,19 +336,19 @@ fn function_params_dependency_resolution() { " FUNCTION foo : BYTE VAR_INPUT - a : DINT; + a : DINT; END_VAR VAR_INPUT {ref} - b : INT; + b : INT; END_VAR VAR_IN_OUT - c : REAL; + c : REAL; END_VAR VAR_OUTPUT d : LREAL; END_VAR VAR - e : WORD; + e : WORD; END_VAR END_FUNCTION ", @@ -385,18 +385,18 @@ fn function_params_dependency_resolution() { fn program_params_dependency_resolution() { let units = [ " - PROGRAM foo + PROGRAM foo VAR_INPUT - a : DINT; + a : DINT; END_VAR VAR_IN_OUT - c : REAL; + c : REAL; END_VAR VAR_OUTPUT d : LREAL; END_VAR VAR - e : WORD; + e : WORD; END_VAR END_PROGRAM ", @@ -429,21 +429,21 @@ fn program_params_dependency_resolution() { fn function_block_params_dependency_resolution() { let units = [ " - FUNCTION_BLOCK fb + FUNCTION_BLOCK fb VAR_INPUT - a : DINT; + a : DINT; END_VAR VAR_INPUT {ref} - b : INT; + b : INT; END_VAR VAR_IN_OUT - c : REAL; + c : REAL; END_VAR VAR_OUTPUT d : LREAL; END_VAR VAR - e : WORD; + e : WORD; END_VAR END_FUNCTION_BLOCK ", diff --git a/src/tests/adr/annotated_ast_adr.rs b/src/tests/adr/annotated_ast_adr.rs index 233b563ade..bdfc003e7c 100644 --- a/src/tests/adr/annotated_ast_adr.rs +++ b/src/tests/adr/annotated_ast_adr.rs @@ -24,7 +24,7 @@ fn references_to_variables_are_annotated() { // parse and index let (statements, annotations, ..) = annotate!( r#" - PROGRAM prg + PROGRAM prg VAR a : SINT; b : SINT; @@ -74,9 +74,9 @@ fn different_types_of_annotations() { // parse and annotate the following program let (statements, annotations, ..) = annotate!( r#" - PROGRAM prg + PROGRAM prg VAR p : POINT END_VAR - + p.x; // to a variable (POINT.x) foo(); // resolves to a call p.y + foo(); // resolves to a value @@ -85,7 +85,7 @@ fn different_types_of_annotations() { FUNCTION foo : DINT END_FUNCTION - PROGRAM Main + PROGRAM Main VAR_INPUT in : INT; END_VAR END_FUNCTION @@ -182,13 +182,13 @@ fn different_types_of_annotations() { fn type_annotations_reflect_the_evaluation_result() { let (statements, annotations, idx) = annotate!( r#" - PROGRAM prg - VAR - i : INT; + PROGRAM prg + VAR + i : INT; d : DINT; l : LINT; END_VAR - + i + d; i + 3; l - d; @@ -220,12 +220,12 @@ fn type_annotations_reflect_the_evaluation_result() { fn type_annotations_indicates_necessary_casts() { let (statements, annotations, _) = annotate!( r#" - PROGRAM prg - VAR - i : INT; + PROGRAM prg + VAR + i : INT; d : DINT; END_VAR - + i := d; d := i; foo(3); @@ -270,13 +270,13 @@ fn type_annotations_indicates_necessary_casts() { fn type_annotations_for_binary_expression() { let (statements, annotations, _) = annotate!( r#" - PROGRAM prg - VAR - i : INT; + PROGRAM prg + VAR + i : INT; d : DINT; r : LREAL; END_VAR - + i + d; r / d; END_PROGRAM @@ -309,12 +309,12 @@ fn type_annotations_for_binary_expression() { fn useful_type_annotation_method() { let (statements, annotations, idx) = annotate!( r#" - PROGRAM prg - VAR - i : INT; + PROGRAM prg + VAR + i : INT; d : DINT; END_VAR - + i + d; END_PROGRAM "# diff --git a/src/tests/adr/arrays_adr.rs b/src/tests/adr/arrays_adr.rs index 7538b8a564..492a0d2a22 100644 --- a/src/tests/adr/arrays_adr.rs +++ b/src/tests/adr/arrays_adr.rs @@ -109,7 +109,7 @@ fn accessing_array_elements() { END_VAR a[2] := b[4]; - END_PROGRAM + END_PROGRAM "#; // ... both will use 0-based indexing internally, although one is 0-based and the other is 3-based diff --git a/src/tests/adr/enum_adr.rs b/src/tests/adr/enum_adr.rs index b43f7b0f3b..43aa3b68a7 100644 --- a/src/tests/adr/enum_adr.rs +++ b/src/tests/adr/enum_adr.rs @@ -102,7 +102,7 @@ fn using_enums() { let src = r#" TYPE ProcessState : (open := 1, closed := 4, idle, running); END_TYPE; - + TYPE Door : (open := 8, closed := 16); END_TYPE; diff --git a/src/tests/adr/pou_adr.rs b/src/tests/adr/pou_adr.rs index d9fd1c63b2..d5bf53649c 100644 --- a/src/tests/adr/pou_adr.rs +++ b/src/tests/adr/pou_adr.rs @@ -28,7 +28,7 @@ use crate::test_utils::tests::{annotate_with_ids, codegen, index_with_ids}; /// global variable withe the program's name. When calling a program all parameters, except IN_OUT parameters, are optional. const DEFAULT_PRG: &str = r#" - PROGRAM main_prg + PROGRAM main_prg VAR_INPUT i : INT END_VAR VAR_IN_OUT io : INT END_VAR VAR_OUTPUT o : INT; END_VAR @@ -77,11 +77,11 @@ fn programs_state_is_stored_in_a_struct() { TextLocation { line: 2, column: 20, - offset: 43, + offset: 42, }..TextLocation { line: 2, column: 21, - offset: 44, + offset: 43, }, ), }, @@ -104,11 +104,11 @@ fn programs_state_is_stored_in_a_struct() { TextLocation { line: 3, column: 20, - offset: 83, + offset: 82, }..TextLocation { line: 3, column: 22, - offset: 85, + offset: 84, }, ), }, @@ -131,11 +131,11 @@ fn programs_state_is_stored_in_a_struct() { TextLocation { line: 4, column: 20, - offset: 123, + offset: 122, }..TextLocation { line: 4, column: 21, - offset: 124, + offset: 123, }, ), }, @@ -158,11 +158,11 @@ fn programs_state_is_stored_in_a_struct() { TextLocation { line: 5, column: 20, - offset: 163, + offset: 162, }..TextLocation { line: 5, column: 21, - offset: 164, + offset: 163, }, ), }, @@ -185,11 +185,11 @@ fn programs_state_is_stored_in_a_struct() { TextLocation { line: 6, column: 20, - offset: 203, + offset: 202, }..TextLocation { line: 6, column: 22, - offset: 205, + offset: 204, }, ), }, @@ -259,7 +259,7 @@ fn calling_a_program() { r#" FUNCTION foo : INT VAR x, y : INT; END_VAR - main_prg(i := 1, io := y, o => x); + main_prg(i := 1, io := y, o => x); END_FUNCTION {DEFAULT_PRG} @@ -361,8 +361,8 @@ fn calling_a_function_block() { PROGRAM foo VAR x, y : INT; END_VAR VAR fb : main_fb; END_VAR - - fb(i := 1, io := y, o => x); + + fb(i := 1, io := y, o => x); END_PROGRAM {DEFAULT_FB} @@ -460,10 +460,10 @@ fn calling_a_function() { r#" PROGRAM prg VAR - x : INT; - z : SINT; - END_VAR - main_fun(x, z); + x : INT; + z : SINT; + END_VAR + main_fun(x, z); END_FUNCTION {DEFAULT_FUNC} @@ -526,9 +526,9 @@ fn return_a_complex_type_from_function() { PROGRAM prg VAR - s : STRING; + s : STRING; END_VAR - s := foo(); + s := foo(); END_FUNCTION "#; insta::assert_snapshot!(codegen(returning_string), @r###" @@ -594,8 +594,8 @@ fn passing_by_ref_to_functions() { // ... END_FUNCTION PROGRAM main - VAR - str1, str2 : STRING; + VAR + str1, str2 : STRING; END_VAR StrEqual(str1, str2); //looks like pass by-val END_PROGRAM diff --git a/src/tests/adr/vla_adr.rs b/src/tests/adr/vla_adr.rs index 2cfe6ce7cd..0fc8ab72cc 100644 --- a/src/tests/adr/vla_adr.rs +++ b/src/tests/adr/vla_adr.rs @@ -27,7 +27,7 @@ fn representation() { // The probably most interesting entry here is the `source` field, indicating that the given struct is a // VLA with one dimension of type DINT. - insta::assert_debug_snapshot!(index.find_effective_type_by_name("__foo_arr").unwrap(), + insta::assert_debug_snapshot!(index.find_effective_type_by_name("__foo_arr").unwrap(), @r###" DataType { name: "__foo_arr", @@ -95,7 +95,7 @@ fn representation() { "###); // Pointer to `__arr_vla_1_dint`, which translates to... - insta::assert_debug_snapshot!(index.find_effective_type_by_name("__ptr_to___arr_vla_1_dint").unwrap(), + insta::assert_debug_snapshot!(index.find_effective_type_by_name("__ptr_to___arr_vla_1_dint").unwrap(), @r###" DataType { name: "__ptr_to___arr_vla_1_dint", @@ -136,7 +136,7 @@ fn representation() { "###); // Finally the dimensions array, which is being populated at runtime; see [`pass`] - insta::assert_debug_snapshot!(index.find_effective_type_by_name("__bounds___arr_vla_1_dint").unwrap(), + insta::assert_debug_snapshot!(index.find_effective_type_by_name("__bounds___arr_vla_1_dint").unwrap(), @r###" DataType { name: "__bounds___arr_vla_1_dint", @@ -211,7 +211,7 @@ fn pass() { let (_, local) = deconstruct_call_statement!(&statements[0]); // `local` is defined as an array of type DINT... - insta::assert_debug_snapshot!(annotations.get_type(local[0], &index).unwrap(), + insta::assert_debug_snapshot!(annotations.get_type(local[0], &index).unwrap(), @r###" DataType { name: "__main_local", @@ -256,7 +256,7 @@ fn pass() { // ...but their type-hint indicates it should be VLA / fat-pointer struct. Such type-mismatches (for VLAs) // result in wrapping arrays into structs. let hint = annotations.get_type_hint(local[0], &index).unwrap(); - insta::assert_debug_snapshot!(index.find_elementary_pointer_type(&hint.information), + insta::assert_debug_snapshot!(index.find_elementary_pointer_type(&hint.information), @r###" Struct { name: "__foo_arr", @@ -309,7 +309,7 @@ fn pass() { // 1. Stack-allocate a struct // 2. GEP the structs array and dimension field // 3. Populate them based on the information we have on `local`, i.e. 1D and (start, end)-offset = (0, 5) - insta::assert_snapshot!(codegen(src), + insta::assert_snapshot!(codegen(src), @r###" ; ModuleID = 'main' source_filename = "main" @@ -375,7 +375,7 @@ fn access() { END_FUNCTION "; - insta::assert_snapshot!(codegen(src), + insta::assert_snapshot!(codegen(src), @r###" ; ModuleID = 'main' source_filename = "main" @@ -433,15 +433,15 @@ fn multi_dimensional() { // To increase readability of the generated IR, most values are named according to their purpose. // When dealing with a higher dimension-count or multiple access statements, the IR gets bloated really fast and // is borderline incomprehensible as a result, if not given readable names. - insta::assert_snapshot!(codegen(src), + insta::assert_snapshot!(codegen(src), @r###" ; ModuleID = 'main' source_filename = "main" - + %__foo_arr = type { i32*, [4 x i32] } - + @____foo_arr__init = unnamed_addr constant %__foo_arr zeroinitializer - + define i32 @foo(%__foo_arr* %0) { entry: %foo = alloca i32, align 4 diff --git a/src/validation/statement.rs b/src/validation/statement.rs index be37f3c0ff..d45b93f307 100644 --- a/src/validation/statement.rs +++ b/src/validation/statement.rs @@ -1039,7 +1039,7 @@ fn validate_type_nature( // check if type_hint and actual_type is compatible // should be handled by assignment validation if !(actual_type.has_nature(*generic_nature, context.index) - // INT parameter for REAL is allowed + // INT parameter for REAL is allowed | (type_hint.is_real() & actual_type.is_numerical())) { validator.push_diagnostic(Diagnostic::invalid_type_nature( diff --git a/src/validation/tests/array_validation_test.rs b/src/validation/tests/array_validation_test.rs index e541b62237..a56080c7b8 100644 --- a/src/validation/tests/array_validation_test.rs +++ b/src/validation/tests/array_validation_test.rs @@ -6,42 +6,42 @@ use crate::test_utils::tests::parse_and_validate_buffered; fn array_access_validation() { let diagnostics = parse_and_validate_buffered( " - VAR_GLOBAL CONSTANT - start : INT := 1; - end : INT := 2; - END_VAR - - PROGRAM prg - VAR - multi : ARRAY[0..1,2..3] OF INT; - nested : ARRAY[0..1] OF ARRAY[2..3] OF INT; - arr : ARRAY[0..1] OF INT; - negative_start : ARRAY[-2..2] OF INT; - negative : ARRAY[-3..-1] OF INT; - const : ARRAY[start..end] OF INT; - int_ref : INT; - string_ref : STRING; - END_VAR - - // valid - multi[0,3]; - nested[1][3]; - arr[1]; - negative_start[-1]; - negative[-2]; - const[1]; - arr[int_ref]; - - // invalid - multi[1,4]; // out of range - nested[1][4]; // out of range - arr[3]; // out of range - negative_start[-4]; // out of range - negative[-4]; // out of range - const[3]; // out of range - arr[string_ref]; // invalid type for array access - int_ref[1]; // not an array - END_PROGRAM + VAR_GLOBAL CONSTANT + start : INT := 1; + end : INT := 2; + END_VAR + + PROGRAM prg + VAR + multi : ARRAY[0..1,2..3] OF INT; + nested : ARRAY[0..1] OF ARRAY[2..3] OF INT; + arr : ARRAY[0..1] OF INT; + negative_start : ARRAY[-2..2] OF INT; + negative : ARRAY[-3..-1] OF INT; + const : ARRAY[start..end] OF INT; + int_ref : INT; + string_ref : STRING; + END_VAR + + // valid + multi[0,3]; + nested[1][3]; + arr[1]; + negative_start[-1]; + negative[-2]; + const[1]; + arr[int_ref]; + + // invalid + multi[1,4]; // out of range + nested[1][4]; // out of range + arr[3]; // out of range + negative_start[-4]; // out of range + negative[-4]; // out of range + const[3]; // out of range + arr[string_ref]; // invalid type for array access + int_ref[1]; // not an array + END_PROGRAM ", ); @@ -52,28 +52,28 @@ fn array_access_validation() { fn array_initialization_validation() { let diagnostics = parse_and_validate_buffered( " - FUNCTION main : DINT - VAR - arr : ARRAY[1..2] OF DINT; - arr2 : ARRAY[1..2] OF DINT := 1, 2; // Missing `[` - arr3 : ARRAY[1..2] OF myStruct := ((var1 := 1), (var1 := 2, var2 := (1, 2))); // Missing `[` - arr4 : ARRAY[1..2] OF myStruct := ((var1 := 1), (var1 := 2, var2 := 1, 2)); // Missing `[` - arr_init : ARRAY[1..2] OF DINT := (1, 2); // Missing `[` - x : myStruct; - y : myStruct := (var1 := 1, var2 := 3, 4); // Missing `[` - END_VAR - arr := 1, 2; // Missing `[` - arr := (1, 2); // Missing `[` - arr := (arr_init); // valid - x := (var1 := 1, var2 := 3, 4); // Missing `[` - x := (var1 := 1, var2 := arr_init); // valid - END_FUNCTION - - TYPE myStruct : STRUCT - var1 : DINT; - var2 : ARRAY[1..2] OF DINT; - END_STRUCT - END_TYPE + FUNCTION main : DINT + VAR + arr : ARRAY[1..2] OF DINT; + arr2 : ARRAY[1..2] OF DINT := 1, 2; // Missing `[` + arr3 : ARRAY[1..2] OF myStruct := ((var1 := 1), (var1 := 2, var2 := (1, 2))); // Missing `[` + arr4 : ARRAY[1..2] OF myStruct := ((var1 := 1), (var1 := 2, var2 := 1, 2)); // Missing `[` + arr_init : ARRAY[1..2] OF DINT := (1, 2); // Missing `[` + x : myStruct; + y : myStruct := (var1 := 1, var2 := 3, 4); // Missing `[` + END_VAR + arr := 1, 2; // Missing `[` + arr := (1, 2); // Missing `[` + arr := (arr_init); // valid + x := (var1 := 1, var2 := 3, 4); // Missing `[` + x := (var1 := 1, var2 := arr_init); // valid + END_FUNCTION + + TYPE myStruct : STRUCT + var1 : DINT; + var2 : ARRAY[1..2] OF DINT; + END_STRUCT + END_TYPE ", ); @@ -84,23 +84,23 @@ fn array_initialization_validation() { fn array_access_dimension_mismatch() { let diagnostics = parse_and_validate_buffered( " - FUNCTION fn : DINT - VAR_INPUT {ref} - arr : ARRAY[0..5] OF DINT; - vla : ARRAY[*] OF DINT; - END_VAR - - // Valid - arr[0] := 1; - vla[0] := 1; - - // Invalid - arr[0, 1] := 1; - vla[0, 1] := 1; - arr[0, 1, 2] := 1; - vla[0, 1, 2] := 1; - END_FUNCTION - ", + FUNCTION fn : DINT + VAR_INPUT {ref} + arr : ARRAY[0..5] OF DINT; + vla : ARRAY[*] OF DINT; + END_VAR + + // Valid + arr[0] := 1; + vla[0] := 1; + + // Invalid + arr[0, 1] := 1; + vla[0, 1] := 1; + arr[0, 1, 2] := 1; + vla[0, 1, 2] := 1; + END_FUNCTION + ", ); assert_snapshot!(diagnostics); @@ -110,23 +110,23 @@ fn array_access_dimension_mismatch() { fn assignment_1d() { let diagnostics = parse_and_validate_buffered( " - FUNCTION main : DINT - VAR - arr : ARRAY[1..5] OF DINT := [1, 2, 3, 4, 5, 6]; - arr_alt : ARRAY[1..5] OF DINT := (1, 2, 3, 4, 5, 6); - END_VAR - - arr := [1, 2, 3, 4]; // Valid - arr := [1, 2, 3, 4, 5]; // Valid - - arr := (1, 2, 3, 4); - arr := (1, 2, 3, 4, 5); - arr := (1, 2, 3, 4, 5, 6); - arr := [1, 2, 3, 4, 5, 6]; - arr := [1, 2, 3, 4, 5); - arr := (1, 2, 3, 4, 5]; - END_FUNCTION - ", + FUNCTION main : DINT + VAR + arr : ARRAY[1..5] OF DINT := [1, 2, 3, 4, 5, 6]; + arr_alt : ARRAY[1..5] OF DINT := (1, 2, 3, 4, 5, 6); + END_VAR + + arr := [1, 2, 3, 4]; // Valid + arr := [1, 2, 3, 4, 5]; // Valid + + arr := (1, 2, 3, 4); + arr := (1, 2, 3, 4, 5); + arr := (1, 2, 3, 4, 5, 6); + arr := [1, 2, 3, 4, 5, 6]; + arr := [1, 2, 3, 4, 5); + arr := (1, 2, 3, 4, 5]; + END_FUNCTION + ", ); assert_snapshot!(diagnostics); @@ -136,28 +136,28 @@ fn assignment_1d() { fn assignment_2d() { let diagnostics = parse_and_validate_buffered( " - FUNCTION main : DINT - VAR - arr : ARRAY[1..2, 1..5] OF DINT := [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]; - arr_alt : ARRAY[1..2, 1..5] OF DINT := (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11); - - arr_nested : ARRAY[1..2] OF ARRAY[1..5] OF DINT := [ [1, 2, 3, 4, 5], [6, 7, 8, 9, 10], [11, 12, 13, 14, 15] ]; - arr_nested_alt : ARRAY[1..2] OF ARRAY[1..5] OF DINT := ( [1, 2, 3, 4, 5], [6, 7, 8, 9, 10], [11, 12, 13, 14, 15] ); - END_VAR - - arr := [1, 2, 3, 4, 5, 6, 7, 8, 9]; // Valid - arr := [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]; // Valid - - arr := (1, 2, 3, 4, 5, 6, 7, 8, 9); - arr := (1, 2, 3, 4, 5, 6, 7, 8, 9, 10); - arr := (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11); - arr := [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]; - - arr_nested := [ [1, 2, 3, 4, 5], [6, 7, 8, 9, 10] ]; // Valid - arr_nested := [ [1, 2, 3, 4, 5], [6, 7, 8, 9, 10], [11, 12, 13, 14, 15] ]; - arr_nested := ( [1, 2, 3, 4, 5], [6, 7, 8, 9, 10], [11, 12, 13, 14, 15] ); - END_FUNCTION - ", + FUNCTION main : DINT + VAR + arr : ARRAY[1..2, 1..5] OF DINT := [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]; + arr_alt : ARRAY[1..2, 1..5] OF DINT := (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11); + + arr_nested : ARRAY[1..2] OF ARRAY[1..5] OF DINT := [ [1, 2, 3, 4, 5], [6, 7, 8, 9, 10], [11, 12, 13, 14, 15] ]; + arr_nested_alt : ARRAY[1..2] OF ARRAY[1..5] OF DINT := ( [1, 2, 3, 4, 5], [6, 7, 8, 9, 10], [11, 12, 13, 14, 15] ); + END_VAR + + arr := [1, 2, 3, 4, 5, 6, 7, 8, 9]; // Valid + arr := [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]; // Valid + + arr := (1, 2, 3, 4, 5, 6, 7, 8, 9); + arr := (1, 2, 3, 4, 5, 6, 7, 8, 9, 10); + arr := (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11); + arr := [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]; + + arr_nested := [ [1, 2, 3, 4, 5], [6, 7, 8, 9, 10] ]; // Valid + arr_nested := [ [1, 2, 3, 4, 5], [6, 7, 8, 9, 10], [11, 12, 13, 14, 15] ]; + arr_nested := ( [1, 2, 3, 4, 5], [6, 7, 8, 9, 10], [11, 12, 13, 14, 15] ); + END_FUNCTION + ", ); assert_snapshot!(diagnostics); @@ -167,27 +167,27 @@ fn assignment_2d() { fn assignment_3d() { let diagnostics = parse_and_validate_buffered( " - FUNCTION main : DINT - VAR - arr : ARRAY[1..2, 1..2, 1..2] OF DINT := [1, 2, 3, 4, 5, 6, 7, 8, 9]; - arr_alt : ARRAY[1..2, 1..2, 1..2] OF DINT := (1, 2, 3, 4, 5, 6, 7, 8, 9); - - arr_nested : ARRAY[1..2] OF ARRAY[1..2] OF ARRAY[1..2] OF DINT := [ [[1, 2], [3, 4]], [[5, 6], [7, 8]], [[9, 10], [11, 12]] ]; - arr_nested_alt : ARRAY[1..2] OF ARRAY[1..2] OF ARRAY[1..2] OF DINT := ( [[1, 2], [3, 4]], [[5, 6], [7, 8]], [[9, 10], [11, 12]] ); - END_VAR - - arr := [1, 2, 3, 4, 5, 6, 7]; // Valid - arr := [1, 2, 3, 4, 5, 6, 7, 8]; // Valid - - arr := (1, 2, 3, 4, 5, 6, 7, 8); - arr := (1, 2, 3, 4, 5, 6, 7, 8, 9); - arr := [1, 2, 3, 4, 5, 6, 7, 8, 9]; - - arr_nested := [ [[1, 2], [3, 4]], [[5, 6], [7, 8]] ]; // Valid - arr_nested := [ [[1, 2], [3, 4]], [[5, 6], [7, 8]], [[9, 10], [11, 12]] ]; - arr_nested := ( [[1, 2], [3, 4]], [[5, 6], [7, 8]], [[9, 10], [11, 12]] ); - END_FUNCTION - ", + FUNCTION main : DINT + VAR + arr : ARRAY[1..2, 1..2, 1..2] OF DINT := [1, 2, 3, 4, 5, 6, 7, 8, 9]; + arr_alt : ARRAY[1..2, 1..2, 1..2] OF DINT := (1, 2, 3, 4, 5, 6, 7, 8, 9); + + arr_nested : ARRAY[1..2] OF ARRAY[1..2] OF ARRAY[1..2] OF DINT := [ [[1, 2], [3, 4]], [[5, 6], [7, 8]], [[9, 10], [11, 12]] ]; + arr_nested_alt : ARRAY[1..2] OF ARRAY[1..2] OF ARRAY[1..2] OF DINT := ( [[1, 2], [3, 4]], [[5, 6], [7, 8]], [[9, 10], [11, 12]] ); + END_VAR + + arr := [1, 2, 3, 4, 5, 6, 7]; // Valid + arr := [1, 2, 3, 4, 5, 6, 7, 8]; // Valid + + arr := (1, 2, 3, 4, 5, 6, 7, 8); + arr := (1, 2, 3, 4, 5, 6, 7, 8, 9); + arr := [1, 2, 3, 4, 5, 6, 7, 8, 9]; + + arr_nested := [ [[1, 2], [3, 4]], [[5, 6], [7, 8]] ]; // Valid + arr_nested := [ [[1, 2], [3, 4]], [[5, 6], [7, 8]], [[9, 10], [11, 12]] ]; + arr_nested := ( [[1, 2], [3, 4]], [[5, 6], [7, 8]], [[9, 10], [11, 12]] ); + END_FUNCTION + ", ); assert_snapshot!(diagnostics); @@ -197,27 +197,27 @@ fn assignment_3d() { fn assignment_structs() { let diagnostics = parse_and_validate_buffered( " - TYPE FOO : STRUCT - idx : DINT; - arr : ARRAY[1..2] OF BAR; - END_STRUCT END_TYPE - - TYPE BAR : STRUCT - arr : ARRAY[1..5] OF DINT; - END_STRUCT END_TYPE - - FUNCTION main : DINT - VAR - foo_valid_0 : FOO := (idx := 0, arr := [(arr := [1, 2, 3, 4, 5])]); - foo_valid_1 : FOO := (idx := 0, arr := [(arr := [1, 2, 3, 4, 5]), (arr := [1, 2, 3])]); - foo_valid_2 : FOO := (idx := 0, arr := [(arr := [1, 2, 3, 4, 5]), (arr := [1, 2, 3, 4, 5])]); - foo_valid_3 : FOO := (arr := [(arr := [1, 2, 3, 4, 5]), (arr := [1, 2, 3, 4, 5])], idx := 0); - - foo_invalid_0 : FOO := (idx := 0, arr := ((arr := (1, 2, 3, 4, 5)), (arr := (1, 2, 3, 4, 5)))); - foo_invalid_1 : FOO := (idx := 0, arr := ((arr := (1, 2, 3, 4, 5)), (arr := (1, 2, 3, 4, 5)))); - END_VAR - END_FUNCTION - ", + TYPE FOO : STRUCT + idx : DINT; + arr : ARRAY[1..2] OF BAR; + END_STRUCT END_TYPE + + TYPE BAR : STRUCT + arr : ARRAY[1..5] OF DINT; + END_STRUCT END_TYPE + + FUNCTION main : DINT + VAR + foo_valid_0 : FOO := (idx := 0, arr := [(arr := [1, 2, 3, 4, 5])]); + foo_valid_1 : FOO := (idx := 0, arr := [(arr := [1, 2, 3, 4, 5]), (arr := [1, 2, 3])]); + foo_valid_2 : FOO := (idx := 0, arr := [(arr := [1, 2, 3, 4, 5]), (arr := [1, 2, 3, 4, 5])]); + foo_valid_3 : FOO := (arr := [(arr := [1, 2, 3, 4, 5]), (arr := [1, 2, 3, 4, 5])], idx := 0); + + foo_invalid_0 : FOO := (idx := 0, arr := ((arr := (1, 2, 3, 4, 5)), (arr := (1, 2, 3, 4, 5)))); + foo_invalid_1 : FOO := (idx := 0, arr := ((arr := (1, 2, 3, 4, 5)), (arr := (1, 2, 3, 4, 5)))); + END_VAR + END_FUNCTION + ", ); assert_snapshot!(diagnostics); @@ -228,35 +228,35 @@ fn assignment_structs() { fn exceeding_size_structs() { let diagnostics = parse_and_validate_buffered( " - TYPE Foo : STRUCT - idx: DINT; - arr : ARRAY[1..2] OF Bar; - END_STRUCT END_TYPE - - TYPE Bar : STRUCT - arr : ARRAY[1..2] OF DINT; - END_STRUCT END_TYPE - - FUNCTION main : DINT - VAR - arr_a : Foo := ( - idx := 1, - arr := [(arr := [1, 2]), (arr := [3, 4]), (arr := [5, 6])] // Invalid, because the outter `arr` can only store 2 elements - ); - - arr_b : ARRAY[1..2] OF Foo := ( - [idx := 2, arr := [(arr := [1, 2, 3]), (arr := [4, 5])]], // Invalid because of the first inner `arr` - [idx := 3, arr := [(arr := [1, 2]), (arr := [3, 4, 5])]], // Invalid because of the second inner `arr` - ); - - arr_c : ARRAY[1..2] OF Foo := ( // Invalid because only 2 elements can be stored, but 3 are provided - (idx := 4, arr := [(arr := [1, 2, 3]), (arr := [4, 5])]), // Invalid because of the first inner `arr` - (idx := 5, arr := [(arr := [1, 2]), (arr := [3, 4, 5])]), // Invalid because of the second inner `arr` - (idx := 6, arr := [(arr := 2(0)), (arr := 4(0))]), // Invalid ebcause of the second inner `arr` - ); - END_VAR - END_FUNCTION - ", + TYPE Foo : STRUCT + idx: DINT; + arr : ARRAY[1..2] OF Bar; + END_STRUCT END_TYPE + + TYPE Bar : STRUCT + arr : ARRAY[1..2] OF DINT; + END_STRUCT END_TYPE + + FUNCTION main : DINT + VAR + arr_a : Foo := ( + idx := 1, + arr := [(arr := [1, 2]), (arr := [3, 4]), (arr := [5, 6])] // Invalid, because the outter `arr` can only store 2 elements + ); + + arr_b : ARRAY[1..2] OF Foo := ( + [idx := 2, arr := [(arr := [1, 2, 3]), (arr := [4, 5])]], // Invalid because of the first inner `arr` + [idx := 3, arr := [(arr := [1, 2]), (arr := [3, 4, 5])]], // Invalid because of the second inner `arr` + ); + + arr_c : ARRAY[1..2] OF Foo := ( // Invalid because only 2 elements can be stored, but 3 are provided + (idx := 4, arr := [(arr := [1, 2, 3]), (arr := [4, 5])]), // Invalid because of the first inner `arr` + (idx := 5, arr := [(arr := [1, 2]), (arr := [3, 4, 5])]), // Invalid because of the second inner `arr` + (idx := 6, arr := [(arr := 2(0)), (arr := 4(0))]), // Invalid ebcause of the second inner `arr` + ); + END_VAR + END_FUNCTION + ", ); assert_snapshot!(diagnostics) @@ -266,32 +266,32 @@ fn exceeding_size_structs() { fn assignment_multiplied_statement() { let diagnostics = parse_and_validate_buffered( " - FUNCTION main : DINT - VAR - arr_1d : ARRAY[1..5] OF DINT := [6(0)]; - - arr_2d : ARRAY[1..2, 1..5] OF DINT := [11(0)]; - arr_2d_nested : ARRAY[1..2] OF ARRAY[1..5] OF DINT := [11(0)]; - - arr_3d : ARRAY[1..2, 1..2, 1..2] OF DINT := [9(0)]; - arr_3d_nested : ARRAY[1..2] OF ARRAY[1..2] OF ARRAY[1..2] OF DINT := [9(0)]; - END_VAR - - // Valid - arr_1d := [5(0)]; - arr_2d := [10(0)]; - arr_2d_nested := [10(0)]; - arr_3d = [8(0)]; - arr_3d_nested := [8(0)]; - - // Invalid - arr_1d := [6(0)]; - arr_2d := [11(0)]; - arr_2d_nested := [11(0)]; - arr_3d := [9(0)]; - arr_3d_nested := [9(0)]; - END_FUNCTION - ", + FUNCTION main : DINT + VAR + arr_1d : ARRAY[1..5] OF DINT := [6(0)]; + + arr_2d : ARRAY[1..2, 1..5] OF DINT := [11(0)]; + arr_2d_nested : ARRAY[1..2] OF ARRAY[1..5] OF DINT := [11(0)]; + + arr_3d : ARRAY[1..2, 1..2, 1..2] OF DINT := [9(0)]; + arr_3d_nested : ARRAY[1..2] OF ARRAY[1..2] OF ARRAY[1..2] OF DINT := [9(0)]; + END_VAR + + // Valid + arr_1d := [5(0)]; + arr_2d := [10(0)]; + arr_2d_nested := [10(0)]; + arr_3d = [8(0)]; + arr_3d_nested := [8(0)]; + + // Invalid + arr_1d := [6(0)]; + arr_2d := [11(0)]; + arr_2d_nested := [11(0)]; + arr_3d := [9(0)]; + arr_3d_nested := [9(0)]; + END_FUNCTION + ", ); assert_snapshot!(diagnostics); diff --git a/src/validation/tests/assignment_validation_tests.rs b/src/validation/tests/assignment_validation_tests.rs index 161b365329..634a7eb857 100644 --- a/src/validation/tests/assignment_validation_tests.rs +++ b/src/validation/tests/assignment_validation_tests.rs @@ -8,7 +8,7 @@ fn constant_assignment_validation() { VAR_GLOBAL CONSTANT v_global : BOOL; END_VAR - + FUNCTION main : DINT // CONSTANT assignment v_global := TRUE; // INVALID @@ -27,26 +27,26 @@ fn real_assignment_validation() { VAR v_real : REAL; v_lreal : LREAL; - + v_udint : UDINT; - + v_dint : DINT; - + v_time : TIME; - + v_word : WORD; - + v_string : STRING; - + v_char : CHAR; - + v_tod : TOD; - + v_ptr_int : REF_TO INT; v_ptr_string : REF_TO STRING; - + v_arr_int_3 : ARRAY[0..3] OF INT; - + v_arr_string_3 : ARRAY[0..3] OF STRING; END_VAR // REAL @@ -85,29 +85,29 @@ fn int_assignment_validation() { FUNCTION main : DINT VAR v_lreal : LREAL; - + v_udint : UDINT; v_ulint : ULINT; - + v_dint : DINT; v_lint : LINT; - + v_time : TIME; v_ltime : LTIME; - + v_word : WORD; - + v_string : STRING; - + v_char : CHAR; - + v_tod : TOD; - + v_ptr_int : REF_TO INT; v_ptr_string : REF_TO STRING; - + v_arr_int_3 : ARRAY[0..3] OF INT; - + v_arr_string_3 : ARRAY[0..3] OF STRING; END_VAR // UNSIGNED @@ -132,7 +132,7 @@ fn int_assignment_validation() { v_udint := v_ptr_string^; // INVALID v_udint := v_arr_int_3[0]; // valid v_udint := v_arr_string_3[0]; // INVALID - + // SIGNED v_dint := v_lreal; // valid v_dint := REAL#2.0; // valid @@ -169,25 +169,25 @@ fn duration_assignment_validation() { FUNCTION main : DINT VAR v_lreal : LREAL; - + v_udint : UDINT; - + v_dint : DINT; - + v_time : TIME; v_ltime : LTIME; - + v_word : WORD; - + v_string : STRING; - + v_char : CHAR; - + v_tod : TOD; - + v_ptr_int : REF_TO INT; v_ptr_string : REF_TO STRING; - + v_arr_int_3 : ARRAY[0..3] OF INT; v_arr_string_3 : ARRAY[0..3] OF STRING; @@ -228,25 +228,25 @@ fn bit_assignment_validation() { FUNCTION main : DINT VAR v_lreal : LREAL; - + v_udint : UDINT; - + v_dint : DINT; - + v_time : TIME; - + v_byte : BYTE; v_word : WORD; - + v_string : STRING; - + v_char : CHAR; v_tod : TOD; - + v_ptr_int : REF_TO INT; v_ptr_string : REF_TO STRING; - + v_arr_int_3 : ARRAY[0..3] OF INT; v_arr_string_3 : ARRAY[0..3] OF STRING; @@ -287,29 +287,29 @@ fn string_assignment_validation() { FUNCTION main : DINT VAR v_lreal : LREAL; - + v_udint : UDINT; - + v_dint : DINT; - + v_time : TIME; - + v_word : WORD; - + v_string : STRING; v_str : STRING; v_string1 : STRING[1]; v_wstring : WSTRING; - + v_char : CHAR; - + v_tod : TOD; - + v_ptr_int : REF_TO INT; v_ptr_string : REF_TO STRING; - + v_arr_int_3 : ARRAY[0..3] OF INT; - + v_arr_string_3 : ARRAY[0..3] OF STRING; END_VAR // STRING @@ -351,30 +351,30 @@ fn char_assignment_validation() { FUNCTION main : DINT VAR v_lreal : LREAL; - + v_udint : UDINT; - + v_dint : DINT; - + v_time : TIME; - + v_word : WORD; - + v_string : STRING; v_str : STRING; v_string1 : STRING[1]; v_wstring : WSTRING; - + v_char : CHAR; v_wchar : WCHAR; - + v_tod : TOD; - + v_ptr_int : REF_TO INT; v_ptr_string : REF_TO STRING; - + v_arr_int_3 : ARRAY[0..3] OF INT; - + v_arr_string_3 : ARRAY[0..3] OF STRING; END_VAR // CHAR @@ -419,27 +419,27 @@ fn date_assignment_validation() { FUNCTION main : DINT VAR v_lreal : LREAL; - + v_udint : UDINT; - + v_dint : DINT; - + v_time : TIME; - + v_word : WORD; - + v_string : STRING; - + v_char : CHAR; - + v_date : DATE; v_tod : TOD; - + v_ptr_int : REF_TO INT; v_ptr_string : REF_TO STRING; v_arr_int_3 : ARRAY[0..3] OF INT; - + v_arr_string_3 : ARRAY[0..3] OF STRING; END_VAR // DATE @@ -478,26 +478,26 @@ fn pointer_assignment_validation() { FUNCTION main : DINT VAR v_real : REAL; - + v_udint : UDINT; - + v_dint : DINT; - + v_time : TIME; - + v_word : WORD; v_lword : LWORD; - + v_string : STRING; - + v_char : CHAR; - + v_date : DATE; v_ptr_int : REF_TO INT; - + v_arr_int_3 : ARRAY[0..3] OF INT; - + v_arr_string_3 : ARRAY[0..3] OF STRING; END_VAR // POINTER @@ -536,27 +536,27 @@ fn array_assignment_validation() { FUNCTION main : DINT VAR v_real : REAL; - + v_dint : DINT; - + v_string : STRING; - + v_char : CHAR; - + v_ptr_int : REF_TO INT; v_ptr_string : REF_TO STRING; - + v_arr_int_2 : ARRAY[0..2] OF INT; v_arr_int_3 : ARRAY[0..3] OF INT; v_arr_int_4 : ARRAY[0..4] OF INT; - + v_arr_real_3 : ARRAY[0..3] OF REAL; - + v_arr_string_3 : ARRAY[0..3] OF STRING; v_arr_sized_string : ARRAY[0..3] OF STRING[256]; v_arr_sized_string1 : ARRAY[0..3] OF STRING[256]; v_arr_sized_string2 : ARRAY[0..8] OF STRING[1256]; - + v_arr_char_3 : ARRAY[0..3] OF CHAR; END_VAR // ARRAY @@ -615,19 +615,19 @@ fn struct_assignment_validation() { END_TYPE FUNCTION_BLOCK fb - VAR_IN_OUT - var_inout_struct1 : STRUCT1; - END_VAR + VAR_IN_OUT + var_inout_struct1 : STRUCT1; + END_VAR END_FUNCTION_BLOCK - + FUNCTION main : DINT VAR v_real : REAL; - + v_string : STRING; - + v_char : CHAR; - + v_struct1 : STRUCT1; v_struct1_2 : STRUCT1; v_ref_to_struct1 : REF_TO STRUCT1; @@ -655,15 +655,15 @@ fn struct_assignment_validation() { v_ref_to_struct1 := REF(v_struct1); // valid v_ref_to_struct1 := ADR(v_struct1); // valid v_ref_to_struct1 := &(v_struct1); // valid - + v_ref_to_struct1 := ADR(v_real); // valid v_ref_to_struct1 := ADR(v_string); // valid v_ref_to_struct1 := ADR(v_char); // valid - + v_ref_to_struct1 := REF(v_real); // INVALID v_ref_to_struct1 := REF(v_string); // INVALID v_ref_to_struct1 := REF(v_char); // INVALID - + v_ref_to_struct1 := &(v_real); // INVALID v_ref_to_struct1 := &(v_string); // INVALID v_ref_to_struct1 := &(v_char); // INVALID @@ -706,13 +706,13 @@ fn invalid_action_call_assignments_are_validated() { in2 : STRING; END_VAR VAR_IN_OUT - auto : WSTRING; + auto : WSTRING; END_VAR VAR_OUTPUT out : ARRAY[0..10] OF WSTRING; END_VAR END_FUNCTION_BLOCK - + ACTIONS fb_t ACTION foo END_ACTION @@ -741,13 +741,13 @@ fn implicit_invalid_action_call_assignments_are_validated() { VAR var1 : ARRAY[0..10] OF WSTRING; var2 : ARRAY[0..10] OF WSTRING; - END_VAR + END_VAR VAR_INPUT in1 : DINT; in2 : STRING; - END_VAR + END_VAR END_FUNCTION_BLOCK - + ACTIONS fb_t ACTION foo END_ACTION @@ -775,10 +775,10 @@ fn invalid_method_call_assignments_are_validated() { VAR x : INT := 10; END_VAR - + METHOD foo : DINT - VAR_INPUT - a : DINT; + VAR_INPUT + a : DINT; b : STRING; END_VAR foo := a + x; @@ -809,7 +809,7 @@ fn invalid_function_block_instantiation_is_validated() { arr_32 : ARRAY[0..1] OF DINT; END_VAR END_FUNCTION_BLOCK - + PROGRAM prog VAR s : STRING := 'HELLO'; @@ -832,14 +832,14 @@ fn implicit_action_downcasts_are_validated() { VAR var1 : ARRAY[0..10] OF WSTRING; var2 : ARRAY[0..10] OF WSTRING; - END_VAR + END_VAR VAR_INPUT in1 : DINT; in2 : DWORD; in3 : BYTE; - END_VAR + END_VAR END_FUNCTION_BLOCK - + ACTIONS fb_t ACTION foo END_ACTION @@ -905,7 +905,7 @@ fn enum_variants_mismatch() { let diagnostics = parse_and_validate( " TYPE Animal: (Dog, Cat, Horse); END_TYPE - + PROGRAM main VAR color: (red, green, blue); diff --git a/src/validation/tests/bitaccess_validation_test.rs b/src/validation/tests/bitaccess_validation_test.rs index 953e0d6d47..fbfb4d0cba 100644 --- a/src/validation/tests/bitaccess_validation_test.rs +++ b/src/validation/tests/bitaccess_validation_test.rs @@ -5,7 +5,7 @@ fn bitaccess_only_on_bit_types() { let diagnostics = parse_and_validate( " PROGRAM prg - VAR + VAR invalid : BOOL; invalid2 : STRING; valid : BYTE; @@ -31,7 +31,7 @@ fn byteaccess_only_on_bigger_sizes() { let diagnostics = parse_and_validate( " PROGRAM prg - VAR + VAR invalid : BYTE; invalid2 : SINT; invalid3 : USINT; @@ -54,7 +54,7 @@ fn wordaccess_only_on_bigger_sizes() { let diagnostics = parse_and_validate( " PROGRAM prg - VAR + VAR invalid : WORD; invalid2 : INT; invalid3 : UINT; @@ -77,7 +77,7 @@ fn dwordaccess_only_on_bigger_sizes() { let diagnostics = parse_and_validate( " PROGRAM prg - VAR + VAR invalid : DWORD; invalid2 : DINT; invalid3 : UDINT; @@ -100,7 +100,7 @@ fn bitaccess_range_test() { let diagnostics = parse_and_validate( " PROGRAM prg - VAR + VAR a : BYTE; b : WORD; c : DWORD; d : LWORD; END_VAR a.8; @@ -119,7 +119,7 @@ fn byteaccess_range_test() { let diagnostics = parse_and_validate( " PROGRAM prg - VAR + VAR b : WORD; c : DWORD; d : LWORD; END_VAR b.%B2; @@ -137,7 +137,7 @@ fn wordaccess_range_test() { let diagnostics = parse_and_validate( " PROGRAM prg - VAR + VAR c : DWORD; d : LWORD; END_VAR c.%W2; @@ -154,7 +154,7 @@ fn dwordaccess_range_test() { let diagnostics = parse_and_validate( " PROGRAM prg - VAR + VAR d : LWORD; END_VAR d.%D2; @@ -170,7 +170,7 @@ fn reference_direct_access_only_with_ints() { let diagnostics = parse_and_validate( " PROGRAM prg - VAR + VAR c : DWORD; d : INT; e : LREAL; f : REAL; END_VAR c.%Xd; diff --git a/src/validation/tests/duplicates_validation_test.rs b/src/validation/tests/duplicates_validation_test.rs index 64f52c1ba6..a4305485b6 100644 --- a/src/validation/tests/duplicates_validation_test.rs +++ b/src/validation/tests/duplicates_validation_test.rs @@ -74,7 +74,7 @@ fn duplicate_global_variables() { VAR_GLOBAL a: BOOL; END_VAR - + "#, ); // THEN there should be 0 duplication diagnostics @@ -190,7 +190,7 @@ fn duplicate_action_should_be_a_problem() { END_VAR END_PROGRAM - ACTIONS + ACTIONS ACTION foo x := 2; END_ACTION @@ -220,14 +220,14 @@ fn duplicate_actions_in_different_pous_are_no_issue() { PROGRAM prg END_PROGRAM - ACTIONS + ACTIONS ACTION foo END_ACTION END_ACTIONS PROGRAM prg2 END_PROGRAM - ACTIONS + ACTIONS ACTION foo END_ACTION END_ACTIONS "#, diff --git a/src/validation/tests/generic_validation_tests.rs b/src/validation/tests/generic_validation_tests.rs index 128d2b5e16..4660c7f5c1 100644 --- a/src/validation/tests/generic_validation_tests.rs +++ b/src/validation/tests/generic_validation_tests.rs @@ -8,12 +8,12 @@ fn any_allows_all_natures() { FUNCTION func1 : INT VAR x : REAL; END_VAR test(x); END_FUNCTION FUNCTION func2 : INT VAR x : UINT; END_VAR test(x); END_FUNCTION FUNCTION func3 : INT VAR x : INT; END_VAR test(x); END_FUNCTION - FUNCTION func4 : INT VAR x : TIME; END_VAR test(x); END_FUNCTION + FUNCTION func4 : INT VAR x : TIME; END_VAR test(x); END_FUNCTION FUNCTION func5 : INT VAR x : BYTE; END_VAR test(x); END_FUNCTION FUNCTION func6 : INT VAR x : STRING; END_VAR test(x); END_FUNCTION FUNCTION func7 : INT VAR x : WSTRING; END_VAR test(x); END_FUNCTION - FUNCTION func8 : INT VAR x : CHAR; END_VAR test(x); END_FUNCTION - FUNCTION func9 : INT VAR x : DATE; END_VAR test(x); END_FUNCTION + FUNCTION func8 : INT VAR x : CHAR; END_VAR test(x); END_FUNCTION + FUNCTION func9 : INT VAR x : DATE; END_VAR test(x); END_FUNCTION FUNCTION func10 : INT VAR x : str; END_VAR test(x); END_FUNCTION "; @@ -81,7 +81,7 @@ fn any_magnitude_allows_ints() { FUNCTION func3 : INT VAR x : DINT; END_VAR test(x); END_FUNCTION FUNCTION func4 : INT VAR x : LINT; END_VAR test(x); END_FUNCTION - FUNCTION func5 : INT VAR x : USINT; END_VAR test(x); END_FUNCTION + FUNCTION func5 : INT VAR x : USINT; END_VAR test(x); END_FUNCTION FUNCTION func6 : INT VAR x : UINT; END_VAR test(x); END_FUNCTION FUNCTION func7 : INT VAR x : UDINT; END_VAR test(x); END_FUNCTION FUNCTION func8 : INT VAR x : ULINT; END_VAR test(x); END_FUNCTION @@ -109,9 +109,9 @@ fn any_magnitude_does_not_allow_bits() { FUNCTION test : INT VAR_INPUT x : T; END_VAR END_FUNCTION FUNCTION func1 : INT VAR x : BOOL; END_VAR test(x); END_FUNCTION FUNCTION func2 : INT VAR x : BYTE; END_VAR test(x); END_FUNCTION - FUNCTION func3 : INT VAR x : WORD; END_VAR test(x); END_FUNCTION + FUNCTION func3 : INT VAR x : WORD; END_VAR test(x); END_FUNCTION FUNCTION func4 : INT VAR x : DWORD; END_VAR test(x); END_FUNCTION - FUNCTION func5 : INT VAR x : LWORD; END_VAR test(x); END_FUNCTION + FUNCTION func5 : INT VAR x : LWORD; END_VAR test(x); END_FUNCTION "; let diagnostics = parse_and_validate(src); @@ -148,9 +148,9 @@ fn any_magnitude_does_not_allow_date() { FUNCTION test : INT VAR_INPUT x : T; END_VAR END_FUNCTION FUNCTION func1 : INT VAR x : DT; END_VAR test(x); END_FUNCTION FUNCTION func2 : INT VAR x : LDT; END_VAR test(x); END_FUNCTION - FUNCTION func3 : INT VAR x : DATE; END_VAR test(x); END_FUNCTION + FUNCTION func3 : INT VAR x : DATE; END_VAR test(x); END_FUNCTION FUNCTION func4 : INT VAR x : TOD; END_VAR test(x); END_FUNCTION - FUNCTION func5 : INT VAR x : LTOD; END_VAR test(x); END_FUNCTION + FUNCTION func5 : INT VAR x : LTOD; END_VAR test(x); END_FUNCTION "; let diagnostics = parse_and_validate(src); @@ -206,7 +206,7 @@ fn any_num_allows_ints() { FUNCTION func3 : INT VAR x : DINT; END_VAR test(x); END_FUNCTION FUNCTION func4 : INT VAR x : LINT; END_VAR test(x); END_FUNCTION - FUNCTION func5 : INT VAR x : USINT; END_VAR test(x); END_FUNCTION + FUNCTION func5 : INT VAR x : USINT; END_VAR test(x); END_FUNCTION FUNCTION func6 : INT VAR x : UINT; END_VAR test(x); END_FUNCTION FUNCTION func7 : INT VAR x : UDINT; END_VAR test(x); END_FUNCTION FUNCTION func8 : INT VAR x : ULINT; END_VAR test(x); END_FUNCTION @@ -234,9 +234,9 @@ fn any_num_does_not_allow_bits() { FUNCTION test : INT VAR_INPUT x : T; END_VAR END_FUNCTION FUNCTION func1 : INT VAR x : BOOL; END_VAR test(x); END_FUNCTION FUNCTION func2 : INT VAR x : BYTE; END_VAR test(x); END_FUNCTION - FUNCTION func3 : INT VAR x : WORD; END_VAR test(x); END_FUNCTION + FUNCTION func3 : INT VAR x : WORD; END_VAR test(x); END_FUNCTION FUNCTION func4 : INT VAR x : DWORD; END_VAR test(x); END_FUNCTION - FUNCTION func5 : INT VAR x : LWORD; END_VAR test(x); END_FUNCTION + FUNCTION func5 : INT VAR x : LWORD; END_VAR test(x); END_FUNCTION "; let diagnostics = parse_and_validate(src); @@ -273,9 +273,9 @@ fn any_num_does_not_allow_date() { FUNCTION test : INT VAR_INPUT x : T; END_VAR END_FUNCTION FUNCTION func1 : INT VAR x : DT; END_VAR test(x); END_FUNCTION FUNCTION func2 : INT VAR x : LDT; END_VAR test(x); END_FUNCTION - FUNCTION func3 : INT VAR x : DATE; END_VAR test(x); END_FUNCTION + FUNCTION func3 : INT VAR x : DATE; END_VAR test(x); END_FUNCTION FUNCTION func4 : INT VAR x : TOD; END_VAR test(x); END_FUNCTION - FUNCTION func5 : INT VAR x : LTOD; END_VAR test(x); END_FUNCTION + FUNCTION func5 : INT VAR x : LTOD; END_VAR test(x); END_FUNCTION "; let diagnostics = parse_and_validate(src); @@ -330,13 +330,13 @@ fn any_real_allows_ints() { FUNCTION func1 : INT VAR x : SINT; END_VAR test(x); END_FUNCTION FUNCTION func2 : INT VAR x : INT; END_VAR test(x); END_FUNCTION - FUNCTION func3 : INT VAR x : DINT; END_VAR test(x); END_FUNCTION - FUNCTION func4 : INT VAR x : LINT; END_VAR test(x); END_FUNCTION + FUNCTION func3 : INT VAR x : DINT; END_VAR test(x); END_FUNCTION + FUNCTION func4 : INT VAR x : LINT; END_VAR test(x); END_FUNCTION - FUNCTION func5 : INT VAR x : USINT; END_VAR test(x); END_FUNCTION + FUNCTION func5 : INT VAR x : USINT; END_VAR test(x); END_FUNCTION FUNCTION func6 : INT VAR x : UINT; END_VAR test(x); END_FUNCTION - FUNCTION func7 : INT VAR x : UDINT; END_VAR test(x); END_FUNCTION - FUNCTION func8 : INT VAR x : ULINT; END_VAR test(x); END_FUNCTION + FUNCTION func7 : INT VAR x : UDINT; END_VAR test(x); END_FUNCTION + FUNCTION func8 : INT VAR x : ULINT; END_VAR test(x); END_FUNCTION "; let diagnostics = parse_and_validate(src); @@ -348,7 +348,7 @@ fn any_real_does_not_allow_time() { let src = r" FUNCTION test : INT VAR_INPUT x : T; END_VAR END_FUNCTION FUNCTION func1 : INT VAR x : TIME; END_VAR test(x); END_FUNCTION - FUNCTION func2 : INT VAR x : LTIME; END_VAR test(x); END_FUNCTION + FUNCTION func2 : INT VAR x : LTIME; END_VAR test(x); END_FUNCTION "; let diagnostics = parse_and_validate(src); @@ -360,10 +360,10 @@ fn any_real_does_not_allow_bits() { let src = r" FUNCTION test : INT VAR_INPUT x : T; END_VAR END_FUNCTION FUNCTION func1 : INT VAR x : BOOL; END_VAR test(x); END_FUNCTION - FUNCTION func2 : INT VAR x : BYTE; END_VAR test(x); END_FUNCTION - FUNCTION func3 : INT VAR x : WORD; END_VAR test(x); END_FUNCTION - FUNCTION func4 : INT VAR x : DWORD; END_VAR test(x); END_FUNCTION - FUNCTION func5 : INT VAR x : LWORD; END_VAR test(x); END_FUNCTION + FUNCTION func2 : INT VAR x : BYTE; END_VAR test(x); END_FUNCTION + FUNCTION func3 : INT VAR x : WORD; END_VAR test(x); END_FUNCTION + FUNCTION func4 : INT VAR x : DWORD; END_VAR test(x); END_FUNCTION + FUNCTION func5 : INT VAR x : LWORD; END_VAR test(x); END_FUNCTION "; let diagnostics = parse_and_validate(src); @@ -375,7 +375,7 @@ fn any_real_does_not_allow_chars() { let src = r" FUNCTION test : INT VAR_INPUT x : T; END_VAR END_FUNCTION FUNCTION func1 : INT VAR x : CHAR; END_VAR test(x); END_FUNCTION - FUNCTION func2 : INT VAR x : WCHAR; END_VAR test(x); END_FUNCTION + FUNCTION func2 : INT VAR x : WCHAR; END_VAR test(x); END_FUNCTION "; let diagnostics = parse_and_validate(src); @@ -399,10 +399,10 @@ fn any_real_does_not_allow_date() { let src = r" FUNCTION test : INT VAR_INPUT x : T; END_VAR END_FUNCTION FUNCTION func1 : INT VAR x : DT; END_VAR test(x); END_FUNCTION - FUNCTION func2 : INT VAR x : LDT; END_VAR test(x); END_FUNCTION - FUNCTION func3 : INT VAR x : DATE; END_VAR test(x); END_FUNCTION - FUNCTION func4 : INT VAR x : TOD; END_VAR test(x); END_FUNCTION - FUNCTION func5 : INT VAR x : LTOD; END_VAR test(x); END_FUNCTION + FUNCTION func2 : INT VAR x : LDT; END_VAR test(x); END_FUNCTION + FUNCTION func3 : INT VAR x : DATE; END_VAR test(x); END_FUNCTION + FUNCTION func4 : INT VAR x : TOD; END_VAR test(x); END_FUNCTION + FUNCTION func5 : INT VAR x : LTOD; END_VAR test(x); END_FUNCTION "; let diagnostics = parse_and_validate(src); @@ -456,13 +456,13 @@ fn any_int_allows_ints() { FUNCTION func1 : INT VAR x : SINT; END_VAR test(x); END_FUNCTION FUNCTION func2 : INT VAR x : INT; END_VAR test(x); END_FUNCTION - FUNCTION func3 : INT VAR x : DINT; END_VAR test(x); END_FUNCTION - FUNCTION func4 : INT VAR x : LINT; END_VAR test(x); END_FUNCTION + FUNCTION func3 : INT VAR x : DINT; END_VAR test(x); END_FUNCTION + FUNCTION func4 : INT VAR x : LINT; END_VAR test(x); END_FUNCTION - FUNCTION func5 : INT VAR x : USINT; END_VAR test(x); END_FUNCTION + FUNCTION func5 : INT VAR x : USINT; END_VAR test(x); END_FUNCTION FUNCTION func6 : INT VAR x : UINT; END_VAR test(x); END_FUNCTION - FUNCTION func7 : INT VAR x : UDINT; END_VAR test(x); END_FUNCTION - FUNCTION func8 : INT VAR x : ULINT; END_VAR test(x); END_FUNCTION + FUNCTION func7 : INT VAR x : UDINT; END_VAR test(x); END_FUNCTION + FUNCTION func8 : INT VAR x : ULINT; END_VAR test(x); END_FUNCTION "; let diagnostics = parse_and_validate(src); @@ -474,7 +474,7 @@ fn any_int_does_not_allow_time() { let src = r" FUNCTION test : INT VAR_INPUT x : T; END_VAR END_FUNCTION FUNCTION func1 : INT VAR x : TIME; END_VAR test(x); END_FUNCTION - FUNCTION func2 : INT VAR x : LTIME; END_VAR test(x); END_FUNCTION + FUNCTION func2 : INT VAR x : LTIME; END_VAR test(x); END_FUNCTION "; let diagnostics = parse_and_validate(src); @@ -486,10 +486,10 @@ fn any_int_does_not_allow_bits() { let src = r" FUNCTION test : INT VAR_INPUT x : T; END_VAR END_FUNCTION FUNCTION func1 : INT VAR x : BOOL; END_VAR test(x); END_FUNCTION - FUNCTION func2 : INT VAR x : BYTE; END_VAR test(x); END_FUNCTION - FUNCTION func3 : INT VAR x : WORD; END_VAR test(x); END_FUNCTION - FUNCTION func4 : INT VAR x : DWORD; END_VAR test(x); END_FUNCTION - FUNCTION func5 : INT VAR x : LWORD; END_VAR test(x); END_FUNCTION + FUNCTION func2 : INT VAR x : BYTE; END_VAR test(x); END_FUNCTION + FUNCTION func3 : INT VAR x : WORD; END_VAR test(x); END_FUNCTION + FUNCTION func4 : INT VAR x : DWORD; END_VAR test(x); END_FUNCTION + FUNCTION func5 : INT VAR x : LWORD; END_VAR test(x); END_FUNCTION "; let diagnostics = parse_and_validate(src); @@ -501,7 +501,7 @@ fn any_int_does_not_allow_chars() { let src = r" FUNCTION test : INT VAR_INPUT x : T; END_VAR END_FUNCTION FUNCTION func1 : INT VAR x : CHAR; END_VAR test(x); END_FUNCTION - FUNCTION func2 : INT VAR x : WCHAR; END_VAR test(x); END_FUNCTION + FUNCTION func2 : INT VAR x : WCHAR; END_VAR test(x); END_FUNCTION "; let diagnostics = parse_and_validate(src); @@ -525,10 +525,10 @@ fn any_int_does_not_allow_date() { let src = r" FUNCTION test : INT VAR_INPUT x : T; END_VAR END_FUNCTION FUNCTION func1 : INT VAR x : DT; END_VAR test(x); END_FUNCTION - FUNCTION func2 : INT VAR x : LDT; END_VAR test(x); END_FUNCTION - FUNCTION func3 : INT VAR x : DATE; END_VAR test(x); END_FUNCTION - FUNCTION func4 : INT VAR x : TOD; END_VAR test(x); END_FUNCTION - FUNCTION func5 : INT VAR x : LTOD; END_VAR test(x); END_FUNCTION + FUNCTION func2 : INT VAR x : LDT; END_VAR test(x); END_FUNCTION + FUNCTION func3 : INT VAR x : DATE; END_VAR test(x); END_FUNCTION + FUNCTION func4 : INT VAR x : TOD; END_VAR test(x); END_FUNCTION + FUNCTION func5 : INT VAR x : LTOD; END_VAR test(x); END_FUNCTION "; let diagnostics = parse_and_validate(src); @@ -581,8 +581,8 @@ fn any_unsigned_allows_unsigned_ints() { FUNCTION test : INT VAR_INPUT x : T; END_VAR END_FUNCTION FUNCTION func1 : INT VAR x : USINT; END_VAR test(x); END_FUNCTION FUNCTION func2 : INT VAR x : UINT; END_VAR test(x); END_FUNCTION - FUNCTION func3 : INT VAR x : UDINT; END_VAR test(x); END_FUNCTION - FUNCTION func4 : INT VAR x : ULINT; END_VAR test(x); END_FUNCTION + FUNCTION func3 : INT VAR x : UDINT; END_VAR test(x); END_FUNCTION + FUNCTION func4 : INT VAR x : ULINT; END_VAR test(x); END_FUNCTION "; let diagnostics = parse_and_validate(src); @@ -593,10 +593,10 @@ fn any_unsigned_allows_unsigned_ints() { fn any_unsigned_does_not_allow_signed_ints() { let src = r" FUNCTION test : INT VAR_INPUT x : T; END_VAR END_FUNCTION - FUNCTION func1 : INT VAR x : SINT; END_VAR test(x); END_FUNCTION + FUNCTION func1 : INT VAR x : SINT; END_VAR test(x); END_FUNCTION FUNCTION func2 : INT VAR x : INT; END_VAR test(x); END_FUNCTION - FUNCTION func3 : INT VAR x : DINT; END_VAR test(x); END_FUNCTION - FUNCTION func4 : INT VAR x : LINT; END_VAR test(x); END_FUNCTION + FUNCTION func3 : INT VAR x : DINT; END_VAR test(x); END_FUNCTION + FUNCTION func4 : INT VAR x : LINT; END_VAR test(x); END_FUNCTION "; let diagnostics = parse_and_validate(src); @@ -608,7 +608,7 @@ fn any_unsigned_does_not_allow_time() { let src = r" FUNCTION test : INT VAR_INPUT x : T; END_VAR END_FUNCTION FUNCTION func1 : INT VAR x : TIME; END_VAR test(x); END_FUNCTION - FUNCTION func2 : INT VAR x : LTIME; END_VAR test(x); END_FUNCTION + FUNCTION func2 : INT VAR x : LTIME; END_VAR test(x); END_FUNCTION "; let diagnostics = parse_and_validate(src); @@ -620,10 +620,10 @@ fn any_unsigned_does_not_allow_bits() { let src = r" FUNCTION test : INT VAR_INPUT x : T; END_VAR END_FUNCTION FUNCTION func1 : INT VAR x : BOOL; END_VAR test(x); END_FUNCTION - FUNCTION func2 : INT VAR x : BYTE; END_VAR test(x); END_FUNCTION - FUNCTION func3 : INT VAR x : WORD; END_VAR test(x); END_FUNCTION - FUNCTION func4 : INT VAR x : DWORD; END_VAR test(x); END_FUNCTION - FUNCTION func5 : INT VAR x : LWORD; END_VAR test(x); END_FUNCTION + FUNCTION func2 : INT VAR x : BYTE; END_VAR test(x); END_FUNCTION + FUNCTION func3 : INT VAR x : WORD; END_VAR test(x); END_FUNCTION + FUNCTION func4 : INT VAR x : DWORD; END_VAR test(x); END_FUNCTION + FUNCTION func5 : INT VAR x : LWORD; END_VAR test(x); END_FUNCTION "; let diagnostics = parse_and_validate(src); @@ -635,7 +635,7 @@ fn any_unsigned_does_not_allow_chars() { let src = r" FUNCTION test : INT VAR_INPUT x : T; END_VAR END_FUNCTION FUNCTION func1 : INT VAR x : CHAR; END_VAR test(x); END_FUNCTION - FUNCTION func2 : INT VAR x : WCHAR; END_VAR test(x); END_FUNCTION + FUNCTION func2 : INT VAR x : WCHAR; END_VAR test(x); END_FUNCTION "; let diagnostics = parse_and_validate(src); @@ -659,10 +659,10 @@ fn any_unsigned_does_not_allow_date() { let src = r" FUNCTION test : INT VAR_INPUT x : T; END_VAR END_FUNCTION FUNCTION func1 : INT VAR x : DT; END_VAR test(x); END_FUNCTION - FUNCTION func2 : INT VAR x : LDT; END_VAR test(x); END_FUNCTION - FUNCTION func3 : INT VAR x : DATE; END_VAR test(x); END_FUNCTION - FUNCTION func4 : INT VAR x : TOD; END_VAR test(x); END_FUNCTION - FUNCTION func5 : INT VAR x : LTOD; END_VAR test(x); END_FUNCTION + FUNCTION func2 : INT VAR x : LDT; END_VAR test(x); END_FUNCTION + FUNCTION func3 : INT VAR x : DATE; END_VAR test(x); END_FUNCTION + FUNCTION func4 : INT VAR x : TOD; END_VAR test(x); END_FUNCTION + FUNCTION func5 : INT VAR x : LTOD; END_VAR test(x); END_FUNCTION "; let diagnostics = parse_and_validate(src); @@ -715,8 +715,8 @@ fn any_signed_allows_signed_ints() { FUNCTION test : INT VAR_INPUT x : T; END_VAR END_FUNCTION FUNCTION func1 : INT VAR x : SINT; END_VAR test(x); END_FUNCTION FUNCTION func2 : INT VAR x : INT; END_VAR test(x); END_FUNCTION - FUNCTION func3 : INT VAR x : DINT; END_VAR test(x); END_FUNCTION - FUNCTION func4 : INT VAR x : LINT; END_VAR test(x); END_FUNCTION + FUNCTION func3 : INT VAR x : DINT; END_VAR test(x); END_FUNCTION + FUNCTION func4 : INT VAR x : LINT; END_VAR test(x); END_FUNCTION "; let diagnostics = parse_and_validate(src); @@ -727,10 +727,10 @@ fn any_signed_allows_signed_ints() { fn any_signed_does_not_allow_unsigned_ints() { let src = r" FUNCTION test : INT VAR_INPUT x : T; END_VAR END_FUNCTION - FUNCTION func1 : INT VAR x : USINT; END_VAR test(x); END_FUNCTION + FUNCTION func1 : INT VAR x : USINT; END_VAR test(x); END_FUNCTION FUNCTION func2 : INT VAR x : UINT; END_VAR test(x); END_FUNCTION - FUNCTION func3 : INT VAR x : UDINT; END_VAR test(x); END_FUNCTION - FUNCTION func4 : INT VAR x : ULINT; END_VAR test(x); END_FUNCTION + FUNCTION func3 : INT VAR x : UDINT; END_VAR test(x); END_FUNCTION + FUNCTION func4 : INT VAR x : ULINT; END_VAR test(x); END_FUNCTION "; let diagnostics = parse_and_validate(src); @@ -742,7 +742,7 @@ fn any_signed_does_not_allow_time() { let src = r" FUNCTION test : INT VAR_INPUT x : T; END_VAR END_FUNCTION FUNCTION func1 : INT VAR x : TIME; END_VAR test(x); END_FUNCTION - FUNCTION func2 : INT VAR x : LTIME; END_VAR test(x); END_FUNCTION + FUNCTION func2 : INT VAR x : LTIME; END_VAR test(x); END_FUNCTION "; let diagnostics = parse_and_validate(src); @@ -754,10 +754,10 @@ fn any_signed_does_not_allow_bits() { let src = r" FUNCTION test : INT VAR_INPUT x : T; END_VAR END_FUNCTION FUNCTION func1 : INT VAR x : BOOL; END_VAR test(x); END_FUNCTION - FUNCTION func2 : INT VAR x : BYTE; END_VAR test(x); END_FUNCTION - FUNCTION func3 : INT VAR x : WORD; END_VAR test(x); END_FUNCTION - FUNCTION func4 : INT VAR x : DWORD; END_VAR test(x); END_FUNCTION - FUNCTION func5 : INT VAR x : LWORD; END_VAR test(x); END_FUNCTION + FUNCTION func2 : INT VAR x : BYTE; END_VAR test(x); END_FUNCTION + FUNCTION func3 : INT VAR x : WORD; END_VAR test(x); END_FUNCTION + FUNCTION func4 : INT VAR x : DWORD; END_VAR test(x); END_FUNCTION + FUNCTION func5 : INT VAR x : LWORD; END_VAR test(x); END_FUNCTION "; let diagnostics = parse_and_validate(src); @@ -769,7 +769,7 @@ fn any_signed_does_not_allow_chars() { let src = r" FUNCTION test : INT VAR_INPUT x : T; END_VAR END_FUNCTION FUNCTION func1 : INT VAR x : CHAR; END_VAR test(x); END_FUNCTION - FUNCTION func2 : INT VAR x : WCHAR; END_VAR test(x); END_FUNCTION + FUNCTION func2 : INT VAR x : WCHAR; END_VAR test(x); END_FUNCTION "; let diagnostics = parse_and_validate(src); @@ -793,10 +793,10 @@ fn any_signed_does_not_allow_date() { let src = r" FUNCTION test : INT VAR_INPUT x : T; END_VAR END_FUNCTION FUNCTION func1 : INT VAR x : DT; END_VAR test(x); END_FUNCTION - FUNCTION func2 : INT VAR x : LDT; END_VAR test(x); END_FUNCTION - FUNCTION func3 : INT VAR x : DATE; END_VAR test(x); END_FUNCTION - FUNCTION func4 : INT VAR x : TOD; END_VAR test(x); END_FUNCTION - FUNCTION func5 : INT VAR x : LTOD; END_VAR test(x); END_FUNCTION + FUNCTION func2 : INT VAR x : LDT; END_VAR test(x); END_FUNCTION + FUNCTION func3 : INT VAR x : DATE; END_VAR test(x); END_FUNCTION + FUNCTION func4 : INT VAR x : TOD; END_VAR test(x); END_FUNCTION + FUNCTION func5 : INT VAR x : LTOD; END_VAR test(x); END_FUNCTION "; let diagnostics = parse_and_validate(src); @@ -848,15 +848,15 @@ fn any_duration_does_not_allow_ints() { let src = r" FUNCTION test : INT VAR_INPUT x : T; END_VAR END_FUNCTION - FUNCTION func1 : INT VAR x : USINT; END_VAR test(x); END_FUNCTION + FUNCTION func1 : INT VAR x : USINT; END_VAR test(x); END_FUNCTION FUNCTION func2 : INT VAR x : UINT; END_VAR test(x); END_FUNCTION - FUNCTION func3 : INT VAR x : UDINT; END_VAR test(x); END_FUNCTION - FUNCTION func4 : INT VAR x : ULINT; END_VAR test(x); END_FUNCTION + FUNCTION func3 : INT VAR x : UDINT; END_VAR test(x); END_FUNCTION + FUNCTION func4 : INT VAR x : ULINT; END_VAR test(x); END_FUNCTION - FUNCTION func5 : INT VAR x : SINT; END_VAR test(x); END_FUNCTION + FUNCTION func5 : INT VAR x : SINT; END_VAR test(x); END_FUNCTION FUNCTION func6 : INT VAR x : INT; END_VAR test(x); END_FUNCTION - FUNCTION func7 : INT VAR x : DINT; END_VAR test(x); END_FUNCTION - FUNCTION func8 : INT VAR x : LINT; END_VAR test(x); END_FUNCTION + FUNCTION func7 : INT VAR x : DINT; END_VAR test(x); END_FUNCTION + FUNCTION func8 : INT VAR x : LINT; END_VAR test(x); END_FUNCTION "; let diagnostics = parse_and_validate(src); @@ -868,7 +868,7 @@ fn any_duration_allows_time() { let src = r" FUNCTION test : INT VAR_INPUT x : T; END_VAR END_FUNCTION FUNCTION func1 : INT VAR x : TIME; END_VAR test(x); END_FUNCTION - FUNCTION func2 : INT VAR x : LTIME; END_VAR test(x); END_FUNCTION + FUNCTION func2 : INT VAR x : LTIME; END_VAR test(x); END_FUNCTION "; let diagnostics = parse_and_validate(src); @@ -880,10 +880,10 @@ fn any_duration_does_not_allow_bits() { let src = r" FUNCTION test : INT VAR_INPUT x : T; END_VAR END_FUNCTION FUNCTION func1 : INT VAR x : BOOL; END_VAR test(x); END_FUNCTION - FUNCTION func2 : INT VAR x : BYTE; END_VAR test(x); END_FUNCTION - FUNCTION func3 : INT VAR x : WORD; END_VAR test(x); END_FUNCTION - FUNCTION func4 : INT VAR x : DWORD; END_VAR test(x); END_FUNCTION - FUNCTION func5 : INT VAR x : LWORD; END_VAR test(x); END_FUNCTION + FUNCTION func2 : INT VAR x : BYTE; END_VAR test(x); END_FUNCTION + FUNCTION func3 : INT VAR x : WORD; END_VAR test(x); END_FUNCTION + FUNCTION func4 : INT VAR x : DWORD; END_VAR test(x); END_FUNCTION + FUNCTION func5 : INT VAR x : LWORD; END_VAR test(x); END_FUNCTION "; let diagnostics = parse_and_validate(src); @@ -895,7 +895,7 @@ fn any_duration_does_not_allow_chars() { let src = r" FUNCTION test : INT VAR_INPUT x : T; END_VAR END_FUNCTION FUNCTION func1 : INT VAR x : CHAR; END_VAR test(x); END_FUNCTION - FUNCTION func2 : INT VAR x : WCHAR; END_VAR test(x); END_FUNCTION + FUNCTION func2 : INT VAR x : WCHAR; END_VAR test(x); END_FUNCTION "; let diagnostics = parse_and_validate(src); @@ -919,10 +919,10 @@ fn any_duration_does_not_allow_date() { let src = r" FUNCTION test : INT VAR_INPUT x : T; END_VAR END_FUNCTION FUNCTION func1 : INT VAR x : DT; END_VAR test(x); END_FUNCTION - FUNCTION func2 : INT VAR x : LDT; END_VAR test(x); END_FUNCTION - FUNCTION func3 : INT VAR x : DATE; END_VAR test(x); END_FUNCTION - FUNCTION func4 : INT VAR x : TOD; END_VAR test(x); END_FUNCTION - FUNCTION func5 : INT VAR x : LTOD; END_VAR test(x); END_FUNCTION + FUNCTION func2 : INT VAR x : LDT; END_VAR test(x); END_FUNCTION + FUNCTION func3 : INT VAR x : DATE; END_VAR test(x); END_FUNCTION + FUNCTION func4 : INT VAR x : TOD; END_VAR test(x); END_FUNCTION + FUNCTION func5 : INT VAR x : LTOD; END_VAR test(x); END_FUNCTION "; let diagnostics = parse_and_validate(src); @@ -974,15 +974,15 @@ fn any_bit_does_not_allow_ints() { let src = r" FUNCTION test : INT VAR_INPUT x : T; END_VAR END_FUNCTION - FUNCTION func1 : INT VAR x : USINT; END_VAR test(x); END_FUNCTION + FUNCTION func1 : INT VAR x : USINT; END_VAR test(x); END_FUNCTION FUNCTION func2 : INT VAR x : UINT; END_VAR test(x); END_FUNCTION - FUNCTION func3 : INT VAR x : UDINT; END_VAR test(x); END_FUNCTION - FUNCTION func4 : INT VAR x : ULINT; END_VAR test(x); END_FUNCTION + FUNCTION func3 : INT VAR x : UDINT; END_VAR test(x); END_FUNCTION + FUNCTION func4 : INT VAR x : ULINT; END_VAR test(x); END_FUNCTION - FUNCTION func5 : INT VAR x : SINT; END_VAR test(x); END_FUNCTION + FUNCTION func5 : INT VAR x : SINT; END_VAR test(x); END_FUNCTION FUNCTION func6 : INT VAR x : INT; END_VAR test(x); END_FUNCTION - FUNCTION func7 : INT VAR x : DINT; END_VAR test(x); END_FUNCTION - FUNCTION func8 : INT VAR x : LINT; END_VAR test(x); END_FUNCTION + FUNCTION func7 : INT VAR x : DINT; END_VAR test(x); END_FUNCTION + FUNCTION func8 : INT VAR x : LINT; END_VAR test(x); END_FUNCTION "; let diagnostics = parse_and_validate(src); @@ -994,7 +994,7 @@ fn any_bit_does_not_allow_time() { let src = r" FUNCTION test : INT VAR_INPUT x : T; END_VAR END_FUNCTION FUNCTION func1 : INT VAR x : TIME; END_VAR test(x); END_FUNCTION - FUNCTION func2 : INT VAR x : LTIME; END_VAR test(x); END_FUNCTION + FUNCTION func2 : INT VAR x : LTIME; END_VAR test(x); END_FUNCTION "; let diagnostics = parse_and_validate(src); @@ -1006,12 +1006,12 @@ fn any_bit_allows_bits() { let src = r" FUNCTION test : INT VAR_INPUT x : T; END_VAR END_FUNCTION FUNCTION func1 : INT VAR x : BOOL; END_VAR test(x); END_FUNCTION - FUNCTION func2 : INT VAR x : BYTE; END_VAR test(x); END_FUNCTION - FUNCTION func3 : INT VAR x : WORD; END_VAR test(x); END_FUNCTION - FUNCTION func4 : INT VAR x : DWORD; END_VAR test(x); END_FUNCTION - FUNCTION func5 : INT VAR x : LWORD; END_VAR test(x); END_FUNCTION + FUNCTION func2 : INT VAR x : BYTE; END_VAR test(x); END_FUNCTION + FUNCTION func3 : INT VAR x : WORD; END_VAR test(x); END_FUNCTION + FUNCTION func4 : INT VAR x : DWORD; END_VAR test(x); END_FUNCTION + FUNCTION func5 : INT VAR x : LWORD; END_VAR test(x); END_FUNCTION // binary expressions - FUNCTION func6 : INT + FUNCTION func6 : INT VAR a : BOOL; b : BYTE; @@ -1035,7 +1035,7 @@ fn any_bit_does_not_allow_chars() { let src = r" FUNCTION test : INT VAR_INPUT x : T; END_VAR END_FUNCTION FUNCTION func1 : INT VAR x : CHAR; END_VAR test(x); END_FUNCTION - FUNCTION func2 : INT VAR x : WCHAR; END_VAR test(x); END_FUNCTION + FUNCTION func2 : INT VAR x : WCHAR; END_VAR test(x); END_FUNCTION "; let diagnostics = parse_and_validate(src); @@ -1059,10 +1059,10 @@ fn any_bit_does_not_allow_date() { let src = r" FUNCTION test : INT VAR_INPUT x : T; END_VAR END_FUNCTION FUNCTION func1 : INT VAR x : DT; END_VAR test(x); END_FUNCTION - FUNCTION func2 : INT VAR x : LDT; END_VAR test(x); END_FUNCTION - FUNCTION func3 : INT VAR x : DATE; END_VAR test(x); END_FUNCTION - FUNCTION func4 : INT VAR x : TOD; END_VAR test(x); END_FUNCTION - FUNCTION func5 : INT VAR x : LTOD; END_VAR test(x); END_FUNCTION + FUNCTION func2 : INT VAR x : LDT; END_VAR test(x); END_FUNCTION + FUNCTION func3 : INT VAR x : DATE; END_VAR test(x); END_FUNCTION + FUNCTION func4 : INT VAR x : TOD; END_VAR test(x); END_FUNCTION + FUNCTION func5 : INT VAR x : LTOD; END_VAR test(x); END_FUNCTION "; let diagnostics = parse_and_validate(src); @@ -1114,15 +1114,15 @@ fn any_chars_does_not_allow_ints() { let src = r" FUNCTION test : INT VAR_INPUT x : T; END_VAR END_FUNCTION - FUNCTION func1 : INT VAR x : USINT; END_VAR test(x); END_FUNCTION + FUNCTION func1 : INT VAR x : USINT; END_VAR test(x); END_FUNCTION FUNCTION func2 : INT VAR x : UINT; END_VAR test(x); END_FUNCTION - FUNCTION func3 : INT VAR x : UDINT; END_VAR test(x); END_FUNCTION - FUNCTION func4 : INT VAR x : ULINT; END_VAR test(x); END_FUNCTION + FUNCTION func3 : INT VAR x : UDINT; END_VAR test(x); END_FUNCTION + FUNCTION func4 : INT VAR x : ULINT; END_VAR test(x); END_FUNCTION - FUNCTION func5 : INT VAR x : SINT; END_VAR test(x); END_FUNCTION + FUNCTION func5 : INT VAR x : SINT; END_VAR test(x); END_FUNCTION FUNCTION func6 : INT VAR x : INT; END_VAR test(x); END_FUNCTION - FUNCTION func7 : INT VAR x : DINT; END_VAR test(x); END_FUNCTION - FUNCTION func8 : INT VAR x : LINT; END_VAR test(x); END_FUNCTION + FUNCTION func7 : INT VAR x : DINT; END_VAR test(x); END_FUNCTION + FUNCTION func8 : INT VAR x : LINT; END_VAR test(x); END_FUNCTION "; let diagnostics = parse_and_validate(src); @@ -1134,7 +1134,7 @@ fn any_chars_does_not_allow_time() { let src = r" FUNCTION test : INT VAR_INPUT x : T; END_VAR END_FUNCTION FUNCTION func1 : INT VAR x : TIME; END_VAR test(x); END_FUNCTION - FUNCTION func2 : INT VAR x : LTIME; END_VAR test(x); END_FUNCTION + FUNCTION func2 : INT VAR x : LTIME; END_VAR test(x); END_FUNCTION "; let diagnostics = parse_and_validate(src); @@ -1146,10 +1146,10 @@ fn any_chars_does_not_allow_bits() { let src = r" FUNCTION test : INT VAR_INPUT x : T; END_VAR END_FUNCTION FUNCTION func1 : INT VAR x : BOOL; END_VAR test(x); END_FUNCTION - FUNCTION func2 : INT VAR x : BYTE; END_VAR test(x); END_FUNCTION - FUNCTION func3 : INT VAR x : WORD; END_VAR test(x); END_FUNCTION - FUNCTION func4 : INT VAR x : DWORD; END_VAR test(x); END_FUNCTION - FUNCTION func5 : INT VAR x : LWORD; END_VAR test(x); END_FUNCTION + FUNCTION func2 : INT VAR x : BYTE; END_VAR test(x); END_FUNCTION + FUNCTION func3 : INT VAR x : WORD; END_VAR test(x); END_FUNCTION + FUNCTION func4 : INT VAR x : DWORD; END_VAR test(x); END_FUNCTION + FUNCTION func5 : INT VAR x : LWORD; END_VAR test(x); END_FUNCTION "; let diagnostics = parse_and_validate(src); @@ -1161,7 +1161,7 @@ fn any_chars_allows_chars() { let src = r" FUNCTION test : INT VAR_INPUT x : T; END_VAR END_FUNCTION FUNCTION func1 : INT VAR x : CHAR; END_VAR test(x); END_FUNCTION - FUNCTION func2 : INT VAR x : WCHAR; END_VAR test(x); END_FUNCTION + FUNCTION func2 : INT VAR x : WCHAR; END_VAR test(x); END_FUNCTION "; let diagnostics = parse_and_validate(src); @@ -1185,10 +1185,10 @@ fn any_chars_does_not_allow_date() { let src = r" FUNCTION test : INT VAR_INPUT x : T; END_VAR END_FUNCTION FUNCTION func1 : INT VAR x : DT; END_VAR test(x); END_FUNCTION - FUNCTION func2 : INT VAR x : LDT; END_VAR test(x); END_FUNCTION - FUNCTION func3 : INT VAR x : DATE; END_VAR test(x); END_FUNCTION - FUNCTION func4 : INT VAR x : TOD; END_VAR test(x); END_FUNCTION - FUNCTION func5 : INT VAR x : LTOD; END_VAR test(x); END_FUNCTION + FUNCTION func2 : INT VAR x : LDT; END_VAR test(x); END_FUNCTION + FUNCTION func3 : INT VAR x : DATE; END_VAR test(x); END_FUNCTION + FUNCTION func4 : INT VAR x : TOD; END_VAR test(x); END_FUNCTION + FUNCTION func5 : INT VAR x : LTOD; END_VAR test(x); END_FUNCTION "; let diagnostics = parse_and_validate(src); @@ -1240,15 +1240,15 @@ fn any_string_does_not_allow_ints() { let src = r" FUNCTION test : INT VAR_INPUT x : T; END_VAR END_FUNCTION - FUNCTION func1 : INT VAR x : USINT; END_VAR test(x); END_FUNCTION + FUNCTION func1 : INT VAR x : USINT; END_VAR test(x); END_FUNCTION FUNCTION func2 : INT VAR x : UINT; END_VAR test(x); END_FUNCTION - FUNCTION func3 : INT VAR x : UDINT; END_VAR test(x); END_FUNCTION - FUNCTION func4 : INT VAR x : ULINT; END_VAR test(x); END_FUNCTION + FUNCTION func3 : INT VAR x : UDINT; END_VAR test(x); END_FUNCTION + FUNCTION func4 : INT VAR x : ULINT; END_VAR test(x); END_FUNCTION - FUNCTION func5 : INT VAR x : SINT; END_VAR test(x); END_FUNCTION + FUNCTION func5 : INT VAR x : SINT; END_VAR test(x); END_FUNCTION FUNCTION func6 : INT VAR x : INT; END_VAR test(x); END_FUNCTION - FUNCTION func7 : INT VAR x : DINT; END_VAR test(x); END_FUNCTION - FUNCTION func8 : INT VAR x : LINT; END_VAR test(x); END_FUNCTION + FUNCTION func7 : INT VAR x : DINT; END_VAR test(x); END_FUNCTION + FUNCTION func8 : INT VAR x : LINT; END_VAR test(x); END_FUNCTION "; let diagnostics = parse_and_validate(src); @@ -1260,7 +1260,7 @@ fn any_string_does_not_allow_time() { let src = r" FUNCTION test : INT VAR_INPUT x : T; END_VAR END_FUNCTION FUNCTION func1 : INT VAR x : TIME; END_VAR test(x); END_FUNCTION - FUNCTION func2 : INT VAR x : LTIME; END_VAR test(x); END_FUNCTION + FUNCTION func2 : INT VAR x : LTIME; END_VAR test(x); END_FUNCTION "; let diagnostics = parse_and_validate(src); @@ -1272,10 +1272,10 @@ fn any_string_does_not_allow_bits() { let src = r" FUNCTION test : INT VAR_INPUT x : T; END_VAR END_FUNCTION FUNCTION func1 : INT VAR x : BOOL; END_VAR test(x); END_FUNCTION - FUNCTION func2 : INT VAR x : BYTE; END_VAR test(x); END_FUNCTION - FUNCTION func3 : INT VAR x : WORD; END_VAR test(x); END_FUNCTION - FUNCTION func4 : INT VAR x : DWORD; END_VAR test(x); END_FUNCTION - FUNCTION func5 : INT VAR x : LWORD; END_VAR test(x); END_FUNCTION + FUNCTION func2 : INT VAR x : BYTE; END_VAR test(x); END_FUNCTION + FUNCTION func3 : INT VAR x : WORD; END_VAR test(x); END_FUNCTION + FUNCTION func4 : INT VAR x : DWORD; END_VAR test(x); END_FUNCTION + FUNCTION func5 : INT VAR x : LWORD; END_VAR test(x); END_FUNCTION "; let diagnostics = parse_and_validate(src); @@ -1287,7 +1287,7 @@ fn any_string_does_not_allow_chars() { let src = r" FUNCTION test : INT VAR_INPUT x : T; END_VAR END_FUNCTION FUNCTION func1 : INT VAR x : CHAR; END_VAR test(x); END_FUNCTION - FUNCTION func2 : INT VAR x : WCHAR; END_VAR test(x); END_FUNCTION + FUNCTION func2 : INT VAR x : WCHAR; END_VAR test(x); END_FUNCTION "; let diagnostics = parse_and_validate(src); @@ -1311,10 +1311,10 @@ fn any_string_does_not_allow_date() { let src = r" FUNCTION test : INT VAR_INPUT x : T; END_VAR END_FUNCTION FUNCTION func1 : INT VAR x : DT; END_VAR test(x); END_FUNCTION - FUNCTION func2 : INT VAR x : LDT; END_VAR test(x); END_FUNCTION - FUNCTION func3 : INT VAR x : DATE; END_VAR test(x); END_FUNCTION - FUNCTION func4 : INT VAR x : TOD; END_VAR test(x); END_FUNCTION - FUNCTION func5 : INT VAR x : LTOD; END_VAR test(x); END_FUNCTION + FUNCTION func2 : INT VAR x : LDT; END_VAR test(x); END_FUNCTION + FUNCTION func3 : INT VAR x : DATE; END_VAR test(x); END_FUNCTION + FUNCTION func4 : INT VAR x : TOD; END_VAR test(x); END_FUNCTION + FUNCTION func5 : INT VAR x : LTOD; END_VAR test(x); END_FUNCTION "; let diagnostics = parse_and_validate(src); @@ -1366,15 +1366,15 @@ fn any_char_does_not_allow_ints() { let src = r" FUNCTION test : INT VAR_INPUT x : T; END_VAR END_FUNCTION - FUNCTION func1 : INT VAR x : USINT; END_VAR test(x); END_FUNCTION + FUNCTION func1 : INT VAR x : USINT; END_VAR test(x); END_FUNCTION FUNCTION func2 : INT VAR x : UINT; END_VAR test(x); END_FUNCTION - FUNCTION func3 : INT VAR x : UDINT; END_VAR test(x); END_FUNCTION - FUNCTION func4 : INT VAR x : ULINT; END_VAR test(x); END_FUNCTION + FUNCTION func3 : INT VAR x : UDINT; END_VAR test(x); END_FUNCTION + FUNCTION func4 : INT VAR x : ULINT; END_VAR test(x); END_FUNCTION - FUNCTION func5 : INT VAR x : SINT; END_VAR test(x); END_FUNCTION + FUNCTION func5 : INT VAR x : SINT; END_VAR test(x); END_FUNCTION FUNCTION func6 : INT VAR x : INT; END_VAR test(x); END_FUNCTION - FUNCTION func7 : INT VAR x : DINT; END_VAR test(x); END_FUNCTION - FUNCTION func8 : INT VAR x : LINT; END_VAR test(x); END_FUNCTION + FUNCTION func7 : INT VAR x : DINT; END_VAR test(x); END_FUNCTION + FUNCTION func8 : INT VAR x : LINT; END_VAR test(x); END_FUNCTION "; let diagnostics = parse_and_validate(src); @@ -1386,7 +1386,7 @@ fn any_char_does_not_allow_time() { let src = r" FUNCTION test : INT VAR_INPUT x : T; END_VAR END_FUNCTION FUNCTION func1 : INT VAR x : TIME; END_VAR test(x); END_FUNCTION - FUNCTION func2 : INT VAR x : LTIME; END_VAR test(x); END_FUNCTION + FUNCTION func2 : INT VAR x : LTIME; END_VAR test(x); END_FUNCTION "; let diagnostics = parse_and_validate(src); @@ -1398,10 +1398,10 @@ fn any_char_does_not_allow_bits() { let src = r" FUNCTION test : INT VAR_INPUT x : T; END_VAR END_FUNCTION FUNCTION func1 : INT VAR x : BOOL; END_VAR test(x); END_FUNCTION - FUNCTION func2 : INT VAR x : BYTE; END_VAR test(x); END_FUNCTION - FUNCTION func3 : INT VAR x : WORD; END_VAR test(x); END_FUNCTION - FUNCTION func4 : INT VAR x : DWORD; END_VAR test(x); END_FUNCTION - FUNCTION func5 : INT VAR x : LWORD; END_VAR test(x); END_FUNCTION + FUNCTION func2 : INT VAR x : BYTE; END_VAR test(x); END_FUNCTION + FUNCTION func3 : INT VAR x : WORD; END_VAR test(x); END_FUNCTION + FUNCTION func4 : INT VAR x : DWORD; END_VAR test(x); END_FUNCTION + FUNCTION func5 : INT VAR x : LWORD; END_VAR test(x); END_FUNCTION "; let diagnostics = parse_and_validate(src); @@ -1413,7 +1413,7 @@ fn any_char_allows_chars() { let src = r" FUNCTION test : INT VAR_INPUT x : T; END_VAR END_FUNCTION FUNCTION func1 : INT VAR x : CHAR; END_VAR test(x); END_FUNCTION - FUNCTION func2 : INT VAR x : WCHAR; END_VAR test(x); END_FUNCTION + FUNCTION func2 : INT VAR x : WCHAR; END_VAR test(x); END_FUNCTION "; let diagnostics = parse_and_validate(src); @@ -1437,10 +1437,10 @@ fn any_char_does_not_allow_date() { let src = r" FUNCTION test : INT VAR_INPUT x : T; END_VAR END_FUNCTION FUNCTION func1 : INT VAR x : DT; END_VAR test(x); END_FUNCTION - FUNCTION func2 : INT VAR x : LDT; END_VAR test(x); END_FUNCTION - FUNCTION func3 : INT VAR x : DATE; END_VAR test(x); END_FUNCTION - FUNCTION func4 : INT VAR x : TOD; END_VAR test(x); END_FUNCTION - FUNCTION func5 : INT VAR x : LTOD; END_VAR test(x); END_FUNCTION + FUNCTION func2 : INT VAR x : LDT; END_VAR test(x); END_FUNCTION + FUNCTION func3 : INT VAR x : DATE; END_VAR test(x); END_FUNCTION + FUNCTION func4 : INT VAR x : TOD; END_VAR test(x); END_FUNCTION + FUNCTION func5 : INT VAR x : LTOD; END_VAR test(x); END_FUNCTION "; let diagnostics = parse_and_validate(src); @@ -1492,15 +1492,15 @@ fn any_date_does_not_allow_ints() { let src = r" FUNCTION test : INT VAR_INPUT x : T; END_VAR END_FUNCTION - FUNCTION func1 : INT VAR x : USINT; END_VAR test(x); END_FUNCTION + FUNCTION func1 : INT VAR x : USINT; END_VAR test(x); END_FUNCTION FUNCTION func2 : INT VAR x : UINT; END_VAR test(x); END_FUNCTION - FUNCTION func3 : INT VAR x : UDINT; END_VAR test(x); END_FUNCTION - FUNCTION func4 : INT VAR x : ULINT; END_VAR test(x); END_FUNCTION + FUNCTION func3 : INT VAR x : UDINT; END_VAR test(x); END_FUNCTION + FUNCTION func4 : INT VAR x : ULINT; END_VAR test(x); END_FUNCTION - FUNCTION func5 : INT VAR x : SINT; END_VAR test(x); END_FUNCTION + FUNCTION func5 : INT VAR x : SINT; END_VAR test(x); END_FUNCTION FUNCTION func6 : INT VAR x : INT; END_VAR test(x); END_FUNCTION - FUNCTION func7 : INT VAR x : DINT; END_VAR test(x); END_FUNCTION - FUNCTION func8 : INT VAR x : LINT; END_VAR test(x); END_FUNCTION + FUNCTION func7 : INT VAR x : DINT; END_VAR test(x); END_FUNCTION + FUNCTION func8 : INT VAR x : LINT; END_VAR test(x); END_FUNCTION "; let diagnostics = parse_and_validate(src); @@ -1512,7 +1512,7 @@ fn any_date_does_not_allow_time() { let src = r" FUNCTION test : INT VAR_INPUT x : T; END_VAR END_FUNCTION FUNCTION func1 : INT VAR x : TIME; END_VAR test(x); END_FUNCTION - FUNCTION func2 : INT VAR x : LTIME; END_VAR test(x); END_FUNCTION + FUNCTION func2 : INT VAR x : LTIME; END_VAR test(x); END_FUNCTION "; let diagnostics = parse_and_validate(src); @@ -1524,10 +1524,10 @@ fn any_date_does_not_allow_bits() { let src = r" FUNCTION test : INT VAR_INPUT x : T; END_VAR END_FUNCTION FUNCTION func1 : INT VAR x : BOOL; END_VAR test(x); END_FUNCTION - FUNCTION func2 : INT VAR x : BYTE; END_VAR test(x); END_FUNCTION - FUNCTION func3 : INT VAR x : WORD; END_VAR test(x); END_FUNCTION - FUNCTION func4 : INT VAR x : DWORD; END_VAR test(x); END_FUNCTION - FUNCTION func5 : INT VAR x : LWORD; END_VAR test(x); END_FUNCTION + FUNCTION func2 : INT VAR x : BYTE; END_VAR test(x); END_FUNCTION + FUNCTION func3 : INT VAR x : WORD; END_VAR test(x); END_FUNCTION + FUNCTION func4 : INT VAR x : DWORD; END_VAR test(x); END_FUNCTION + FUNCTION func5 : INT VAR x : LWORD; END_VAR test(x); END_FUNCTION "; let diagnostics = parse_and_validate(src); @@ -1539,7 +1539,7 @@ fn any_date_does_not_allow_chars() { let src = r" FUNCTION test : INT VAR_INPUT x : T; END_VAR END_FUNCTION FUNCTION func1 : INT VAR x : CHAR; END_VAR test(x); END_FUNCTION - FUNCTION func2 : INT VAR x : WCHAR; END_VAR test(x); END_FUNCTION + FUNCTION func2 : INT VAR x : WCHAR; END_VAR test(x); END_FUNCTION "; let diagnostics = parse_and_validate(src); @@ -1563,10 +1563,10 @@ fn any_date_allows_date() { let src = r" FUNCTION test : INT VAR_INPUT x : T; END_VAR END_FUNCTION FUNCTION func1 : INT VAR x : DT; END_VAR test(x); END_FUNCTION - FUNCTION func2 : INT VAR x : LDT; END_VAR test(x); END_FUNCTION - FUNCTION func3 : INT VAR x : DATE; END_VAR test(x); END_FUNCTION - FUNCTION func4 : INT VAR x : TOD; END_VAR test(x); END_FUNCTION - FUNCTION func5 : INT VAR x : LTOD; END_VAR test(x); END_FUNCTION + FUNCTION func2 : INT VAR x : LDT; END_VAR test(x); END_FUNCTION + FUNCTION func3 : INT VAR x : DATE; END_VAR test(x); END_FUNCTION + FUNCTION func4 : INT VAR x : TOD; END_VAR test(x); END_FUNCTION + FUNCTION func5 : INT VAR x : LTOD; END_VAR test(x); END_FUNCTION "; let diagnostics = parse_and_validate(src); diff --git a/src/validation/tests/literals_validation_tests.rs b/src/validation/tests/literals_validation_tests.rs index 7d2346df3f..62069e2905 100644 --- a/src/validation/tests/literals_validation_tests.rs +++ b/src/validation/tests/literals_validation_tests.rs @@ -49,7 +49,7 @@ fn string_literal_casts_are_validated() { let diagnostics = parse_and_validate( r#" PROGRAM prg - + STRING#"TRUE"; WSTRING#'TRUE'; @@ -75,7 +75,7 @@ fn real_literal_casts_are_validated() { let diagnostics = parse_and_validate( r#" PROGRAM prg - + REAL#3.14; LREAL#3.15; REAL#10; @@ -84,7 +84,7 @@ fn real_literal_casts_are_validated() { REAL#TRUE; REAL#1; REAL#'3.14'; - + LREAL#TRUE; LREAL#1; LREAL#"3.14"; @@ -98,10 +98,10 @@ fn real_literal_casts_are_validated() { #[test] fn literal_cast_with_non_literal() { let diagnostics = parse_and_validate( - "PROGRAM exp - INT#[x]; + "PROGRAM exp + INT#[x]; END_PROGRAM - + VAR_GLOBAL x : INT; END_VAR", ); assert_validation_snapshot!(&diagnostics); @@ -113,10 +113,10 @@ fn literal_enum_elements_validate_without_errors() { " TYPE Animal: (Dog, Cat, Horse); END_TYPE TYPE Color: (Red, Yellow, Green); END_TYPE - - PROGRAM exp - Animal#Dog; - Color#Yellow; + + PROGRAM exp + Animal#Dog; + Color#Yellow; END_PROGRAM", ); @@ -155,12 +155,12 @@ fn char_cast_validate() { let diagnostics = parse_and_validate( r#" PROGRAM prg - + CHAR#"A"; WCHAR#'B'; - CHAR#"XY"; - WCHAR#'YZ'; + CHAR#"XY"; + WCHAR#'YZ'; END_PROGRAM "#, diff --git a/src/validation/tests/pou_validation_tests.rs b/src/validation/tests/pou_validation_tests.rs index 27ee808e09..c769b59f01 100644 --- a/src/validation/tests/pou_validation_tests.rs +++ b/src/validation/tests/pou_validation_tests.rs @@ -24,8 +24,8 @@ fn class_has_implementation() { // WHEN parse_and_validate is done let diagnostics = parse_and_validate( " - CLASS myCLASS - VAR + CLASS myCLASS + VAR LIGHT: BOOL; END_VAR LIGHT := TRUE; @@ -46,7 +46,7 @@ fn program_has_super_class() { END_CLASS PROGRAM prog EXTENDS cls - END_PROGRAM + END_PROGRAM ", ); // THEN there should be one diagnostic -> Program cannot have super class @@ -63,7 +63,7 @@ fn function_has_super_class() { END_CLASS FUNCTION func EXTENDS cls - END_FUNCTION + END_FUNCTION ", ); // THEN there should be one diagnostic -> Function cannot have super class @@ -193,19 +193,19 @@ fn in_out_variable_out_of_order() { fb.foo(myOtherInOut := out2, myInOut := out1); // valid END_PROGRAM - + FUNCTION_BLOCK fb_t VAR - myVar : BOOL; + myVar : BOOL; END_VAR VAR_INPUT - myInput : USINT; + myInput : USINT; END_VAR VAR_IN_OUT - myInOut : BOOL; + myInOut : BOOL; END_VAR VAR_OUTPUT - myOut : BOOL; + myOut : BOOL; END_VAR VAR_IN_OUT myOtherInOut : BOOL; diff --git a/src/validation/tests/recursive_validation_tests.rs b/src/validation/tests/recursive_validation_tests.rs index 02a6972194..2efa35ee9a 100644 --- a/src/validation/tests/recursive_validation_tests.rs +++ b/src/validation/tests/recursive_validation_tests.rs @@ -120,7 +120,7 @@ mod structs { a : A; e : e; END_STRUCT END_TYPE - + TYPE E : STRUCT a_int: INT; END_STRUCT END_TYPE @@ -182,11 +182,11 @@ mod structs { TYPE A : STRUCT b : B; END_STRUCT END_TYPE - + TYPE B : STRUCT c : C; END_STRUCT END_TYPE - + TYPE C : STRUCT b : B; END_STRUCT END_TYPE @@ -200,13 +200,13 @@ mod structs { fn one_cycle_with_multiple_identical_members_aba() { let diagnostics = parse_and_validate( " - TYPE A : STRUCT + TYPE A : STRUCT b1 : B; b2 : B; b3 : B; END_STRUCT END_TYPE - TYPE B : STRUCT + TYPE B : STRUCT a : A; END_STRUCT END_TYPE ", @@ -223,7 +223,7 @@ mod structs { a : A; b : B; END_STRUCT END_TYPE - + TYPE B : STRUCT a : A; END_STRUCT END_TYPE @@ -240,16 +240,16 @@ mod structs { TYPE A : STRUCT b : B; END_STRUCT END_TYPE - + TYPE B : STRUCT c : C; END_STRUCT END_TYPE - + TYPE C : STRUCT c : C; e : E; END_STRUCT END_TYPE - + TYPE E : STRUCT c : C; END_STRUCT END_TYPE @@ -314,7 +314,7 @@ mod arrays { a : ARRAY[0..1] OF A; b : ARRAY[0..1] OF B; END_STRUCT END_TYPE - + TYPE B : STRUCT a : A; END_STRUCT END_TYPE @@ -331,11 +331,11 @@ mod arrays { TYPE A : STRUCT b : ARRAY[0..1] OF B; END_STRUCT END_TYPE - + TYPE B : STRUCT c : ARRAY[0..1] OF C; END_STRUCT END_TYPE - + TYPE C : STRUCT b : ARRAY[0..1] OF B; END_STRUCT END_TYPE @@ -349,13 +349,13 @@ mod arrays { fn one_cycle_with_multiple_identical_members_aba() { let diagnostics = parse_and_validate( " - TYPE A : STRUCT + TYPE A : STRUCT b1 : ARRAY[0..1] OF B; b2 : ARRAY[0..1] OF B; b3 : ARRAY[0..1] OF B; END_STRUCT END_TYPE - TYPE B : STRUCT + TYPE B : STRUCT a : A; END_STRUCT END_TYPE ", @@ -425,18 +425,18 @@ mod arrays { TYPE E : STRUCT f : ARRAY [0..1] OF F; END_STRUCT END_TYPE - + FUNCTION_BLOCK F VAR_INPUT g : G; b : B; END_VAR END_FUNCTION_BLOCK - + TYPE G : STRUCT h : H; END_STRUCT END_TYPE - + FUNCTION_BLOCK H VAR_INPUT i : I; @@ -572,20 +572,20 @@ mod functionblocks { f : F; END_VAR END_FUNCTION_BLOCK - + FUNCTION_BLOCK F VAR_INPUT g : G; b : B; END_VAR END_FUNCTION_BLOCK - + FUNCTION_BLOCK G VAR_INPUT h : H; END_VAR END_FUNCTION_BLOCK - + FUNCTION_BLOCK H VAR_INPUT i : I; @@ -669,18 +669,18 @@ mod mixed_structs_and_functionblocks { TYPE E : STRUCT f : F; END_STRUCT END_TYPE - + FUNCTION_BLOCK F VAR_INPUT g : G; b : B; END_VAR END_FUNCTION_BLOCK - + TYPE G : STRUCT h : H; END_STRUCT END_TYPE - + FUNCTION_BLOCK H VAR_INPUT i : I; diff --git a/src/validation/tests/reference_resolve_tests.rs b/src/validation/tests/reference_resolve_tests.rs index b97c03aca4..646afe2970 100644 --- a/src/validation/tests/reference_resolve_tests.rs +++ b/src/validation/tests/reference_resolve_tests.rs @@ -62,7 +62,7 @@ fn resole_struct_member_access() { subfield3: INT; END_STRUCT END_TYPE - + TYPE MyStruct: STRUCT field1: INT; field2: INT; @@ -72,8 +72,8 @@ fn resole_struct_member_access() { END_TYPE PROGRAM prg - VAR - a : INT; + VAR + a : INT; s : MyStruct; END_VAR (* should be fine *) @@ -85,7 +85,7 @@ fn resole_struct_member_access() { s.field10; s.field20; s.field30; - + (* should be fine*) s.sub.subfield1; s.sub.subfield2; @@ -115,7 +115,7 @@ fn resolve_function_block_calls_field_access() { END_FUNCTION_BLOCK PROGRAM prg - VAR + VAR s : FB; END_VAR s; @@ -150,9 +150,9 @@ fn resolve_function_block_calls_in_structs_and_field_access() { fb2: FB; END_STRUCT END_TYPE - + PROGRAM prg - VAR + VAR s : MyStruct; END_VAR @@ -176,7 +176,7 @@ fn resolve_function_members_via_qualifier() { let diagnostics = parse_and_validate( " PROGRAM prg - VAR + VAR s : MyStruct; END_VAR foo(a := 1, b := 2, c := 3); (* ok *) @@ -202,7 +202,7 @@ fn reference_to_private_variable_is_illegal() { let diagnostics = parse_and_validate( " PROGRAM prg - VAR + VAR s : INT; END_VAR END_PROGRAM @@ -233,7 +233,7 @@ fn reference_to_private_variable_in_intermediate_fb() { FUNCTION_BLOCK fb2 VAR_INPUT - x : INT; + x : INT; END_VAR END_FUNCTION_BLOCK @@ -257,7 +257,7 @@ fn program_vars_are_allowed_in_their_actions() { let diagnostics = parse_and_validate( " PROGRAM prg - VAR + VAR s : INT; END_VAR END_PROGRAM @@ -276,7 +276,7 @@ fn program_vars_are_allowed_in_their_actions() { fn fb_pointer_access_call_statement_resolves_without_validation_errors() { let diagnostics = parse_and_validate( " - PROGRAM main + PROGRAM main VAR FileOpen : REF_TO file; END_VAR @@ -303,7 +303,7 @@ fn fb_pointer_access_call_statement_resolves_without_validation_errors() { fn resolve_array_of_struct_as_member_of_another_struct_initializer() { let diagnostics = parse_and_validate( " - PROGRAM mainProg + PROGRAM mainProg VAR var_str1 : STRUCT1 := (myArr := [(x1 := FALSE, x2 := TRUE)]); END_VAR diff --git a/src/validation/tests/snapshots/rusty__validation__tests__array_validation_test__array_access_dimension_mismatch.snap b/src/validation/tests/snapshots/rusty__validation__tests__array_validation_test__array_access_dimension_mismatch.snap index da865f2806..034c3f4785 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__array_validation_test__array_access_dimension_mismatch.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__array_validation_test__array_access_dimension_mismatch.snap @@ -3,27 +3,27 @@ source: src/validation/tests/array_validation_test.rs expression: diagnostics --- error: Expected array access with 1 dimensions, found 2 - ┌─ :13:8 + ┌─ :13:17 │ -13 │ arr[0, 1] := 1; - │ ^^^^ Expected array access with 1 dimensions, found 2 +13 │ arr[0, 1] := 1; + │ ^^^^ Expected array access with 1 dimensions, found 2 error: Expected array access with 1 dimensions, found 2 - ┌─ :14:8 + ┌─ :14:17 │ -14 │ vla[0, 1] := 1; - │ ^^^^ Expected array access with 1 dimensions, found 2 +14 │ vla[0, 1] := 1; + │ ^^^^ Expected array access with 1 dimensions, found 2 error: Expected array access with 1 dimensions, found 3 - ┌─ :15:8 + ┌─ :15:17 │ -15 │ arr[0, 1, 2] := 1; - │ ^^^^^^^ Expected array access with 1 dimensions, found 3 +15 │ arr[0, 1, 2] := 1; + │ ^^^^^^^ Expected array access with 1 dimensions, found 3 error: Expected array access with 1 dimensions, found 3 - ┌─ :16:8 + ┌─ :16:17 │ -16 │ vla[0, 1, 2] := 1; - │ ^^^^^^^ Expected array access with 1 dimensions, found 3 +16 │ vla[0, 1, 2] := 1; + │ ^^^^^^^ Expected array access with 1 dimensions, found 3 diff --git a/src/validation/tests/snapshots/rusty__validation__tests__array_validation_test__array_access_validation.snap b/src/validation/tests/snapshots/rusty__validation__tests__array_validation_test__array_access_validation.snap index a79831278c..6928297a58 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__array_validation_test__array_access_validation.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__array_validation_test__array_access_validation.snap @@ -3,51 +3,51 @@ source: src/validation/tests/array_validation_test.rs expression: "&diagnostics" --- error: Array access must be in the range 2..3 - ┌─ :29:12 + ┌─ :29:21 │ -29 │ multi[1,4]; // out of range - │ ^ Array access must be in the range 2..3 +29 │ multi[1,4]; // out of range + │ ^ Array access must be in the range 2..3 error: Array access must be in the range 2..3 - ┌─ :30:14 + ┌─ :30:23 │ -30 │ nested[1][4]; // out of range - │ ^ Array access must be in the range 2..3 +30 │ nested[1][4]; // out of range + │ ^ Array access must be in the range 2..3 error: Array access must be in the range 0..1 - ┌─ :31:8 + ┌─ :31:17 │ -31 │ arr[3]; // out of range - │ ^ Array access must be in the range 0..1 +31 │ arr[3]; // out of range + │ ^ Array access must be in the range 0..1 error: Array access must be in the range -2..2 - ┌─ :32:19 + ┌─ :32:28 │ -32 │ negative_start[-4]; // out of range - │ ^^ Array access must be in the range -2..2 +32 │ negative_start[-4]; // out of range + │ ^^ Array access must be in the range -2..2 error: Array access must be in the range -3..-1 - ┌─ :33:13 + ┌─ :33:22 │ -33 │ negative[-4]; // out of range - │ ^^ Array access must be in the range -3..-1 +33 │ negative[-4]; // out of range + │ ^^ Array access must be in the range -3..-1 error: Array access must be in the range 1..2 - ┌─ :34:10 + ┌─ :34:19 │ -34 │ const[3]; // out of range - │ ^ Array access must be in the range 1..2 +34 │ const[3]; // out of range + │ ^ Array access must be in the range 1..2 error: Invalid type STRING for array access. Only variables of Integer types are allowed to access an array - ┌─ :35:8 + ┌─ :35:17 │ -35 │ arr[string_ref]; // invalid type for array access - │ ^^^^^^^^^^ Invalid type STRING for array access. Only variables of Integer types are allowed to access an array +35 │ arr[string_ref]; // invalid type for array access + │ ^^^^^^^^^^ Invalid type STRING for array access. Only variables of Integer types are allowed to access an array error: Invalid type INT for array access. Only variables of Array types are allowed - ┌─ :36:12 + ┌─ :36:21 │ -36 │ int_ref[1]; // not an array - │ ^ Invalid type INT for array access. Only variables of Array types are allowed +36 │ int_ref[1]; // not an array + │ ^ Invalid type INT for array access. Only variables of Array types are allowed diff --git a/src/validation/tests/snapshots/rusty__validation__tests__array_validation_test__array_initialization_validation.snap b/src/validation/tests/snapshots/rusty__validation__tests__array_validation_test__array_initialization_validation.snap index eb91d8a089..071e59081b 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__array_validation_test__array_initialization_validation.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__array_validation_test__array_initialization_validation.snap @@ -3,63 +3,63 @@ source: src/validation/tests/array_validation_test.rs expression: "&diagnostics" --- error: Array assignments must be surrounded with `[]` - ┌─ :5:35 + ┌─ :5:50 │ -5 │ arr2 : ARRAY[1..2] OF DINT := 1, 2; // Missing `[` - │ ^^^^ Array assignments must be surrounded with `[]` +5 │ arr2 : ARRAY[1..2] OF DINT := 1, 2; // Missing `[` + │ ^^^^ Array assignments must be surrounded with `[]` error: Array assignments must be surrounded with `[]` - ┌─ :6:40 + ┌─ :6:55 │ -6 │ arr3 : ARRAY[1..2] OF myStruct := ((var1 := 1), (var1 := 2, var2 := (1, 2))); // Missing `[` - │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Array assignments must be surrounded with `[]` +6 │ arr3 : ARRAY[1..2] OF myStruct := ((var1 := 1), (var1 := 2, var2 := (1, 2))); // Missing `[` + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Array assignments must be surrounded with `[]` error: Array assignments must be surrounded with `[]` - ┌─ :6:74 + ┌─ :6:89 │ -6 │ arr3 : ARRAY[1..2] OF myStruct := ((var1 := 1), (var1 := 2, var2 := (1, 2))); // Missing `[` - │ ^^^^ Array assignments must be surrounded with `[]` +6 │ arr3 : ARRAY[1..2] OF myStruct := ((var1 := 1), (var1 := 2, var2 := (1, 2))); // Missing `[` + │ ^^^^ Array assignments must be surrounded with `[]` error: Array assignments must be surrounded with `[]` - ┌─ :7:40 + ┌─ :7:55 │ -7 │ arr4 : ARRAY[1..2] OF myStruct := ((var1 := 1), (var1 := 2, var2 := 1, 2)); // Missing `[` - │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Array assignments must be surrounded with `[]` +7 │ arr4 : ARRAY[1..2] OF myStruct := ((var1 := 1), (var1 := 2, var2 := 1, 2)); // Missing `[` + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Array assignments must be surrounded with `[]` error: Array assignments must be surrounded with `[]` - ┌─ :7:73 + ┌─ :7:88 │ -7 │ arr4 : ARRAY[1..2] OF myStruct := ((var1 := 1), (var1 := 2, var2 := 1, 2)); // Missing `[` - │ ^ Array assignments must be surrounded with `[]` +7 │ arr4 : ARRAY[1..2] OF myStruct := ((var1 := 1), (var1 := 2, var2 := 1, 2)); // Missing `[` + │ ^ Array assignments must be surrounded with `[]` error: Array assignments must be surrounded with `[]` - ┌─ :8:39 + ┌─ :8:51 │ -8 │ arr_init : ARRAY[1..2] OF DINT := (1, 2); // Missing `[` - │ ^^^^ Array assignments must be surrounded with `[]` +8 │ arr_init : ARRAY[1..2] OF DINT := (1, 2); // Missing `[` + │ ^^^^ Array assignments must be surrounded with `[]` error: Array assignments must be surrounded with `[]` - ┌─ :10:43 + ┌─ :10:59 │ -10 │ y : myStruct := (var1 := 1, var2 := 3, 4); // Missing `[` - │ ^ Array assignments must be surrounded with `[]` +10 │ y : myStruct := (var1 := 1, var2 := 3, 4); // Missing `[` + │ ^ Array assignments must be surrounded with `[]` error: Array assignments must be surrounded with `[]` - ┌─ :12:11 + ┌─ :12:20 │ -12 │ arr := 1, 2; // Missing `[` - │ ^ Array assignments must be surrounded with `[]` +12 │ arr := 1, 2; // Missing `[` + │ ^ Array assignments must be surrounded with `[]` error: Array assignments must be surrounded with `[]` - ┌─ :13:12 + ┌─ :13:21 │ -13 │ arr := (1, 2); // Missing `[` - │ ^^^^ Array assignments must be surrounded with `[]` +13 │ arr := (1, 2); // Missing `[` + │ ^^^^ Array assignments must be surrounded with `[]` error: Array assignments must be surrounded with `[]` - ┌─ :15:29 + ┌─ :15:40 │ -15 │ x := (var1 := 1, var2 := 3, 4); // Missing `[` - │ ^ Array assignments must be surrounded with `[]` +15 │ x := (var1 := 1, var2 := 3, 4); // Missing `[` + │ ^ Array assignments must be surrounded with `[]` diff --git a/src/validation/tests/snapshots/rusty__validation__tests__array_validation_test__assignment_1d.snap b/src/validation/tests/snapshots/rusty__validation__tests__array_validation_test__assignment_1d.snap index 5c898e938b..f2a359ccfc 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__array_validation_test__assignment_1d.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__array_validation_test__assignment_1d.snap @@ -3,81 +3,81 @@ source: src/validation/tests/array_validation_test.rs expression: diagnostics --- error: Unexpected token: expected KeywordSquareParensClose but found ) - ┌─ :15:25 + ┌─ :15:34 │ -15 │ arr := [1, 2, 3, 4, 5); - │ ^ Unexpected token: expected KeywordSquareParensClose but found ) +15 │ arr := [1, 2, 3, 4, 5); + │ ^ Unexpected token: expected KeywordSquareParensClose but found ) error: Unexpected token: expected KeywordSemicolon but found ')' - ┌─ :15:25 + ┌─ :15:34 │ -15 │ arr := [1, 2, 3, 4, 5); - │ ^ Unexpected token: expected KeywordSemicolon but found ')' +15 │ arr := [1, 2, 3, 4, 5); + │ ^ Unexpected token: expected KeywordSemicolon but found ')' error: Unexpected token: expected KeywordParensClose but found ']' - ┌─ :16:25 + ┌─ :16:34 │ -16 │ arr := (1, 2, 3, 4, 5]; - │ ^ Unexpected token: expected KeywordParensClose but found ']' +16 │ arr := (1, 2, 3, 4, 5]; + │ ^ Unexpected token: expected KeywordParensClose but found ']' error: Missing expected Token [KeywordParensClose] - ┌─ :16:26 + ┌─ :16:35 │ -16 │ arr := (1, 2, 3, 4, 5]; - │ ^ Missing expected Token [KeywordParensClose] +16 │ arr := (1, 2, 3, 4, 5]; + │ ^ Missing expected Token [KeywordParensClose] error: Unexpected token: expected KeywordParensClose but found ';' - ┌─ :16:26 + ┌─ :16:35 │ -16 │ arr := (1, 2, 3, 4, 5]; - │ ^ Unexpected token: expected KeywordParensClose but found ';' +16 │ arr := (1, 2, 3, 4, 5]; + │ ^ Unexpected token: expected KeywordParensClose but found ';' error: Array __main_arr has a size of 5, but 6 elements were provided - ┌─ :4:36 + ┌─ :4:54 │ -4 │ arr : ARRAY[1..5] OF DINT := [1, 2, 3, 4, 5, 6]; - │ ^^^^^^^^^^^^^^^^^^ Array __main_arr has a size of 5, but 6 elements were provided +4 │ arr : ARRAY[1..5] OF DINT := [1, 2, 3, 4, 5, 6]; + │ ^^^^^^^^^^^^^^^^^^ Array __main_arr has a size of 5, but 6 elements were provided error: Array assignments must be surrounded with `[]` - ┌─ :5:40 + ┌─ :5:55 │ -5 │ arr_alt : ARRAY[1..5] OF DINT := (1, 2, 3, 4, 5, 6); - │ ^^^^^^^^^^^^^^^^ Array assignments must be surrounded with `[]` +5 │ arr_alt : ARRAY[1..5] OF DINT := (1, 2, 3, 4, 5, 6); + │ ^^^^^^^^^^^^^^^^ Array assignments must be surrounded with `[]` error: Array assignments must be surrounded with `[]` - ┌─ :11:12 + ┌─ :11:21 │ -11 │ arr := (1, 2, 3, 4); - │ ^^^^^^^^^^ Array assignments must be surrounded with `[]` +11 │ arr := (1, 2, 3, 4); + │ ^^^^^^^^^^ Array assignments must be surrounded with `[]` error: Array assignments must be surrounded with `[]` - ┌─ :12:12 + ┌─ :12:21 │ -12 │ arr := (1, 2, 3, 4, 5); - │ ^^^^^^^^^^^^^ Array assignments must be surrounded with `[]` +12 │ arr := (1, 2, 3, 4, 5); + │ ^^^^^^^^^^^^^ Array assignments must be surrounded with `[]` error: Array assignments must be surrounded with `[]` - ┌─ :13:12 + ┌─ :13:21 │ -13 │ arr := (1, 2, 3, 4, 5, 6); - │ ^^^^^^^^^^^^^^^^ Array assignments must be surrounded with `[]` +13 │ arr := (1, 2, 3, 4, 5, 6); + │ ^^^^^^^^^^^^^^^^ Array assignments must be surrounded with `[]` error: Array __main_arr has a size of 5, but 6 elements were provided - ┌─ :14:11 + ┌─ :14:20 │ -14 │ arr := [1, 2, 3, 4, 5, 6]; - │ ^^^^^^^^^^^^^^^^^^ Array __main_arr has a size of 5, but 6 elements were provided +14 │ arr := [1, 2, 3, 4, 5, 6]; + │ ^^^^^^^^^^^^^^^^^^ Array __main_arr has a size of 5, but 6 elements were provided error: Array assignments must be surrounded with `[]` - ┌─ :15:25 + ┌─ :15:34 │ -15 │ arr := [1, 2, 3, 4, 5); - │ ^ Array assignments must be surrounded with `[]` +15 │ arr := [1, 2, 3, 4, 5); + │ ^ Array assignments must be surrounded with `[]` error: Array assignments must be surrounded with `[]` - ┌─ :16:12 + ┌─ :16:21 │ -16 │ arr := (1, 2, 3, 4, 5]; - │ ^^^^^^^^^^^^^ Array assignments must be surrounded with `[]` +16 │ arr := (1, 2, 3, 4, 5]; + │ ^^^^^^^^^^^^^ Array assignments must be surrounded with `[]` diff --git a/src/validation/tests/snapshots/rusty__validation__tests__array_validation_test__assignment_2d.snap b/src/validation/tests/snapshots/rusty__validation__tests__array_validation_test__assignment_2d.snap index 73f6a0dd4d..1088f43f87 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__array_validation_test__assignment_2d.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__array_validation_test__assignment_2d.snap @@ -3,63 +3,63 @@ source: src/validation/tests/array_validation_test.rs expression: diagnostics --- error: Array __main_arr has a size of 10, but 11 elements were provided - ┌─ :4:43 + ┌─ :4:64 │ -4 │ arr : ARRAY[1..2, 1..5] OF DINT := [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]; - │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Array __main_arr has a size of 10, but 11 elements were provided +4 │ arr : ARRAY[1..2, 1..5] OF DINT := [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]; + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Array __main_arr has a size of 10, but 11 elements were provided error: Array assignments must be surrounded with `[]` - ┌─ :5:47 + ┌─ :5:65 │ -5 │ arr_alt : ARRAY[1..2, 1..5] OF DINT := (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11); - │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Array assignments must be surrounded with `[]` +5 │ arr_alt : ARRAY[1..2, 1..5] OF DINT := (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11); + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Array assignments must be surrounded with `[]` error: Array __main_arr_nested has a size of 10, but 15 elements were provided - ┌─ :7:57 + ┌─ :7:73 │ -7 │ arr_nested : ARRAY[1..2] OF ARRAY[1..5] OF DINT := [ [1, 2, 3, 4, 5], [6, 7, 8, 9, 10], [11, 12, 13, 14, 15] ]; - │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Array __main_arr_nested has a size of 10, but 15 elements were provided +7 │ arr_nested : ARRAY[1..2] OF ARRAY[1..5] OF DINT := [ [1, 2, 3, 4, 5], [6, 7, 8, 9, 10], [11, 12, 13, 14, 15] ]; + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Array __main_arr_nested has a size of 10, but 15 elements were provided error: Array assignments must be surrounded with `[]` - ┌─ :8:62 + ┌─ :8:75 │ -8 │ arr_nested_alt : ARRAY[1..2] OF ARRAY[1..5] OF DINT := ( [1, 2, 3, 4, 5], [6, 7, 8, 9, 10], [11, 12, 13, 14, 15] ); - │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Array assignments must be surrounded with `[]` +8 │ arr_nested_alt : ARRAY[1..2] OF ARRAY[1..5] OF DINT := ( [1, 2, 3, 4, 5], [6, 7, 8, 9, 10], [11, 12, 13, 14, 15] ); + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Array assignments must be surrounded with `[]` error: Array assignments must be surrounded with `[]` - ┌─ :14:12 + ┌─ :14:21 │ -14 │ arr := (1, 2, 3, 4, 5, 6, 7, 8, 9); - │ ^^^^^^^^^^^^^^^^^^^^^^^^^ Array assignments must be surrounded with `[]` +14 │ arr := (1, 2, 3, 4, 5, 6, 7, 8, 9); + │ ^^^^^^^^^^^^^^^^^^^^^^^^^ Array assignments must be surrounded with `[]` error: Array assignments must be surrounded with `[]` - ┌─ :15:12 + ┌─ :15:21 │ -15 │ arr := (1, 2, 3, 4, 5, 6, 7, 8, 9, 10); - │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Array assignments must be surrounded with `[]` +15 │ arr := (1, 2, 3, 4, 5, 6, 7, 8, 9, 10); + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Array assignments must be surrounded with `[]` error: Array assignments must be surrounded with `[]` - ┌─ :16:12 + ┌─ :16:21 │ -16 │ arr := (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11); - │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Array assignments must be surrounded with `[]` +16 │ arr := (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11); + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Array assignments must be surrounded with `[]` error: Array __main_arr has a size of 10, but 11 elements were provided - ┌─ :17:11 + ┌─ :17:20 │ -17 │ arr := [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]; - │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Array __main_arr has a size of 10, but 11 elements were provided +17 │ arr := [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]; + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Array __main_arr has a size of 10, but 11 elements were provided error: Array __main_arr_nested has a size of 10, but 15 elements were provided - ┌─ :20:19 + ┌─ :20:32 │ -20 │ arr_nested := [ [1, 2, 3, 4, 5], [6, 7, 8, 9, 10], [11, 12, 13, 14, 15] ]; - │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Array __main_arr_nested has a size of 10, but 15 elements were provided +20 │ arr_nested := [ [1, 2, 3, 4, 5], [6, 7, 8, 9, 10], [11, 12, 13, 14, 15] ]; + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Array __main_arr_nested has a size of 10, but 15 elements were provided error: Array assignments must be surrounded with `[]` - ┌─ :21:21 + ┌─ :21:34 │ -21 │ arr_nested := ( [1, 2, 3, 4, 5], [6, 7, 8, 9, 10], [11, 12, 13, 14, 15] ); - │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Array assignments must be surrounded with `[]` +21 │ arr_nested := ( [1, 2, 3, 4, 5], [6, 7, 8, 9, 10], [11, 12, 13, 14, 15] ); + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Array assignments must be surrounded with `[]` diff --git a/src/validation/tests/snapshots/rusty__validation__tests__array_validation_test__assignment_3d.snap b/src/validation/tests/snapshots/rusty__validation__tests__array_validation_test__assignment_3d.snap index af71ef3695..35218d5538 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__array_validation_test__assignment_3d.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__array_validation_test__assignment_3d.snap @@ -3,57 +3,57 @@ source: src/validation/tests/array_validation_test.rs expression: diagnostics --- error: Array __main_arr has a size of 8, but 9 elements were provided - ┌─ :4:48 + ┌─ :4:66 │ -4 │ arr : ARRAY[1..2, 1..2, 1..2] OF DINT := [1, 2, 3, 4, 5, 6, 7, 8, 9]; - │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^ Array __main_arr has a size of 8, but 9 elements were provided +4 │ arr : ARRAY[1..2, 1..2, 1..2] OF DINT := [1, 2, 3, 4, 5, 6, 7, 8, 9]; + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^ Array __main_arr has a size of 8, but 9 elements were provided error: Array assignments must be surrounded with `[]` - ┌─ :5:52 + ┌─ :5:67 │ -5 │ arr_alt : ARRAY[1..2, 1..2, 1..2] OF DINT := (1, 2, 3, 4, 5, 6, 7, 8, 9); - │ ^^^^^^^^^^^^^^^^^^^^^^^^^ Array assignments must be surrounded with `[]` +5 │ arr_alt : ARRAY[1..2, 1..2, 1..2] OF DINT := (1, 2, 3, 4, 5, 6, 7, 8, 9); + │ ^^^^^^^^^^^^^^^^^^^^^^^^^ Array assignments must be surrounded with `[]` error: Array __main_arr_nested has a size of 8, but 12 elements were provided - ┌─ :7:72 + ┌─ :7:88 │ -7 │ arr_nested : ARRAY[1..2] OF ARRAY[1..2] OF ARRAY[1..2] OF DINT := [ [[1, 2], [3, 4]], [[5, 6], [7, 8]], [[9, 10], [11, 12]] ]; - │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Array __main_arr_nested has a size of 8, but 12 elements were provided +7 │ arr_nested : ARRAY[1..2] OF ARRAY[1..2] OF ARRAY[1..2] OF DINT := [ [[1, 2], [3, 4]], [[5, 6], [7, 8]], [[9, 10], [11, 12]] ]; + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Array __main_arr_nested has a size of 8, but 12 elements were provided error: Array assignments must be surrounded with `[]` - ┌─ :8:77 + ┌─ :8:90 │ -8 │ arr_nested_alt : ARRAY[1..2] OF ARRAY[1..2] OF ARRAY[1..2] OF DINT := ( [[1, 2], [3, 4]], [[5, 6], [7, 8]], [[9, 10], [11, 12]] ); - │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Array assignments must be surrounded with `[]` +8 │ arr_nested_alt : ARRAY[1..2] OF ARRAY[1..2] OF ARRAY[1..2] OF DINT := ( [[1, 2], [3, 4]], [[5, 6], [7, 8]], [[9, 10], [11, 12]] ); + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Array assignments must be surrounded with `[]` error: Array assignments must be surrounded with `[]` - ┌─ :14:12 + ┌─ :14:21 │ -14 │ arr := (1, 2, 3, 4, 5, 6, 7, 8); - │ ^^^^^^^^^^^^^^^^^^^^^^ Array assignments must be surrounded with `[]` +14 │ arr := (1, 2, 3, 4, 5, 6, 7, 8); + │ ^^^^^^^^^^^^^^^^^^^^^^ Array assignments must be surrounded with `[]` error: Array assignments must be surrounded with `[]` - ┌─ :15:12 + ┌─ :15:21 │ -15 │ arr := (1, 2, 3, 4, 5, 6, 7, 8, 9); - │ ^^^^^^^^^^^^^^^^^^^^^^^^^ Array assignments must be surrounded with `[]` +15 │ arr := (1, 2, 3, 4, 5, 6, 7, 8, 9); + │ ^^^^^^^^^^^^^^^^^^^^^^^^^ Array assignments must be surrounded with `[]` error: Array __main_arr has a size of 8, but 9 elements were provided - ┌─ :16:11 + ┌─ :16:20 │ -16 │ arr := [1, 2, 3, 4, 5, 6, 7, 8, 9]; - │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^ Array __main_arr has a size of 8, but 9 elements were provided +16 │ arr := [1, 2, 3, 4, 5, 6, 7, 8, 9]; + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^ Array __main_arr has a size of 8, but 9 elements were provided error: Array __main_arr_nested has a size of 8, but 12 elements were provided - ┌─ :19:18 + ┌─ :19:27 │ -19 │ arr_nested := [ [[1, 2], [3, 4]], [[5, 6], [7, 8]], [[9, 10], [11, 12]] ]; - │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Array __main_arr_nested has a size of 8, but 12 elements were provided +19 │ arr_nested := [ [[1, 2], [3, 4]], [[5, 6], [7, 8]], [[9, 10], [11, 12]] ]; + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Array __main_arr_nested has a size of 8, but 12 elements were provided error: Array assignments must be surrounded with `[]` - ┌─ :20:20 + ┌─ :20:29 │ -20 │ arr_nested := ( [[1, 2], [3, 4]], [[5, 6], [7, 8]], [[9, 10], [11, 12]] ); - │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Array assignments must be surrounded with `[]` +20 │ arr_nested := ( [[1, 2], [3, 4]], [[5, 6], [7, 8]], [[9, 10], [11, 12]] ); + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Array assignments must be surrounded with `[]` diff --git a/src/validation/tests/snapshots/rusty__validation__tests__array_validation_test__assignment_multiplied_statement.snap b/src/validation/tests/snapshots/rusty__validation__tests__array_validation_test__assignment_multiplied_statement.snap index cb6a126568..3084c720a5 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__array_validation_test__assignment_multiplied_statement.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__array_validation_test__assignment_multiplied_statement.snap @@ -3,63 +3,63 @@ source: src/validation/tests/array_validation_test.rs expression: diagnostics --- error: Array __main_arr_1d has a size of 5, but 6 elements were provided - ┌─ :4:37 + ┌─ :4:49 │ -4 │ arr_1d : ARRAY[1..5] OF DINT := [6(0)]; - │ ^^^^^^ Array __main_arr_1d has a size of 5, but 6 elements were provided +4 │ arr_1d : ARRAY[1..5] OF DINT := [6(0)]; + │ ^^^^^^ Array __main_arr_1d has a size of 5, but 6 elements were provided error: Array __main_arr_2d has a size of 10, but 11 elements were provided - ┌─ :6:43 + ┌─ :6:55 │ -6 │ arr_2d : ARRAY[1..2, 1..5] OF DINT := [11(0)]; - │ ^^^^^^^ Array __main_arr_2d has a size of 10, but 11 elements were provided +6 │ arr_2d : ARRAY[1..2, 1..5] OF DINT := [11(0)]; + │ ^^^^^^^ Array __main_arr_2d has a size of 10, but 11 elements were provided error: Array __main_arr_2d_nested has a size of 10, but 11 elements were provided - ┌─ :7:59 + ┌─ :7:71 │ -7 │ arr_2d_nested : ARRAY[1..2] OF ARRAY[1..5] OF DINT := [11(0)]; - │ ^^^^^^^ Array __main_arr_2d_nested has a size of 10, but 11 elements were provided +7 │ arr_2d_nested : ARRAY[1..2] OF ARRAY[1..5] OF DINT := [11(0)]; + │ ^^^^^^^ Array __main_arr_2d_nested has a size of 10, but 11 elements were provided error: Array __main_arr_3d has a size of 8, but 9 elements were provided - ┌─ :9:49 + ┌─ :9:61 │ -9 │ arr_3d : ARRAY[1..2, 1..2, 1..2] OF DINT := [9(0)]; - │ ^^^^^^ Array __main_arr_3d has a size of 8, but 9 elements were provided +9 │ arr_3d : ARRAY[1..2, 1..2, 1..2] OF DINT := [9(0)]; + │ ^^^^^^ Array __main_arr_3d has a size of 8, but 9 elements were provided error: Array __main_arr_3d_nested has a size of 8, but 9 elements were provided - ┌─ :10:74 + ┌─ :10:86 │ -10 │ arr_3d_nested : ARRAY[1..2] OF ARRAY[1..2] OF ARRAY[1..2] OF DINT := [9(0)]; - │ ^^^^^^ Array __main_arr_3d_nested has a size of 8, but 9 elements were provided +10 │ arr_3d_nested : ARRAY[1..2] OF ARRAY[1..2] OF ARRAY[1..2] OF DINT := [9(0)]; + │ ^^^^^^ Array __main_arr_3d_nested has a size of 8, but 9 elements were provided error: Array __main_arr_1d has a size of 5, but 6 elements were provided - ┌─ :21:14 + ┌─ :21:23 │ -21 │ arr_1d := [6(0)]; - │ ^^^^^^ Array __main_arr_1d has a size of 5, but 6 elements were provided +21 │ arr_1d := [6(0)]; + │ ^^^^^^ Array __main_arr_1d has a size of 5, but 6 elements were provided error: Array __main_arr_2d has a size of 10, but 11 elements were provided - ┌─ :22:14 + ┌─ :22:23 │ -22 │ arr_2d := [11(0)]; - │ ^^^^^^^ Array __main_arr_2d has a size of 10, but 11 elements were provided +22 │ arr_2d := [11(0)]; + │ ^^^^^^^ Array __main_arr_2d has a size of 10, but 11 elements were provided error: Array __main_arr_2d_nested has a size of 10, but 11 elements were provided - ┌─ :23:21 + ┌─ :23:30 │ -23 │ arr_2d_nested := [11(0)]; - │ ^^^^^^^ Array __main_arr_2d_nested has a size of 10, but 11 elements were provided +23 │ arr_2d_nested := [11(0)]; + │ ^^^^^^^ Array __main_arr_2d_nested has a size of 10, but 11 elements were provided error: Array __main_arr_3d has a size of 8, but 9 elements were provided - ┌─ :24:14 + ┌─ :24:23 │ -24 │ arr_3d := [9(0)]; - │ ^^^^^^ Array __main_arr_3d has a size of 8, but 9 elements were provided +24 │ arr_3d := [9(0)]; + │ ^^^^^^ Array __main_arr_3d has a size of 8, but 9 elements were provided error: Array __main_arr_3d_nested has a size of 8, but 9 elements were provided - ┌─ :25:21 + ┌─ :25:30 │ -25 │ arr_3d_nested := [9(0)]; - │ ^^^^^^ Array __main_arr_3d_nested has a size of 8, but 9 elements were provided +25 │ arr_3d_nested := [9(0)]; + │ ^^^^^^ Array __main_arr_3d_nested has a size of 8, but 9 elements were provided diff --git a/src/validation/tests/snapshots/rusty__validation__tests__array_validation_test__assignment_structs.snap b/src/validation/tests/snapshots/rusty__validation__tests__array_validation_test__assignment_structs.snap index e0d7cbeceb..17d1c1ac29 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__array_validation_test__assignment_structs.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__array_validation_test__assignment_structs.snap @@ -3,39 +3,39 @@ source: src/validation/tests/array_validation_test.rs expression: diagnostics --- error: Array assignments must be surrounded with `[]` - ┌─ :18:57 + ┌─ :18:70 │ -18 │ foo_invalid_0 : FOO := (idx := 0, arr := ((arr := (1, 2, 3, 4, 5)), (arr := (1, 2, 3, 4, 5)))); - │ ^^^^^^^^^^^^^ Array assignments must be surrounded with `[]` +18 │ foo_invalid_0 : FOO := (idx := 0, arr := ((arr := (1, 2, 3, 4, 5)), (arr := (1, 2, 3, 4, 5)))); + │ ^^^^^^^^^^^^^ Array assignments must be surrounded with `[]` error: Array assignments must be surrounded with `[]` - ┌─ :18:83 + ┌─ :18:96 │ -18 │ foo_invalid_0 : FOO := (idx := 0, arr := ((arr := (1, 2, 3, 4, 5)), (arr := (1, 2, 3, 4, 5)))); - │ ^^^^^^^^^^^^^ Array assignments must be surrounded with `[]` +18 │ foo_invalid_0 : FOO := (idx := 0, arr := ((arr := (1, 2, 3, 4, 5)), (arr := (1, 2, 3, 4, 5)))); + │ ^^^^^^^^^^^^^ Array assignments must be surrounded with `[]` error: Array assignments must be surrounded with `[]` - ┌─ :18:48 + ┌─ :18:61 │ -18 │ foo_invalid_0 : FOO := (idx := 0, arr := ((arr := (1, 2, 3, 4, 5)), (arr := (1, 2, 3, 4, 5)))); - │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Array assignments must be surrounded with `[]` +18 │ foo_invalid_0 : FOO := (idx := 0, arr := ((arr := (1, 2, 3, 4, 5)), (arr := (1, 2, 3, 4, 5)))); + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Array assignments must be surrounded with `[]` error: Array assignments must be surrounded with `[]` - ┌─ :19:57 + ┌─ :19:70 │ -19 │ foo_invalid_1 : FOO := (idx := 0, arr := ((arr := (1, 2, 3, 4, 5)), (arr := (1, 2, 3, 4, 5)))); - │ ^^^^^^^^^^^^^ Array assignments must be surrounded with `[]` +19 │ foo_invalid_1 : FOO := (idx := 0, arr := ((arr := (1, 2, 3, 4, 5)), (arr := (1, 2, 3, 4, 5)))); + │ ^^^^^^^^^^^^^ Array assignments must be surrounded with `[]` error: Array assignments must be surrounded with `[]` - ┌─ :19:83 + ┌─ :19:96 │ -19 │ foo_invalid_1 : FOO := (idx := 0, arr := ((arr := (1, 2, 3, 4, 5)), (arr := (1, 2, 3, 4, 5)))); - │ ^^^^^^^^^^^^^ Array assignments must be surrounded with `[]` +19 │ foo_invalid_1 : FOO := (idx := 0, arr := ((arr := (1, 2, 3, 4, 5)), (arr := (1, 2, 3, 4, 5)))); + │ ^^^^^^^^^^^^^ Array assignments must be surrounded with `[]` error: Array assignments must be surrounded with `[]` - ┌─ :19:48 + ┌─ :19:61 │ -19 │ foo_invalid_1 : FOO := (idx := 0, arr := ((arr := (1, 2, 3, 4, 5)), (arr := (1, 2, 3, 4, 5)))); - │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Array assignments must be surrounded with `[]` +19 │ foo_invalid_1 : FOO := (idx := 0, arr := ((arr := (1, 2, 3, 4, 5)), (arr := (1, 2, 3, 4, 5)))); + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Array assignments must be surrounded with `[]` diff --git a/src/validation/tests/snapshots/rusty__validation__tests__assignment_validation_tests__array_assignment_validation.snap b/src/validation/tests/snapshots/rusty__validation__tests__assignment_validation_tests__array_assignment_validation.snap index af8364070d..58f77aa6b2 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__assignment_validation_tests__array_assignment_validation.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__assignment_validation_tests__array_assignment_validation.snap @@ -2,21 +2,21 @@ source: src/validation/tests/assignment_validation_tests.rs expression: res --- -SyntaxError { message: "Invalid assignment: cannot assign '__main_v_arr_sized_string2' to '__main_v_arr_sized_string'", range: [SourceLocation { span: Range(TextLocation { line: 29, column: 4, offset: 761 }..TextLocation { line: 29, column: 45, offset: 802 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid assignment: cannot assign '__main_v_arr_int_2' to '__main_v_arr_int_3'", range: [SourceLocation { span: Range(TextLocation { line: 30, column: 4, offset: 819 }..TextLocation { line: 30, column: 30, offset: 845 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid assignment: cannot assign '__main_v_arr_int_4' to '__main_v_arr_int_3'", range: [SourceLocation { span: Range(TextLocation { line: 32, column: 4, offset: 903 }..TextLocation { line: 32, column: 30, offset: 929 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid assignment: cannot assign '__main_v_arr_real_3' to '__main_v_arr_int_3'", range: [SourceLocation { span: Range(TextLocation { line: 33, column: 4, offset: 946 }..TextLocation { line: 33, column: 31, offset: 973 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid assignment: cannot assign '__main_v_arr_string_3' to '__main_v_arr_int_3'", range: [SourceLocation { span: Range(TextLocation { line: 34, column: 4, offset: 990 }..TextLocation { line: 34, column: 33, offset: 1019 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid assignment: cannot assign '__main_v_arr_char_3' to '__main_v_arr_int_3'", range: [SourceLocation { span: Range(TextLocation { line: 35, column: 4, offset: 1036 }..TextLocation { line: 35, column: 31, offset: 1063 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Array assignments must be surrounded with `[]`", range: [SourceLocation { span: Range(TextLocation { line: 36, column: 19, offset: 1095 }..TextLocation { line: 36, column: 20, offset: 1096 }) }], err_no: arr__invalid_array_assignment } -SyntaxError { message: "Array assignments must be surrounded with `[]`", range: [SourceLocation { span: Range(TextLocation { line: 37, column: 20, offset: 1138 }..TextLocation { line: 37, column: 30, offset: 1148 }) }], err_no: arr__invalid_array_assignment } -SyntaxError { message: "Array assignments must be surrounded with `[]`", range: [SourceLocation { span: Range(TextLocation { line: 38, column: 20, offset: 1180 }..TextLocation { line: 38, column: 36, offset: 1196 }) }], err_no: arr__invalid_array_assignment } -SyntaxError { message: "Invalid assignment: cannot assign 'STRING' to 'INT'", range: [SourceLocation { span: Range(TextLocation { line: 43, column: 4, offset: 1384 }..TextLocation { line: 43, column: 30, offset: 1410 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid assignment: cannot assign 'STRING' to 'INT'", range: [SourceLocation { span: Range(TextLocation { line: 44, column: 4, offset: 1427 }..TextLocation { line: 44, column: 37, offset: 1460 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid assignment: cannot assign 'STRING' to 'INT'", range: [SourceLocation { span: Range(TextLocation { line: 45, column: 4, offset: 1477 }..TextLocation { line: 45, column: 30, offset: 1503 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid assignment: cannot assign 'CHAR' to 'INT'", range: [SourceLocation { span: Range(TextLocation { line: 46, column: 4, offset: 1520 }..TextLocation { line: 46, column: 28, offset: 1544 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid assignment: cannot assign 'CHAR' to 'INT'", range: [SourceLocation { span: Range(TextLocation { line: 47, column: 4, offset: 1561 }..TextLocation { line: 47, column: 30, offset: 1587 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid assignment: cannot assign 'STRING' to 'INT'", range: [SourceLocation { span: Range(TextLocation { line: 49, column: 4, offset: 1647 }..TextLocation { line: 49, column: 35, offset: 1678 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid assignment: cannot assign 'DINT' to '__main_v_arr_int_3'", range: [SourceLocation { span: Range(TextLocation { line: 50, column: 4, offset: 1695 }..TextLocation { line: 50, column: 25, offset: 1716 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid assignment: cannot assign '__main_v_arr_int_3' to 'DINT'", range: [SourceLocation { span: Range(TextLocation { line: 51, column: 4, offset: 1733 }..TextLocation { line: 51, column: 25, offset: 1754 }) }], err_no: var__invalid_assignment } +SyntaxError { message: "Invalid assignment: cannot assign '__main_v_arr_sized_string2' to '__main_v_arr_sized_string'", range: [SourceLocation { span: Range(TextLocation { line: 29, column: 4, offset: 729 }..TextLocation { line: 29, column: 45, offset: 770 }) }], err_no: var__invalid_assignment } +SyntaxError { message: "Invalid assignment: cannot assign '__main_v_arr_int_2' to '__main_v_arr_int_3'", range: [SourceLocation { span: Range(TextLocation { line: 30, column: 4, offset: 787 }..TextLocation { line: 30, column: 30, offset: 813 }) }], err_no: var__invalid_assignment } +SyntaxError { message: "Invalid assignment: cannot assign '__main_v_arr_int_4' to '__main_v_arr_int_3'", range: [SourceLocation { span: Range(TextLocation { line: 32, column: 4, offset: 871 }..TextLocation { line: 32, column: 30, offset: 897 }) }], err_no: var__invalid_assignment } +SyntaxError { message: "Invalid assignment: cannot assign '__main_v_arr_real_3' to '__main_v_arr_int_3'", range: [SourceLocation { span: Range(TextLocation { line: 33, column: 4, offset: 914 }..TextLocation { line: 33, column: 31, offset: 941 }) }], err_no: var__invalid_assignment } +SyntaxError { message: "Invalid assignment: cannot assign '__main_v_arr_string_3' to '__main_v_arr_int_3'", range: [SourceLocation { span: Range(TextLocation { line: 34, column: 4, offset: 958 }..TextLocation { line: 34, column: 33, offset: 987 }) }], err_no: var__invalid_assignment } +SyntaxError { message: "Invalid assignment: cannot assign '__main_v_arr_char_3' to '__main_v_arr_int_3'", range: [SourceLocation { span: Range(TextLocation { line: 35, column: 4, offset: 1004 }..TextLocation { line: 35, column: 31, offset: 1031 }) }], err_no: var__invalid_assignment } +SyntaxError { message: "Array assignments must be surrounded with `[]`", range: [SourceLocation { span: Range(TextLocation { line: 36, column: 19, offset: 1063 }..TextLocation { line: 36, column: 20, offset: 1064 }) }], err_no: arr__invalid_array_assignment } +SyntaxError { message: "Array assignments must be surrounded with `[]`", range: [SourceLocation { span: Range(TextLocation { line: 37, column: 20, offset: 1106 }..TextLocation { line: 37, column: 30, offset: 1116 }) }], err_no: arr__invalid_array_assignment } +SyntaxError { message: "Array assignments must be surrounded with `[]`", range: [SourceLocation { span: Range(TextLocation { line: 38, column: 20, offset: 1148 }..TextLocation { line: 38, column: 36, offset: 1164 }) }], err_no: arr__invalid_array_assignment } +SyntaxError { message: "Invalid assignment: cannot assign 'STRING' to 'INT'", range: [SourceLocation { span: Range(TextLocation { line: 43, column: 4, offset: 1352 }..TextLocation { line: 43, column: 30, offset: 1378 }) }], err_no: var__invalid_assignment } +SyntaxError { message: "Invalid assignment: cannot assign 'STRING' to 'INT'", range: [SourceLocation { span: Range(TextLocation { line: 44, column: 4, offset: 1395 }..TextLocation { line: 44, column: 37, offset: 1428 }) }], err_no: var__invalid_assignment } +SyntaxError { message: "Invalid assignment: cannot assign 'STRING' to 'INT'", range: [SourceLocation { span: Range(TextLocation { line: 45, column: 4, offset: 1445 }..TextLocation { line: 45, column: 30, offset: 1471 }) }], err_no: var__invalid_assignment } +SyntaxError { message: "Invalid assignment: cannot assign 'CHAR' to 'INT'", range: [SourceLocation { span: Range(TextLocation { line: 46, column: 4, offset: 1488 }..TextLocation { line: 46, column: 28, offset: 1512 }) }], err_no: var__invalid_assignment } +SyntaxError { message: "Invalid assignment: cannot assign 'CHAR' to 'INT'", range: [SourceLocation { span: Range(TextLocation { line: 47, column: 4, offset: 1529 }..TextLocation { line: 47, column: 30, offset: 1555 }) }], err_no: var__invalid_assignment } +SyntaxError { message: "Invalid assignment: cannot assign 'STRING' to 'INT'", range: [SourceLocation { span: Range(TextLocation { line: 49, column: 4, offset: 1615 }..TextLocation { line: 49, column: 35, offset: 1646 }) }], err_no: var__invalid_assignment } +SyntaxError { message: "Invalid assignment: cannot assign 'DINT' to '__main_v_arr_int_3'", range: [SourceLocation { span: Range(TextLocation { line: 50, column: 4, offset: 1663 }..TextLocation { line: 50, column: 25, offset: 1684 }) }], err_no: var__invalid_assignment } +SyntaxError { message: "Invalid assignment: cannot assign '__main_v_arr_int_3' to 'DINT'", range: [SourceLocation { span: Range(TextLocation { line: 51, column: 4, offset: 1701 }..TextLocation { line: 51, column: 25, offset: 1722 }) }], err_no: var__invalid_assignment } diff --git a/src/validation/tests/snapshots/rusty__validation__tests__assignment_validation_tests__bit_assignment_validation.snap b/src/validation/tests/snapshots/rusty__validation__tests__assignment_validation_tests__bit_assignment_validation.snap index 4282b2b621..0a8291248b 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__assignment_validation_tests__bit_assignment_validation.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__assignment_validation_tests__bit_assignment_validation.snap @@ -2,11 +2,11 @@ source: src/validation/tests/assignment_validation_tests.rs expression: res --- -SyntaxError { message: "Invalid assignment: cannot assign 'STRING' to 'BYTE'", range: [SourceLocation { span: Range(TextLocation { line: 38, column: 4, offset: 807 }..TextLocation { line: 38, column: 22, offset: 825 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid assignment: cannot assign 'STRING' to 'BYTE'", range: [SourceLocation { span: Range(TextLocation { line: 39, column: 4, offset: 842 }..TextLocation { line: 39, column: 29, offset: 867 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid assignment: cannot assign 'STRING' to 'BYTE'", range: [SourceLocation { span: Range(TextLocation { line: 40, column: 4, offset: 884 }..TextLocation { line: 40, column: 22, offset: 902 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid assignment: cannot assign 'CHAR' to 'BYTE'", range: [SourceLocation { span: Range(TextLocation { line: 41, column: 4, offset: 919 }..TextLocation { line: 41, column: 20, offset: 935 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid assignment: cannot assign 'CHAR' to 'BYTE'", range: [SourceLocation { span: Range(TextLocation { line: 42, column: 4, offset: 952 }..TextLocation { line: 42, column: 22, offset: 970 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid assignment: cannot assign 'STRING' to 'BYTE'", range: [SourceLocation { span: Range(TextLocation { line: 46, column: 4, offset: 1089 }..TextLocation { line: 46, column: 27, offset: 1112 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid assignment: cannot assign 'STRING' to 'BYTE'", range: [SourceLocation { span: Range(TextLocation { line: 48, column: 4, offset: 1168 }..TextLocation { line: 48, column: 31, offset: 1195 }) }], err_no: var__invalid_assignment } +SyntaxError { message: "Invalid assignment: cannot assign 'STRING' to 'BYTE'", range: [SourceLocation { span: Range(TextLocation { line: 38, column: 4, offset: 775 }..TextLocation { line: 38, column: 22, offset: 793 }) }], err_no: var__invalid_assignment } +SyntaxError { message: "Invalid assignment: cannot assign 'STRING' to 'BYTE'", range: [SourceLocation { span: Range(TextLocation { line: 39, column: 4, offset: 810 }..TextLocation { line: 39, column: 29, offset: 835 }) }], err_no: var__invalid_assignment } +SyntaxError { message: "Invalid assignment: cannot assign 'STRING' to 'BYTE'", range: [SourceLocation { span: Range(TextLocation { line: 40, column: 4, offset: 852 }..TextLocation { line: 40, column: 22, offset: 870 }) }], err_no: var__invalid_assignment } +SyntaxError { message: "Invalid assignment: cannot assign 'CHAR' to 'BYTE'", range: [SourceLocation { span: Range(TextLocation { line: 41, column: 4, offset: 887 }..TextLocation { line: 41, column: 20, offset: 903 }) }], err_no: var__invalid_assignment } +SyntaxError { message: "Invalid assignment: cannot assign 'CHAR' to 'BYTE'", range: [SourceLocation { span: Range(TextLocation { line: 42, column: 4, offset: 920 }..TextLocation { line: 42, column: 22, offset: 938 }) }], err_no: var__invalid_assignment } +SyntaxError { message: "Invalid assignment: cannot assign 'STRING' to 'BYTE'", range: [SourceLocation { span: Range(TextLocation { line: 46, column: 4, offset: 1057 }..TextLocation { line: 46, column: 27, offset: 1080 }) }], err_no: var__invalid_assignment } +SyntaxError { message: "Invalid assignment: cannot assign 'STRING' to 'BYTE'", range: [SourceLocation { span: Range(TextLocation { line: 48, column: 4, offset: 1136 }..TextLocation { line: 48, column: 31, offset: 1163 }) }], err_no: var__invalid_assignment } diff --git a/src/validation/tests/snapshots/rusty__validation__tests__assignment_validation_tests__char_assignment_validation.snap b/src/validation/tests/snapshots/rusty__validation__tests__assignment_validation_tests__char_assignment_validation.snap index 4e9f8f907c..1fbeda4d02 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__assignment_validation_tests__char_assignment_validation.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__assignment_validation_tests__char_assignment_validation.snap @@ -2,29 +2,29 @@ source: src/validation/tests/assignment_validation_tests.rs expression: res --- -SyntaxError { message: "Invalid assignment: cannot assign 'LREAL' to 'CHAR'", range: [SourceLocation { span: Range(TextLocation { line: 31, column: 4, offset: 571 }..TextLocation { line: 31, column: 21, offset: 588 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid assignment: cannot assign 'REAL' to 'CHAR'", range: [SourceLocation { span: Range(TextLocation { line: 32, column: 4, offset: 605 }..TextLocation { line: 32, column: 22, offset: 623 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid assignment: cannot assign 'UDINT' to 'CHAR'", range: [SourceLocation { span: Range(TextLocation { line: 33, column: 4, offset: 640 }..TextLocation { line: 33, column: 21, offset: 657 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid assignment: cannot assign 'UDINT' to 'CHAR'", range: [SourceLocation { span: Range(TextLocation { line: 34, column: 4, offset: 674 }..TextLocation { line: 34, column: 22, offset: 692 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid assignment: cannot assign 'DINT' to 'CHAR'", range: [SourceLocation { span: Range(TextLocation { line: 35, column: 4, offset: 709 }..TextLocation { line: 35, column: 20, offset: 725 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid assignment: cannot assign 'DINT' to 'CHAR'", range: [SourceLocation { span: Range(TextLocation { line: 36, column: 4, offset: 742 }..TextLocation { line: 36, column: 21, offset: 759 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid assignment: cannot assign 'TIME' to 'CHAR'", range: [SourceLocation { span: Range(TextLocation { line: 37, column: 4, offset: 776 }..TextLocation { line: 37, column: 20, offset: 792 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid assignment: cannot assign 'TIME' to 'CHAR'", range: [SourceLocation { span: Range(TextLocation { line: 38, column: 4, offset: 809 }..TextLocation { line: 38, column: 28, offset: 833 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid assignment: cannot assign 'WORD' to 'CHAR'", range: [SourceLocation { span: Range(TextLocation { line: 39, column: 4, offset: 850 }..TextLocation { line: 39, column: 20, offset: 866 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid assignment: cannot assign 'WORD' to 'CHAR'", range: [SourceLocation { span: Range(TextLocation { line: 40, column: 4, offset: 883 }..TextLocation { line: 40, column: 26, offset: 905 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid assignment: cannot assign 'STRING' to 'CHAR'", range: [SourceLocation { span: Range(TextLocation { line: 41, column: 4, offset: 922 }..TextLocation { line: 41, column: 23, offset: 941 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid assignment: cannot assign 'STRING' to 'CHAR'", range: [SourceLocation { span: Range(TextLocation { line: 42, column: 4, offset: 973 }..TextLocation { line: 42, column: 24, offset: 993 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid assignment: cannot assign 'WSTRING' to 'CHAR'", range: [SourceLocation { span: Range(TextLocation { line: 44, column: 4, offset: 1053 }..TextLocation { line: 44, column: 17, offset: 1066 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid assignment: cannot assign 'STRING' to 'CHAR'", range: [SourceLocation { span: Range(TextLocation { line: 45, column: 4, offset: 1083 }..TextLocation { line: 45, column: 22, offset: 1101 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid assignment: cannot assign 'STRING' to 'CHAR'", range: [SourceLocation { span: Range(TextLocation { line: 46, column: 4, offset: 1118 }..TextLocation { line: 46, column: 29, offset: 1143 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Value: 'string' exceeds length for type: CHAR", range: [SourceLocation { span: Range(TextLocation { line: 47, column: 4, offset: 1160 }..TextLocation { line: 47, column: 22, offset: 1178 }) }], err_no: syntax__generic_error } -SyntaxError { message: "Invalid assignment: cannot assign 'STRING' to 'CHAR'", range: [SourceLocation { span: Range(TextLocation { line: 47, column: 4, offset: 1160 }..TextLocation { line: 47, column: 22, offset: 1178 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid assignment: cannot assign 'WCHAR' to 'CHAR'", range: [SourceLocation { span: Range(TextLocation { line: 50, column: 4, offset: 1259 }..TextLocation { line: 50, column: 21, offset: 1276 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid assignment: cannot assign 'WCHAR' to 'CHAR'", range: [SourceLocation { span: Range(TextLocation { line: 51, column: 4, offset: 1293 }..TextLocation { line: 51, column: 23, offset: 1312 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid assignment: cannot assign 'TIME_OF_DAY' to 'CHAR'", range: [SourceLocation { span: Range(TextLocation { line: 52, column: 4, offset: 1329 }..TextLocation { line: 52, column: 19, offset: 1344 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid assignment: cannot assign 'TIME_OF_DAY' to 'CHAR'", range: [SourceLocation { span: Range(TextLocation { line: 53, column: 4, offset: 1361 }..TextLocation { line: 53, column: 26, offset: 1383 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid assignment: cannot assign 'INT' to 'CHAR'", range: [SourceLocation { span: Range(TextLocation { line: 54, column: 4, offset: 1400 }..TextLocation { line: 54, column: 24, offset: 1420 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid assignment: cannot assign 'STRING' to 'CHAR'", range: [SourceLocation { span: Range(TextLocation { line: 55, column: 4, offset: 1437 }..TextLocation { line: 55, column: 27, offset: 1460 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid assignment: cannot assign 'INT' to 'CHAR'", range: [SourceLocation { span: Range(TextLocation { line: 56, column: 4, offset: 1477 }..TextLocation { line: 56, column: 28, offset: 1501 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid assignment: cannot assign 'STRING' to 'CHAR'", range: [SourceLocation { span: Range(TextLocation { line: 57, column: 4, offset: 1518 }..TextLocation { line: 57, column: 31, offset: 1545 }) }], err_no: var__invalid_assignment } +SyntaxError { message: "Invalid assignment: cannot assign 'LREAL' to 'CHAR'", range: [SourceLocation { span: Range(TextLocation { line: 31, column: 4, offset: 531 }..TextLocation { line: 31, column: 21, offset: 548 }) }], err_no: var__invalid_assignment } +SyntaxError { message: "Invalid assignment: cannot assign 'REAL' to 'CHAR'", range: [SourceLocation { span: Range(TextLocation { line: 32, column: 4, offset: 565 }..TextLocation { line: 32, column: 22, offset: 583 }) }], err_no: var__invalid_assignment } +SyntaxError { message: "Invalid assignment: cannot assign 'UDINT' to 'CHAR'", range: [SourceLocation { span: Range(TextLocation { line: 33, column: 4, offset: 600 }..TextLocation { line: 33, column: 21, offset: 617 }) }], err_no: var__invalid_assignment } +SyntaxError { message: "Invalid assignment: cannot assign 'UDINT' to 'CHAR'", range: [SourceLocation { span: Range(TextLocation { line: 34, column: 4, offset: 634 }..TextLocation { line: 34, column: 22, offset: 652 }) }], err_no: var__invalid_assignment } +SyntaxError { message: "Invalid assignment: cannot assign 'DINT' to 'CHAR'", range: [SourceLocation { span: Range(TextLocation { line: 35, column: 4, offset: 669 }..TextLocation { line: 35, column: 20, offset: 685 }) }], err_no: var__invalid_assignment } +SyntaxError { message: "Invalid assignment: cannot assign 'DINT' to 'CHAR'", range: [SourceLocation { span: Range(TextLocation { line: 36, column: 4, offset: 702 }..TextLocation { line: 36, column: 21, offset: 719 }) }], err_no: var__invalid_assignment } +SyntaxError { message: "Invalid assignment: cannot assign 'TIME' to 'CHAR'", range: [SourceLocation { span: Range(TextLocation { line: 37, column: 4, offset: 736 }..TextLocation { line: 37, column: 20, offset: 752 }) }], err_no: var__invalid_assignment } +SyntaxError { message: "Invalid assignment: cannot assign 'TIME' to 'CHAR'", range: [SourceLocation { span: Range(TextLocation { line: 38, column: 4, offset: 769 }..TextLocation { line: 38, column: 28, offset: 793 }) }], err_no: var__invalid_assignment } +SyntaxError { message: "Invalid assignment: cannot assign 'WORD' to 'CHAR'", range: [SourceLocation { span: Range(TextLocation { line: 39, column: 4, offset: 810 }..TextLocation { line: 39, column: 20, offset: 826 }) }], err_no: var__invalid_assignment } +SyntaxError { message: "Invalid assignment: cannot assign 'WORD' to 'CHAR'", range: [SourceLocation { span: Range(TextLocation { line: 40, column: 4, offset: 843 }..TextLocation { line: 40, column: 26, offset: 865 }) }], err_no: var__invalid_assignment } +SyntaxError { message: "Invalid assignment: cannot assign 'STRING' to 'CHAR'", range: [SourceLocation { span: Range(TextLocation { line: 41, column: 4, offset: 882 }..TextLocation { line: 41, column: 23, offset: 901 }) }], err_no: var__invalid_assignment } +SyntaxError { message: "Invalid assignment: cannot assign 'STRING' to 'CHAR'", range: [SourceLocation { span: Range(TextLocation { line: 42, column: 4, offset: 933 }..TextLocation { line: 42, column: 24, offset: 953 }) }], err_no: var__invalid_assignment } +SyntaxError { message: "Invalid assignment: cannot assign 'WSTRING' to 'CHAR'", range: [SourceLocation { span: Range(TextLocation { line: 44, column: 4, offset: 1013 }..TextLocation { line: 44, column: 17, offset: 1026 }) }], err_no: var__invalid_assignment } +SyntaxError { message: "Invalid assignment: cannot assign 'STRING' to 'CHAR'", range: [SourceLocation { span: Range(TextLocation { line: 45, column: 4, offset: 1043 }..TextLocation { line: 45, column: 22, offset: 1061 }) }], err_no: var__invalid_assignment } +SyntaxError { message: "Invalid assignment: cannot assign 'STRING' to 'CHAR'", range: [SourceLocation { span: Range(TextLocation { line: 46, column: 4, offset: 1078 }..TextLocation { line: 46, column: 29, offset: 1103 }) }], err_no: var__invalid_assignment } +SyntaxError { message: "Value: 'string' exceeds length for type: CHAR", range: [SourceLocation { span: Range(TextLocation { line: 47, column: 4, offset: 1120 }..TextLocation { line: 47, column: 22, offset: 1138 }) }], err_no: syntax__generic_error } +SyntaxError { message: "Invalid assignment: cannot assign 'STRING' to 'CHAR'", range: [SourceLocation { span: Range(TextLocation { line: 47, column: 4, offset: 1120 }..TextLocation { line: 47, column: 22, offset: 1138 }) }], err_no: var__invalid_assignment } +SyntaxError { message: "Invalid assignment: cannot assign 'WCHAR' to 'CHAR'", range: [SourceLocation { span: Range(TextLocation { line: 50, column: 4, offset: 1219 }..TextLocation { line: 50, column: 21, offset: 1236 }) }], err_no: var__invalid_assignment } +SyntaxError { message: "Invalid assignment: cannot assign 'WCHAR' to 'CHAR'", range: [SourceLocation { span: Range(TextLocation { line: 51, column: 4, offset: 1253 }..TextLocation { line: 51, column: 23, offset: 1272 }) }], err_no: var__invalid_assignment } +SyntaxError { message: "Invalid assignment: cannot assign 'TIME_OF_DAY' to 'CHAR'", range: [SourceLocation { span: Range(TextLocation { line: 52, column: 4, offset: 1289 }..TextLocation { line: 52, column: 19, offset: 1304 }) }], err_no: var__invalid_assignment } +SyntaxError { message: "Invalid assignment: cannot assign 'TIME_OF_DAY' to 'CHAR'", range: [SourceLocation { span: Range(TextLocation { line: 53, column: 4, offset: 1321 }..TextLocation { line: 53, column: 26, offset: 1343 }) }], err_no: var__invalid_assignment } +SyntaxError { message: "Invalid assignment: cannot assign 'INT' to 'CHAR'", range: [SourceLocation { span: Range(TextLocation { line: 54, column: 4, offset: 1360 }..TextLocation { line: 54, column: 24, offset: 1380 }) }], err_no: var__invalid_assignment } +SyntaxError { message: "Invalid assignment: cannot assign 'STRING' to 'CHAR'", range: [SourceLocation { span: Range(TextLocation { line: 55, column: 4, offset: 1397 }..TextLocation { line: 55, column: 27, offset: 1420 }) }], err_no: var__invalid_assignment } +SyntaxError { message: "Invalid assignment: cannot assign 'INT' to 'CHAR'", range: [SourceLocation { span: Range(TextLocation { line: 56, column: 4, offset: 1437 }..TextLocation { line: 56, column: 28, offset: 1461 }) }], err_no: var__invalid_assignment } +SyntaxError { message: "Invalid assignment: cannot assign 'STRING' to 'CHAR'", range: [SourceLocation { span: Range(TextLocation { line: 57, column: 4, offset: 1478 }..TextLocation { line: 57, column: 31, offset: 1505 }) }], err_no: var__invalid_assignment } diff --git a/src/validation/tests/snapshots/rusty__validation__tests__assignment_validation_tests__constant_assignment_validation.snap b/src/validation/tests/snapshots/rusty__validation__tests__assignment_validation_tests__constant_assignment_validation.snap index 0698108984..a667b02c5f 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__assignment_validation_tests__constant_assignment_validation.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__assignment_validation_tests__constant_assignment_validation.snap @@ -2,5 +2,5 @@ source: src/validation/tests/assignment_validation_tests.rs expression: res --- -SyntaxError { message: "Cannot assign to CONSTANT 'v_global'", range: [SourceLocation { span: Range(TextLocation { line: 7, column: 4, offset: 123 }..TextLocation { line: 7, column: 12, offset: 131 }) }], err_no: var__cannot_assign_to_const } +SyntaxError { message: "Cannot assign to CONSTANT 'v_global'", range: [SourceLocation { span: Range(TextLocation { line: 7, column: 4, offset: 119 }..TextLocation { line: 7, column: 12, offset: 127 }) }], err_no: var__cannot_assign_to_const } diff --git a/src/validation/tests/snapshots/rusty__validation__tests__assignment_validation_tests__date_assignment_validation.snap b/src/validation/tests/snapshots/rusty__validation__tests__assignment_validation_tests__date_assignment_validation.snap index 98ed103fc9..47da84344e 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__assignment_validation_tests__date_assignment_validation.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__assignment_validation_tests__date_assignment_validation.snap @@ -2,11 +2,11 @@ source: src/validation/tests/assignment_validation_tests.rs expression: res --- -SyntaxError { message: "Invalid assignment: cannot assign 'STRING' to 'DATE'", range: [SourceLocation { span: Range(TextLocation { line: 38, column: 4, offset: 812 }..TextLocation { line: 38, column: 22, offset: 830 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid assignment: cannot assign 'STRING' to 'DATE'", range: [SourceLocation { span: Range(TextLocation { line: 39, column: 4, offset: 847 }..TextLocation { line: 39, column: 29, offset: 872 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid assignment: cannot assign 'STRING' to 'DATE'", range: [SourceLocation { span: Range(TextLocation { line: 40, column: 4, offset: 889 }..TextLocation { line: 40, column: 22, offset: 907 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid assignment: cannot assign 'CHAR' to 'DATE'", range: [SourceLocation { span: Range(TextLocation { line: 41, column: 4, offset: 924 }..TextLocation { line: 41, column: 20, offset: 940 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid assignment: cannot assign 'CHAR' to 'DATE'", range: [SourceLocation { span: Range(TextLocation { line: 42, column: 4, offset: 957 }..TextLocation { line: 42, column: 22, offset: 975 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid assignment: cannot assign 'STRING' to 'DATE'", range: [SourceLocation { span: Range(TextLocation { line: 46, column: 4, offset: 1094 }..TextLocation { line: 46, column: 27, offset: 1117 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid assignment: cannot assign 'STRING' to 'DATE'", range: [SourceLocation { span: Range(TextLocation { line: 48, column: 4, offset: 1173 }..TextLocation { line: 48, column: 31, offset: 1200 }) }], err_no: var__invalid_assignment } +SyntaxError { message: "Invalid assignment: cannot assign 'STRING' to 'DATE'", range: [SourceLocation { span: Range(TextLocation { line: 38, column: 4, offset: 776 }..TextLocation { line: 38, column: 22, offset: 794 }) }], err_no: var__invalid_assignment } +SyntaxError { message: "Invalid assignment: cannot assign 'STRING' to 'DATE'", range: [SourceLocation { span: Range(TextLocation { line: 39, column: 4, offset: 811 }..TextLocation { line: 39, column: 29, offset: 836 }) }], err_no: var__invalid_assignment } +SyntaxError { message: "Invalid assignment: cannot assign 'STRING' to 'DATE'", range: [SourceLocation { span: Range(TextLocation { line: 40, column: 4, offset: 853 }..TextLocation { line: 40, column: 22, offset: 871 }) }], err_no: var__invalid_assignment } +SyntaxError { message: "Invalid assignment: cannot assign 'CHAR' to 'DATE'", range: [SourceLocation { span: Range(TextLocation { line: 41, column: 4, offset: 888 }..TextLocation { line: 41, column: 20, offset: 904 }) }], err_no: var__invalid_assignment } +SyntaxError { message: "Invalid assignment: cannot assign 'CHAR' to 'DATE'", range: [SourceLocation { span: Range(TextLocation { line: 42, column: 4, offset: 921 }..TextLocation { line: 42, column: 22, offset: 939 }) }], err_no: var__invalid_assignment } +SyntaxError { message: "Invalid assignment: cannot assign 'STRING' to 'DATE'", range: [SourceLocation { span: Range(TextLocation { line: 46, column: 4, offset: 1058 }..TextLocation { line: 46, column: 27, offset: 1081 }) }], err_no: var__invalid_assignment } +SyntaxError { message: "Invalid assignment: cannot assign 'STRING' to 'DATE'", range: [SourceLocation { span: Range(TextLocation { line: 48, column: 4, offset: 1137 }..TextLocation { line: 48, column: 31, offset: 1164 }) }], err_no: var__invalid_assignment } diff --git a/src/validation/tests/snapshots/rusty__validation__tests__assignment_validation_tests__duration_assignment_validation.snap b/src/validation/tests/snapshots/rusty__validation__tests__assignment_validation_tests__duration_assignment_validation.snap index 740974f392..d31c506dfb 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__assignment_validation_tests__duration_assignment_validation.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__assignment_validation_tests__duration_assignment_validation.snap @@ -2,11 +2,11 @@ source: src/validation/tests/assignment_validation_tests.rs expression: res --- -SyntaxError { message: "Invalid assignment: cannot assign 'STRING' to 'TIME'", range: [SourceLocation { span: Range(TextLocation { line: 38, column: 4, offset: 816 }..TextLocation { line: 38, column: 22, offset: 834 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid assignment: cannot assign 'STRING' to 'TIME'", range: [SourceLocation { span: Range(TextLocation { line: 39, column: 4, offset: 851 }..TextLocation { line: 39, column: 29, offset: 876 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid assignment: cannot assign 'STRING' to 'TIME'", range: [SourceLocation { span: Range(TextLocation { line: 40, column: 4, offset: 893 }..TextLocation { line: 40, column: 22, offset: 911 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid assignment: cannot assign 'CHAR' to 'TIME'", range: [SourceLocation { span: Range(TextLocation { line: 41, column: 4, offset: 928 }..TextLocation { line: 41, column: 20, offset: 944 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid assignment: cannot assign 'CHAR' to 'TIME'", range: [SourceLocation { span: Range(TextLocation { line: 42, column: 4, offset: 961 }..TextLocation { line: 42, column: 22, offset: 979 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid assignment: cannot assign 'STRING' to 'TIME'", range: [SourceLocation { span: Range(TextLocation { line: 46, column: 4, offset: 1098 }..TextLocation { line: 46, column: 27, offset: 1121 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid assignment: cannot assign 'STRING' to 'TIME'", range: [SourceLocation { span: Range(TextLocation { line: 48, column: 4, offset: 1177 }..TextLocation { line: 48, column: 31, offset: 1204 }) }], err_no: var__invalid_assignment } +SyntaxError { message: "Invalid assignment: cannot assign 'STRING' to 'TIME'", range: [SourceLocation { span: Range(TextLocation { line: 38, column: 4, offset: 780 }..TextLocation { line: 38, column: 22, offset: 798 }) }], err_no: var__invalid_assignment } +SyntaxError { message: "Invalid assignment: cannot assign 'STRING' to 'TIME'", range: [SourceLocation { span: Range(TextLocation { line: 39, column: 4, offset: 815 }..TextLocation { line: 39, column: 29, offset: 840 }) }], err_no: var__invalid_assignment } +SyntaxError { message: "Invalid assignment: cannot assign 'STRING' to 'TIME'", range: [SourceLocation { span: Range(TextLocation { line: 40, column: 4, offset: 857 }..TextLocation { line: 40, column: 22, offset: 875 }) }], err_no: var__invalid_assignment } +SyntaxError { message: "Invalid assignment: cannot assign 'CHAR' to 'TIME'", range: [SourceLocation { span: Range(TextLocation { line: 41, column: 4, offset: 892 }..TextLocation { line: 41, column: 20, offset: 908 }) }], err_no: var__invalid_assignment } +SyntaxError { message: "Invalid assignment: cannot assign 'CHAR' to 'TIME'", range: [SourceLocation { span: Range(TextLocation { line: 42, column: 4, offset: 925 }..TextLocation { line: 42, column: 22, offset: 943 }) }], err_no: var__invalid_assignment } +SyntaxError { message: "Invalid assignment: cannot assign 'STRING' to 'TIME'", range: [SourceLocation { span: Range(TextLocation { line: 46, column: 4, offset: 1062 }..TextLocation { line: 46, column: 27, offset: 1085 }) }], err_no: var__invalid_assignment } +SyntaxError { message: "Invalid assignment: cannot assign 'STRING' to 'TIME'", range: [SourceLocation { span: Range(TextLocation { line: 48, column: 4, offset: 1141 }..TextLocation { line: 48, column: 31, offset: 1168 }) }], err_no: var__invalid_assignment } diff --git a/src/validation/tests/snapshots/rusty__validation__tests__assignment_validation_tests__enum_variants_mismatch.snap b/src/validation/tests/snapshots/rusty__validation__tests__assignment_validation_tests__enum_variants_mismatch.snap index 98c995dff2..efacb1a32d 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__assignment_validation_tests__enum_variants_mismatch.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__assignment_validation_tests__enum_variants_mismatch.snap @@ -2,8 +2,8 @@ source: src/validation/tests/assignment_validation_tests.rs expression: res --- -SemanticError { message: "Assigned value is not a variant of main.color", range: [SourceLocation { span: Range(TextLocation { line: 10, column: 21, offset: 291 }..TextLocation { line: 10, column: 24, offset: 294 }) }], err_no: var__invalid_enum_variant } -SemanticError { message: "Assigned value is not a variant of main.water", range: [SourceLocation { span: Range(TextLocation { line: 11, column: 21, offset: 334 }..TextLocation { line: 11, column: 25, offset: 338 }) }], err_no: var__invalid_enum_variant } -SemanticError { message: "Assigned value is not a variant of main.color", range: [SourceLocation { span: Range(TextLocation { line: 12, column: 21, offset: 377 }..TextLocation { line: 12, column: 30, offset: 386 }) }], err_no: var__invalid_enum_variant } -SemanticError { message: "Assigned value is not a variant of main.color", range: [SourceLocation { span: Range(TextLocation { line: 13, column: 21, offset: 420 }..TextLocation { line: 13, column: 22, offset: 421 }) }], err_no: var__invalid_enum_variant } +SemanticError { message: "Assigned value is not a variant of main.color", range: [SourceLocation { span: Range(TextLocation { line: 10, column: 21, offset: 283 }..TextLocation { line: 10, column: 24, offset: 286 }) }], err_no: var__invalid_enum_variant } +SemanticError { message: "Assigned value is not a variant of main.water", range: [SourceLocation { span: Range(TextLocation { line: 11, column: 21, offset: 326 }..TextLocation { line: 11, column: 25, offset: 330 }) }], err_no: var__invalid_enum_variant } +SemanticError { message: "Assigned value is not a variant of main.color", range: [SourceLocation { span: Range(TextLocation { line: 12, column: 21, offset: 369 }..TextLocation { line: 12, column: 30, offset: 378 }) }], err_no: var__invalid_enum_variant } +SemanticError { message: "Assigned value is not a variant of main.color", range: [SourceLocation { span: Range(TextLocation { line: 13, column: 21, offset: 412 }..TextLocation { line: 13, column: 22, offset: 413 }) }], err_no: var__invalid_enum_variant } diff --git a/src/validation/tests/snapshots/rusty__validation__tests__assignment_validation_tests__implicit_action_downcasts_are_validated.snap b/src/validation/tests/snapshots/rusty__validation__tests__assignment_validation_tests__implicit_action_downcasts_are_validated.snap index 9005b0bdc4..1d1336ec39 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__assignment_validation_tests__implicit_action_downcasts_are_validated.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__assignment_validation_tests__implicit_action_downcasts_are_validated.snap @@ -2,5 +2,5 @@ source: src/validation/tests/assignment_validation_tests.rs expression: res --- -SyntaxError { message: "Invalid assignment: cannot assign 'STRING' to 'BYTE'", range: [SourceLocation { span: Range(TextLocation { line: 25, column: 31, offset: 564 }..TextLocation { line: 25, column: 35, offset: 568 }) }], err_no: var__invalid_assignment } +SyntaxError { message: "Invalid assignment: cannot assign 'STRING' to 'BYTE'", range: [SourceLocation { span: Range(TextLocation { line: 25, column: 31, offset: 548 }..TextLocation { line: 25, column: 35, offset: 552 }) }], err_no: var__invalid_assignment } diff --git a/src/validation/tests/snapshots/rusty__validation__tests__assignment_validation_tests__implicit_invalid_action_call_assignments_are_validated.snap b/src/validation/tests/snapshots/rusty__validation__tests__assignment_validation_tests__implicit_invalid_action_call_assignments_are_validated.snap index 0de113e839..ab08bc0074 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__assignment_validation_tests__implicit_invalid_action_call_assignments_are_validated.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__assignment_validation_tests__implicit_invalid_action_call_assignments_are_validated.snap @@ -2,6 +2,6 @@ source: src/validation/tests/assignment_validation_tests.rs expression: res --- -SyntaxError { message: "Invalid assignment: cannot assign '__main_arr' to 'DINT'", range: [SourceLocation { span: Range(TextLocation { line: 23, column: 19, offset: 532 }..TextLocation { line: 23, column: 22, offset: 535 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid assignment: cannot assign '__main_arr' to 'STRING'", range: [SourceLocation { span: Range(TextLocation { line: 23, column: 24, offset: 537 }..TextLocation { line: 23, column: 27, offset: 540 }) }], err_no: var__invalid_assignment } +SyntaxError { message: "Invalid assignment: cannot assign '__main_arr' to 'DINT'", range: [SourceLocation { span: Range(TextLocation { line: 23, column: 19, offset: 516 }..TextLocation { line: 23, column: 22, offset: 519 }) }], err_no: var__invalid_assignment } +SyntaxError { message: "Invalid assignment: cannot assign '__main_arr' to 'STRING'", range: [SourceLocation { span: Range(TextLocation { line: 23, column: 24, offset: 521 }..TextLocation { line: 23, column: 27, offset: 524 }) }], err_no: var__invalid_assignment } diff --git a/src/validation/tests/snapshots/rusty__validation__tests__assignment_validation_tests__int_assignment_validation.snap b/src/validation/tests/snapshots/rusty__validation__tests__assignment_validation_tests__int_assignment_validation.snap index c6ae8e377d..8432940d79 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__assignment_validation_tests__int_assignment_validation.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__assignment_validation_tests__int_assignment_validation.snap @@ -2,18 +2,18 @@ source: src/validation/tests/assignment_validation_tests.rs expression: res --- -SyntaxError { message: "Invalid assignment: cannot assign 'STRING' to 'UDINT'", range: [SourceLocation { span: Range(TextLocation { line: 40, column: 4, offset: 880 }..TextLocation { line: 40, column: 23, offset: 899 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid assignment: cannot assign 'STRING' to 'UDINT'", range: [SourceLocation { span: Range(TextLocation { line: 41, column: 4, offset: 916 }..TextLocation { line: 41, column: 30, offset: 942 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid assignment: cannot assign 'STRING' to 'UDINT'", range: [SourceLocation { span: Range(TextLocation { line: 42, column: 4, offset: 959 }..TextLocation { line: 42, column: 23, offset: 978 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid assignment: cannot assign 'CHAR' to 'UDINT'", range: [SourceLocation { span: Range(TextLocation { line: 43, column: 4, offset: 995 }..TextLocation { line: 43, column: 21, offset: 1012 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid assignment: cannot assign 'CHAR' to 'UDINT'", range: [SourceLocation { span: Range(TextLocation { line: 44, column: 4, offset: 1029 }..TextLocation { line: 44, column: 23, offset: 1048 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid assignment: cannot assign 'STRING' to 'UDINT'", range: [SourceLocation { span: Range(TextLocation { line: 48, column: 4, offset: 1170 }..TextLocation { line: 48, column: 28, offset: 1194 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid assignment: cannot assign 'STRING' to 'UDINT'", range: [SourceLocation { span: Range(TextLocation { line: 50, column: 4, offset: 1251 }..TextLocation { line: 50, column: 32, offset: 1279 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid assignment: cannot assign 'STRING' to 'DINT'", range: [SourceLocation { span: Range(TextLocation { line: 63, column: 4, offset: 1646 }..TextLocation { line: 63, column: 22, offset: 1664 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid assignment: cannot assign 'STRING' to 'DINT'", range: [SourceLocation { span: Range(TextLocation { line: 64, column: 4, offset: 1681 }..TextLocation { line: 64, column: 29, offset: 1706 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid assignment: cannot assign 'STRING' to 'DINT'", range: [SourceLocation { span: Range(TextLocation { line: 65, column: 4, offset: 1723 }..TextLocation { line: 65, column: 22, offset: 1741 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid assignment: cannot assign 'CHAR' to 'DINT'", range: [SourceLocation { span: Range(TextLocation { line: 66, column: 4, offset: 1758 }..TextLocation { line: 66, column: 20, offset: 1774 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid assignment: cannot assign 'CHAR' to 'DINT'", range: [SourceLocation { span: Range(TextLocation { line: 67, column: 4, offset: 1791 }..TextLocation { line: 67, column: 22, offset: 1809 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid assignment: cannot assign 'STRING' to 'DINT'", range: [SourceLocation { span: Range(TextLocation { line: 71, column: 4, offset: 1928 }..TextLocation { line: 71, column: 27, offset: 1951 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid assignment: cannot assign 'STRING' to 'DINT'", range: [SourceLocation { span: Range(TextLocation { line: 73, column: 4, offset: 2007 }..TextLocation { line: 73, column: 31, offset: 2034 }) }], err_no: var__invalid_assignment } +SyntaxError { message: "Invalid assignment: cannot assign 'STRING' to 'UDINT'", range: [SourceLocation { span: Range(TextLocation { line: 40, column: 4, offset: 840 }..TextLocation { line: 40, column: 23, offset: 859 }) }], err_no: var__invalid_assignment } +SyntaxError { message: "Invalid assignment: cannot assign 'STRING' to 'UDINT'", range: [SourceLocation { span: Range(TextLocation { line: 41, column: 4, offset: 876 }..TextLocation { line: 41, column: 30, offset: 902 }) }], err_no: var__invalid_assignment } +SyntaxError { message: "Invalid assignment: cannot assign 'STRING' to 'UDINT'", range: [SourceLocation { span: Range(TextLocation { line: 42, column: 4, offset: 919 }..TextLocation { line: 42, column: 23, offset: 938 }) }], err_no: var__invalid_assignment } +SyntaxError { message: "Invalid assignment: cannot assign 'CHAR' to 'UDINT'", range: [SourceLocation { span: Range(TextLocation { line: 43, column: 4, offset: 955 }..TextLocation { line: 43, column: 21, offset: 972 }) }], err_no: var__invalid_assignment } +SyntaxError { message: "Invalid assignment: cannot assign 'CHAR' to 'UDINT'", range: [SourceLocation { span: Range(TextLocation { line: 44, column: 4, offset: 989 }..TextLocation { line: 44, column: 23, offset: 1008 }) }], err_no: var__invalid_assignment } +SyntaxError { message: "Invalid assignment: cannot assign 'STRING' to 'UDINT'", range: [SourceLocation { span: Range(TextLocation { line: 48, column: 4, offset: 1130 }..TextLocation { line: 48, column: 28, offset: 1154 }) }], err_no: var__invalid_assignment } +SyntaxError { message: "Invalid assignment: cannot assign 'STRING' to 'UDINT'", range: [SourceLocation { span: Range(TextLocation { line: 50, column: 4, offset: 1211 }..TextLocation { line: 50, column: 32, offset: 1239 }) }], err_no: var__invalid_assignment } +SyntaxError { message: "Invalid assignment: cannot assign 'STRING' to 'DINT'", range: [SourceLocation { span: Range(TextLocation { line: 63, column: 4, offset: 1602 }..TextLocation { line: 63, column: 22, offset: 1620 }) }], err_no: var__invalid_assignment } +SyntaxError { message: "Invalid assignment: cannot assign 'STRING' to 'DINT'", range: [SourceLocation { span: Range(TextLocation { line: 64, column: 4, offset: 1637 }..TextLocation { line: 64, column: 29, offset: 1662 }) }], err_no: var__invalid_assignment } +SyntaxError { message: "Invalid assignment: cannot assign 'STRING' to 'DINT'", range: [SourceLocation { span: Range(TextLocation { line: 65, column: 4, offset: 1679 }..TextLocation { line: 65, column: 22, offset: 1697 }) }], err_no: var__invalid_assignment } +SyntaxError { message: "Invalid assignment: cannot assign 'CHAR' to 'DINT'", range: [SourceLocation { span: Range(TextLocation { line: 66, column: 4, offset: 1714 }..TextLocation { line: 66, column: 20, offset: 1730 }) }], err_no: var__invalid_assignment } +SyntaxError { message: "Invalid assignment: cannot assign 'CHAR' to 'DINT'", range: [SourceLocation { span: Range(TextLocation { line: 67, column: 4, offset: 1747 }..TextLocation { line: 67, column: 22, offset: 1765 }) }], err_no: var__invalid_assignment } +SyntaxError { message: "Invalid assignment: cannot assign 'STRING' to 'DINT'", range: [SourceLocation { span: Range(TextLocation { line: 71, column: 4, offset: 1884 }..TextLocation { line: 71, column: 27, offset: 1907 }) }], err_no: var__invalid_assignment } +SyntaxError { message: "Invalid assignment: cannot assign 'STRING' to 'DINT'", range: [SourceLocation { span: Range(TextLocation { line: 73, column: 4, offset: 1963 }..TextLocation { line: 73, column: 31, offset: 1990 }) }], err_no: var__invalid_assignment } diff --git a/src/validation/tests/snapshots/rusty__validation__tests__assignment_validation_tests__invalid_function_block_instantiation_is_validated.snap b/src/validation/tests/snapshots/rusty__validation__tests__assignment_validation_tests__invalid_function_block_instantiation_is_validated.snap index 6d4f043879..13a20dfb10 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__assignment_validation_tests__invalid_function_block_instantiation_is_validated.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__assignment_validation_tests__invalid_function_block_instantiation_is_validated.snap @@ -2,8 +2,8 @@ source: src/validation/tests/assignment_validation_tests.rs expression: res --- -SyntaxError { message: "Invalid assignment: cannot assign 'STRING' to 'WSTRING'", range: [SourceLocation { span: Range(TextLocation { line: 14, column: 15, offset: 323 }..TextLocation { line: 14, column: 22, offset: 330 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid assignment: cannot assign '__prog_arr_64' to '__fb_t_arr_32'", range: [SourceLocation { span: Range(TextLocation { line: 14, column: 24, offset: 332 }..TextLocation { line: 14, column: 40, offset: 348 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid assignment: cannot assign 'STRING' to 'WSTRING'", range: [SourceLocation { span: Range(TextLocation { line: 15, column: 15, offset: 386 }..TextLocation { line: 15, column: 16, offset: 387 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid assignment: cannot assign '__prog_arr_64' to '__fb_t_arr_32'", range: [SourceLocation { span: Range(TextLocation { line: 15, column: 18, offset: 389 }..TextLocation { line: 15, column: 24, offset: 395 }) }], err_no: var__invalid_assignment } +SyntaxError { message: "Invalid assignment: cannot assign 'STRING' to 'WSTRING'", range: [SourceLocation { span: Range(TextLocation { line: 14, column: 15, offset: 319 }..TextLocation { line: 14, column: 22, offset: 326 }) }], err_no: var__invalid_assignment } +SyntaxError { message: "Invalid assignment: cannot assign '__prog_arr_64' to '__fb_t_arr_32'", range: [SourceLocation { span: Range(TextLocation { line: 14, column: 24, offset: 328 }..TextLocation { line: 14, column: 40, offset: 344 }) }], err_no: var__invalid_assignment } +SyntaxError { message: "Invalid assignment: cannot assign 'STRING' to 'WSTRING'", range: [SourceLocation { span: Range(TextLocation { line: 15, column: 15, offset: 382 }..TextLocation { line: 15, column: 16, offset: 383 }) }], err_no: var__invalid_assignment } +SyntaxError { message: "Invalid assignment: cannot assign '__prog_arr_64' to '__fb_t_arr_32'", range: [SourceLocation { span: Range(TextLocation { line: 15, column: 18, offset: 385 }..TextLocation { line: 15, column: 24, offset: 391 }) }], err_no: var__invalid_assignment } diff --git a/src/validation/tests/snapshots/rusty__validation__tests__assignment_validation_tests__invalid_method_call_assignments_are_validated.snap b/src/validation/tests/snapshots/rusty__validation__tests__assignment_validation_tests__invalid_method_call_assignments_are_validated.snap index a65376c0ba..bdc1434d4e 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__assignment_validation_tests__invalid_method_call_assignments_are_validated.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__assignment_validation_tests__invalid_method_call_assignments_are_validated.snap @@ -2,6 +2,6 @@ source: src/validation/tests/assignment_validation_tests.rs expression: res --- -SyntaxError { message: "Invalid assignment: cannot assign '__main_arr' to 'DINT'", range: [SourceLocation { span: Range(TextLocation { line: 21, column: 19, offset: 435 }..TextLocation { line: 21, column: 22, offset: 438 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid assignment: cannot assign '__main_arr' to 'STRING'", range: [SourceLocation { span: Range(TextLocation { line: 21, column: 24, offset: 440 }..TextLocation { line: 21, column: 27, offset: 443 }) }], err_no: var__invalid_assignment } +SyntaxError { message: "Invalid assignment: cannot assign '__main_arr' to 'DINT'", range: [SourceLocation { span: Range(TextLocation { line: 21, column: 19, offset: 425 }..TextLocation { line: 21, column: 22, offset: 428 }) }], err_no: var__invalid_assignment } +SyntaxError { message: "Invalid assignment: cannot assign '__main_arr' to 'STRING'", range: [SourceLocation { span: Range(TextLocation { line: 21, column: 24, offset: 430 }..TextLocation { line: 21, column: 27, offset: 433 }) }], err_no: var__invalid_assignment } diff --git a/src/validation/tests/snapshots/rusty__validation__tests__assignment_validation_tests__pointer_assignment_validation.snap b/src/validation/tests/snapshots/rusty__validation__tests__assignment_validation_tests__pointer_assignment_validation.snap index 053e80fe4d..e4c8298392 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__assignment_validation_tests__pointer_assignment_validation.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__assignment_validation_tests__pointer_assignment_validation.snap @@ -2,13 +2,13 @@ source: src/validation/tests/assignment_validation_tests.rs expression: res --- -SyntaxError { message: "The type DINT 32 is too small to hold a Pointer", range: [SourceLocation { span: Range(TextLocation { line: 27, column: 4, offset: 448 }..TextLocation { line: 27, column: 23, offset: 467 }) }], err_no: type__incompatible_size } -SyntaxError { message: "Invalid assignment: cannot assign '__main_v_ptr_int' to 'DINT'", range: [SourceLocation { span: Range(TextLocation { line: 27, column: 4, offset: 448 }..TextLocation { line: 27, column: 23, offset: 467 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "The type WORD 16 is too small to hold a Pointer", range: [SourceLocation { span: Range(TextLocation { line: 28, column: 4, offset: 484 }..TextLocation { line: 28, column: 23, offset: 503 }) }], err_no: type__incompatible_size } -SyntaxError { message: "Invalid assignment: cannot assign '__main_v_ptr_int' to 'WORD'", range: [SourceLocation { span: Range(TextLocation { line: 28, column: 4, offset: 484 }..TextLocation { line: 28, column: 23, offset: 503 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid assignment: cannot assign '__POINTER_TO_REAL' to '__main_v_ptr_int'", range: [SourceLocation { span: Range(TextLocation { line: 30, column: 4, offset: 555 }..TextLocation { line: 30, column: 24, offset: 575 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid assignment: cannot assign '__POINTER_TO_STRING' to '__main_v_ptr_int'", range: [SourceLocation { span: Range(TextLocation { line: 40, column: 4, offset: 934 }..TextLocation { line: 40, column: 26, offset: 956 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid assignment: cannot assign 'STRING' to 'INT'", range: [SourceLocation { span: Range(TextLocation { line: 41, column: 4, offset: 973 }..TextLocation { line: 41, column: 26, offset: 995 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid assignment: cannot assign 'CHAR' to 'INT'", range: [SourceLocation { span: Range(TextLocation { line: 43, column: 4, offset: 1077 }..TextLocation { line: 43, column: 24, offset: 1097 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid assignment: cannot assign 'STRING' to 'INT'", range: [SourceLocation { span: Range(TextLocation { line: 47, column: 4, offset: 1227 }..TextLocation { line: 47, column: 35, offset: 1258 }) }], err_no: var__invalid_assignment } +SyntaxError { message: "The type DINT 32 is too small to hold a Pointer", range: [SourceLocation { span: Range(TextLocation { line: 27, column: 4, offset: 412 }..TextLocation { line: 27, column: 23, offset: 431 }) }], err_no: type__incompatible_size } +SyntaxError { message: "Invalid assignment: cannot assign '__main_v_ptr_int' to 'DINT'", range: [SourceLocation { span: Range(TextLocation { line: 27, column: 4, offset: 412 }..TextLocation { line: 27, column: 23, offset: 431 }) }], err_no: var__invalid_assignment } +SyntaxError { message: "The type WORD 16 is too small to hold a Pointer", range: [SourceLocation { span: Range(TextLocation { line: 28, column: 4, offset: 448 }..TextLocation { line: 28, column: 23, offset: 467 }) }], err_no: type__incompatible_size } +SyntaxError { message: "Invalid assignment: cannot assign '__main_v_ptr_int' to 'WORD'", range: [SourceLocation { span: Range(TextLocation { line: 28, column: 4, offset: 448 }..TextLocation { line: 28, column: 23, offset: 467 }) }], err_no: var__invalid_assignment } +SyntaxError { message: "Invalid assignment: cannot assign '__POINTER_TO_REAL' to '__main_v_ptr_int'", range: [SourceLocation { span: Range(TextLocation { line: 30, column: 4, offset: 519 }..TextLocation { line: 30, column: 24, offset: 539 }) }], err_no: var__invalid_assignment } +SyntaxError { message: "Invalid assignment: cannot assign '__POINTER_TO_STRING' to '__main_v_ptr_int'", range: [SourceLocation { span: Range(TextLocation { line: 40, column: 4, offset: 898 }..TextLocation { line: 40, column: 26, offset: 920 }) }], err_no: var__invalid_assignment } +SyntaxError { message: "Invalid assignment: cannot assign 'STRING' to 'INT'", range: [SourceLocation { span: Range(TextLocation { line: 41, column: 4, offset: 937 }..TextLocation { line: 41, column: 26, offset: 959 }) }], err_no: var__invalid_assignment } +SyntaxError { message: "Invalid assignment: cannot assign 'CHAR' to 'INT'", range: [SourceLocation { span: Range(TextLocation { line: 43, column: 4, offset: 1041 }..TextLocation { line: 43, column: 24, offset: 1061 }) }], err_no: var__invalid_assignment } +SyntaxError { message: "Invalid assignment: cannot assign 'STRING' to 'INT'", range: [SourceLocation { span: Range(TextLocation { line: 47, column: 4, offset: 1191 }..TextLocation { line: 47, column: 35, offset: 1222 }) }], err_no: var__invalid_assignment } diff --git a/src/validation/tests/snapshots/rusty__validation__tests__assignment_validation_tests__real_assignment_validation.snap b/src/validation/tests/snapshots/rusty__validation__tests__assignment_validation_tests__real_assignment_validation.snap index f26ad5a6f8..9126bdd1a2 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__assignment_validation_tests__real_assignment_validation.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__assignment_validation_tests__real_assignment_validation.snap @@ -2,11 +2,11 @@ source: src/validation/tests/assignment_validation_tests.rs expression: res --- -SyntaxError { message: "Invalid assignment: cannot assign 'STRING' to 'REAL'", range: [SourceLocation { span: Range(TextLocation { line: 38, column: 4, offset: 816 }..TextLocation { line: 38, column: 22, offset: 834 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid assignment: cannot assign 'STRING' to 'REAL'", range: [SourceLocation { span: Range(TextLocation { line: 39, column: 4, offset: 851 }..TextLocation { line: 39, column: 29, offset: 876 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid assignment: cannot assign 'STRING' to 'REAL'", range: [SourceLocation { span: Range(TextLocation { line: 40, column: 4, offset: 893 }..TextLocation { line: 40, column: 22, offset: 911 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid assignment: cannot assign 'CHAR' to 'REAL'", range: [SourceLocation { span: Range(TextLocation { line: 41, column: 4, offset: 928 }..TextLocation { line: 41, column: 20, offset: 944 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid assignment: cannot assign 'CHAR' to 'REAL'", range: [SourceLocation { span: Range(TextLocation { line: 42, column: 4, offset: 961 }..TextLocation { line: 42, column: 22, offset: 979 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid assignment: cannot assign 'STRING' to 'REAL'", range: [SourceLocation { span: Range(TextLocation { line: 46, column: 4, offset: 1098 }..TextLocation { line: 46, column: 27, offset: 1121 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid assignment: cannot assign 'STRING' to 'REAL'", range: [SourceLocation { span: Range(TextLocation { line: 48, column: 4, offset: 1177 }..TextLocation { line: 48, column: 31, offset: 1204 }) }], err_no: var__invalid_assignment } +SyntaxError { message: "Invalid assignment: cannot assign 'STRING' to 'REAL'", range: [SourceLocation { span: Range(TextLocation { line: 38, column: 4, offset: 776 }..TextLocation { line: 38, column: 22, offset: 794 }) }], err_no: var__invalid_assignment } +SyntaxError { message: "Invalid assignment: cannot assign 'STRING' to 'REAL'", range: [SourceLocation { span: Range(TextLocation { line: 39, column: 4, offset: 811 }..TextLocation { line: 39, column: 29, offset: 836 }) }], err_no: var__invalid_assignment } +SyntaxError { message: "Invalid assignment: cannot assign 'STRING' to 'REAL'", range: [SourceLocation { span: Range(TextLocation { line: 40, column: 4, offset: 853 }..TextLocation { line: 40, column: 22, offset: 871 }) }], err_no: var__invalid_assignment } +SyntaxError { message: "Invalid assignment: cannot assign 'CHAR' to 'REAL'", range: [SourceLocation { span: Range(TextLocation { line: 41, column: 4, offset: 888 }..TextLocation { line: 41, column: 20, offset: 904 }) }], err_no: var__invalid_assignment } +SyntaxError { message: "Invalid assignment: cannot assign 'CHAR' to 'REAL'", range: [SourceLocation { span: Range(TextLocation { line: 42, column: 4, offset: 921 }..TextLocation { line: 42, column: 22, offset: 939 }) }], err_no: var__invalid_assignment } +SyntaxError { message: "Invalid assignment: cannot assign 'STRING' to 'REAL'", range: [SourceLocation { span: Range(TextLocation { line: 46, column: 4, offset: 1058 }..TextLocation { line: 46, column: 27, offset: 1081 }) }], err_no: var__invalid_assignment } +SyntaxError { message: "Invalid assignment: cannot assign 'STRING' to 'REAL'", range: [SourceLocation { span: Range(TextLocation { line: 48, column: 4, offset: 1137 }..TextLocation { line: 48, column: 31, offset: 1164 }) }], err_no: var__invalid_assignment } diff --git a/src/validation/tests/snapshots/rusty__validation__tests__assignment_validation_tests__string_assignment_validation.snap b/src/validation/tests/snapshots/rusty__validation__tests__assignment_validation_tests__string_assignment_validation.snap index 15d258721f..e647402cbb 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__assignment_validation_tests__string_assignment_validation.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__assignment_validation_tests__string_assignment_validation.snap @@ -2,23 +2,23 @@ source: src/validation/tests/assignment_validation_tests.rs expression: res --- -SyntaxError { message: "Invalid assignment: cannot assign 'LREAL' to 'STRING'", range: [SourceLocation { span: Range(TextLocation { line: 30, column: 4, offset: 548 }..TextLocation { line: 30, column: 23, offset: 567 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid assignment: cannot assign 'REAL' to 'STRING'", range: [SourceLocation { span: Range(TextLocation { line: 31, column: 4, offset: 584 }..TextLocation { line: 31, column: 24, offset: 604 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid assignment: cannot assign 'UDINT' to 'STRING'", range: [SourceLocation { span: Range(TextLocation { line: 32, column: 4, offset: 621 }..TextLocation { line: 32, column: 23, offset: 640 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid assignment: cannot assign 'UDINT' to 'STRING'", range: [SourceLocation { span: Range(TextLocation { line: 33, column: 4, offset: 657 }..TextLocation { line: 33, column: 24, offset: 677 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid assignment: cannot assign 'DINT' to 'STRING'", range: [SourceLocation { span: Range(TextLocation { line: 34, column: 4, offset: 694 }..TextLocation { line: 34, column: 22, offset: 712 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid assignment: cannot assign 'DINT' to 'STRING'", range: [SourceLocation { span: Range(TextLocation { line: 35, column: 4, offset: 729 }..TextLocation { line: 35, column: 23, offset: 748 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid assignment: cannot assign 'TIME' to 'STRING'", range: [SourceLocation { span: Range(TextLocation { line: 36, column: 4, offset: 765 }..TextLocation { line: 36, column: 22, offset: 783 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid assignment: cannot assign 'TIME' to 'STRING'", range: [SourceLocation { span: Range(TextLocation { line: 37, column: 4, offset: 800 }..TextLocation { line: 37, column: 30, offset: 826 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid assignment: cannot assign 'WORD' to 'STRING'", range: [SourceLocation { span: Range(TextLocation { line: 38, column: 4, offset: 843 }..TextLocation { line: 38, column: 22, offset: 861 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid assignment: cannot assign 'WORD' to 'STRING'", range: [SourceLocation { span: Range(TextLocation { line: 39, column: 4, offset: 878 }..TextLocation { line: 39, column: 28, offset: 902 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid assignment: cannot assign 'WSTRING' to 'STRING'", range: [SourceLocation { span: Range(TextLocation { line: 43, column: 4, offset: 1028 }..TextLocation { line: 43, column: 25, offset: 1049 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid assignment: cannot assign 'WSTRING' to 'STRING'", range: [SourceLocation { span: Range(TextLocation { line: 44, column: 4, offset: 1066 }..TextLocation { line: 44, column: 33, offset: 1095 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid assignment: cannot assign 'WSTRING' to 'STRING'", range: [SourceLocation { span: Range(TextLocation { line: 45, column: 4, offset: 1112 }..TextLocation { line: 45, column: 25, offset: 1133 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid assignment: cannot assign 'CHAR' to 'STRING'", range: [SourceLocation { span: Range(TextLocation { line: 46, column: 4, offset: 1150 }..TextLocation { line: 46, column: 22, offset: 1168 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid assignment: cannot assign 'CHAR' to 'STRING'", range: [SourceLocation { span: Range(TextLocation { line: 47, column: 4, offset: 1185 }..TextLocation { line: 47, column: 24, offset: 1205 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid assignment: cannot assign 'TIME_OF_DAY' to 'STRING'", range: [SourceLocation { span: Range(TextLocation { line: 48, column: 4, offset: 1222 }..TextLocation { line: 48, column: 21, offset: 1239 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid assignment: cannot assign 'TIME_OF_DAY' to 'STRING'", range: [SourceLocation { span: Range(TextLocation { line: 49, column: 4, offset: 1256 }..TextLocation { line: 49, column: 28, offset: 1280 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid assignment: cannot assign 'INT' to 'STRING'", range: [SourceLocation { span: Range(TextLocation { line: 50, column: 4, offset: 1297 }..TextLocation { line: 50, column: 26, offset: 1319 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid assignment: cannot assign 'INT' to 'STRING'", range: [SourceLocation { span: Range(TextLocation { line: 52, column: 4, offset: 1376 }..TextLocation { line: 52, column: 30, offset: 1402 }) }], err_no: var__invalid_assignment } +SyntaxError { message: "Invalid assignment: cannot assign 'LREAL' to 'STRING'", range: [SourceLocation { span: Range(TextLocation { line: 30, column: 4, offset: 508 }..TextLocation { line: 30, column: 23, offset: 527 }) }], err_no: var__invalid_assignment } +SyntaxError { message: "Invalid assignment: cannot assign 'REAL' to 'STRING'", range: [SourceLocation { span: Range(TextLocation { line: 31, column: 4, offset: 544 }..TextLocation { line: 31, column: 24, offset: 564 }) }], err_no: var__invalid_assignment } +SyntaxError { message: "Invalid assignment: cannot assign 'UDINT' to 'STRING'", range: [SourceLocation { span: Range(TextLocation { line: 32, column: 4, offset: 581 }..TextLocation { line: 32, column: 23, offset: 600 }) }], err_no: var__invalid_assignment } +SyntaxError { message: "Invalid assignment: cannot assign 'UDINT' to 'STRING'", range: [SourceLocation { span: Range(TextLocation { line: 33, column: 4, offset: 617 }..TextLocation { line: 33, column: 24, offset: 637 }) }], err_no: var__invalid_assignment } +SyntaxError { message: "Invalid assignment: cannot assign 'DINT' to 'STRING'", range: [SourceLocation { span: Range(TextLocation { line: 34, column: 4, offset: 654 }..TextLocation { line: 34, column: 22, offset: 672 }) }], err_no: var__invalid_assignment } +SyntaxError { message: "Invalid assignment: cannot assign 'DINT' to 'STRING'", range: [SourceLocation { span: Range(TextLocation { line: 35, column: 4, offset: 689 }..TextLocation { line: 35, column: 23, offset: 708 }) }], err_no: var__invalid_assignment } +SyntaxError { message: "Invalid assignment: cannot assign 'TIME' to 'STRING'", range: [SourceLocation { span: Range(TextLocation { line: 36, column: 4, offset: 725 }..TextLocation { line: 36, column: 22, offset: 743 }) }], err_no: var__invalid_assignment } +SyntaxError { message: "Invalid assignment: cannot assign 'TIME' to 'STRING'", range: [SourceLocation { span: Range(TextLocation { line: 37, column: 4, offset: 760 }..TextLocation { line: 37, column: 30, offset: 786 }) }], err_no: var__invalid_assignment } +SyntaxError { message: "Invalid assignment: cannot assign 'WORD' to 'STRING'", range: [SourceLocation { span: Range(TextLocation { line: 38, column: 4, offset: 803 }..TextLocation { line: 38, column: 22, offset: 821 }) }], err_no: var__invalid_assignment } +SyntaxError { message: "Invalid assignment: cannot assign 'WORD' to 'STRING'", range: [SourceLocation { span: Range(TextLocation { line: 39, column: 4, offset: 838 }..TextLocation { line: 39, column: 28, offset: 862 }) }], err_no: var__invalid_assignment } +SyntaxError { message: "Invalid assignment: cannot assign 'WSTRING' to 'STRING'", range: [SourceLocation { span: Range(TextLocation { line: 43, column: 4, offset: 988 }..TextLocation { line: 43, column: 25, offset: 1009 }) }], err_no: var__invalid_assignment } +SyntaxError { message: "Invalid assignment: cannot assign 'WSTRING' to 'STRING'", range: [SourceLocation { span: Range(TextLocation { line: 44, column: 4, offset: 1026 }..TextLocation { line: 44, column: 33, offset: 1055 }) }], err_no: var__invalid_assignment } +SyntaxError { message: "Invalid assignment: cannot assign 'WSTRING' to 'STRING'", range: [SourceLocation { span: Range(TextLocation { line: 45, column: 4, offset: 1072 }..TextLocation { line: 45, column: 25, offset: 1093 }) }], err_no: var__invalid_assignment } +SyntaxError { message: "Invalid assignment: cannot assign 'CHAR' to 'STRING'", range: [SourceLocation { span: Range(TextLocation { line: 46, column: 4, offset: 1110 }..TextLocation { line: 46, column: 22, offset: 1128 }) }], err_no: var__invalid_assignment } +SyntaxError { message: "Invalid assignment: cannot assign 'CHAR' to 'STRING'", range: [SourceLocation { span: Range(TextLocation { line: 47, column: 4, offset: 1145 }..TextLocation { line: 47, column: 24, offset: 1165 }) }], err_no: var__invalid_assignment } +SyntaxError { message: "Invalid assignment: cannot assign 'TIME_OF_DAY' to 'STRING'", range: [SourceLocation { span: Range(TextLocation { line: 48, column: 4, offset: 1182 }..TextLocation { line: 48, column: 21, offset: 1199 }) }], err_no: var__invalid_assignment } +SyntaxError { message: "Invalid assignment: cannot assign 'TIME_OF_DAY' to 'STRING'", range: [SourceLocation { span: Range(TextLocation { line: 49, column: 4, offset: 1216 }..TextLocation { line: 49, column: 28, offset: 1240 }) }], err_no: var__invalid_assignment } +SyntaxError { message: "Invalid assignment: cannot assign 'INT' to 'STRING'", range: [SourceLocation { span: Range(TextLocation { line: 50, column: 4, offset: 1257 }..TextLocation { line: 50, column: 26, offset: 1279 }) }], err_no: var__invalid_assignment } +SyntaxError { message: "Invalid assignment: cannot assign 'INT' to 'STRING'", range: [SourceLocation { span: Range(TextLocation { line: 52, column: 4, offset: 1336 }..TextLocation { line: 52, column: 30, offset: 1362 }) }], err_no: var__invalid_assignment } diff --git a/src/validation/tests/snapshots/rusty__validation__tests__assignment_validation_tests__struct_assignment_validation.snap b/src/validation/tests/snapshots/rusty__validation__tests__assignment_validation_tests__struct_assignment_validation.snap index 67ca9d1aa4..22cb0ebbe1 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__assignment_validation_tests__struct_assignment_validation.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__assignment_validation_tests__struct_assignment_validation.snap @@ -2,15 +2,15 @@ source: src/validation/tests/assignment_validation_tests.rs expression: res --- -SyntaxError { message: "Invalid assignment: cannot assign 'STRUCT1' to 'REAL'", range: [SourceLocation { span: Range(TextLocation { line: 45, column: 4, offset: 758 }..TextLocation { line: 45, column: 23, offset: 777 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid assignment: cannot assign 'REAL' to 'STRUCT1'", range: [SourceLocation { span: Range(TextLocation { line: 46, column: 4, offset: 794 }..TextLocation { line: 46, column: 23, offset: 813 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid assignment: cannot assign 'STRUCT2' to 'STRUCT1'", range: [SourceLocation { span: Range(TextLocation { line: 49, column: 4, offset: 870 }..TextLocation { line: 49, column: 26, offset: 892 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid assignment: cannot assign 'STRUCT2' to 'STRUCT1'", range: [SourceLocation { span: Range(TextLocation { line: 52, column: 18, offset: 978 }..TextLocation { line: 52, column: 42, offset: 1002 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid assignment: cannot assign 'STRUCT2' to 'STRUCT1'", range: [SourceLocation { span: Range(TextLocation { line: 55, column: 9, offset: 1077 }..TextLocation { line: 55, column: 39, offset: 1107 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid assignment: cannot assign '__POINTER_TO_REAL' to '__main_v_ref_to_struct1'", range: [SourceLocation { span: Range(TextLocation { line: 66, column: 4, offset: 1422 }..TextLocation { line: 66, column: 35, offset: 1453 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid assignment: cannot assign '__POINTER_TO_STRING' to '__main_v_ref_to_struct1'", range: [SourceLocation { span: Range(TextLocation { line: 67, column: 4, offset: 1470 }..TextLocation { line: 67, column: 37, offset: 1503 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid assignment: cannot assign '__POINTER_TO_CHAR' to '__main_v_ref_to_struct1'", range: [SourceLocation { span: Range(TextLocation { line: 68, column: 4, offset: 1520 }..TextLocation { line: 68, column: 35, offset: 1551 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid assignment: cannot assign '__POINTER_TO_REAL' to '__main_v_ref_to_struct1'", range: [SourceLocation { span: Range(TextLocation { line: 70, column: 4, offset: 1573 }..TextLocation { line: 70, column: 33, offset: 1602 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid assignment: cannot assign '__POINTER_TO_STRING' to '__main_v_ref_to_struct1'", range: [SourceLocation { span: Range(TextLocation { line: 71, column: 4, offset: 1619 }..TextLocation { line: 71, column: 35, offset: 1650 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid assignment: cannot assign '__POINTER_TO_CHAR' to '__main_v_ref_to_struct1'", range: [SourceLocation { span: Range(TextLocation { line: 72, column: 4, offset: 1667 }..TextLocation { line: 72, column: 33, offset: 1696 }) }], err_no: var__invalid_assignment } +SyntaxError { message: "Invalid assignment: cannot assign 'STRUCT1' to 'REAL'", range: [SourceLocation { span: Range(TextLocation { line: 45, column: 4, offset: 754 }..TextLocation { line: 45, column: 23, offset: 773 }) }], err_no: var__invalid_assignment } +SyntaxError { message: "Invalid assignment: cannot assign 'REAL' to 'STRUCT1'", range: [SourceLocation { span: Range(TextLocation { line: 46, column: 4, offset: 790 }..TextLocation { line: 46, column: 23, offset: 809 }) }], err_no: var__invalid_assignment } +SyntaxError { message: "Invalid assignment: cannot assign 'STRUCT2' to 'STRUCT1'", range: [SourceLocation { span: Range(TextLocation { line: 49, column: 4, offset: 866 }..TextLocation { line: 49, column: 26, offset: 888 }) }], err_no: var__invalid_assignment } +SyntaxError { message: "Invalid assignment: cannot assign 'STRUCT2' to 'STRUCT1'", range: [SourceLocation { span: Range(TextLocation { line: 52, column: 18, offset: 974 }..TextLocation { line: 52, column: 42, offset: 998 }) }], err_no: var__invalid_assignment } +SyntaxError { message: "Invalid assignment: cannot assign 'STRUCT2' to 'STRUCT1'", range: [SourceLocation { span: Range(TextLocation { line: 55, column: 9, offset: 1073 }..TextLocation { line: 55, column: 39, offset: 1103 }) }], err_no: var__invalid_assignment } +SyntaxError { message: "Invalid assignment: cannot assign '__POINTER_TO_REAL' to '__main_v_ref_to_struct1'", range: [SourceLocation { span: Range(TextLocation { line: 66, column: 4, offset: 1410 }..TextLocation { line: 66, column: 35, offset: 1441 }) }], err_no: var__invalid_assignment } +SyntaxError { message: "Invalid assignment: cannot assign '__POINTER_TO_STRING' to '__main_v_ref_to_struct1'", range: [SourceLocation { span: Range(TextLocation { line: 67, column: 4, offset: 1458 }..TextLocation { line: 67, column: 37, offset: 1491 }) }], err_no: var__invalid_assignment } +SyntaxError { message: "Invalid assignment: cannot assign '__POINTER_TO_CHAR' to '__main_v_ref_to_struct1'", range: [SourceLocation { span: Range(TextLocation { line: 68, column: 4, offset: 1508 }..TextLocation { line: 68, column: 35, offset: 1539 }) }], err_no: var__invalid_assignment } +SyntaxError { message: "Invalid assignment: cannot assign '__POINTER_TO_REAL' to '__main_v_ref_to_struct1'", range: [SourceLocation { span: Range(TextLocation { line: 70, column: 4, offset: 1557 }..TextLocation { line: 70, column: 33, offset: 1586 }) }], err_no: var__invalid_assignment } +SyntaxError { message: "Invalid assignment: cannot assign '__POINTER_TO_STRING' to '__main_v_ref_to_struct1'", range: [SourceLocation { span: Range(TextLocation { line: 71, column: 4, offset: 1603 }..TextLocation { line: 71, column: 35, offset: 1634 }) }], err_no: var__invalid_assignment } +SyntaxError { message: "Invalid assignment: cannot assign '__POINTER_TO_CHAR' to '__main_v_ref_to_struct1'", range: [SourceLocation { span: Range(TextLocation { line: 72, column: 4, offset: 1651 }..TextLocation { line: 72, column: 33, offset: 1680 }) }], err_no: var__invalid_assignment } diff --git a/src/validation/tests/snapshots/rusty__validation__tests__bitaccess_validation_test__bitaccess_only_on_bit_types.snap b/src/validation/tests/snapshots/rusty__validation__tests__bitaccess_validation_test__bitaccess_only_on_bit_types.snap index a207312d09..af71110414 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__bitaccess_validation_test__bitaccess_only_on_bit_types.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__bitaccess_validation_test__bitaccess_only_on_bit_types.snap @@ -2,7 +2,7 @@ source: src/validation/tests/bitaccess_validation_test.rs expression: res --- -SyntaxError { message: "Bit-Wise access requires a Numerical type larger than 1 bits", range: [SourceLocation { span: Range(TextLocation { line: 10, column: 20, offset: 223 }..TextLocation { line: 10, column: 21, offset: 224 }) }], err_no: type__incompatible_directaccess } -SyntaxError { message: "Bit-Wise access requires a Numerical type larger than 1 bits", range: [SourceLocation { span: Range(TextLocation { line: 11, column: 21, offset: 247 }..TextLocation { line: 11, column: 22, offset: 248 }) }], err_no: type__incompatible_directaccess } -SyntaxError { message: "Bit-Wise access requires a Numerical type larger than 1 bits", range: [SourceLocation { span: Range(TextLocation { line: 12, column: 20, offset: 270 }..TextLocation { line: 12, column: 21, offset: 271 }) }], err_no: type__incompatible_directaccess } +SyntaxError { message: "Bit-Wise access requires a Numerical type larger than 1 bits", range: [SourceLocation { span: Range(TextLocation { line: 10, column: 20, offset: 222 }..TextLocation { line: 10, column: 21, offset: 223 }) }], err_no: type__incompatible_directaccess } +SyntaxError { message: "Bit-Wise access requires a Numerical type larger than 1 bits", range: [SourceLocation { span: Range(TextLocation { line: 11, column: 21, offset: 246 }..TextLocation { line: 11, column: 22, offset: 247 }) }], err_no: type__incompatible_directaccess } +SyntaxError { message: "Bit-Wise access requires a Numerical type larger than 1 bits", range: [SourceLocation { span: Range(TextLocation { line: 12, column: 20, offset: 269 }..TextLocation { line: 12, column: 21, offset: 270 }) }], err_no: type__incompatible_directaccess } diff --git a/src/validation/tests/snapshots/rusty__validation__tests__bitaccess_validation_test__bitaccess_range_test.snap b/src/validation/tests/snapshots/rusty__validation__tests__bitaccess_validation_test__bitaccess_range_test.snap index e13ef2b0c3..04e2bd713c 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__bitaccess_validation_test__bitaccess_range_test.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__bitaccess_validation_test__bitaccess_range_test.snap @@ -2,8 +2,8 @@ source: src/validation/tests/bitaccess_validation_test.rs expression: res --- -SyntaxError { message: "Bit-Wise access for type BYTE must be in the range 0..7", range: [SourceLocation { span: Range(TextLocation { line: 5, column: 18, offset: 138 }..TextLocation { line: 5, column: 19, offset: 139 }) }], err_no: type__incompatible_directaccess_range } -SyntaxError { message: "Bit-Wise access for type WORD must be in the range 0..15", range: [SourceLocation { span: Range(TextLocation { line: 6, column: 18, offset: 159 }..TextLocation { line: 6, column: 20, offset: 161 }) }], err_no: type__incompatible_directaccess_range } -SyntaxError { message: "Bit-Wise access for type DWORD must be in the range 0..31", range: [SourceLocation { span: Range(TextLocation { line: 7, column: 18, offset: 181 }..TextLocation { line: 7, column: 20, offset: 183 }) }], err_no: type__incompatible_directaccess_range } -SyntaxError { message: "Bit-Wise access for type LWORD must be in the range 0..63", range: [SourceLocation { span: Range(TextLocation { line: 8, column: 18, offset: 203 }..TextLocation { line: 8, column: 20, offset: 205 }) }], err_no: type__incompatible_directaccess_range } +SyntaxError { message: "Bit-Wise access for type BYTE must be in the range 0..7", range: [SourceLocation { span: Range(TextLocation { line: 5, column: 18, offset: 137 }..TextLocation { line: 5, column: 19, offset: 138 }) }], err_no: type__incompatible_directaccess_range } +SyntaxError { message: "Bit-Wise access for type WORD must be in the range 0..15", range: [SourceLocation { span: Range(TextLocation { line: 6, column: 18, offset: 158 }..TextLocation { line: 6, column: 20, offset: 160 }) }], err_no: type__incompatible_directaccess_range } +SyntaxError { message: "Bit-Wise access for type DWORD must be in the range 0..31", range: [SourceLocation { span: Range(TextLocation { line: 7, column: 18, offset: 180 }..TextLocation { line: 7, column: 20, offset: 182 }) }], err_no: type__incompatible_directaccess_range } +SyntaxError { message: "Bit-Wise access for type LWORD must be in the range 0..63", range: [SourceLocation { span: Range(TextLocation { line: 8, column: 18, offset: 202 }..TextLocation { line: 8, column: 20, offset: 204 }) }], err_no: type__incompatible_directaccess_range } diff --git a/src/validation/tests/snapshots/rusty__validation__tests__bitaccess_validation_test__byteaccess_only_on_bigger_sizes.snap b/src/validation/tests/snapshots/rusty__validation__tests__bitaccess_validation_test__byteaccess_only_on_bigger_sizes.snap index bdc955b11d..6d500b3f39 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__bitaccess_validation_test__byteaccess_only_on_bigger_sizes.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__bitaccess_validation_test__byteaccess_only_on_bigger_sizes.snap @@ -2,7 +2,7 @@ source: src/validation/tests/bitaccess_validation_test.rs expression: res --- -SyntaxError { message: "Byte-Wise access requires a Numerical type larger than 8 bits", range: [SourceLocation { span: Range(TextLocation { line: 9, column: 20, offset: 195 }..TextLocation { line: 9, column: 23, offset: 198 }) }], err_no: type__incompatible_directaccess } -SyntaxError { message: "Byte-Wise access requires a Numerical type larger than 8 bits", range: [SourceLocation { span: Range(TextLocation { line: 10, column: 21, offset: 221 }..TextLocation { line: 10, column: 24, offset: 224 }) }], err_no: type__incompatible_directaccess } -SyntaxError { message: "Byte-Wise access requires a Numerical type larger than 8 bits", range: [SourceLocation { span: Range(TextLocation { line: 11, column: 21, offset: 247 }..TextLocation { line: 11, column: 24, offset: 250 }) }], err_no: type__incompatible_directaccess } +SyntaxError { message: "Byte-Wise access requires a Numerical type larger than 8 bits", range: [SourceLocation { span: Range(TextLocation { line: 9, column: 20, offset: 194 }..TextLocation { line: 9, column: 23, offset: 197 }) }], err_no: type__incompatible_directaccess } +SyntaxError { message: "Byte-Wise access requires a Numerical type larger than 8 bits", range: [SourceLocation { span: Range(TextLocation { line: 10, column: 21, offset: 220 }..TextLocation { line: 10, column: 24, offset: 223 }) }], err_no: type__incompatible_directaccess } +SyntaxError { message: "Byte-Wise access requires a Numerical type larger than 8 bits", range: [SourceLocation { span: Range(TextLocation { line: 11, column: 21, offset: 246 }..TextLocation { line: 11, column: 24, offset: 249 }) }], err_no: type__incompatible_directaccess } diff --git a/src/validation/tests/snapshots/rusty__validation__tests__bitaccess_validation_test__byteaccess_range_test.snap b/src/validation/tests/snapshots/rusty__validation__tests__bitaccess_validation_test__byteaccess_range_test.snap index fcfd804994..8c1c7fea53 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__bitaccess_validation_test__byteaccess_range_test.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__bitaccess_validation_test__byteaccess_range_test.snap @@ -2,7 +2,7 @@ source: src/validation/tests/bitaccess_validation_test.rs expression: res --- -SyntaxError { message: "Byte-Wise access for type WORD must be in the range 0..1", range: [SourceLocation { span: Range(TextLocation { line: 5, column: 18, offset: 128 }..TextLocation { line: 5, column: 21, offset: 131 }) }], err_no: type__incompatible_directaccess_range } -SyntaxError { message: "Byte-Wise access for type DWORD must be in the range 0..3", range: [SourceLocation { span: Range(TextLocation { line: 6, column: 18, offset: 151 }..TextLocation { line: 6, column: 21, offset: 154 }) }], err_no: type__incompatible_directaccess_range } -SyntaxError { message: "Byte-Wise access for type LWORD must be in the range 0..7", range: [SourceLocation { span: Range(TextLocation { line: 7, column: 18, offset: 174 }..TextLocation { line: 7, column: 21, offset: 177 }) }], err_no: type__incompatible_directaccess_range } +SyntaxError { message: "Byte-Wise access for type WORD must be in the range 0..1", range: [SourceLocation { span: Range(TextLocation { line: 5, column: 18, offset: 127 }..TextLocation { line: 5, column: 21, offset: 130 }) }], err_no: type__incompatible_directaccess_range } +SyntaxError { message: "Byte-Wise access for type DWORD must be in the range 0..3", range: [SourceLocation { span: Range(TextLocation { line: 6, column: 18, offset: 150 }..TextLocation { line: 6, column: 21, offset: 153 }) }], err_no: type__incompatible_directaccess_range } +SyntaxError { message: "Byte-Wise access for type LWORD must be in the range 0..7", range: [SourceLocation { span: Range(TextLocation { line: 7, column: 18, offset: 173 }..TextLocation { line: 7, column: 21, offset: 176 }) }], err_no: type__incompatible_directaccess_range } diff --git a/src/validation/tests/snapshots/rusty__validation__tests__bitaccess_validation_test__dwordaccess_only_on_bigger_sizes.snap b/src/validation/tests/snapshots/rusty__validation__tests__bitaccess_validation_test__dwordaccess_only_on_bigger_sizes.snap index 76e0d33ff5..4d655bcabc 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__bitaccess_validation_test__dwordaccess_only_on_bigger_sizes.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__bitaccess_validation_test__dwordaccess_only_on_bigger_sizes.snap @@ -2,7 +2,7 @@ source: src/validation/tests/bitaccess_validation_test.rs expression: res --- -SyntaxError { message: "DWord-Wise access requires a Numerical type larger than 32 bits", range: [SourceLocation { span: Range(TextLocation { line: 9, column: 20, offset: 197 }..TextLocation { line: 9, column: 23, offset: 200 }) }], err_no: type__incompatible_directaccess } -SyntaxError { message: "DWord-Wise access requires a Numerical type larger than 32 bits", range: [SourceLocation { span: Range(TextLocation { line: 10, column: 21, offset: 223 }..TextLocation { line: 10, column: 24, offset: 226 }) }], err_no: type__incompatible_directaccess } -SyntaxError { message: "DWord-Wise access requires a Numerical type larger than 32 bits", range: [SourceLocation { span: Range(TextLocation { line: 11, column: 21, offset: 249 }..TextLocation { line: 11, column: 24, offset: 252 }) }], err_no: type__incompatible_directaccess } +SyntaxError { message: "DWord-Wise access requires a Numerical type larger than 32 bits", range: [SourceLocation { span: Range(TextLocation { line: 9, column: 20, offset: 196 }..TextLocation { line: 9, column: 23, offset: 199 }) }], err_no: type__incompatible_directaccess } +SyntaxError { message: "DWord-Wise access requires a Numerical type larger than 32 bits", range: [SourceLocation { span: Range(TextLocation { line: 10, column: 21, offset: 222 }..TextLocation { line: 10, column: 24, offset: 225 }) }], err_no: type__incompatible_directaccess } +SyntaxError { message: "DWord-Wise access requires a Numerical type larger than 32 bits", range: [SourceLocation { span: Range(TextLocation { line: 11, column: 21, offset: 248 }..TextLocation { line: 11, column: 24, offset: 251 }) }], err_no: type__incompatible_directaccess } diff --git a/src/validation/tests/snapshots/rusty__validation__tests__bitaccess_validation_test__dwordaccess_range_test.snap b/src/validation/tests/snapshots/rusty__validation__tests__bitaccess_validation_test__dwordaccess_range_test.snap index 1153059e4f..419f2365ff 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__bitaccess_validation_test__dwordaccess_range_test.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__bitaccess_validation_test__dwordaccess_range_test.snap @@ -2,5 +2,5 @@ source: src/validation/tests/bitaccess_validation_test.rs expression: res --- -SyntaxError { message: "DWord-Wise access for type LWORD must be in the range 0..1", range: [SourceLocation { span: Range(TextLocation { line: 5, column: 18, offset: 107 }..TextLocation { line: 5, column: 21, offset: 110 }) }], err_no: type__incompatible_directaccess_range } +SyntaxError { message: "DWord-Wise access for type LWORD must be in the range 0..1", range: [SourceLocation { span: Range(TextLocation { line: 5, column: 18, offset: 106 }..TextLocation { line: 5, column: 21, offset: 109 }) }], err_no: type__incompatible_directaccess_range } diff --git a/src/validation/tests/snapshots/rusty__validation__tests__bitaccess_validation_test__reference_direct_access_only_with_ints.snap b/src/validation/tests/snapshots/rusty__validation__tests__bitaccess_validation_test__reference_direct_access_only_with_ints.snap index 0586ff36ca..e613224530 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__bitaccess_validation_test__reference_direct_access_only_with_ints.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__bitaccess_validation_test__reference_direct_access_only_with_ints.snap @@ -2,6 +2,6 @@ source: src/validation/tests/bitaccess_validation_test.rs expression: res --- -SyntaxError { message: "Invalid type LREAL for direct variable access. Only variables of Integer types are allowed", range: [SourceLocation { span: Range(TextLocation { line: 6, column: 18, offset: 160 }..TextLocation { line: 6, column: 21, offset: 163 }) }], err_no: type__incompatible_directaccess_variable } -SyntaxError { message: "Invalid type REAL for direct variable access. Only variables of Integer types are allowed", range: [SourceLocation { span: Range(TextLocation { line: 7, column: 18, offset: 183 }..TextLocation { line: 7, column: 21, offset: 186 }) }], err_no: type__incompatible_directaccess_variable } +SyntaxError { message: "Invalid type LREAL for direct variable access. Only variables of Integer types are allowed", range: [SourceLocation { span: Range(TextLocation { line: 6, column: 18, offset: 159 }..TextLocation { line: 6, column: 21, offset: 162 }) }], err_no: type__incompatible_directaccess_variable } +SyntaxError { message: "Invalid type REAL for direct variable access. Only variables of Integer types are allowed", range: [SourceLocation { span: Range(TextLocation { line: 7, column: 18, offset: 182 }..TextLocation { line: 7, column: 21, offset: 185 }) }], err_no: type__incompatible_directaccess_variable } diff --git a/src/validation/tests/snapshots/rusty__validation__tests__bitaccess_validation_test__wordaccess_only_on_bigger_sizes.snap b/src/validation/tests/snapshots/rusty__validation__tests__bitaccess_validation_test__wordaccess_only_on_bigger_sizes.snap index 8c11ae7609..2713560021 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__bitaccess_validation_test__wordaccess_only_on_bigger_sizes.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__bitaccess_validation_test__wordaccess_only_on_bigger_sizes.snap @@ -2,7 +2,7 @@ source: src/validation/tests/bitaccess_validation_test.rs expression: res --- -SyntaxError { message: "Word-Wise access requires a Numerical type larger than 16 bits", range: [SourceLocation { span: Range(TextLocation { line: 9, column: 20, offset: 194 }..TextLocation { line: 9, column: 23, offset: 197 }) }], err_no: type__incompatible_directaccess } -SyntaxError { message: "Word-Wise access requires a Numerical type larger than 16 bits", range: [SourceLocation { span: Range(TextLocation { line: 10, column: 21, offset: 220 }..TextLocation { line: 10, column: 24, offset: 223 }) }], err_no: type__incompatible_directaccess } -SyntaxError { message: "Word-Wise access requires a Numerical type larger than 16 bits", range: [SourceLocation { span: Range(TextLocation { line: 11, column: 21, offset: 246 }..TextLocation { line: 11, column: 24, offset: 249 }) }], err_no: type__incompatible_directaccess } +SyntaxError { message: "Word-Wise access requires a Numerical type larger than 16 bits", range: [SourceLocation { span: Range(TextLocation { line: 9, column: 20, offset: 193 }..TextLocation { line: 9, column: 23, offset: 196 }) }], err_no: type__incompatible_directaccess } +SyntaxError { message: "Word-Wise access requires a Numerical type larger than 16 bits", range: [SourceLocation { span: Range(TextLocation { line: 10, column: 21, offset: 219 }..TextLocation { line: 10, column: 24, offset: 222 }) }], err_no: type__incompatible_directaccess } +SyntaxError { message: "Word-Wise access requires a Numerical type larger than 16 bits", range: [SourceLocation { span: Range(TextLocation { line: 11, column: 21, offset: 245 }..TextLocation { line: 11, column: 24, offset: 248 }) }], err_no: type__incompatible_directaccess } diff --git a/src/validation/tests/snapshots/rusty__validation__tests__bitaccess_validation_test__wordaccess_range_test.snap b/src/validation/tests/snapshots/rusty__validation__tests__bitaccess_validation_test__wordaccess_range_test.snap index 4837fa59d9..568aac496f 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__bitaccess_validation_test__wordaccess_range_test.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__bitaccess_validation_test__wordaccess_range_test.snap @@ -2,6 +2,6 @@ source: src/validation/tests/bitaccess_validation_test.rs expression: res --- -SyntaxError { message: "Word-Wise access for type DWORD must be in the range 0..1", range: [SourceLocation { span: Range(TextLocation { line: 5, column: 18, offset: 118 }..TextLocation { line: 5, column: 21, offset: 121 }) }], err_no: type__incompatible_directaccess_range } -SyntaxError { message: "Word-Wise access for type LWORD must be in the range 0..3", range: [SourceLocation { span: Range(TextLocation { line: 6, column: 18, offset: 141 }..TextLocation { line: 6, column: 21, offset: 144 }) }], err_no: type__incompatible_directaccess_range } +SyntaxError { message: "Word-Wise access for type DWORD must be in the range 0..1", range: [SourceLocation { span: Range(TextLocation { line: 5, column: 18, offset: 117 }..TextLocation { line: 5, column: 21, offset: 120 }) }], err_no: type__incompatible_directaccess_range } +SyntaxError { message: "Word-Wise access for type LWORD must be in the range 0..3", range: [SourceLocation { span: Range(TextLocation { line: 6, column: 18, offset: 140 }..TextLocation { line: 6, column: 21, offset: 143 }) }], err_no: type__incompatible_directaccess_range } diff --git a/src/validation/tests/snapshots/rusty__validation__tests__duplicates_validation_test__duplicate_action_should_be_a_problem.snap b/src/validation/tests/snapshots/rusty__validation__tests__duplicates_validation_test__duplicate_action_should_be_a_problem.snap index e7cdf31da3..ac1ddf51bc 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__duplicates_validation_test__duplicate_action_should_be_a_problem.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__duplicates_validation_test__duplicate_action_should_be_a_problem.snap @@ -2,6 +2,6 @@ source: src/validation/tests/duplicates_validation_test.rs expression: res --- -SyntaxError { message: "prg.foo: Ambiguous callable symbol.", range: [SourceLocation { span: Range(TextLocation { line: 8, column: 19, offset: 168 }..TextLocation { line: 8, column: 22, offset: 171 }) }, SourceLocation { span: Range(TextLocation { line: 16, column: 19, offset: 310 }..TextLocation { line: 16, column: 22, offset: 313 }) }], err_no: duplicate_symbol } -SyntaxError { message: "prg.foo: Ambiguous callable symbol.", range: [SourceLocation { span: Range(TextLocation { line: 16, column: 19, offset: 310 }..TextLocation { line: 16, column: 22, offset: 313 }) }, SourceLocation { span: Range(TextLocation { line: 8, column: 19, offset: 168 }..TextLocation { line: 8, column: 22, offset: 171 }) }], err_no: duplicate_symbol } +SyntaxError { message: "prg.foo: Ambiguous callable symbol.", range: [SourceLocation { span: Range(TextLocation { line: 8, column: 19, offset: 167 }..TextLocation { line: 8, column: 22, offset: 170 }) }, SourceLocation { span: Range(TextLocation { line: 16, column: 19, offset: 309 }..TextLocation { line: 16, column: 22, offset: 312 }) }], err_no: duplicate_symbol } +SyntaxError { message: "prg.foo: Ambiguous callable symbol.", range: [SourceLocation { span: Range(TextLocation { line: 16, column: 19, offset: 309 }..TextLocation { line: 16, column: 22, offset: 312 }) }, SourceLocation { span: Range(TextLocation { line: 8, column: 19, offset: 167 }..TextLocation { line: 8, column: 22, offset: 170 }) }], err_no: duplicate_symbol } diff --git a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_bit_does_not_allow_chars.snap b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_bit_does_not_allow_chars.snap index d149b5c152..e6b58999b4 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_bit_does_not_allow_chars.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_bit_does_not_allow_chars.snap @@ -4,6 +4,6 @@ expression: res --- SyntaxError { message: "Invalid assignment: cannot assign 'CHAR' to 'BOOL'", range: [SourceLocation { span: Range(TextLocation { line: 2, column: 57, offset: 137 }..TextLocation { line: 2, column: 58, offset: 138 }) }], err_no: var__invalid_assignment } SyntaxError { message: "Invalid type nature for generic argument. CHAR is no Bit.", range: [SourceLocation { span: Range(TextLocation { line: 2, column: 57, offset: 137 }..TextLocation { line: 2, column: 58, offset: 138 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid assignment: cannot assign 'WCHAR' to 'BOOL'", range: [SourceLocation { span: Range(TextLocation { line: 3, column: 52, offset: 206 }..TextLocation { line: 3, column: 53, offset: 207 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid type nature for generic argument. WCHAR is no Bit.", range: [SourceLocation { span: Range(TextLocation { line: 3, column: 52, offset: 206 }..TextLocation { line: 3, column: 53, offset: 207 }) }], err_no: type__invalid_nature } +SyntaxError { message: "Invalid assignment: cannot assign 'WCHAR' to 'BOOL'", range: [SourceLocation { span: Range(TextLocation { line: 3, column: 58, offset: 212 }..TextLocation { line: 3, column: 59, offset: 213 }) }], err_no: var__invalid_assignment } +SyntaxError { message: "Invalid type nature for generic argument. WCHAR is no Bit.", range: [SourceLocation { span: Range(TextLocation { line: 3, column: 58, offset: 212 }..TextLocation { line: 3, column: 59, offset: 213 }) }], err_no: type__invalid_nature } diff --git a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_bit_does_not_allow_date.snap b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_bit_does_not_allow_date.snap index a17645d4a4..237bef9b7c 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_bit_does_not_allow_date.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_bit_does_not_allow_date.snap @@ -3,8 +3,8 @@ source: src/validation/tests/generic_validation_tests.rs expression: res --- SyntaxError { message: "Invalid type nature for generic argument. DATE_AND_TIME is no Bit.", range: [SourceLocation { span: Range(TextLocation { line: 2, column: 55, offset: 135 }..TextLocation { line: 2, column: 56, offset: 136 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid type nature for generic argument. DATE_AND_TIME is no Bit.", range: [SourceLocation { span: Range(TextLocation { line: 3, column: 50, offset: 202 }..TextLocation { line: 3, column: 51, offset: 203 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid type nature for generic argument. DATE is no Bit.", range: [SourceLocation { span: Range(TextLocation { line: 4, column: 51, offset: 270 }..TextLocation { line: 4, column: 52, offset: 271 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid type nature for generic argument. TIME_OF_DAY is no Bit.", range: [SourceLocation { span: Range(TextLocation { line: 5, column: 50, offset: 337 }..TextLocation { line: 5, column: 51, offset: 338 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid type nature for generic argument. TIME_OF_DAY is no Bit.", range: [SourceLocation { span: Range(TextLocation { line: 6, column: 51, offset: 405 }..TextLocation { line: 6, column: 52, offset: 406 }) }], err_no: type__invalid_nature } +SyntaxError { message: "Invalid type nature for generic argument. DATE_AND_TIME is no Bit.", range: [SourceLocation { span: Range(TextLocation { line: 3, column: 56, offset: 208 }..TextLocation { line: 3, column: 57, offset: 209 }) }], err_no: type__invalid_nature } +SyntaxError { message: "Invalid type nature for generic argument. DATE is no Bit.", range: [SourceLocation { span: Range(TextLocation { line: 4, column: 57, offset: 282 }..TextLocation { line: 4, column: 58, offset: 283 }) }], err_no: type__invalid_nature } +SyntaxError { message: "Invalid type nature for generic argument. TIME_OF_DAY is no Bit.", range: [SourceLocation { span: Range(TextLocation { line: 5, column: 56, offset: 355 }..TextLocation { line: 5, column: 57, offset: 356 }) }], err_no: type__invalid_nature } +SyntaxError { message: "Invalid type nature for generic argument. TIME_OF_DAY is no Bit.", range: [SourceLocation { span: Range(TextLocation { line: 6, column: 57, offset: 429 }..TextLocation { line: 6, column: 58, offset: 430 }) }], err_no: type__invalid_nature } diff --git a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_bit_does_not_allow_ints.snap b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_bit_does_not_allow_ints.snap index beb147c098..247d3ad4ba 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_bit_does_not_allow_ints.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_bit_does_not_allow_ints.snap @@ -2,12 +2,12 @@ source: src/validation/tests/generic_validation_tests.rs expression: res --- -SyntaxError { message: "Invalid type nature for generic argument. USINT is no Bit.", range: [SourceLocation { span: Range(TextLocation { line: 3, column: 52, offset: 133 }..TextLocation { line: 3, column: 53, offset: 134 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid type nature for generic argument. UINT is no Bit.", range: [SourceLocation { span: Range(TextLocation { line: 4, column: 57, offset: 207 }..TextLocation { line: 4, column: 58, offset: 208 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid type nature for generic argument. UDINT is no Bit.", range: [SourceLocation { span: Range(TextLocation { line: 5, column: 52, offset: 276 }..TextLocation { line: 5, column: 53, offset: 277 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid type nature for generic argument. ULINT is no Bit.", range: [SourceLocation { span: Range(TextLocation { line: 6, column: 52, offset: 345 }..TextLocation { line: 6, column: 53, offset: 346 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid type nature for generic argument. SINT is no Bit.", range: [SourceLocation { span: Range(TextLocation { line: 8, column: 51, offset: 414 }..TextLocation { line: 8, column: 52, offset: 415 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid type nature for generic argument. INT is no Bit.", range: [SourceLocation { span: Range(TextLocation { line: 9, column: 56, offset: 487 }..TextLocation { line: 9, column: 57, offset: 488 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid type nature for generic argument. DINT is no Bit.", range: [SourceLocation { span: Range(TextLocation { line: 10, column: 51, offset: 555 }..TextLocation { line: 10, column: 52, offset: 556 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid type nature for generic argument. LINT is no Bit.", range: [SourceLocation { span: Range(TextLocation { line: 11, column: 51, offset: 623 }..TextLocation { line: 11, column: 52, offset: 624 }) }], err_no: type__invalid_nature } +SyntaxError { message: "Invalid type nature for generic argument. USINT is no Bit.", range: [SourceLocation { span: Range(TextLocation { line: 3, column: 58, offset: 139 }..TextLocation { line: 3, column: 59, offset: 140 }) }], err_no: type__invalid_nature } +SyntaxError { message: "Invalid type nature for generic argument. UINT is no Bit.", range: [SourceLocation { span: Range(TextLocation { line: 4, column: 57, offset: 213 }..TextLocation { line: 4, column: 58, offset: 214 }) }], err_no: type__invalid_nature } +SyntaxError { message: "Invalid type nature for generic argument. UDINT is no Bit.", range: [SourceLocation { span: Range(TextLocation { line: 5, column: 58, offset: 288 }..TextLocation { line: 5, column: 59, offset: 289 }) }], err_no: type__invalid_nature } +SyntaxError { message: "Invalid type nature for generic argument. ULINT is no Bit.", range: [SourceLocation { span: Range(TextLocation { line: 6, column: 58, offset: 363 }..TextLocation { line: 6, column: 59, offset: 364 }) }], err_no: type__invalid_nature } +SyntaxError { message: "Invalid type nature for generic argument. SINT is no Bit.", range: [SourceLocation { span: Range(TextLocation { line: 8, column: 57, offset: 438 }..TextLocation { line: 8, column: 58, offset: 439 }) }], err_no: type__invalid_nature } +SyntaxError { message: "Invalid type nature for generic argument. INT is no Bit.", range: [SourceLocation { span: Range(TextLocation { line: 9, column: 56, offset: 511 }..TextLocation { line: 9, column: 57, offset: 512 }) }], err_no: type__invalid_nature } +SyntaxError { message: "Invalid type nature for generic argument. DINT is no Bit.", range: [SourceLocation { span: Range(TextLocation { line: 10, column: 57, offset: 585 }..TextLocation { line: 10, column: 58, offset: 586 }) }], err_no: type__invalid_nature } +SyntaxError { message: "Invalid type nature for generic argument. LINT is no Bit.", range: [SourceLocation { span: Range(TextLocation { line: 11, column: 57, offset: 659 }..TextLocation { line: 11, column: 58, offset: 660 }) }], err_no: type__invalid_nature } diff --git a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_bit_does_not_allow_time.snap b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_bit_does_not_allow_time.snap index 20147c3587..a15b9832f1 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_bit_does_not_allow_time.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_bit_does_not_allow_time.snap @@ -3,5 +3,5 @@ source: src/validation/tests/generic_validation_tests.rs expression: res --- SyntaxError { message: "Invalid type nature for generic argument. TIME is no Bit.", range: [SourceLocation { span: Range(TextLocation { line: 2, column: 57, offset: 137 }..TextLocation { line: 2, column: 58, offset: 138 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid type nature for generic argument. TIME is no Bit.", range: [SourceLocation { span: Range(TextLocation { line: 3, column: 52, offset: 206 }..TextLocation { line: 3, column: 53, offset: 207 }) }], err_no: type__invalid_nature } +SyntaxError { message: "Invalid type nature for generic argument. TIME is no Bit.", range: [SourceLocation { span: Range(TextLocation { line: 3, column: 58, offset: 212 }..TextLocation { line: 3, column: 59, offset: 213 }) }], err_no: type__invalid_nature } diff --git a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_char_does_not_allow_bits.snap b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_char_does_not_allow_bits.snap index 8d97ebf741..a9179b1af6 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_char_does_not_allow_bits.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_char_does_not_allow_bits.snap @@ -4,12 +4,12 @@ expression: res --- SyntaxError { message: "Invalid assignment: cannot assign 'BOOL' to 'CHAR'", range: [SourceLocation { span: Range(TextLocation { line: 2, column: 57, offset: 138 }..TextLocation { line: 2, column: 58, offset: 139 }) }], err_no: var__invalid_assignment } SyntaxError { message: "Invalid type nature for generic argument. BOOL is no Char.", range: [SourceLocation { span: Range(TextLocation { line: 2, column: 57, offset: 138 }..TextLocation { line: 2, column: 58, offset: 139 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid assignment: cannot assign 'BYTE' to 'CHAR'", range: [SourceLocation { span: Range(TextLocation { line: 3, column: 51, offset: 206 }..TextLocation { line: 3, column: 52, offset: 207 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid type nature for generic argument. BYTE is no Char.", range: [SourceLocation { span: Range(TextLocation { line: 3, column: 51, offset: 206 }..TextLocation { line: 3, column: 52, offset: 207 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid assignment: cannot assign 'WORD' to 'CHAR'", range: [SourceLocation { span: Range(TextLocation { line: 4, column: 51, offset: 274 }..TextLocation { line: 4, column: 52, offset: 275 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid type nature for generic argument. WORD is no Char.", range: [SourceLocation { span: Range(TextLocation { line: 4, column: 51, offset: 274 }..TextLocation { line: 4, column: 52, offset: 275 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid assignment: cannot assign 'DWORD' to 'CHAR'", range: [SourceLocation { span: Range(TextLocation { line: 5, column: 52, offset: 343 }..TextLocation { line: 5, column: 53, offset: 344 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid type nature for generic argument. DWORD is no Char.", range: [SourceLocation { span: Range(TextLocation { line: 5, column: 52, offset: 343 }..TextLocation { line: 5, column: 53, offset: 344 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid assignment: cannot assign 'LWORD' to 'CHAR'", range: [SourceLocation { span: Range(TextLocation { line: 6, column: 52, offset: 412 }..TextLocation { line: 6, column: 53, offset: 413 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid type nature for generic argument. LWORD is no Char.", range: [SourceLocation { span: Range(TextLocation { line: 6, column: 52, offset: 412 }..TextLocation { line: 6, column: 53, offset: 413 }) }], err_no: type__invalid_nature } +SyntaxError { message: "Invalid assignment: cannot assign 'BYTE' to 'CHAR'", range: [SourceLocation { span: Range(TextLocation { line: 3, column: 57, offset: 212 }..TextLocation { line: 3, column: 58, offset: 213 }) }], err_no: var__invalid_assignment } +SyntaxError { message: "Invalid type nature for generic argument. BYTE is no Char.", range: [SourceLocation { span: Range(TextLocation { line: 3, column: 57, offset: 212 }..TextLocation { line: 3, column: 58, offset: 213 }) }], err_no: type__invalid_nature } +SyntaxError { message: "Invalid assignment: cannot assign 'WORD' to 'CHAR'", range: [SourceLocation { span: Range(TextLocation { line: 4, column: 57, offset: 286 }..TextLocation { line: 4, column: 58, offset: 287 }) }], err_no: var__invalid_assignment } +SyntaxError { message: "Invalid type nature for generic argument. WORD is no Char.", range: [SourceLocation { span: Range(TextLocation { line: 4, column: 57, offset: 286 }..TextLocation { line: 4, column: 58, offset: 287 }) }], err_no: type__invalid_nature } +SyntaxError { message: "Invalid assignment: cannot assign 'DWORD' to 'CHAR'", range: [SourceLocation { span: Range(TextLocation { line: 5, column: 58, offset: 361 }..TextLocation { line: 5, column: 59, offset: 362 }) }], err_no: var__invalid_assignment } +SyntaxError { message: "Invalid type nature for generic argument. DWORD is no Char.", range: [SourceLocation { span: Range(TextLocation { line: 5, column: 58, offset: 361 }..TextLocation { line: 5, column: 59, offset: 362 }) }], err_no: type__invalid_nature } +SyntaxError { message: "Invalid assignment: cannot assign 'LWORD' to 'CHAR'", range: [SourceLocation { span: Range(TextLocation { line: 6, column: 58, offset: 436 }..TextLocation { line: 6, column: 59, offset: 437 }) }], err_no: var__invalid_assignment } +SyntaxError { message: "Invalid type nature for generic argument. LWORD is no Char.", range: [SourceLocation { span: Range(TextLocation { line: 6, column: 58, offset: 436 }..TextLocation { line: 6, column: 59, offset: 437 }) }], err_no: type__invalid_nature } diff --git a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_char_does_not_allow_date.snap b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_char_does_not_allow_date.snap index 1be04ad156..eff0b3584f 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_char_does_not_allow_date.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_char_does_not_allow_date.snap @@ -4,12 +4,12 @@ expression: res --- SyntaxError { message: "Invalid assignment: cannot assign 'DATE_AND_TIME' to 'CHAR'", range: [SourceLocation { span: Range(TextLocation { line: 2, column: 55, offset: 136 }..TextLocation { line: 2, column: 56, offset: 137 }) }], err_no: var__invalid_assignment } SyntaxError { message: "Invalid type nature for generic argument. DATE_AND_TIME is no Char.", range: [SourceLocation { span: Range(TextLocation { line: 2, column: 55, offset: 136 }..TextLocation { line: 2, column: 56, offset: 137 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid assignment: cannot assign 'DATE_AND_TIME' to 'CHAR'", range: [SourceLocation { span: Range(TextLocation { line: 3, column: 50, offset: 203 }..TextLocation { line: 3, column: 51, offset: 204 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid type nature for generic argument. DATE_AND_TIME is no Char.", range: [SourceLocation { span: Range(TextLocation { line: 3, column: 50, offset: 203 }..TextLocation { line: 3, column: 51, offset: 204 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid assignment: cannot assign 'DATE' to 'CHAR'", range: [SourceLocation { span: Range(TextLocation { line: 4, column: 51, offset: 271 }..TextLocation { line: 4, column: 52, offset: 272 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid type nature for generic argument. DATE is no Char.", range: [SourceLocation { span: Range(TextLocation { line: 4, column: 51, offset: 271 }..TextLocation { line: 4, column: 52, offset: 272 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid assignment: cannot assign 'TIME_OF_DAY' to 'CHAR'", range: [SourceLocation { span: Range(TextLocation { line: 5, column: 50, offset: 338 }..TextLocation { line: 5, column: 51, offset: 339 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid type nature for generic argument. TIME_OF_DAY is no Char.", range: [SourceLocation { span: Range(TextLocation { line: 5, column: 50, offset: 338 }..TextLocation { line: 5, column: 51, offset: 339 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid assignment: cannot assign 'TIME_OF_DAY' to 'CHAR'", range: [SourceLocation { span: Range(TextLocation { line: 6, column: 51, offset: 406 }..TextLocation { line: 6, column: 52, offset: 407 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid type nature for generic argument. TIME_OF_DAY is no Char.", range: [SourceLocation { span: Range(TextLocation { line: 6, column: 51, offset: 406 }..TextLocation { line: 6, column: 52, offset: 407 }) }], err_no: type__invalid_nature } +SyntaxError { message: "Invalid assignment: cannot assign 'DATE_AND_TIME' to 'CHAR'", range: [SourceLocation { span: Range(TextLocation { line: 3, column: 56, offset: 209 }..TextLocation { line: 3, column: 57, offset: 210 }) }], err_no: var__invalid_assignment } +SyntaxError { message: "Invalid type nature for generic argument. DATE_AND_TIME is no Char.", range: [SourceLocation { span: Range(TextLocation { line: 3, column: 56, offset: 209 }..TextLocation { line: 3, column: 57, offset: 210 }) }], err_no: type__invalid_nature } +SyntaxError { message: "Invalid assignment: cannot assign 'DATE' to 'CHAR'", range: [SourceLocation { span: Range(TextLocation { line: 4, column: 57, offset: 283 }..TextLocation { line: 4, column: 58, offset: 284 }) }], err_no: var__invalid_assignment } +SyntaxError { message: "Invalid type nature for generic argument. DATE is no Char.", range: [SourceLocation { span: Range(TextLocation { line: 4, column: 57, offset: 283 }..TextLocation { line: 4, column: 58, offset: 284 }) }], err_no: type__invalid_nature } +SyntaxError { message: "Invalid assignment: cannot assign 'TIME_OF_DAY' to 'CHAR'", range: [SourceLocation { span: Range(TextLocation { line: 5, column: 56, offset: 356 }..TextLocation { line: 5, column: 57, offset: 357 }) }], err_no: var__invalid_assignment } +SyntaxError { message: "Invalid type nature for generic argument. TIME_OF_DAY is no Char.", range: [SourceLocation { span: Range(TextLocation { line: 5, column: 56, offset: 356 }..TextLocation { line: 5, column: 57, offset: 357 }) }], err_no: type__invalid_nature } +SyntaxError { message: "Invalid assignment: cannot assign 'TIME_OF_DAY' to 'CHAR'", range: [SourceLocation { span: Range(TextLocation { line: 6, column: 57, offset: 430 }..TextLocation { line: 6, column: 58, offset: 431 }) }], err_no: var__invalid_assignment } +SyntaxError { message: "Invalid type nature for generic argument. TIME_OF_DAY is no Char.", range: [SourceLocation { span: Range(TextLocation { line: 6, column: 57, offset: 430 }..TextLocation { line: 6, column: 58, offset: 431 }) }], err_no: type__invalid_nature } diff --git a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_char_does_not_allow_ints.snap b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_char_does_not_allow_ints.snap index 1d08ddb86e..989627379e 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_char_does_not_allow_ints.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_char_does_not_allow_ints.snap @@ -2,20 +2,20 @@ source: src/validation/tests/generic_validation_tests.rs expression: res --- -SyntaxError { message: "Invalid assignment: cannot assign 'USINT' to 'CHAR'", range: [SourceLocation { span: Range(TextLocation { line: 3, column: 52, offset: 134 }..TextLocation { line: 3, column: 53, offset: 135 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid type nature for generic argument. USINT is no Char.", range: [SourceLocation { span: Range(TextLocation { line: 3, column: 52, offset: 134 }..TextLocation { line: 3, column: 53, offset: 135 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid assignment: cannot assign 'UINT' to 'CHAR'", range: [SourceLocation { span: Range(TextLocation { line: 4, column: 57, offset: 208 }..TextLocation { line: 4, column: 58, offset: 209 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid type nature for generic argument. UINT is no Char.", range: [SourceLocation { span: Range(TextLocation { line: 4, column: 57, offset: 208 }..TextLocation { line: 4, column: 58, offset: 209 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid assignment: cannot assign 'UDINT' to 'CHAR'", range: [SourceLocation { span: Range(TextLocation { line: 5, column: 52, offset: 277 }..TextLocation { line: 5, column: 53, offset: 278 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid type nature for generic argument. UDINT is no Char.", range: [SourceLocation { span: Range(TextLocation { line: 5, column: 52, offset: 277 }..TextLocation { line: 5, column: 53, offset: 278 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid assignment: cannot assign 'ULINT' to 'CHAR'", range: [SourceLocation { span: Range(TextLocation { line: 6, column: 52, offset: 346 }..TextLocation { line: 6, column: 53, offset: 347 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid type nature for generic argument. ULINT is no Char.", range: [SourceLocation { span: Range(TextLocation { line: 6, column: 52, offset: 346 }..TextLocation { line: 6, column: 53, offset: 347 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid assignment: cannot assign 'SINT' to 'CHAR'", range: [SourceLocation { span: Range(TextLocation { line: 8, column: 51, offset: 415 }..TextLocation { line: 8, column: 52, offset: 416 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid type nature for generic argument. SINT is no Char.", range: [SourceLocation { span: Range(TextLocation { line: 8, column: 51, offset: 415 }..TextLocation { line: 8, column: 52, offset: 416 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid assignment: cannot assign 'INT' to 'CHAR'", range: [SourceLocation { span: Range(TextLocation { line: 9, column: 56, offset: 488 }..TextLocation { line: 9, column: 57, offset: 489 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid type nature for generic argument. INT is no Char.", range: [SourceLocation { span: Range(TextLocation { line: 9, column: 56, offset: 488 }..TextLocation { line: 9, column: 57, offset: 489 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid assignment: cannot assign 'DINT' to 'CHAR'", range: [SourceLocation { span: Range(TextLocation { line: 10, column: 51, offset: 556 }..TextLocation { line: 10, column: 52, offset: 557 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid type nature for generic argument. DINT is no Char.", range: [SourceLocation { span: Range(TextLocation { line: 10, column: 51, offset: 556 }..TextLocation { line: 10, column: 52, offset: 557 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid assignment: cannot assign 'LINT' to 'CHAR'", range: [SourceLocation { span: Range(TextLocation { line: 11, column: 51, offset: 624 }..TextLocation { line: 11, column: 52, offset: 625 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid type nature for generic argument. LINT is no Char.", range: [SourceLocation { span: Range(TextLocation { line: 11, column: 51, offset: 624 }..TextLocation { line: 11, column: 52, offset: 625 }) }], err_no: type__invalid_nature } +SyntaxError { message: "Invalid assignment: cannot assign 'USINT' to 'CHAR'", range: [SourceLocation { span: Range(TextLocation { line: 3, column: 58, offset: 140 }..TextLocation { line: 3, column: 59, offset: 141 }) }], err_no: var__invalid_assignment } +SyntaxError { message: "Invalid type nature for generic argument. USINT is no Char.", range: [SourceLocation { span: Range(TextLocation { line: 3, column: 58, offset: 140 }..TextLocation { line: 3, column: 59, offset: 141 }) }], err_no: type__invalid_nature } +SyntaxError { message: "Invalid assignment: cannot assign 'UINT' to 'CHAR'", range: [SourceLocation { span: Range(TextLocation { line: 4, column: 57, offset: 214 }..TextLocation { line: 4, column: 58, offset: 215 }) }], err_no: var__invalid_assignment } +SyntaxError { message: "Invalid type nature for generic argument. UINT is no Char.", range: [SourceLocation { span: Range(TextLocation { line: 4, column: 57, offset: 214 }..TextLocation { line: 4, column: 58, offset: 215 }) }], err_no: type__invalid_nature } +SyntaxError { message: "Invalid assignment: cannot assign 'UDINT' to 'CHAR'", range: [SourceLocation { span: Range(TextLocation { line: 5, column: 58, offset: 289 }..TextLocation { line: 5, column: 59, offset: 290 }) }], err_no: var__invalid_assignment } +SyntaxError { message: "Invalid type nature for generic argument. UDINT is no Char.", range: [SourceLocation { span: Range(TextLocation { line: 5, column: 58, offset: 289 }..TextLocation { line: 5, column: 59, offset: 290 }) }], err_no: type__invalid_nature } +SyntaxError { message: "Invalid assignment: cannot assign 'ULINT' to 'CHAR'", range: [SourceLocation { span: Range(TextLocation { line: 6, column: 58, offset: 364 }..TextLocation { line: 6, column: 59, offset: 365 }) }], err_no: var__invalid_assignment } +SyntaxError { message: "Invalid type nature for generic argument. ULINT is no Char.", range: [SourceLocation { span: Range(TextLocation { line: 6, column: 58, offset: 364 }..TextLocation { line: 6, column: 59, offset: 365 }) }], err_no: type__invalid_nature } +SyntaxError { message: "Invalid assignment: cannot assign 'SINT' to 'CHAR'", range: [SourceLocation { span: Range(TextLocation { line: 8, column: 57, offset: 439 }..TextLocation { line: 8, column: 58, offset: 440 }) }], err_no: var__invalid_assignment } +SyntaxError { message: "Invalid type nature for generic argument. SINT is no Char.", range: [SourceLocation { span: Range(TextLocation { line: 8, column: 57, offset: 439 }..TextLocation { line: 8, column: 58, offset: 440 }) }], err_no: type__invalid_nature } +SyntaxError { message: "Invalid assignment: cannot assign 'INT' to 'CHAR'", range: [SourceLocation { span: Range(TextLocation { line: 9, column: 56, offset: 512 }..TextLocation { line: 9, column: 57, offset: 513 }) }], err_no: var__invalid_assignment } +SyntaxError { message: "Invalid type nature for generic argument. INT is no Char.", range: [SourceLocation { span: Range(TextLocation { line: 9, column: 56, offset: 512 }..TextLocation { line: 9, column: 57, offset: 513 }) }], err_no: type__invalid_nature } +SyntaxError { message: "Invalid assignment: cannot assign 'DINT' to 'CHAR'", range: [SourceLocation { span: Range(TextLocation { line: 10, column: 57, offset: 586 }..TextLocation { line: 10, column: 58, offset: 587 }) }], err_no: var__invalid_assignment } +SyntaxError { message: "Invalid type nature for generic argument. DINT is no Char.", range: [SourceLocation { span: Range(TextLocation { line: 10, column: 57, offset: 586 }..TextLocation { line: 10, column: 58, offset: 587 }) }], err_no: type__invalid_nature } +SyntaxError { message: "Invalid assignment: cannot assign 'LINT' to 'CHAR'", range: [SourceLocation { span: Range(TextLocation { line: 11, column: 57, offset: 660 }..TextLocation { line: 11, column: 58, offset: 661 }) }], err_no: var__invalid_assignment } +SyntaxError { message: "Invalid type nature for generic argument. LINT is no Char.", range: [SourceLocation { span: Range(TextLocation { line: 11, column: 57, offset: 660 }..TextLocation { line: 11, column: 58, offset: 661 }) }], err_no: type__invalid_nature } diff --git a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_char_does_not_allow_time.snap b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_char_does_not_allow_time.snap index 4344c341fc..0683c8046c 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_char_does_not_allow_time.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_char_does_not_allow_time.snap @@ -4,6 +4,6 @@ expression: res --- SyntaxError { message: "Invalid assignment: cannot assign 'TIME' to 'CHAR'", range: [SourceLocation { span: Range(TextLocation { line: 2, column: 57, offset: 138 }..TextLocation { line: 2, column: 58, offset: 139 }) }], err_no: var__invalid_assignment } SyntaxError { message: "Invalid type nature for generic argument. TIME is no Char.", range: [SourceLocation { span: Range(TextLocation { line: 2, column: 57, offset: 138 }..TextLocation { line: 2, column: 58, offset: 139 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid assignment: cannot assign 'TIME' to 'CHAR'", range: [SourceLocation { span: Range(TextLocation { line: 3, column: 52, offset: 207 }..TextLocation { line: 3, column: 53, offset: 208 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid type nature for generic argument. TIME is no Char.", range: [SourceLocation { span: Range(TextLocation { line: 3, column: 52, offset: 207 }..TextLocation { line: 3, column: 53, offset: 208 }) }], err_no: type__invalid_nature } +SyntaxError { message: "Invalid assignment: cannot assign 'TIME' to 'CHAR'", range: [SourceLocation { span: Range(TextLocation { line: 3, column: 58, offset: 213 }..TextLocation { line: 3, column: 59, offset: 214 }) }], err_no: var__invalid_assignment } +SyntaxError { message: "Invalid type nature for generic argument. TIME is no Char.", range: [SourceLocation { span: Range(TextLocation { line: 3, column: 58, offset: 213 }..TextLocation { line: 3, column: 59, offset: 214 }) }], err_no: type__invalid_nature } diff --git a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_chars_does_not_allow_bits.snap b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_chars_does_not_allow_bits.snap index 3659415195..8b5f560bb7 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_chars_does_not_allow_bits.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_chars_does_not_allow_bits.snap @@ -4,12 +4,12 @@ expression: res --- SyntaxError { message: "Invalid assignment: cannot assign 'BOOL' to 'CHAR'", range: [SourceLocation { span: Range(TextLocation { line: 2, column: 57, offset: 139 }..TextLocation { line: 2, column: 58, offset: 140 }) }], err_no: var__invalid_assignment } SyntaxError { message: "Invalid type nature for generic argument. BOOL is no Chars.", range: [SourceLocation { span: Range(TextLocation { line: 2, column: 57, offset: 139 }..TextLocation { line: 2, column: 58, offset: 140 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid assignment: cannot assign 'BYTE' to 'CHAR'", range: [SourceLocation { span: Range(TextLocation { line: 3, column: 51, offset: 207 }..TextLocation { line: 3, column: 52, offset: 208 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid type nature for generic argument. BYTE is no Chars.", range: [SourceLocation { span: Range(TextLocation { line: 3, column: 51, offset: 207 }..TextLocation { line: 3, column: 52, offset: 208 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid assignment: cannot assign 'WORD' to 'CHAR'", range: [SourceLocation { span: Range(TextLocation { line: 4, column: 51, offset: 275 }..TextLocation { line: 4, column: 52, offset: 276 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid type nature for generic argument. WORD is no Chars.", range: [SourceLocation { span: Range(TextLocation { line: 4, column: 51, offset: 275 }..TextLocation { line: 4, column: 52, offset: 276 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid assignment: cannot assign 'DWORD' to 'CHAR'", range: [SourceLocation { span: Range(TextLocation { line: 5, column: 52, offset: 344 }..TextLocation { line: 5, column: 53, offset: 345 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid type nature for generic argument. DWORD is no Chars.", range: [SourceLocation { span: Range(TextLocation { line: 5, column: 52, offset: 344 }..TextLocation { line: 5, column: 53, offset: 345 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid assignment: cannot assign 'LWORD' to 'CHAR'", range: [SourceLocation { span: Range(TextLocation { line: 6, column: 52, offset: 413 }..TextLocation { line: 6, column: 53, offset: 414 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid type nature for generic argument. LWORD is no Chars.", range: [SourceLocation { span: Range(TextLocation { line: 6, column: 52, offset: 413 }..TextLocation { line: 6, column: 53, offset: 414 }) }], err_no: type__invalid_nature } +SyntaxError { message: "Invalid assignment: cannot assign 'BYTE' to 'CHAR'", range: [SourceLocation { span: Range(TextLocation { line: 3, column: 57, offset: 213 }..TextLocation { line: 3, column: 58, offset: 214 }) }], err_no: var__invalid_assignment } +SyntaxError { message: "Invalid type nature for generic argument. BYTE is no Chars.", range: [SourceLocation { span: Range(TextLocation { line: 3, column: 57, offset: 213 }..TextLocation { line: 3, column: 58, offset: 214 }) }], err_no: type__invalid_nature } +SyntaxError { message: "Invalid assignment: cannot assign 'WORD' to 'CHAR'", range: [SourceLocation { span: Range(TextLocation { line: 4, column: 57, offset: 287 }..TextLocation { line: 4, column: 58, offset: 288 }) }], err_no: var__invalid_assignment } +SyntaxError { message: "Invalid type nature for generic argument. WORD is no Chars.", range: [SourceLocation { span: Range(TextLocation { line: 4, column: 57, offset: 287 }..TextLocation { line: 4, column: 58, offset: 288 }) }], err_no: type__invalid_nature } +SyntaxError { message: "Invalid assignment: cannot assign 'DWORD' to 'CHAR'", range: [SourceLocation { span: Range(TextLocation { line: 5, column: 58, offset: 362 }..TextLocation { line: 5, column: 59, offset: 363 }) }], err_no: var__invalid_assignment } +SyntaxError { message: "Invalid type nature for generic argument. DWORD is no Chars.", range: [SourceLocation { span: Range(TextLocation { line: 5, column: 58, offset: 362 }..TextLocation { line: 5, column: 59, offset: 363 }) }], err_no: type__invalid_nature } +SyntaxError { message: "Invalid assignment: cannot assign 'LWORD' to 'CHAR'", range: [SourceLocation { span: Range(TextLocation { line: 6, column: 58, offset: 437 }..TextLocation { line: 6, column: 59, offset: 438 }) }], err_no: var__invalid_assignment } +SyntaxError { message: "Invalid type nature for generic argument. LWORD is no Chars.", range: [SourceLocation { span: Range(TextLocation { line: 6, column: 58, offset: 437 }..TextLocation { line: 6, column: 59, offset: 438 }) }], err_no: type__invalid_nature } diff --git a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_chars_does_not_allow_date.snap b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_chars_does_not_allow_date.snap index da6dc67691..2d80369825 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_chars_does_not_allow_date.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_chars_does_not_allow_date.snap @@ -4,12 +4,12 @@ expression: res --- SyntaxError { message: "Invalid assignment: cannot assign 'DATE_AND_TIME' to 'CHAR'", range: [SourceLocation { span: Range(TextLocation { line: 2, column: 55, offset: 137 }..TextLocation { line: 2, column: 56, offset: 138 }) }], err_no: var__invalid_assignment } SyntaxError { message: "Invalid type nature for generic argument. DATE_AND_TIME is no Chars.", range: [SourceLocation { span: Range(TextLocation { line: 2, column: 55, offset: 137 }..TextLocation { line: 2, column: 56, offset: 138 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid assignment: cannot assign 'DATE_AND_TIME' to 'CHAR'", range: [SourceLocation { span: Range(TextLocation { line: 3, column: 50, offset: 204 }..TextLocation { line: 3, column: 51, offset: 205 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid type nature for generic argument. DATE_AND_TIME is no Chars.", range: [SourceLocation { span: Range(TextLocation { line: 3, column: 50, offset: 204 }..TextLocation { line: 3, column: 51, offset: 205 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid assignment: cannot assign 'DATE' to 'CHAR'", range: [SourceLocation { span: Range(TextLocation { line: 4, column: 51, offset: 272 }..TextLocation { line: 4, column: 52, offset: 273 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid type nature for generic argument. DATE is no Chars.", range: [SourceLocation { span: Range(TextLocation { line: 4, column: 51, offset: 272 }..TextLocation { line: 4, column: 52, offset: 273 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid assignment: cannot assign 'TIME_OF_DAY' to 'CHAR'", range: [SourceLocation { span: Range(TextLocation { line: 5, column: 50, offset: 339 }..TextLocation { line: 5, column: 51, offset: 340 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid type nature for generic argument. TIME_OF_DAY is no Chars.", range: [SourceLocation { span: Range(TextLocation { line: 5, column: 50, offset: 339 }..TextLocation { line: 5, column: 51, offset: 340 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid assignment: cannot assign 'TIME_OF_DAY' to 'CHAR'", range: [SourceLocation { span: Range(TextLocation { line: 6, column: 51, offset: 407 }..TextLocation { line: 6, column: 52, offset: 408 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid type nature for generic argument. TIME_OF_DAY is no Chars.", range: [SourceLocation { span: Range(TextLocation { line: 6, column: 51, offset: 407 }..TextLocation { line: 6, column: 52, offset: 408 }) }], err_no: type__invalid_nature } +SyntaxError { message: "Invalid assignment: cannot assign 'DATE_AND_TIME' to 'CHAR'", range: [SourceLocation { span: Range(TextLocation { line: 3, column: 56, offset: 210 }..TextLocation { line: 3, column: 57, offset: 211 }) }], err_no: var__invalid_assignment } +SyntaxError { message: "Invalid type nature for generic argument. DATE_AND_TIME is no Chars.", range: [SourceLocation { span: Range(TextLocation { line: 3, column: 56, offset: 210 }..TextLocation { line: 3, column: 57, offset: 211 }) }], err_no: type__invalid_nature } +SyntaxError { message: "Invalid assignment: cannot assign 'DATE' to 'CHAR'", range: [SourceLocation { span: Range(TextLocation { line: 4, column: 57, offset: 284 }..TextLocation { line: 4, column: 58, offset: 285 }) }], err_no: var__invalid_assignment } +SyntaxError { message: "Invalid type nature for generic argument. DATE is no Chars.", range: [SourceLocation { span: Range(TextLocation { line: 4, column: 57, offset: 284 }..TextLocation { line: 4, column: 58, offset: 285 }) }], err_no: type__invalid_nature } +SyntaxError { message: "Invalid assignment: cannot assign 'TIME_OF_DAY' to 'CHAR'", range: [SourceLocation { span: Range(TextLocation { line: 5, column: 56, offset: 357 }..TextLocation { line: 5, column: 57, offset: 358 }) }], err_no: var__invalid_assignment } +SyntaxError { message: "Invalid type nature for generic argument. TIME_OF_DAY is no Chars.", range: [SourceLocation { span: Range(TextLocation { line: 5, column: 56, offset: 357 }..TextLocation { line: 5, column: 57, offset: 358 }) }], err_no: type__invalid_nature } +SyntaxError { message: "Invalid assignment: cannot assign 'TIME_OF_DAY' to 'CHAR'", range: [SourceLocation { span: Range(TextLocation { line: 6, column: 57, offset: 431 }..TextLocation { line: 6, column: 58, offset: 432 }) }], err_no: var__invalid_assignment } +SyntaxError { message: "Invalid type nature for generic argument. TIME_OF_DAY is no Chars.", range: [SourceLocation { span: Range(TextLocation { line: 6, column: 57, offset: 431 }..TextLocation { line: 6, column: 58, offset: 432 }) }], err_no: type__invalid_nature } diff --git a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_chars_does_not_allow_ints.snap b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_chars_does_not_allow_ints.snap index 05f4c88d56..f5c8601f0b 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_chars_does_not_allow_ints.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_chars_does_not_allow_ints.snap @@ -2,20 +2,20 @@ source: src/validation/tests/generic_validation_tests.rs expression: res --- -SyntaxError { message: "Invalid assignment: cannot assign 'USINT' to 'CHAR'", range: [SourceLocation { span: Range(TextLocation { line: 3, column: 52, offset: 135 }..TextLocation { line: 3, column: 53, offset: 136 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid type nature for generic argument. USINT is no Chars.", range: [SourceLocation { span: Range(TextLocation { line: 3, column: 52, offset: 135 }..TextLocation { line: 3, column: 53, offset: 136 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid assignment: cannot assign 'UINT' to 'CHAR'", range: [SourceLocation { span: Range(TextLocation { line: 4, column: 57, offset: 209 }..TextLocation { line: 4, column: 58, offset: 210 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid type nature for generic argument. UINT is no Chars.", range: [SourceLocation { span: Range(TextLocation { line: 4, column: 57, offset: 209 }..TextLocation { line: 4, column: 58, offset: 210 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid assignment: cannot assign 'UDINT' to 'CHAR'", range: [SourceLocation { span: Range(TextLocation { line: 5, column: 52, offset: 278 }..TextLocation { line: 5, column: 53, offset: 279 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid type nature for generic argument. UDINT is no Chars.", range: [SourceLocation { span: Range(TextLocation { line: 5, column: 52, offset: 278 }..TextLocation { line: 5, column: 53, offset: 279 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid assignment: cannot assign 'ULINT' to 'CHAR'", range: [SourceLocation { span: Range(TextLocation { line: 6, column: 52, offset: 347 }..TextLocation { line: 6, column: 53, offset: 348 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid type nature for generic argument. ULINT is no Chars.", range: [SourceLocation { span: Range(TextLocation { line: 6, column: 52, offset: 347 }..TextLocation { line: 6, column: 53, offset: 348 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid assignment: cannot assign 'SINT' to 'CHAR'", range: [SourceLocation { span: Range(TextLocation { line: 8, column: 51, offset: 416 }..TextLocation { line: 8, column: 52, offset: 417 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid type nature for generic argument. SINT is no Chars.", range: [SourceLocation { span: Range(TextLocation { line: 8, column: 51, offset: 416 }..TextLocation { line: 8, column: 52, offset: 417 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid assignment: cannot assign 'INT' to 'CHAR'", range: [SourceLocation { span: Range(TextLocation { line: 9, column: 56, offset: 489 }..TextLocation { line: 9, column: 57, offset: 490 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid type nature for generic argument. INT is no Chars.", range: [SourceLocation { span: Range(TextLocation { line: 9, column: 56, offset: 489 }..TextLocation { line: 9, column: 57, offset: 490 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid assignment: cannot assign 'DINT' to 'CHAR'", range: [SourceLocation { span: Range(TextLocation { line: 10, column: 51, offset: 557 }..TextLocation { line: 10, column: 52, offset: 558 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid type nature for generic argument. DINT is no Chars.", range: [SourceLocation { span: Range(TextLocation { line: 10, column: 51, offset: 557 }..TextLocation { line: 10, column: 52, offset: 558 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid assignment: cannot assign 'LINT' to 'CHAR'", range: [SourceLocation { span: Range(TextLocation { line: 11, column: 51, offset: 625 }..TextLocation { line: 11, column: 52, offset: 626 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid type nature for generic argument. LINT is no Chars.", range: [SourceLocation { span: Range(TextLocation { line: 11, column: 51, offset: 625 }..TextLocation { line: 11, column: 52, offset: 626 }) }], err_no: type__invalid_nature } +SyntaxError { message: "Invalid assignment: cannot assign 'USINT' to 'CHAR'", range: [SourceLocation { span: Range(TextLocation { line: 3, column: 58, offset: 141 }..TextLocation { line: 3, column: 59, offset: 142 }) }], err_no: var__invalid_assignment } +SyntaxError { message: "Invalid type nature for generic argument. USINT is no Chars.", range: [SourceLocation { span: Range(TextLocation { line: 3, column: 58, offset: 141 }..TextLocation { line: 3, column: 59, offset: 142 }) }], err_no: type__invalid_nature } +SyntaxError { message: "Invalid assignment: cannot assign 'UINT' to 'CHAR'", range: [SourceLocation { span: Range(TextLocation { line: 4, column: 57, offset: 215 }..TextLocation { line: 4, column: 58, offset: 216 }) }], err_no: var__invalid_assignment } +SyntaxError { message: "Invalid type nature for generic argument. UINT is no Chars.", range: [SourceLocation { span: Range(TextLocation { line: 4, column: 57, offset: 215 }..TextLocation { line: 4, column: 58, offset: 216 }) }], err_no: type__invalid_nature } +SyntaxError { message: "Invalid assignment: cannot assign 'UDINT' to 'CHAR'", range: [SourceLocation { span: Range(TextLocation { line: 5, column: 58, offset: 290 }..TextLocation { line: 5, column: 59, offset: 291 }) }], err_no: var__invalid_assignment } +SyntaxError { message: "Invalid type nature for generic argument. UDINT is no Chars.", range: [SourceLocation { span: Range(TextLocation { line: 5, column: 58, offset: 290 }..TextLocation { line: 5, column: 59, offset: 291 }) }], err_no: type__invalid_nature } +SyntaxError { message: "Invalid assignment: cannot assign 'ULINT' to 'CHAR'", range: [SourceLocation { span: Range(TextLocation { line: 6, column: 58, offset: 365 }..TextLocation { line: 6, column: 59, offset: 366 }) }], err_no: var__invalid_assignment } +SyntaxError { message: "Invalid type nature for generic argument. ULINT is no Chars.", range: [SourceLocation { span: Range(TextLocation { line: 6, column: 58, offset: 365 }..TextLocation { line: 6, column: 59, offset: 366 }) }], err_no: type__invalid_nature } +SyntaxError { message: "Invalid assignment: cannot assign 'SINT' to 'CHAR'", range: [SourceLocation { span: Range(TextLocation { line: 8, column: 57, offset: 440 }..TextLocation { line: 8, column: 58, offset: 441 }) }], err_no: var__invalid_assignment } +SyntaxError { message: "Invalid type nature for generic argument. SINT is no Chars.", range: [SourceLocation { span: Range(TextLocation { line: 8, column: 57, offset: 440 }..TextLocation { line: 8, column: 58, offset: 441 }) }], err_no: type__invalid_nature } +SyntaxError { message: "Invalid assignment: cannot assign 'INT' to 'CHAR'", range: [SourceLocation { span: Range(TextLocation { line: 9, column: 56, offset: 513 }..TextLocation { line: 9, column: 57, offset: 514 }) }], err_no: var__invalid_assignment } +SyntaxError { message: "Invalid type nature for generic argument. INT is no Chars.", range: [SourceLocation { span: Range(TextLocation { line: 9, column: 56, offset: 513 }..TextLocation { line: 9, column: 57, offset: 514 }) }], err_no: type__invalid_nature } +SyntaxError { message: "Invalid assignment: cannot assign 'DINT' to 'CHAR'", range: [SourceLocation { span: Range(TextLocation { line: 10, column: 57, offset: 587 }..TextLocation { line: 10, column: 58, offset: 588 }) }], err_no: var__invalid_assignment } +SyntaxError { message: "Invalid type nature for generic argument. DINT is no Chars.", range: [SourceLocation { span: Range(TextLocation { line: 10, column: 57, offset: 587 }..TextLocation { line: 10, column: 58, offset: 588 }) }], err_no: type__invalid_nature } +SyntaxError { message: "Invalid assignment: cannot assign 'LINT' to 'CHAR'", range: [SourceLocation { span: Range(TextLocation { line: 11, column: 57, offset: 661 }..TextLocation { line: 11, column: 58, offset: 662 }) }], err_no: var__invalid_assignment } +SyntaxError { message: "Invalid type nature for generic argument. LINT is no Chars.", range: [SourceLocation { span: Range(TextLocation { line: 11, column: 57, offset: 661 }..TextLocation { line: 11, column: 58, offset: 662 }) }], err_no: type__invalid_nature } diff --git a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_chars_does_not_allow_time.snap b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_chars_does_not_allow_time.snap index d1114fec01..1c2fceb8c2 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_chars_does_not_allow_time.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_chars_does_not_allow_time.snap @@ -4,6 +4,6 @@ expression: res --- SyntaxError { message: "Invalid assignment: cannot assign 'TIME' to 'CHAR'", range: [SourceLocation { span: Range(TextLocation { line: 2, column: 57, offset: 139 }..TextLocation { line: 2, column: 58, offset: 140 }) }], err_no: var__invalid_assignment } SyntaxError { message: "Invalid type nature for generic argument. TIME is no Chars.", range: [SourceLocation { span: Range(TextLocation { line: 2, column: 57, offset: 139 }..TextLocation { line: 2, column: 58, offset: 140 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid assignment: cannot assign 'TIME' to 'CHAR'", range: [SourceLocation { span: Range(TextLocation { line: 3, column: 52, offset: 208 }..TextLocation { line: 3, column: 53, offset: 209 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid type nature for generic argument. TIME is no Chars.", range: [SourceLocation { span: Range(TextLocation { line: 3, column: 52, offset: 208 }..TextLocation { line: 3, column: 53, offset: 209 }) }], err_no: type__invalid_nature } +SyntaxError { message: "Invalid assignment: cannot assign 'TIME' to 'CHAR'", range: [SourceLocation { span: Range(TextLocation { line: 3, column: 58, offset: 214 }..TextLocation { line: 3, column: 59, offset: 215 }) }], err_no: var__invalid_assignment } +SyntaxError { message: "Invalid type nature for generic argument. TIME is no Chars.", range: [SourceLocation { span: Range(TextLocation { line: 3, column: 58, offset: 214 }..TextLocation { line: 3, column: 59, offset: 215 }) }], err_no: type__invalid_nature } diff --git a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_date_does_not_allow_bits.snap b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_date_does_not_allow_bits.snap index 9a502a838e..65ab24f356 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_date_does_not_allow_bits.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_date_does_not_allow_bits.snap @@ -3,8 +3,8 @@ source: src/validation/tests/generic_validation_tests.rs expression: res --- SyntaxError { message: "Invalid type nature for generic argument. BOOL is no Date.", range: [SourceLocation { span: Range(TextLocation { line: 2, column: 57, offset: 138 }..TextLocation { line: 2, column: 58, offset: 139 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid type nature for generic argument. BYTE is no Date.", range: [SourceLocation { span: Range(TextLocation { line: 3, column: 51, offset: 206 }..TextLocation { line: 3, column: 52, offset: 207 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid type nature for generic argument. WORD is no Date.", range: [SourceLocation { span: Range(TextLocation { line: 4, column: 51, offset: 274 }..TextLocation { line: 4, column: 52, offset: 275 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid type nature for generic argument. DWORD is no Date.", range: [SourceLocation { span: Range(TextLocation { line: 5, column: 52, offset: 343 }..TextLocation { line: 5, column: 53, offset: 344 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid type nature for generic argument. LWORD is no Date.", range: [SourceLocation { span: Range(TextLocation { line: 6, column: 52, offset: 412 }..TextLocation { line: 6, column: 53, offset: 413 }) }], err_no: type__invalid_nature } +SyntaxError { message: "Invalid type nature for generic argument. BYTE is no Date.", range: [SourceLocation { span: Range(TextLocation { line: 3, column: 57, offset: 212 }..TextLocation { line: 3, column: 58, offset: 213 }) }], err_no: type__invalid_nature } +SyntaxError { message: "Invalid type nature for generic argument. WORD is no Date.", range: [SourceLocation { span: Range(TextLocation { line: 4, column: 57, offset: 286 }..TextLocation { line: 4, column: 58, offset: 287 }) }], err_no: type__invalid_nature } +SyntaxError { message: "Invalid type nature for generic argument. DWORD is no Date.", range: [SourceLocation { span: Range(TextLocation { line: 5, column: 58, offset: 361 }..TextLocation { line: 5, column: 59, offset: 362 }) }], err_no: type__invalid_nature } +SyntaxError { message: "Invalid type nature for generic argument. LWORD is no Date.", range: [SourceLocation { span: Range(TextLocation { line: 6, column: 58, offset: 436 }..TextLocation { line: 6, column: 59, offset: 437 }) }], err_no: type__invalid_nature } diff --git a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_date_does_not_allow_chars.snap b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_date_does_not_allow_chars.snap index 9bd1db826f..9e8bbce461 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_date_does_not_allow_chars.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_date_does_not_allow_chars.snap @@ -4,6 +4,6 @@ expression: res --- SyntaxError { message: "Invalid assignment: cannot assign 'CHAR' to 'DATE'", range: [SourceLocation { span: Range(TextLocation { line: 2, column: 57, offset: 138 }..TextLocation { line: 2, column: 58, offset: 139 }) }], err_no: var__invalid_assignment } SyntaxError { message: "Invalid type nature for generic argument. CHAR is no Date.", range: [SourceLocation { span: Range(TextLocation { line: 2, column: 57, offset: 138 }..TextLocation { line: 2, column: 58, offset: 139 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid assignment: cannot assign 'WCHAR' to 'DATE'", range: [SourceLocation { span: Range(TextLocation { line: 3, column: 52, offset: 207 }..TextLocation { line: 3, column: 53, offset: 208 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid type nature for generic argument. WCHAR is no Date.", range: [SourceLocation { span: Range(TextLocation { line: 3, column: 52, offset: 207 }..TextLocation { line: 3, column: 53, offset: 208 }) }], err_no: type__invalid_nature } +SyntaxError { message: "Invalid assignment: cannot assign 'WCHAR' to 'DATE'", range: [SourceLocation { span: Range(TextLocation { line: 3, column: 58, offset: 213 }..TextLocation { line: 3, column: 59, offset: 214 }) }], err_no: var__invalid_assignment } +SyntaxError { message: "Invalid type nature for generic argument. WCHAR is no Date.", range: [SourceLocation { span: Range(TextLocation { line: 3, column: 58, offset: 213 }..TextLocation { line: 3, column: 59, offset: 214 }) }], err_no: type__invalid_nature } diff --git a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_date_does_not_allow_ints.snap b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_date_does_not_allow_ints.snap index ad82e89f3f..41fce0ed7d 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_date_does_not_allow_ints.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_date_does_not_allow_ints.snap @@ -2,12 +2,12 @@ source: src/validation/tests/generic_validation_tests.rs expression: res --- -SyntaxError { message: "Invalid type nature for generic argument. USINT is no Date.", range: [SourceLocation { span: Range(TextLocation { line: 3, column: 52, offset: 134 }..TextLocation { line: 3, column: 53, offset: 135 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid type nature for generic argument. UINT is no Date.", range: [SourceLocation { span: Range(TextLocation { line: 4, column: 57, offset: 208 }..TextLocation { line: 4, column: 58, offset: 209 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid type nature for generic argument. UDINT is no Date.", range: [SourceLocation { span: Range(TextLocation { line: 5, column: 52, offset: 277 }..TextLocation { line: 5, column: 53, offset: 278 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid type nature for generic argument. ULINT is no Date.", range: [SourceLocation { span: Range(TextLocation { line: 6, column: 52, offset: 346 }..TextLocation { line: 6, column: 53, offset: 347 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid type nature for generic argument. SINT is no Date.", range: [SourceLocation { span: Range(TextLocation { line: 8, column: 51, offset: 415 }..TextLocation { line: 8, column: 52, offset: 416 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid type nature for generic argument. INT is no Date.", range: [SourceLocation { span: Range(TextLocation { line: 9, column: 56, offset: 488 }..TextLocation { line: 9, column: 57, offset: 489 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid type nature for generic argument. DINT is no Date.", range: [SourceLocation { span: Range(TextLocation { line: 10, column: 51, offset: 556 }..TextLocation { line: 10, column: 52, offset: 557 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid type nature for generic argument. LINT is no Date.", range: [SourceLocation { span: Range(TextLocation { line: 11, column: 51, offset: 624 }..TextLocation { line: 11, column: 52, offset: 625 }) }], err_no: type__invalid_nature } +SyntaxError { message: "Invalid type nature for generic argument. USINT is no Date.", range: [SourceLocation { span: Range(TextLocation { line: 3, column: 58, offset: 140 }..TextLocation { line: 3, column: 59, offset: 141 }) }], err_no: type__invalid_nature } +SyntaxError { message: "Invalid type nature for generic argument. UINT is no Date.", range: [SourceLocation { span: Range(TextLocation { line: 4, column: 57, offset: 214 }..TextLocation { line: 4, column: 58, offset: 215 }) }], err_no: type__invalid_nature } +SyntaxError { message: "Invalid type nature for generic argument. UDINT is no Date.", range: [SourceLocation { span: Range(TextLocation { line: 5, column: 58, offset: 289 }..TextLocation { line: 5, column: 59, offset: 290 }) }], err_no: type__invalid_nature } +SyntaxError { message: "Invalid type nature for generic argument. ULINT is no Date.", range: [SourceLocation { span: Range(TextLocation { line: 6, column: 58, offset: 364 }..TextLocation { line: 6, column: 59, offset: 365 }) }], err_no: type__invalid_nature } +SyntaxError { message: "Invalid type nature for generic argument. SINT is no Date.", range: [SourceLocation { span: Range(TextLocation { line: 8, column: 57, offset: 439 }..TextLocation { line: 8, column: 58, offset: 440 }) }], err_no: type__invalid_nature } +SyntaxError { message: "Invalid type nature for generic argument. INT is no Date.", range: [SourceLocation { span: Range(TextLocation { line: 9, column: 56, offset: 512 }..TextLocation { line: 9, column: 57, offset: 513 }) }], err_no: type__invalid_nature } +SyntaxError { message: "Invalid type nature for generic argument. DINT is no Date.", range: [SourceLocation { span: Range(TextLocation { line: 10, column: 57, offset: 586 }..TextLocation { line: 10, column: 58, offset: 587 }) }], err_no: type__invalid_nature } +SyntaxError { message: "Invalid type nature for generic argument. LINT is no Date.", range: [SourceLocation { span: Range(TextLocation { line: 11, column: 57, offset: 660 }..TextLocation { line: 11, column: 58, offset: 661 }) }], err_no: type__invalid_nature } diff --git a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_date_does_not_allow_time.snap b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_date_does_not_allow_time.snap index 97a763d929..4dd3ed2327 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_date_does_not_allow_time.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_date_does_not_allow_time.snap @@ -3,5 +3,5 @@ source: src/validation/tests/generic_validation_tests.rs expression: res --- SyntaxError { message: "Invalid type nature for generic argument. TIME is no Date.", range: [SourceLocation { span: Range(TextLocation { line: 2, column: 57, offset: 138 }..TextLocation { line: 2, column: 58, offset: 139 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid type nature for generic argument. TIME is no Date.", range: [SourceLocation { span: Range(TextLocation { line: 3, column: 52, offset: 207 }..TextLocation { line: 3, column: 53, offset: 208 }) }], err_no: type__invalid_nature } +SyntaxError { message: "Invalid type nature for generic argument. TIME is no Date.", range: [SourceLocation { span: Range(TextLocation { line: 3, column: 58, offset: 213 }..TextLocation { line: 3, column: 59, offset: 214 }) }], err_no: type__invalid_nature } diff --git a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_duration_does_not_allow_bits.snap b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_duration_does_not_allow_bits.snap index 26d980f897..4879a7153e 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_duration_does_not_allow_bits.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_duration_does_not_allow_bits.snap @@ -3,8 +3,8 @@ source: src/validation/tests/generic_validation_tests.rs expression: res --- SyntaxError { message: "Invalid type nature for generic argument. BOOL is no Duration.", range: [SourceLocation { span: Range(TextLocation { line: 2, column: 57, offset: 142 }..TextLocation { line: 2, column: 58, offset: 143 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid type nature for generic argument. BYTE is no Duration.", range: [SourceLocation { span: Range(TextLocation { line: 3, column: 51, offset: 210 }..TextLocation { line: 3, column: 52, offset: 211 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid type nature for generic argument. WORD is no Duration.", range: [SourceLocation { span: Range(TextLocation { line: 4, column: 51, offset: 278 }..TextLocation { line: 4, column: 52, offset: 279 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid type nature for generic argument. DWORD is no Duration.", range: [SourceLocation { span: Range(TextLocation { line: 5, column: 52, offset: 347 }..TextLocation { line: 5, column: 53, offset: 348 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid type nature for generic argument. LWORD is no Duration.", range: [SourceLocation { span: Range(TextLocation { line: 6, column: 52, offset: 416 }..TextLocation { line: 6, column: 53, offset: 417 }) }], err_no: type__invalid_nature } +SyntaxError { message: "Invalid type nature for generic argument. BYTE is no Duration.", range: [SourceLocation { span: Range(TextLocation { line: 3, column: 57, offset: 216 }..TextLocation { line: 3, column: 58, offset: 217 }) }], err_no: type__invalid_nature } +SyntaxError { message: "Invalid type nature for generic argument. WORD is no Duration.", range: [SourceLocation { span: Range(TextLocation { line: 4, column: 57, offset: 290 }..TextLocation { line: 4, column: 58, offset: 291 }) }], err_no: type__invalid_nature } +SyntaxError { message: "Invalid type nature for generic argument. DWORD is no Duration.", range: [SourceLocation { span: Range(TextLocation { line: 5, column: 58, offset: 365 }..TextLocation { line: 5, column: 59, offset: 366 }) }], err_no: type__invalid_nature } +SyntaxError { message: "Invalid type nature for generic argument. LWORD is no Duration.", range: [SourceLocation { span: Range(TextLocation { line: 6, column: 58, offset: 440 }..TextLocation { line: 6, column: 59, offset: 441 }) }], err_no: type__invalid_nature } diff --git a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_duration_does_not_allow_chars.snap b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_duration_does_not_allow_chars.snap index b9e6712662..c338874d39 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_duration_does_not_allow_chars.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_duration_does_not_allow_chars.snap @@ -4,6 +4,6 @@ expression: res --- SyntaxError { message: "Invalid assignment: cannot assign 'CHAR' to 'TIME'", range: [SourceLocation { span: Range(TextLocation { line: 2, column: 57, offset: 142 }..TextLocation { line: 2, column: 58, offset: 143 }) }], err_no: var__invalid_assignment } SyntaxError { message: "Invalid type nature for generic argument. CHAR is no Duration.", range: [SourceLocation { span: Range(TextLocation { line: 2, column: 57, offset: 142 }..TextLocation { line: 2, column: 58, offset: 143 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid assignment: cannot assign 'WCHAR' to 'TIME'", range: [SourceLocation { span: Range(TextLocation { line: 3, column: 52, offset: 211 }..TextLocation { line: 3, column: 53, offset: 212 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid type nature for generic argument. WCHAR is no Duration.", range: [SourceLocation { span: Range(TextLocation { line: 3, column: 52, offset: 211 }..TextLocation { line: 3, column: 53, offset: 212 }) }], err_no: type__invalid_nature } +SyntaxError { message: "Invalid assignment: cannot assign 'WCHAR' to 'TIME'", range: [SourceLocation { span: Range(TextLocation { line: 3, column: 58, offset: 217 }..TextLocation { line: 3, column: 59, offset: 218 }) }], err_no: var__invalid_assignment } +SyntaxError { message: "Invalid type nature for generic argument. WCHAR is no Duration.", range: [SourceLocation { span: Range(TextLocation { line: 3, column: 58, offset: 217 }..TextLocation { line: 3, column: 59, offset: 218 }) }], err_no: type__invalid_nature } diff --git a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_duration_does_not_allow_date.snap b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_duration_does_not_allow_date.snap index 798797a67d..ee99dbfb04 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_duration_does_not_allow_date.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_duration_does_not_allow_date.snap @@ -3,8 +3,8 @@ source: src/validation/tests/generic_validation_tests.rs expression: res --- SyntaxError { message: "Invalid type nature for generic argument. DATE_AND_TIME is no Duration.", range: [SourceLocation { span: Range(TextLocation { line: 2, column: 55, offset: 140 }..TextLocation { line: 2, column: 56, offset: 141 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid type nature for generic argument. DATE_AND_TIME is no Duration.", range: [SourceLocation { span: Range(TextLocation { line: 3, column: 50, offset: 207 }..TextLocation { line: 3, column: 51, offset: 208 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid type nature for generic argument. DATE is no Duration.", range: [SourceLocation { span: Range(TextLocation { line: 4, column: 51, offset: 275 }..TextLocation { line: 4, column: 52, offset: 276 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid type nature for generic argument. TIME_OF_DAY is no Duration.", range: [SourceLocation { span: Range(TextLocation { line: 5, column: 50, offset: 342 }..TextLocation { line: 5, column: 51, offset: 343 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid type nature for generic argument. TIME_OF_DAY is no Duration.", range: [SourceLocation { span: Range(TextLocation { line: 6, column: 51, offset: 410 }..TextLocation { line: 6, column: 52, offset: 411 }) }], err_no: type__invalid_nature } +SyntaxError { message: "Invalid type nature for generic argument. DATE_AND_TIME is no Duration.", range: [SourceLocation { span: Range(TextLocation { line: 3, column: 56, offset: 213 }..TextLocation { line: 3, column: 57, offset: 214 }) }], err_no: type__invalid_nature } +SyntaxError { message: "Invalid type nature for generic argument. DATE is no Duration.", range: [SourceLocation { span: Range(TextLocation { line: 4, column: 57, offset: 287 }..TextLocation { line: 4, column: 58, offset: 288 }) }], err_no: type__invalid_nature } +SyntaxError { message: "Invalid type nature for generic argument. TIME_OF_DAY is no Duration.", range: [SourceLocation { span: Range(TextLocation { line: 5, column: 56, offset: 360 }..TextLocation { line: 5, column: 57, offset: 361 }) }], err_no: type__invalid_nature } +SyntaxError { message: "Invalid type nature for generic argument. TIME_OF_DAY is no Duration.", range: [SourceLocation { span: Range(TextLocation { line: 6, column: 57, offset: 434 }..TextLocation { line: 6, column: 58, offset: 435 }) }], err_no: type__invalid_nature } diff --git a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_duration_does_not_allow_ints.snap b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_duration_does_not_allow_ints.snap index 693b346c10..d4123709c4 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_duration_does_not_allow_ints.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_duration_does_not_allow_ints.snap @@ -2,12 +2,12 @@ source: src/validation/tests/generic_validation_tests.rs expression: res --- -SyntaxError { message: "Invalid type nature for generic argument. USINT is no Duration.", range: [SourceLocation { span: Range(TextLocation { line: 3, column: 52, offset: 138 }..TextLocation { line: 3, column: 53, offset: 139 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid type nature for generic argument. UINT is no Duration.", range: [SourceLocation { span: Range(TextLocation { line: 4, column: 57, offset: 212 }..TextLocation { line: 4, column: 58, offset: 213 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid type nature for generic argument. UDINT is no Duration.", range: [SourceLocation { span: Range(TextLocation { line: 5, column: 52, offset: 281 }..TextLocation { line: 5, column: 53, offset: 282 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid type nature for generic argument. ULINT is no Duration.", range: [SourceLocation { span: Range(TextLocation { line: 6, column: 52, offset: 350 }..TextLocation { line: 6, column: 53, offset: 351 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid type nature for generic argument. SINT is no Duration.", range: [SourceLocation { span: Range(TextLocation { line: 8, column: 51, offset: 419 }..TextLocation { line: 8, column: 52, offset: 420 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid type nature for generic argument. INT is no Duration.", range: [SourceLocation { span: Range(TextLocation { line: 9, column: 56, offset: 492 }..TextLocation { line: 9, column: 57, offset: 493 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid type nature for generic argument. DINT is no Duration.", range: [SourceLocation { span: Range(TextLocation { line: 10, column: 51, offset: 560 }..TextLocation { line: 10, column: 52, offset: 561 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid type nature for generic argument. LINT is no Duration.", range: [SourceLocation { span: Range(TextLocation { line: 11, column: 51, offset: 628 }..TextLocation { line: 11, column: 52, offset: 629 }) }], err_no: type__invalid_nature } +SyntaxError { message: "Invalid type nature for generic argument. USINT is no Duration.", range: [SourceLocation { span: Range(TextLocation { line: 3, column: 58, offset: 144 }..TextLocation { line: 3, column: 59, offset: 145 }) }], err_no: type__invalid_nature } +SyntaxError { message: "Invalid type nature for generic argument. UINT is no Duration.", range: [SourceLocation { span: Range(TextLocation { line: 4, column: 57, offset: 218 }..TextLocation { line: 4, column: 58, offset: 219 }) }], err_no: type__invalid_nature } +SyntaxError { message: "Invalid type nature for generic argument. UDINT is no Duration.", range: [SourceLocation { span: Range(TextLocation { line: 5, column: 58, offset: 293 }..TextLocation { line: 5, column: 59, offset: 294 }) }], err_no: type__invalid_nature } +SyntaxError { message: "Invalid type nature for generic argument. ULINT is no Duration.", range: [SourceLocation { span: Range(TextLocation { line: 6, column: 58, offset: 368 }..TextLocation { line: 6, column: 59, offset: 369 }) }], err_no: type__invalid_nature } +SyntaxError { message: "Invalid type nature for generic argument. SINT is no Duration.", range: [SourceLocation { span: Range(TextLocation { line: 8, column: 57, offset: 443 }..TextLocation { line: 8, column: 58, offset: 444 }) }], err_no: type__invalid_nature } +SyntaxError { message: "Invalid type nature for generic argument. INT is no Duration.", range: [SourceLocation { span: Range(TextLocation { line: 9, column: 56, offset: 516 }..TextLocation { line: 9, column: 57, offset: 517 }) }], err_no: type__invalid_nature } +SyntaxError { message: "Invalid type nature for generic argument. DINT is no Duration.", range: [SourceLocation { span: Range(TextLocation { line: 10, column: 57, offset: 590 }..TextLocation { line: 10, column: 58, offset: 591 }) }], err_no: type__invalid_nature } +SyntaxError { message: "Invalid type nature for generic argument. LINT is no Duration.", range: [SourceLocation { span: Range(TextLocation { line: 11, column: 57, offset: 664 }..TextLocation { line: 11, column: 58, offset: 665 }) }], err_no: type__invalid_nature } diff --git a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_int_does_not_allow_bits.snap b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_int_does_not_allow_bits.snap index 1f95e0c757..e4892529d3 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_int_does_not_allow_bits.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_int_does_not_allow_bits.snap @@ -3,8 +3,8 @@ source: src/validation/tests/generic_validation_tests.rs expression: res --- SyntaxError { message: "Invalid type nature for generic argument. BOOL is no Int.", range: [SourceLocation { span: Range(TextLocation { line: 2, column: 57, offset: 137 }..TextLocation { line: 2, column: 58, offset: 138 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid type nature for generic argument. BYTE is no Int.", range: [SourceLocation { span: Range(TextLocation { line: 3, column: 51, offset: 205 }..TextLocation { line: 3, column: 52, offset: 206 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid type nature for generic argument. WORD is no Int.", range: [SourceLocation { span: Range(TextLocation { line: 4, column: 51, offset: 273 }..TextLocation { line: 4, column: 52, offset: 274 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid type nature for generic argument. DWORD is no Int.", range: [SourceLocation { span: Range(TextLocation { line: 5, column: 52, offset: 342 }..TextLocation { line: 5, column: 53, offset: 343 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid type nature for generic argument. LWORD is no Int.", range: [SourceLocation { span: Range(TextLocation { line: 6, column: 52, offset: 411 }..TextLocation { line: 6, column: 53, offset: 412 }) }], err_no: type__invalid_nature } +SyntaxError { message: "Invalid type nature for generic argument. BYTE is no Int.", range: [SourceLocation { span: Range(TextLocation { line: 3, column: 57, offset: 211 }..TextLocation { line: 3, column: 58, offset: 212 }) }], err_no: type__invalid_nature } +SyntaxError { message: "Invalid type nature for generic argument. WORD is no Int.", range: [SourceLocation { span: Range(TextLocation { line: 4, column: 57, offset: 285 }..TextLocation { line: 4, column: 58, offset: 286 }) }], err_no: type__invalid_nature } +SyntaxError { message: "Invalid type nature for generic argument. DWORD is no Int.", range: [SourceLocation { span: Range(TextLocation { line: 5, column: 58, offset: 360 }..TextLocation { line: 5, column: 59, offset: 361 }) }], err_no: type__invalid_nature } +SyntaxError { message: "Invalid type nature for generic argument. LWORD is no Int.", range: [SourceLocation { span: Range(TextLocation { line: 6, column: 58, offset: 435 }..TextLocation { line: 6, column: 59, offset: 436 }) }], err_no: type__invalid_nature } diff --git a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_int_does_not_allow_chars.snap b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_int_does_not_allow_chars.snap index 4b73ac753d..f02d63128b 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_int_does_not_allow_chars.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_int_does_not_allow_chars.snap @@ -4,6 +4,6 @@ expression: res --- SyntaxError { message: "Invalid assignment: cannot assign 'CHAR' to 'USINT'", range: [SourceLocation { span: Range(TextLocation { line: 2, column: 57, offset: 137 }..TextLocation { line: 2, column: 58, offset: 138 }) }], err_no: var__invalid_assignment } SyntaxError { message: "Invalid type nature for generic argument. CHAR is no Int.", range: [SourceLocation { span: Range(TextLocation { line: 2, column: 57, offset: 137 }..TextLocation { line: 2, column: 58, offset: 138 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid assignment: cannot assign 'WCHAR' to 'USINT'", range: [SourceLocation { span: Range(TextLocation { line: 3, column: 52, offset: 206 }..TextLocation { line: 3, column: 53, offset: 207 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid type nature for generic argument. WCHAR is no Int.", range: [SourceLocation { span: Range(TextLocation { line: 3, column: 52, offset: 206 }..TextLocation { line: 3, column: 53, offset: 207 }) }], err_no: type__invalid_nature } +SyntaxError { message: "Invalid assignment: cannot assign 'WCHAR' to 'USINT'", range: [SourceLocation { span: Range(TextLocation { line: 3, column: 58, offset: 212 }..TextLocation { line: 3, column: 59, offset: 213 }) }], err_no: var__invalid_assignment } +SyntaxError { message: "Invalid type nature for generic argument. WCHAR is no Int.", range: [SourceLocation { span: Range(TextLocation { line: 3, column: 58, offset: 212 }..TextLocation { line: 3, column: 59, offset: 213 }) }], err_no: type__invalid_nature } diff --git a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_int_does_not_allow_date.snap b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_int_does_not_allow_date.snap index 7d5c2c4343..7805d19cbe 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_int_does_not_allow_date.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_int_does_not_allow_date.snap @@ -3,8 +3,8 @@ source: src/validation/tests/generic_validation_tests.rs expression: res --- SyntaxError { message: "Invalid type nature for generic argument. DATE_AND_TIME is no Int.", range: [SourceLocation { span: Range(TextLocation { line: 2, column: 55, offset: 135 }..TextLocation { line: 2, column: 56, offset: 136 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid type nature for generic argument. DATE_AND_TIME is no Int.", range: [SourceLocation { span: Range(TextLocation { line: 3, column: 50, offset: 202 }..TextLocation { line: 3, column: 51, offset: 203 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid type nature for generic argument. DATE is no Int.", range: [SourceLocation { span: Range(TextLocation { line: 4, column: 51, offset: 270 }..TextLocation { line: 4, column: 52, offset: 271 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid type nature for generic argument. TIME_OF_DAY is no Int.", range: [SourceLocation { span: Range(TextLocation { line: 5, column: 50, offset: 337 }..TextLocation { line: 5, column: 51, offset: 338 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid type nature for generic argument. TIME_OF_DAY is no Int.", range: [SourceLocation { span: Range(TextLocation { line: 6, column: 51, offset: 405 }..TextLocation { line: 6, column: 52, offset: 406 }) }], err_no: type__invalid_nature } +SyntaxError { message: "Invalid type nature for generic argument. DATE_AND_TIME is no Int.", range: [SourceLocation { span: Range(TextLocation { line: 3, column: 56, offset: 208 }..TextLocation { line: 3, column: 57, offset: 209 }) }], err_no: type__invalid_nature } +SyntaxError { message: "Invalid type nature for generic argument. DATE is no Int.", range: [SourceLocation { span: Range(TextLocation { line: 4, column: 57, offset: 282 }..TextLocation { line: 4, column: 58, offset: 283 }) }], err_no: type__invalid_nature } +SyntaxError { message: "Invalid type nature for generic argument. TIME_OF_DAY is no Int.", range: [SourceLocation { span: Range(TextLocation { line: 5, column: 56, offset: 355 }..TextLocation { line: 5, column: 57, offset: 356 }) }], err_no: type__invalid_nature } +SyntaxError { message: "Invalid type nature for generic argument. TIME_OF_DAY is no Int.", range: [SourceLocation { span: Range(TextLocation { line: 6, column: 57, offset: 429 }..TextLocation { line: 6, column: 58, offset: 430 }) }], err_no: type__invalid_nature } diff --git a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_int_does_not_allow_time.snap b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_int_does_not_allow_time.snap index 1ff452289e..5347962903 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_int_does_not_allow_time.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_int_does_not_allow_time.snap @@ -3,5 +3,5 @@ source: src/validation/tests/generic_validation_tests.rs expression: res --- SyntaxError { message: "Invalid type nature for generic argument. TIME is no Int.", range: [SourceLocation { span: Range(TextLocation { line: 2, column: 57, offset: 137 }..TextLocation { line: 2, column: 58, offset: 138 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid type nature for generic argument. TIME is no Int.", range: [SourceLocation { span: Range(TextLocation { line: 3, column: 52, offset: 206 }..TextLocation { line: 3, column: 53, offset: 207 }) }], err_no: type__invalid_nature } +SyntaxError { message: "Invalid type nature for generic argument. TIME is no Int.", range: [SourceLocation { span: Range(TextLocation { line: 3, column: 58, offset: 212 }..TextLocation { line: 3, column: 59, offset: 213 }) }], err_no: type__invalid_nature } diff --git a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_magnitude_does_not_allow_bits.snap b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_magnitude_does_not_allow_bits.snap index df38af0ebf..bda566f733 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_magnitude_does_not_allow_bits.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_magnitude_does_not_allow_bits.snap @@ -4,7 +4,7 @@ expression: res --- SyntaxError { message: "Invalid type nature for generic argument. BOOL is no Magnitude.", range: [SourceLocation { span: Range(TextLocation { line: 2, column: 57, offset: 143 }..TextLocation { line: 2, column: 58, offset: 144 }) }], err_no: type__invalid_nature } SyntaxError { message: "Invalid type nature for generic argument. BYTE is no Magnitude.", range: [SourceLocation { span: Range(TextLocation { line: 3, column: 57, offset: 217 }..TextLocation { line: 3, column: 58, offset: 218 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid type nature for generic argument. WORD is no Magnitude.", range: [SourceLocation { span: Range(TextLocation { line: 4, column: 51, offset: 285 }..TextLocation { line: 4, column: 52, offset: 286 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid type nature for generic argument. DWORD is no Magnitude.", range: [SourceLocation { span: Range(TextLocation { line: 5, column: 58, offset: 360 }..TextLocation { line: 5, column: 59, offset: 361 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid type nature for generic argument. LWORD is no Magnitude.", range: [SourceLocation { span: Range(TextLocation { line: 6, column: 52, offset: 429 }..TextLocation { line: 6, column: 53, offset: 430 }) }], err_no: type__invalid_nature } +SyntaxError { message: "Invalid type nature for generic argument. WORD is no Magnitude.", range: [SourceLocation { span: Range(TextLocation { line: 4, column: 57, offset: 291 }..TextLocation { line: 4, column: 58, offset: 292 }) }], err_no: type__invalid_nature } +SyntaxError { message: "Invalid type nature for generic argument. DWORD is no Magnitude.", range: [SourceLocation { span: Range(TextLocation { line: 5, column: 58, offset: 366 }..TextLocation { line: 5, column: 59, offset: 367 }) }], err_no: type__invalid_nature } +SyntaxError { message: "Invalid type nature for generic argument. LWORD is no Magnitude.", range: [SourceLocation { span: Range(TextLocation { line: 6, column: 58, offset: 441 }..TextLocation { line: 6, column: 59, offset: 442 }) }], err_no: type__invalid_nature } diff --git a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_magnitude_does_not_allow_date.snap b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_magnitude_does_not_allow_date.snap index f312875d57..d93f7b9e7c 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_magnitude_does_not_allow_date.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_magnitude_does_not_allow_date.snap @@ -4,7 +4,7 @@ expression: res --- SyntaxError { message: "Invalid type nature for generic argument. DATE_AND_TIME is no Magnitude.", range: [SourceLocation { span: Range(TextLocation { line: 2, column: 55, offset: 141 }..TextLocation { line: 2, column: 56, offset: 142 }) }], err_no: type__invalid_nature } SyntaxError { message: "Invalid type nature for generic argument. DATE_AND_TIME is no Magnitude.", range: [SourceLocation { span: Range(TextLocation { line: 3, column: 56, offset: 214 }..TextLocation { line: 3, column: 57, offset: 215 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid type nature for generic argument. DATE is no Magnitude.", range: [SourceLocation { span: Range(TextLocation { line: 4, column: 51, offset: 282 }..TextLocation { line: 4, column: 52, offset: 283 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid type nature for generic argument. TIME_OF_DAY is no Magnitude.", range: [SourceLocation { span: Range(TextLocation { line: 5, column: 56, offset: 355 }..TextLocation { line: 5, column: 57, offset: 356 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid type nature for generic argument. TIME_OF_DAY is no Magnitude.", range: [SourceLocation { span: Range(TextLocation { line: 6, column: 51, offset: 423 }..TextLocation { line: 6, column: 52, offset: 424 }) }], err_no: type__invalid_nature } +SyntaxError { message: "Invalid type nature for generic argument. DATE is no Magnitude.", range: [SourceLocation { span: Range(TextLocation { line: 4, column: 57, offset: 288 }..TextLocation { line: 4, column: 58, offset: 289 }) }], err_no: type__invalid_nature } +SyntaxError { message: "Invalid type nature for generic argument. TIME_OF_DAY is no Magnitude.", range: [SourceLocation { span: Range(TextLocation { line: 5, column: 56, offset: 361 }..TextLocation { line: 5, column: 57, offset: 362 }) }], err_no: type__invalid_nature } +SyntaxError { message: "Invalid type nature for generic argument. TIME_OF_DAY is no Magnitude.", range: [SourceLocation { span: Range(TextLocation { line: 6, column: 57, offset: 435 }..TextLocation { line: 6, column: 58, offset: 436 }) }], err_no: type__invalid_nature } diff --git a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_num_does_not_allow_bits.snap b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_num_does_not_allow_bits.snap index c0abdecbe9..549a365dd8 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_num_does_not_allow_bits.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_num_does_not_allow_bits.snap @@ -4,7 +4,7 @@ expression: res --- SyntaxError { message: "Invalid type nature for generic argument. BOOL is no Num.", range: [SourceLocation { span: Range(TextLocation { line: 2, column: 57, offset: 137 }..TextLocation { line: 2, column: 58, offset: 138 }) }], err_no: type__invalid_nature } SyntaxError { message: "Invalid type nature for generic argument. BYTE is no Num.", range: [SourceLocation { span: Range(TextLocation { line: 3, column: 57, offset: 211 }..TextLocation { line: 3, column: 58, offset: 212 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid type nature for generic argument. WORD is no Num.", range: [SourceLocation { span: Range(TextLocation { line: 4, column: 51, offset: 279 }..TextLocation { line: 4, column: 52, offset: 280 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid type nature for generic argument. DWORD is no Num.", range: [SourceLocation { span: Range(TextLocation { line: 5, column: 58, offset: 354 }..TextLocation { line: 5, column: 59, offset: 355 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid type nature for generic argument. LWORD is no Num.", range: [SourceLocation { span: Range(TextLocation { line: 6, column: 52, offset: 423 }..TextLocation { line: 6, column: 53, offset: 424 }) }], err_no: type__invalid_nature } +SyntaxError { message: "Invalid type nature for generic argument. WORD is no Num.", range: [SourceLocation { span: Range(TextLocation { line: 4, column: 57, offset: 285 }..TextLocation { line: 4, column: 58, offset: 286 }) }], err_no: type__invalid_nature } +SyntaxError { message: "Invalid type nature for generic argument. DWORD is no Num.", range: [SourceLocation { span: Range(TextLocation { line: 5, column: 58, offset: 360 }..TextLocation { line: 5, column: 59, offset: 361 }) }], err_no: type__invalid_nature } +SyntaxError { message: "Invalid type nature for generic argument. LWORD is no Num.", range: [SourceLocation { span: Range(TextLocation { line: 6, column: 58, offset: 435 }..TextLocation { line: 6, column: 59, offset: 436 }) }], err_no: type__invalid_nature } diff --git a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_num_does_not_allow_date.snap b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_num_does_not_allow_date.snap index 8e11977369..39b7a32eed 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_num_does_not_allow_date.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_num_does_not_allow_date.snap @@ -4,7 +4,7 @@ expression: res --- SyntaxError { message: "Invalid type nature for generic argument. DATE_AND_TIME is no Num.", range: [SourceLocation { span: Range(TextLocation { line: 2, column: 55, offset: 135 }..TextLocation { line: 2, column: 56, offset: 136 }) }], err_no: type__invalid_nature } SyntaxError { message: "Invalid type nature for generic argument. DATE_AND_TIME is no Num.", range: [SourceLocation { span: Range(TextLocation { line: 3, column: 56, offset: 208 }..TextLocation { line: 3, column: 57, offset: 209 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid type nature for generic argument. DATE is no Num.", range: [SourceLocation { span: Range(TextLocation { line: 4, column: 51, offset: 276 }..TextLocation { line: 4, column: 52, offset: 277 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid type nature for generic argument. TIME_OF_DAY is no Num.", range: [SourceLocation { span: Range(TextLocation { line: 5, column: 56, offset: 349 }..TextLocation { line: 5, column: 57, offset: 350 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid type nature for generic argument. TIME_OF_DAY is no Num.", range: [SourceLocation { span: Range(TextLocation { line: 6, column: 51, offset: 417 }..TextLocation { line: 6, column: 52, offset: 418 }) }], err_no: type__invalid_nature } +SyntaxError { message: "Invalid type nature for generic argument. DATE is no Num.", range: [SourceLocation { span: Range(TextLocation { line: 4, column: 57, offset: 282 }..TextLocation { line: 4, column: 58, offset: 283 }) }], err_no: type__invalid_nature } +SyntaxError { message: "Invalid type nature for generic argument. TIME_OF_DAY is no Num.", range: [SourceLocation { span: Range(TextLocation { line: 5, column: 56, offset: 355 }..TextLocation { line: 5, column: 57, offset: 356 }) }], err_no: type__invalid_nature } +SyntaxError { message: "Invalid type nature for generic argument. TIME_OF_DAY is no Num.", range: [SourceLocation { span: Range(TextLocation { line: 6, column: 57, offset: 429 }..TextLocation { line: 6, column: 58, offset: 430 }) }], err_no: type__invalid_nature } diff --git a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_real_does_not_allow_bits.snap b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_real_does_not_allow_bits.snap index 207f40c7f0..89e7550982 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_real_does_not_allow_bits.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_real_does_not_allow_bits.snap @@ -3,8 +3,8 @@ source: src/validation/tests/generic_validation_tests.rs expression: res --- SyntaxError { message: "Invalid type nature for generic argument. BOOL is no Real.", range: [SourceLocation { span: Range(TextLocation { line: 2, column: 57, offset: 138 }..TextLocation { line: 2, column: 58, offset: 139 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid type nature for generic argument. BYTE is no Real.", range: [SourceLocation { span: Range(TextLocation { line: 3, column: 51, offset: 206 }..TextLocation { line: 3, column: 52, offset: 207 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid type nature for generic argument. WORD is no Real.", range: [SourceLocation { span: Range(TextLocation { line: 4, column: 51, offset: 274 }..TextLocation { line: 4, column: 52, offset: 275 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid type nature for generic argument. DWORD is no Real.", range: [SourceLocation { span: Range(TextLocation { line: 5, column: 52, offset: 343 }..TextLocation { line: 5, column: 53, offset: 344 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid type nature for generic argument. LWORD is no Real.", range: [SourceLocation { span: Range(TextLocation { line: 6, column: 52, offset: 412 }..TextLocation { line: 6, column: 53, offset: 413 }) }], err_no: type__invalid_nature } +SyntaxError { message: "Invalid type nature for generic argument. BYTE is no Real.", range: [SourceLocation { span: Range(TextLocation { line: 3, column: 57, offset: 212 }..TextLocation { line: 3, column: 58, offset: 213 }) }], err_no: type__invalid_nature } +SyntaxError { message: "Invalid type nature for generic argument. WORD is no Real.", range: [SourceLocation { span: Range(TextLocation { line: 4, column: 57, offset: 286 }..TextLocation { line: 4, column: 58, offset: 287 }) }], err_no: type__invalid_nature } +SyntaxError { message: "Invalid type nature for generic argument. DWORD is no Real.", range: [SourceLocation { span: Range(TextLocation { line: 5, column: 58, offset: 361 }..TextLocation { line: 5, column: 59, offset: 362 }) }], err_no: type__invalid_nature } +SyntaxError { message: "Invalid type nature for generic argument. LWORD is no Real.", range: [SourceLocation { span: Range(TextLocation { line: 6, column: 58, offset: 436 }..TextLocation { line: 6, column: 59, offset: 437 }) }], err_no: type__invalid_nature } diff --git a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_real_does_not_allow_chars.snap b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_real_does_not_allow_chars.snap index 309b1aed9f..e7853d2ce5 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_real_does_not_allow_chars.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_real_does_not_allow_chars.snap @@ -4,6 +4,6 @@ expression: res --- SyntaxError { message: "Invalid assignment: cannot assign 'CHAR' to 'REAL'", range: [SourceLocation { span: Range(TextLocation { line: 2, column: 57, offset: 138 }..TextLocation { line: 2, column: 58, offset: 139 }) }], err_no: var__invalid_assignment } SyntaxError { message: "Invalid type nature for generic argument. CHAR is no Real.", range: [SourceLocation { span: Range(TextLocation { line: 2, column: 57, offset: 138 }..TextLocation { line: 2, column: 58, offset: 139 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid assignment: cannot assign 'WCHAR' to 'REAL'", range: [SourceLocation { span: Range(TextLocation { line: 3, column: 52, offset: 207 }..TextLocation { line: 3, column: 53, offset: 208 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid type nature for generic argument. WCHAR is no Real.", range: [SourceLocation { span: Range(TextLocation { line: 3, column: 52, offset: 207 }..TextLocation { line: 3, column: 53, offset: 208 }) }], err_no: type__invalid_nature } +SyntaxError { message: "Invalid assignment: cannot assign 'WCHAR' to 'REAL'", range: [SourceLocation { span: Range(TextLocation { line: 3, column: 58, offset: 213 }..TextLocation { line: 3, column: 59, offset: 214 }) }], err_no: var__invalid_assignment } +SyntaxError { message: "Invalid type nature for generic argument. WCHAR is no Real.", range: [SourceLocation { span: Range(TextLocation { line: 3, column: 58, offset: 213 }..TextLocation { line: 3, column: 59, offset: 214 }) }], err_no: type__invalid_nature } diff --git a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_real_does_not_allow_date.snap b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_real_does_not_allow_date.snap index 4bb4a372e6..31fc52d197 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_real_does_not_allow_date.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_real_does_not_allow_date.snap @@ -3,8 +3,8 @@ source: src/validation/tests/generic_validation_tests.rs expression: res --- SyntaxError { message: "Invalid type nature for generic argument. DATE_AND_TIME is no Real.", range: [SourceLocation { span: Range(TextLocation { line: 2, column: 55, offset: 136 }..TextLocation { line: 2, column: 56, offset: 137 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid type nature for generic argument. DATE_AND_TIME is no Real.", range: [SourceLocation { span: Range(TextLocation { line: 3, column: 50, offset: 203 }..TextLocation { line: 3, column: 51, offset: 204 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid type nature for generic argument. DATE is no Real.", range: [SourceLocation { span: Range(TextLocation { line: 4, column: 51, offset: 271 }..TextLocation { line: 4, column: 52, offset: 272 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid type nature for generic argument. TIME_OF_DAY is no Real.", range: [SourceLocation { span: Range(TextLocation { line: 5, column: 50, offset: 338 }..TextLocation { line: 5, column: 51, offset: 339 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid type nature for generic argument. TIME_OF_DAY is no Real.", range: [SourceLocation { span: Range(TextLocation { line: 6, column: 51, offset: 406 }..TextLocation { line: 6, column: 52, offset: 407 }) }], err_no: type__invalid_nature } +SyntaxError { message: "Invalid type nature for generic argument. DATE_AND_TIME is no Real.", range: [SourceLocation { span: Range(TextLocation { line: 3, column: 56, offset: 209 }..TextLocation { line: 3, column: 57, offset: 210 }) }], err_no: type__invalid_nature } +SyntaxError { message: "Invalid type nature for generic argument. DATE is no Real.", range: [SourceLocation { span: Range(TextLocation { line: 4, column: 57, offset: 283 }..TextLocation { line: 4, column: 58, offset: 284 }) }], err_no: type__invalid_nature } +SyntaxError { message: "Invalid type nature for generic argument. TIME_OF_DAY is no Real.", range: [SourceLocation { span: Range(TextLocation { line: 5, column: 56, offset: 356 }..TextLocation { line: 5, column: 57, offset: 357 }) }], err_no: type__invalid_nature } +SyntaxError { message: "Invalid type nature for generic argument. TIME_OF_DAY is no Real.", range: [SourceLocation { span: Range(TextLocation { line: 6, column: 57, offset: 430 }..TextLocation { line: 6, column: 58, offset: 431 }) }], err_no: type__invalid_nature } diff --git a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_real_does_not_allow_time.snap b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_real_does_not_allow_time.snap index 9b0f72d426..1a45686ba3 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_real_does_not_allow_time.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_real_does_not_allow_time.snap @@ -3,5 +3,5 @@ source: src/validation/tests/generic_validation_tests.rs expression: res --- SyntaxError { message: "Invalid type nature for generic argument. TIME is no Real.", range: [SourceLocation { span: Range(TextLocation { line: 2, column: 57, offset: 138 }..TextLocation { line: 2, column: 58, offset: 139 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid type nature for generic argument. TIME is no Real.", range: [SourceLocation { span: Range(TextLocation { line: 3, column: 52, offset: 207 }..TextLocation { line: 3, column: 53, offset: 208 }) }], err_no: type__invalid_nature } +SyntaxError { message: "Invalid type nature for generic argument. TIME is no Real.", range: [SourceLocation { span: Range(TextLocation { line: 3, column: 58, offset: 213 }..TextLocation { line: 3, column: 59, offset: 214 }) }], err_no: type__invalid_nature } diff --git a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_signed_does_not_allow_bits.snap b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_signed_does_not_allow_bits.snap index 8ef232087a..8cfcae02e7 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_signed_does_not_allow_bits.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_signed_does_not_allow_bits.snap @@ -3,8 +3,8 @@ source: src/validation/tests/generic_validation_tests.rs expression: res --- SyntaxError { message: "Invalid type nature for generic argument. BOOL is no Signed.", range: [SourceLocation { span: Range(TextLocation { line: 2, column: 57, offset: 140 }..TextLocation { line: 2, column: 58, offset: 141 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid type nature for generic argument. BYTE is no Signed.", range: [SourceLocation { span: Range(TextLocation { line: 3, column: 51, offset: 208 }..TextLocation { line: 3, column: 52, offset: 209 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid type nature for generic argument. WORD is no Signed.", range: [SourceLocation { span: Range(TextLocation { line: 4, column: 51, offset: 276 }..TextLocation { line: 4, column: 52, offset: 277 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid type nature for generic argument. DWORD is no Signed.", range: [SourceLocation { span: Range(TextLocation { line: 5, column: 52, offset: 345 }..TextLocation { line: 5, column: 53, offset: 346 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid type nature for generic argument. LWORD is no Signed.", range: [SourceLocation { span: Range(TextLocation { line: 6, column: 52, offset: 414 }..TextLocation { line: 6, column: 53, offset: 415 }) }], err_no: type__invalid_nature } +SyntaxError { message: "Invalid type nature for generic argument. BYTE is no Signed.", range: [SourceLocation { span: Range(TextLocation { line: 3, column: 57, offset: 214 }..TextLocation { line: 3, column: 58, offset: 215 }) }], err_no: type__invalid_nature } +SyntaxError { message: "Invalid type nature for generic argument. WORD is no Signed.", range: [SourceLocation { span: Range(TextLocation { line: 4, column: 57, offset: 288 }..TextLocation { line: 4, column: 58, offset: 289 }) }], err_no: type__invalid_nature } +SyntaxError { message: "Invalid type nature for generic argument. DWORD is no Signed.", range: [SourceLocation { span: Range(TextLocation { line: 5, column: 58, offset: 363 }..TextLocation { line: 5, column: 59, offset: 364 }) }], err_no: type__invalid_nature } +SyntaxError { message: "Invalid type nature for generic argument. LWORD is no Signed.", range: [SourceLocation { span: Range(TextLocation { line: 6, column: 58, offset: 438 }..TextLocation { line: 6, column: 59, offset: 439 }) }], err_no: type__invalid_nature } diff --git a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_signed_does_not_allow_chars.snap b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_signed_does_not_allow_chars.snap index 995e9556e6..2a3755c4f5 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_signed_does_not_allow_chars.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_signed_does_not_allow_chars.snap @@ -4,6 +4,6 @@ expression: res --- SyntaxError { message: "Invalid assignment: cannot assign 'CHAR' to 'SINT'", range: [SourceLocation { span: Range(TextLocation { line: 2, column: 57, offset: 140 }..TextLocation { line: 2, column: 58, offset: 141 }) }], err_no: var__invalid_assignment } SyntaxError { message: "Invalid type nature for generic argument. CHAR is no Signed.", range: [SourceLocation { span: Range(TextLocation { line: 2, column: 57, offset: 140 }..TextLocation { line: 2, column: 58, offset: 141 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid assignment: cannot assign 'WCHAR' to 'SINT'", range: [SourceLocation { span: Range(TextLocation { line: 3, column: 52, offset: 209 }..TextLocation { line: 3, column: 53, offset: 210 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid type nature for generic argument. WCHAR is no Signed.", range: [SourceLocation { span: Range(TextLocation { line: 3, column: 52, offset: 209 }..TextLocation { line: 3, column: 53, offset: 210 }) }], err_no: type__invalid_nature } +SyntaxError { message: "Invalid assignment: cannot assign 'WCHAR' to 'SINT'", range: [SourceLocation { span: Range(TextLocation { line: 3, column: 58, offset: 215 }..TextLocation { line: 3, column: 59, offset: 216 }) }], err_no: var__invalid_assignment } +SyntaxError { message: "Invalid type nature for generic argument. WCHAR is no Signed.", range: [SourceLocation { span: Range(TextLocation { line: 3, column: 58, offset: 215 }..TextLocation { line: 3, column: 59, offset: 216 }) }], err_no: type__invalid_nature } diff --git a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_signed_does_not_allow_date.snap b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_signed_does_not_allow_date.snap index a4281f084d..27bf8b80cd 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_signed_does_not_allow_date.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_signed_does_not_allow_date.snap @@ -3,8 +3,8 @@ source: src/validation/tests/generic_validation_tests.rs expression: res --- SyntaxError { message: "Invalid type nature for generic argument. DATE_AND_TIME is no Signed.", range: [SourceLocation { span: Range(TextLocation { line: 2, column: 55, offset: 138 }..TextLocation { line: 2, column: 56, offset: 139 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid type nature for generic argument. DATE_AND_TIME is no Signed.", range: [SourceLocation { span: Range(TextLocation { line: 3, column: 50, offset: 205 }..TextLocation { line: 3, column: 51, offset: 206 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid type nature for generic argument. DATE is no Signed.", range: [SourceLocation { span: Range(TextLocation { line: 4, column: 51, offset: 273 }..TextLocation { line: 4, column: 52, offset: 274 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid type nature for generic argument. TIME_OF_DAY is no Signed.", range: [SourceLocation { span: Range(TextLocation { line: 5, column: 50, offset: 340 }..TextLocation { line: 5, column: 51, offset: 341 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid type nature for generic argument. TIME_OF_DAY is no Signed.", range: [SourceLocation { span: Range(TextLocation { line: 6, column: 51, offset: 408 }..TextLocation { line: 6, column: 52, offset: 409 }) }], err_no: type__invalid_nature } +SyntaxError { message: "Invalid type nature for generic argument. DATE_AND_TIME is no Signed.", range: [SourceLocation { span: Range(TextLocation { line: 3, column: 56, offset: 211 }..TextLocation { line: 3, column: 57, offset: 212 }) }], err_no: type__invalid_nature } +SyntaxError { message: "Invalid type nature for generic argument. DATE is no Signed.", range: [SourceLocation { span: Range(TextLocation { line: 4, column: 57, offset: 285 }..TextLocation { line: 4, column: 58, offset: 286 }) }], err_no: type__invalid_nature } +SyntaxError { message: "Invalid type nature for generic argument. TIME_OF_DAY is no Signed.", range: [SourceLocation { span: Range(TextLocation { line: 5, column: 56, offset: 358 }..TextLocation { line: 5, column: 57, offset: 359 }) }], err_no: type__invalid_nature } +SyntaxError { message: "Invalid type nature for generic argument. TIME_OF_DAY is no Signed.", range: [SourceLocation { span: Range(TextLocation { line: 6, column: 57, offset: 432 }..TextLocation { line: 6, column: 58, offset: 433 }) }], err_no: type__invalid_nature } diff --git a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_signed_does_not_allow_time.snap b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_signed_does_not_allow_time.snap index 27663b3b69..ed44095305 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_signed_does_not_allow_time.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_signed_does_not_allow_time.snap @@ -3,5 +3,5 @@ source: src/validation/tests/generic_validation_tests.rs expression: res --- SyntaxError { message: "Invalid type nature for generic argument. TIME is no Signed.", range: [SourceLocation { span: Range(TextLocation { line: 2, column: 57, offset: 140 }..TextLocation { line: 2, column: 58, offset: 141 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid type nature for generic argument. TIME is no Signed.", range: [SourceLocation { span: Range(TextLocation { line: 3, column: 52, offset: 209 }..TextLocation { line: 3, column: 53, offset: 210 }) }], err_no: type__invalid_nature } +SyntaxError { message: "Invalid type nature for generic argument. TIME is no Signed.", range: [SourceLocation { span: Range(TextLocation { line: 3, column: 58, offset: 215 }..TextLocation { line: 3, column: 59, offset: 216 }) }], err_no: type__invalid_nature } diff --git a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_signed_does_not_allow_unsigned_ints.snap b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_signed_does_not_allow_unsigned_ints.snap index 8c96bb8493..dae2f20f80 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_signed_does_not_allow_unsigned_ints.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_signed_does_not_allow_unsigned_ints.snap @@ -2,8 +2,8 @@ source: src/validation/tests/generic_validation_tests.rs expression: res --- -SyntaxError { message: "Invalid type nature for generic argument. USINT is no Signed.", range: [SourceLocation { span: Range(TextLocation { line: 2, column: 52, offset: 135 }..TextLocation { line: 2, column: 53, offset: 136 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid type nature for generic argument. UINT is no Signed.", range: [SourceLocation { span: Range(TextLocation { line: 3, column: 57, offset: 209 }..TextLocation { line: 3, column: 58, offset: 210 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid type nature for generic argument. UDINT is no Signed.", range: [SourceLocation { span: Range(TextLocation { line: 4, column: 52, offset: 278 }..TextLocation { line: 4, column: 53, offset: 279 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid type nature for generic argument. ULINT is no Signed.", range: [SourceLocation { span: Range(TextLocation { line: 5, column: 52, offset: 347 }..TextLocation { line: 5, column: 53, offset: 348 }) }], err_no: type__invalid_nature } +SyntaxError { message: "Invalid type nature for generic argument. USINT is no Signed.", range: [SourceLocation { span: Range(TextLocation { line: 2, column: 58, offset: 141 }..TextLocation { line: 2, column: 59, offset: 142 }) }], err_no: type__invalid_nature } +SyntaxError { message: "Invalid type nature for generic argument. UINT is no Signed.", range: [SourceLocation { span: Range(TextLocation { line: 3, column: 57, offset: 215 }..TextLocation { line: 3, column: 58, offset: 216 }) }], err_no: type__invalid_nature } +SyntaxError { message: "Invalid type nature for generic argument. UDINT is no Signed.", range: [SourceLocation { span: Range(TextLocation { line: 4, column: 58, offset: 290 }..TextLocation { line: 4, column: 59, offset: 291 }) }], err_no: type__invalid_nature } +SyntaxError { message: "Invalid type nature for generic argument. ULINT is no Signed.", range: [SourceLocation { span: Range(TextLocation { line: 5, column: 58, offset: 365 }..TextLocation { line: 5, column: 59, offset: 366 }) }], err_no: type__invalid_nature } diff --git a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_string_does_not_allow_bits.snap b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_string_does_not_allow_bits.snap index 2ddfec1848..11c387aaa2 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_string_does_not_allow_bits.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_string_does_not_allow_bits.snap @@ -4,12 +4,12 @@ expression: res --- SyntaxError { message: "Invalid assignment: cannot assign 'BOOL' to 'STRING'", range: [SourceLocation { span: Range(TextLocation { line: 2, column: 57, offset: 140 }..TextLocation { line: 2, column: 58, offset: 141 }) }], err_no: var__invalid_assignment } SyntaxError { message: "Invalid type nature for generic argument. BOOL is no String.", range: [SourceLocation { span: Range(TextLocation { line: 2, column: 57, offset: 140 }..TextLocation { line: 2, column: 58, offset: 141 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid assignment: cannot assign 'BYTE' to 'STRING'", range: [SourceLocation { span: Range(TextLocation { line: 3, column: 51, offset: 208 }..TextLocation { line: 3, column: 52, offset: 209 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid type nature for generic argument. BYTE is no String.", range: [SourceLocation { span: Range(TextLocation { line: 3, column: 51, offset: 208 }..TextLocation { line: 3, column: 52, offset: 209 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid assignment: cannot assign 'WORD' to 'STRING'", range: [SourceLocation { span: Range(TextLocation { line: 4, column: 51, offset: 276 }..TextLocation { line: 4, column: 52, offset: 277 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid type nature for generic argument. WORD is no String.", range: [SourceLocation { span: Range(TextLocation { line: 4, column: 51, offset: 276 }..TextLocation { line: 4, column: 52, offset: 277 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid assignment: cannot assign 'DWORD' to 'STRING'", range: [SourceLocation { span: Range(TextLocation { line: 5, column: 52, offset: 345 }..TextLocation { line: 5, column: 53, offset: 346 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid type nature for generic argument. DWORD is no String.", range: [SourceLocation { span: Range(TextLocation { line: 5, column: 52, offset: 345 }..TextLocation { line: 5, column: 53, offset: 346 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid assignment: cannot assign 'LWORD' to 'STRING'", range: [SourceLocation { span: Range(TextLocation { line: 6, column: 52, offset: 414 }..TextLocation { line: 6, column: 53, offset: 415 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid type nature for generic argument. LWORD is no String.", range: [SourceLocation { span: Range(TextLocation { line: 6, column: 52, offset: 414 }..TextLocation { line: 6, column: 53, offset: 415 }) }], err_no: type__invalid_nature } +SyntaxError { message: "Invalid assignment: cannot assign 'BYTE' to 'STRING'", range: [SourceLocation { span: Range(TextLocation { line: 3, column: 57, offset: 214 }..TextLocation { line: 3, column: 58, offset: 215 }) }], err_no: var__invalid_assignment } +SyntaxError { message: "Invalid type nature for generic argument. BYTE is no String.", range: [SourceLocation { span: Range(TextLocation { line: 3, column: 57, offset: 214 }..TextLocation { line: 3, column: 58, offset: 215 }) }], err_no: type__invalid_nature } +SyntaxError { message: "Invalid assignment: cannot assign 'WORD' to 'STRING'", range: [SourceLocation { span: Range(TextLocation { line: 4, column: 57, offset: 288 }..TextLocation { line: 4, column: 58, offset: 289 }) }], err_no: var__invalid_assignment } +SyntaxError { message: "Invalid type nature for generic argument. WORD is no String.", range: [SourceLocation { span: Range(TextLocation { line: 4, column: 57, offset: 288 }..TextLocation { line: 4, column: 58, offset: 289 }) }], err_no: type__invalid_nature } +SyntaxError { message: "Invalid assignment: cannot assign 'DWORD' to 'STRING'", range: [SourceLocation { span: Range(TextLocation { line: 5, column: 58, offset: 363 }..TextLocation { line: 5, column: 59, offset: 364 }) }], err_no: var__invalid_assignment } +SyntaxError { message: "Invalid type nature for generic argument. DWORD is no String.", range: [SourceLocation { span: Range(TextLocation { line: 5, column: 58, offset: 363 }..TextLocation { line: 5, column: 59, offset: 364 }) }], err_no: type__invalid_nature } +SyntaxError { message: "Invalid assignment: cannot assign 'LWORD' to 'STRING'", range: [SourceLocation { span: Range(TextLocation { line: 6, column: 58, offset: 438 }..TextLocation { line: 6, column: 59, offset: 439 }) }], err_no: var__invalid_assignment } +SyntaxError { message: "Invalid type nature for generic argument. LWORD is no String.", range: [SourceLocation { span: Range(TextLocation { line: 6, column: 58, offset: 438 }..TextLocation { line: 6, column: 59, offset: 439 }) }], err_no: type__invalid_nature } diff --git a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_string_does_not_allow_chars.snap b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_string_does_not_allow_chars.snap index 23d8821f85..9c182c5061 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_string_does_not_allow_chars.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_string_does_not_allow_chars.snap @@ -4,6 +4,6 @@ expression: res --- SyntaxError { message: "Invalid assignment: cannot assign 'CHAR' to 'STRING'", range: [SourceLocation { span: Range(TextLocation { line: 2, column: 57, offset: 140 }..TextLocation { line: 2, column: 58, offset: 141 }) }], err_no: var__invalid_assignment } SyntaxError { message: "Invalid type nature for generic argument. CHAR is no String.", range: [SourceLocation { span: Range(TextLocation { line: 2, column: 57, offset: 140 }..TextLocation { line: 2, column: 58, offset: 141 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid assignment: cannot assign 'WCHAR' to 'STRING'", range: [SourceLocation { span: Range(TextLocation { line: 3, column: 52, offset: 209 }..TextLocation { line: 3, column: 53, offset: 210 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid type nature for generic argument. WCHAR is no String.", range: [SourceLocation { span: Range(TextLocation { line: 3, column: 52, offset: 209 }..TextLocation { line: 3, column: 53, offset: 210 }) }], err_no: type__invalid_nature } +SyntaxError { message: "Invalid assignment: cannot assign 'WCHAR' to 'STRING'", range: [SourceLocation { span: Range(TextLocation { line: 3, column: 58, offset: 215 }..TextLocation { line: 3, column: 59, offset: 216 }) }], err_no: var__invalid_assignment } +SyntaxError { message: "Invalid type nature for generic argument. WCHAR is no String.", range: [SourceLocation { span: Range(TextLocation { line: 3, column: 58, offset: 215 }..TextLocation { line: 3, column: 59, offset: 216 }) }], err_no: type__invalid_nature } diff --git a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_string_does_not_allow_date.snap b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_string_does_not_allow_date.snap index c3beee6bcb..3eb8916b5c 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_string_does_not_allow_date.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_string_does_not_allow_date.snap @@ -4,12 +4,12 @@ expression: res --- SyntaxError { message: "Invalid assignment: cannot assign 'DATE_AND_TIME' to 'STRING'", range: [SourceLocation { span: Range(TextLocation { line: 2, column: 55, offset: 138 }..TextLocation { line: 2, column: 56, offset: 139 }) }], err_no: var__invalid_assignment } SyntaxError { message: "Invalid type nature for generic argument. DATE_AND_TIME is no String.", range: [SourceLocation { span: Range(TextLocation { line: 2, column: 55, offset: 138 }..TextLocation { line: 2, column: 56, offset: 139 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid assignment: cannot assign 'DATE_AND_TIME' to 'STRING'", range: [SourceLocation { span: Range(TextLocation { line: 3, column: 50, offset: 205 }..TextLocation { line: 3, column: 51, offset: 206 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid type nature for generic argument. DATE_AND_TIME is no String.", range: [SourceLocation { span: Range(TextLocation { line: 3, column: 50, offset: 205 }..TextLocation { line: 3, column: 51, offset: 206 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid assignment: cannot assign 'DATE' to 'STRING'", range: [SourceLocation { span: Range(TextLocation { line: 4, column: 51, offset: 273 }..TextLocation { line: 4, column: 52, offset: 274 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid type nature for generic argument. DATE is no String.", range: [SourceLocation { span: Range(TextLocation { line: 4, column: 51, offset: 273 }..TextLocation { line: 4, column: 52, offset: 274 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid assignment: cannot assign 'TIME_OF_DAY' to 'STRING'", range: [SourceLocation { span: Range(TextLocation { line: 5, column: 50, offset: 340 }..TextLocation { line: 5, column: 51, offset: 341 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid type nature for generic argument. TIME_OF_DAY is no String.", range: [SourceLocation { span: Range(TextLocation { line: 5, column: 50, offset: 340 }..TextLocation { line: 5, column: 51, offset: 341 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid assignment: cannot assign 'TIME_OF_DAY' to 'STRING'", range: [SourceLocation { span: Range(TextLocation { line: 6, column: 51, offset: 408 }..TextLocation { line: 6, column: 52, offset: 409 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid type nature for generic argument. TIME_OF_DAY is no String.", range: [SourceLocation { span: Range(TextLocation { line: 6, column: 51, offset: 408 }..TextLocation { line: 6, column: 52, offset: 409 }) }], err_no: type__invalid_nature } +SyntaxError { message: "Invalid assignment: cannot assign 'DATE_AND_TIME' to 'STRING'", range: [SourceLocation { span: Range(TextLocation { line: 3, column: 56, offset: 211 }..TextLocation { line: 3, column: 57, offset: 212 }) }], err_no: var__invalid_assignment } +SyntaxError { message: "Invalid type nature for generic argument. DATE_AND_TIME is no String.", range: [SourceLocation { span: Range(TextLocation { line: 3, column: 56, offset: 211 }..TextLocation { line: 3, column: 57, offset: 212 }) }], err_no: type__invalid_nature } +SyntaxError { message: "Invalid assignment: cannot assign 'DATE' to 'STRING'", range: [SourceLocation { span: Range(TextLocation { line: 4, column: 57, offset: 285 }..TextLocation { line: 4, column: 58, offset: 286 }) }], err_no: var__invalid_assignment } +SyntaxError { message: "Invalid type nature for generic argument. DATE is no String.", range: [SourceLocation { span: Range(TextLocation { line: 4, column: 57, offset: 285 }..TextLocation { line: 4, column: 58, offset: 286 }) }], err_no: type__invalid_nature } +SyntaxError { message: "Invalid assignment: cannot assign 'TIME_OF_DAY' to 'STRING'", range: [SourceLocation { span: Range(TextLocation { line: 5, column: 56, offset: 358 }..TextLocation { line: 5, column: 57, offset: 359 }) }], err_no: var__invalid_assignment } +SyntaxError { message: "Invalid type nature for generic argument. TIME_OF_DAY is no String.", range: [SourceLocation { span: Range(TextLocation { line: 5, column: 56, offset: 358 }..TextLocation { line: 5, column: 57, offset: 359 }) }], err_no: type__invalid_nature } +SyntaxError { message: "Invalid assignment: cannot assign 'TIME_OF_DAY' to 'STRING'", range: [SourceLocation { span: Range(TextLocation { line: 6, column: 57, offset: 432 }..TextLocation { line: 6, column: 58, offset: 433 }) }], err_no: var__invalid_assignment } +SyntaxError { message: "Invalid type nature for generic argument. TIME_OF_DAY is no String.", range: [SourceLocation { span: Range(TextLocation { line: 6, column: 57, offset: 432 }..TextLocation { line: 6, column: 58, offset: 433 }) }], err_no: type__invalid_nature } diff --git a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_string_does_not_allow_ints.snap b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_string_does_not_allow_ints.snap index ea5b1db49a..f422281cd8 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_string_does_not_allow_ints.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_string_does_not_allow_ints.snap @@ -2,20 +2,20 @@ source: src/validation/tests/generic_validation_tests.rs expression: res --- -SyntaxError { message: "Invalid assignment: cannot assign 'USINT' to 'STRING'", range: [SourceLocation { span: Range(TextLocation { line: 3, column: 52, offset: 136 }..TextLocation { line: 3, column: 53, offset: 137 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid type nature for generic argument. USINT is no String.", range: [SourceLocation { span: Range(TextLocation { line: 3, column: 52, offset: 136 }..TextLocation { line: 3, column: 53, offset: 137 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid assignment: cannot assign 'UINT' to 'STRING'", range: [SourceLocation { span: Range(TextLocation { line: 4, column: 57, offset: 210 }..TextLocation { line: 4, column: 58, offset: 211 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid type nature for generic argument. UINT is no String.", range: [SourceLocation { span: Range(TextLocation { line: 4, column: 57, offset: 210 }..TextLocation { line: 4, column: 58, offset: 211 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid assignment: cannot assign 'UDINT' to 'STRING'", range: [SourceLocation { span: Range(TextLocation { line: 5, column: 52, offset: 279 }..TextLocation { line: 5, column: 53, offset: 280 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid type nature for generic argument. UDINT is no String.", range: [SourceLocation { span: Range(TextLocation { line: 5, column: 52, offset: 279 }..TextLocation { line: 5, column: 53, offset: 280 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid assignment: cannot assign 'ULINT' to 'STRING'", range: [SourceLocation { span: Range(TextLocation { line: 6, column: 52, offset: 348 }..TextLocation { line: 6, column: 53, offset: 349 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid type nature for generic argument. ULINT is no String.", range: [SourceLocation { span: Range(TextLocation { line: 6, column: 52, offset: 348 }..TextLocation { line: 6, column: 53, offset: 349 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid assignment: cannot assign 'SINT' to 'STRING'", range: [SourceLocation { span: Range(TextLocation { line: 8, column: 51, offset: 417 }..TextLocation { line: 8, column: 52, offset: 418 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid type nature for generic argument. SINT is no String.", range: [SourceLocation { span: Range(TextLocation { line: 8, column: 51, offset: 417 }..TextLocation { line: 8, column: 52, offset: 418 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid assignment: cannot assign 'INT' to 'STRING'", range: [SourceLocation { span: Range(TextLocation { line: 9, column: 56, offset: 490 }..TextLocation { line: 9, column: 57, offset: 491 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid type nature for generic argument. INT is no String.", range: [SourceLocation { span: Range(TextLocation { line: 9, column: 56, offset: 490 }..TextLocation { line: 9, column: 57, offset: 491 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid assignment: cannot assign 'DINT' to 'STRING'", range: [SourceLocation { span: Range(TextLocation { line: 10, column: 51, offset: 558 }..TextLocation { line: 10, column: 52, offset: 559 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid type nature for generic argument. DINT is no String.", range: [SourceLocation { span: Range(TextLocation { line: 10, column: 51, offset: 558 }..TextLocation { line: 10, column: 52, offset: 559 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid assignment: cannot assign 'LINT' to 'STRING'", range: [SourceLocation { span: Range(TextLocation { line: 11, column: 51, offset: 626 }..TextLocation { line: 11, column: 52, offset: 627 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid type nature for generic argument. LINT is no String.", range: [SourceLocation { span: Range(TextLocation { line: 11, column: 51, offset: 626 }..TextLocation { line: 11, column: 52, offset: 627 }) }], err_no: type__invalid_nature } +SyntaxError { message: "Invalid assignment: cannot assign 'USINT' to 'STRING'", range: [SourceLocation { span: Range(TextLocation { line: 3, column: 58, offset: 142 }..TextLocation { line: 3, column: 59, offset: 143 }) }], err_no: var__invalid_assignment } +SyntaxError { message: "Invalid type nature for generic argument. USINT is no String.", range: [SourceLocation { span: Range(TextLocation { line: 3, column: 58, offset: 142 }..TextLocation { line: 3, column: 59, offset: 143 }) }], err_no: type__invalid_nature } +SyntaxError { message: "Invalid assignment: cannot assign 'UINT' to 'STRING'", range: [SourceLocation { span: Range(TextLocation { line: 4, column: 57, offset: 216 }..TextLocation { line: 4, column: 58, offset: 217 }) }], err_no: var__invalid_assignment } +SyntaxError { message: "Invalid type nature for generic argument. UINT is no String.", range: [SourceLocation { span: Range(TextLocation { line: 4, column: 57, offset: 216 }..TextLocation { line: 4, column: 58, offset: 217 }) }], err_no: type__invalid_nature } +SyntaxError { message: "Invalid assignment: cannot assign 'UDINT' to 'STRING'", range: [SourceLocation { span: Range(TextLocation { line: 5, column: 58, offset: 291 }..TextLocation { line: 5, column: 59, offset: 292 }) }], err_no: var__invalid_assignment } +SyntaxError { message: "Invalid type nature for generic argument. UDINT is no String.", range: [SourceLocation { span: Range(TextLocation { line: 5, column: 58, offset: 291 }..TextLocation { line: 5, column: 59, offset: 292 }) }], err_no: type__invalid_nature } +SyntaxError { message: "Invalid assignment: cannot assign 'ULINT' to 'STRING'", range: [SourceLocation { span: Range(TextLocation { line: 6, column: 58, offset: 366 }..TextLocation { line: 6, column: 59, offset: 367 }) }], err_no: var__invalid_assignment } +SyntaxError { message: "Invalid type nature for generic argument. ULINT is no String.", range: [SourceLocation { span: Range(TextLocation { line: 6, column: 58, offset: 366 }..TextLocation { line: 6, column: 59, offset: 367 }) }], err_no: type__invalid_nature } +SyntaxError { message: "Invalid assignment: cannot assign 'SINT' to 'STRING'", range: [SourceLocation { span: Range(TextLocation { line: 8, column: 57, offset: 441 }..TextLocation { line: 8, column: 58, offset: 442 }) }], err_no: var__invalid_assignment } +SyntaxError { message: "Invalid type nature for generic argument. SINT is no String.", range: [SourceLocation { span: Range(TextLocation { line: 8, column: 57, offset: 441 }..TextLocation { line: 8, column: 58, offset: 442 }) }], err_no: type__invalid_nature } +SyntaxError { message: "Invalid assignment: cannot assign 'INT' to 'STRING'", range: [SourceLocation { span: Range(TextLocation { line: 9, column: 56, offset: 514 }..TextLocation { line: 9, column: 57, offset: 515 }) }], err_no: var__invalid_assignment } +SyntaxError { message: "Invalid type nature for generic argument. INT is no String.", range: [SourceLocation { span: Range(TextLocation { line: 9, column: 56, offset: 514 }..TextLocation { line: 9, column: 57, offset: 515 }) }], err_no: type__invalid_nature } +SyntaxError { message: "Invalid assignment: cannot assign 'DINT' to 'STRING'", range: [SourceLocation { span: Range(TextLocation { line: 10, column: 57, offset: 588 }..TextLocation { line: 10, column: 58, offset: 589 }) }], err_no: var__invalid_assignment } +SyntaxError { message: "Invalid type nature for generic argument. DINT is no String.", range: [SourceLocation { span: Range(TextLocation { line: 10, column: 57, offset: 588 }..TextLocation { line: 10, column: 58, offset: 589 }) }], err_no: type__invalid_nature } +SyntaxError { message: "Invalid assignment: cannot assign 'LINT' to 'STRING'", range: [SourceLocation { span: Range(TextLocation { line: 11, column: 57, offset: 662 }..TextLocation { line: 11, column: 58, offset: 663 }) }], err_no: var__invalid_assignment } +SyntaxError { message: "Invalid type nature for generic argument. LINT is no String.", range: [SourceLocation { span: Range(TextLocation { line: 11, column: 57, offset: 662 }..TextLocation { line: 11, column: 58, offset: 663 }) }], err_no: type__invalid_nature } diff --git a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_string_does_not_allow_time.snap b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_string_does_not_allow_time.snap index e01dc5acd9..69895eaf1b 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_string_does_not_allow_time.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_string_does_not_allow_time.snap @@ -4,6 +4,6 @@ expression: res --- SyntaxError { message: "Invalid assignment: cannot assign 'TIME' to 'STRING'", range: [SourceLocation { span: Range(TextLocation { line: 2, column: 57, offset: 140 }..TextLocation { line: 2, column: 58, offset: 141 }) }], err_no: var__invalid_assignment } SyntaxError { message: "Invalid type nature for generic argument. TIME is no String.", range: [SourceLocation { span: Range(TextLocation { line: 2, column: 57, offset: 140 }..TextLocation { line: 2, column: 58, offset: 141 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid assignment: cannot assign 'TIME' to 'STRING'", range: [SourceLocation { span: Range(TextLocation { line: 3, column: 52, offset: 209 }..TextLocation { line: 3, column: 53, offset: 210 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid type nature for generic argument. TIME is no String.", range: [SourceLocation { span: Range(TextLocation { line: 3, column: 52, offset: 209 }..TextLocation { line: 3, column: 53, offset: 210 }) }], err_no: type__invalid_nature } +SyntaxError { message: "Invalid assignment: cannot assign 'TIME' to 'STRING'", range: [SourceLocation { span: Range(TextLocation { line: 3, column: 58, offset: 215 }..TextLocation { line: 3, column: 59, offset: 216 }) }], err_no: var__invalid_assignment } +SyntaxError { message: "Invalid type nature for generic argument. TIME is no String.", range: [SourceLocation { span: Range(TextLocation { line: 3, column: 58, offset: 215 }..TextLocation { line: 3, column: 59, offset: 216 }) }], err_no: type__invalid_nature } diff --git a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_unsigned_does_not_allow_bits.snap b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_unsigned_does_not_allow_bits.snap index fce21e9974..91c3f3106f 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_unsigned_does_not_allow_bits.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_unsigned_does_not_allow_bits.snap @@ -3,8 +3,8 @@ source: src/validation/tests/generic_validation_tests.rs expression: res --- SyntaxError { message: "Invalid type nature for generic argument. BOOL is no Unsigned.", range: [SourceLocation { span: Range(TextLocation { line: 2, column: 57, offset: 142 }..TextLocation { line: 2, column: 58, offset: 143 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid type nature for generic argument. BYTE is no Unsigned.", range: [SourceLocation { span: Range(TextLocation { line: 3, column: 51, offset: 210 }..TextLocation { line: 3, column: 52, offset: 211 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid type nature for generic argument. WORD is no Unsigned.", range: [SourceLocation { span: Range(TextLocation { line: 4, column: 51, offset: 278 }..TextLocation { line: 4, column: 52, offset: 279 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid type nature for generic argument. DWORD is no Unsigned.", range: [SourceLocation { span: Range(TextLocation { line: 5, column: 52, offset: 347 }..TextLocation { line: 5, column: 53, offset: 348 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid type nature for generic argument. LWORD is no Unsigned.", range: [SourceLocation { span: Range(TextLocation { line: 6, column: 52, offset: 416 }..TextLocation { line: 6, column: 53, offset: 417 }) }], err_no: type__invalid_nature } +SyntaxError { message: "Invalid type nature for generic argument. BYTE is no Unsigned.", range: [SourceLocation { span: Range(TextLocation { line: 3, column: 57, offset: 216 }..TextLocation { line: 3, column: 58, offset: 217 }) }], err_no: type__invalid_nature } +SyntaxError { message: "Invalid type nature for generic argument. WORD is no Unsigned.", range: [SourceLocation { span: Range(TextLocation { line: 4, column: 57, offset: 290 }..TextLocation { line: 4, column: 58, offset: 291 }) }], err_no: type__invalid_nature } +SyntaxError { message: "Invalid type nature for generic argument. DWORD is no Unsigned.", range: [SourceLocation { span: Range(TextLocation { line: 5, column: 58, offset: 365 }..TextLocation { line: 5, column: 59, offset: 366 }) }], err_no: type__invalid_nature } +SyntaxError { message: "Invalid type nature for generic argument. LWORD is no Unsigned.", range: [SourceLocation { span: Range(TextLocation { line: 6, column: 58, offset: 440 }..TextLocation { line: 6, column: 59, offset: 441 }) }], err_no: type__invalid_nature } diff --git a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_unsigned_does_not_allow_chars.snap b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_unsigned_does_not_allow_chars.snap index 66b260f39b..b16d084c82 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_unsigned_does_not_allow_chars.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_unsigned_does_not_allow_chars.snap @@ -4,6 +4,6 @@ expression: res --- SyntaxError { message: "Invalid assignment: cannot assign 'CHAR' to 'USINT'", range: [SourceLocation { span: Range(TextLocation { line: 2, column: 57, offset: 142 }..TextLocation { line: 2, column: 58, offset: 143 }) }], err_no: var__invalid_assignment } SyntaxError { message: "Invalid type nature for generic argument. CHAR is no Unsigned.", range: [SourceLocation { span: Range(TextLocation { line: 2, column: 57, offset: 142 }..TextLocation { line: 2, column: 58, offset: 143 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid assignment: cannot assign 'WCHAR' to 'USINT'", range: [SourceLocation { span: Range(TextLocation { line: 3, column: 52, offset: 211 }..TextLocation { line: 3, column: 53, offset: 212 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid type nature for generic argument. WCHAR is no Unsigned.", range: [SourceLocation { span: Range(TextLocation { line: 3, column: 52, offset: 211 }..TextLocation { line: 3, column: 53, offset: 212 }) }], err_no: type__invalid_nature } +SyntaxError { message: "Invalid assignment: cannot assign 'WCHAR' to 'USINT'", range: [SourceLocation { span: Range(TextLocation { line: 3, column: 58, offset: 217 }..TextLocation { line: 3, column: 59, offset: 218 }) }], err_no: var__invalid_assignment } +SyntaxError { message: "Invalid type nature for generic argument. WCHAR is no Unsigned.", range: [SourceLocation { span: Range(TextLocation { line: 3, column: 58, offset: 217 }..TextLocation { line: 3, column: 59, offset: 218 }) }], err_no: type__invalid_nature } diff --git a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_unsigned_does_not_allow_date.snap b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_unsigned_does_not_allow_date.snap index c8b0003104..379758d32c 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_unsigned_does_not_allow_date.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_unsigned_does_not_allow_date.snap @@ -3,8 +3,8 @@ source: src/validation/tests/generic_validation_tests.rs expression: res --- SyntaxError { message: "Invalid type nature for generic argument. DATE_AND_TIME is no Unsigned.", range: [SourceLocation { span: Range(TextLocation { line: 2, column: 55, offset: 140 }..TextLocation { line: 2, column: 56, offset: 141 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid type nature for generic argument. DATE_AND_TIME is no Unsigned.", range: [SourceLocation { span: Range(TextLocation { line: 3, column: 50, offset: 207 }..TextLocation { line: 3, column: 51, offset: 208 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid type nature for generic argument. DATE is no Unsigned.", range: [SourceLocation { span: Range(TextLocation { line: 4, column: 51, offset: 275 }..TextLocation { line: 4, column: 52, offset: 276 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid type nature for generic argument. TIME_OF_DAY is no Unsigned.", range: [SourceLocation { span: Range(TextLocation { line: 5, column: 50, offset: 342 }..TextLocation { line: 5, column: 51, offset: 343 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid type nature for generic argument. TIME_OF_DAY is no Unsigned.", range: [SourceLocation { span: Range(TextLocation { line: 6, column: 51, offset: 410 }..TextLocation { line: 6, column: 52, offset: 411 }) }], err_no: type__invalid_nature } +SyntaxError { message: "Invalid type nature for generic argument. DATE_AND_TIME is no Unsigned.", range: [SourceLocation { span: Range(TextLocation { line: 3, column: 56, offset: 213 }..TextLocation { line: 3, column: 57, offset: 214 }) }], err_no: type__invalid_nature } +SyntaxError { message: "Invalid type nature for generic argument. DATE is no Unsigned.", range: [SourceLocation { span: Range(TextLocation { line: 4, column: 57, offset: 287 }..TextLocation { line: 4, column: 58, offset: 288 }) }], err_no: type__invalid_nature } +SyntaxError { message: "Invalid type nature for generic argument. TIME_OF_DAY is no Unsigned.", range: [SourceLocation { span: Range(TextLocation { line: 5, column: 56, offset: 360 }..TextLocation { line: 5, column: 57, offset: 361 }) }], err_no: type__invalid_nature } +SyntaxError { message: "Invalid type nature for generic argument. TIME_OF_DAY is no Unsigned.", range: [SourceLocation { span: Range(TextLocation { line: 6, column: 57, offset: 434 }..TextLocation { line: 6, column: 58, offset: 435 }) }], err_no: type__invalid_nature } diff --git a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_unsigned_does_not_allow_signed_ints.snap b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_unsigned_does_not_allow_signed_ints.snap index 002482de27..ed065d0218 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_unsigned_does_not_allow_signed_ints.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_unsigned_does_not_allow_signed_ints.snap @@ -2,8 +2,8 @@ source: src/validation/tests/generic_validation_tests.rs expression: res --- -SyntaxError { message: "Invalid type nature for generic argument. SINT is no Unsigned.", range: [SourceLocation { span: Range(TextLocation { line: 2, column: 51, offset: 136 }..TextLocation { line: 2, column: 52, offset: 137 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid type nature for generic argument. INT is no Unsigned.", range: [SourceLocation { span: Range(TextLocation { line: 3, column: 56, offset: 209 }..TextLocation { line: 3, column: 57, offset: 210 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid type nature for generic argument. DINT is no Unsigned.", range: [SourceLocation { span: Range(TextLocation { line: 4, column: 51, offset: 277 }..TextLocation { line: 4, column: 52, offset: 278 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid type nature for generic argument. LINT is no Unsigned.", range: [SourceLocation { span: Range(TextLocation { line: 5, column: 51, offset: 345 }..TextLocation { line: 5, column: 52, offset: 346 }) }], err_no: type__invalid_nature } +SyntaxError { message: "Invalid type nature for generic argument. SINT is no Unsigned.", range: [SourceLocation { span: Range(TextLocation { line: 2, column: 57, offset: 142 }..TextLocation { line: 2, column: 58, offset: 143 }) }], err_no: type__invalid_nature } +SyntaxError { message: "Invalid type nature for generic argument. INT is no Unsigned.", range: [SourceLocation { span: Range(TextLocation { line: 3, column: 56, offset: 215 }..TextLocation { line: 3, column: 57, offset: 216 }) }], err_no: type__invalid_nature } +SyntaxError { message: "Invalid type nature for generic argument. DINT is no Unsigned.", range: [SourceLocation { span: Range(TextLocation { line: 4, column: 57, offset: 289 }..TextLocation { line: 4, column: 58, offset: 290 }) }], err_no: type__invalid_nature } +SyntaxError { message: "Invalid type nature for generic argument. LINT is no Unsigned.", range: [SourceLocation { span: Range(TextLocation { line: 5, column: 57, offset: 363 }..TextLocation { line: 5, column: 58, offset: 364 }) }], err_no: type__invalid_nature } diff --git a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_unsigned_does_not_allow_time.snap b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_unsigned_does_not_allow_time.snap index c246010e35..ccb44ea6a9 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_unsigned_does_not_allow_time.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_unsigned_does_not_allow_time.snap @@ -3,5 +3,5 @@ source: src/validation/tests/generic_validation_tests.rs expression: res --- SyntaxError { message: "Invalid type nature for generic argument. TIME is no Unsigned.", range: [SourceLocation { span: Range(TextLocation { line: 2, column: 57, offset: 142 }..TextLocation { line: 2, column: 58, offset: 143 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid type nature for generic argument. TIME is no Unsigned.", range: [SourceLocation { span: Range(TextLocation { line: 3, column: 52, offset: 211 }..TextLocation { line: 3, column: 53, offset: 212 }) }], err_no: type__invalid_nature } +SyntaxError { message: "Invalid type nature for generic argument. TIME is no Unsigned.", range: [SourceLocation { span: Range(TextLocation { line: 3, column: 58, offset: 217 }..TextLocation { line: 3, column: 59, offset: 218 }) }], err_no: type__invalid_nature } diff --git a/src/validation/tests/snapshots/rusty__validation__tests__literals_validation_tests__char_cast_validate.snap b/src/validation/tests/snapshots/rusty__validation__tests__literals_validation_tests__char_cast_validate.snap index 6ad9ad93ce..ce38ccf074 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__literals_validation_tests__char_cast_validate.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__literals_validation_tests__char_cast_validate.snap @@ -2,6 +2,6 @@ source: src/validation/tests/literals_validation_tests.rs expression: res --- -SyntaxError { message: "Literal \"XY\" out of range (CHAR)", range: [SourceLocation { span: Range(TextLocation { line: 6, column: 3, offset: 83 }..TextLocation { line: 6, column: 12, offset: 92 }) }], err_no: type__literal_out_of_range } -SyntaxError { message: "Literal 'YZ' out of range (WCHAR)", range: [SourceLocation { span: Range(TextLocation { line: 7, column: 3, offset: 97 }..TextLocation { line: 7, column: 13, offset: 107 }) }], err_no: type__literal_out_of_range } +SyntaxError { message: "Literal \"XY\" out of range (CHAR)", range: [SourceLocation { span: Range(TextLocation { line: 6, column: 12, offset: 80 }..TextLocation { line: 6, column: 21, offset: 89 }) }], err_no: type__literal_out_of_range } +SyntaxError { message: "Literal 'YZ' out of range (WCHAR)", range: [SourceLocation { span: Range(TextLocation { line: 7, column: 12, offset: 103 }..TextLocation { line: 7, column: 22, offset: 113 }) }], err_no: type__literal_out_of_range } diff --git a/src/validation/tests/snapshots/rusty__validation__tests__literals_validation_tests__literal_cast_with_non_literal.snap b/src/validation/tests/snapshots/rusty__validation__tests__literals_validation_tests__literal_cast_with_non_literal.snap index 496fcacb12..51a2732755 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__literals_validation_tests__literal_cast_with_non_literal.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__literals_validation_tests__literal_cast_with_non_literal.snap @@ -2,5 +2,5 @@ source: src/validation/tests/literals_validation_tests.rs expression: res --- -SyntaxError { message: "Expected literal", range: [SourceLocation { span: Range(TextLocation { line: 1, column: 12, offset: 25 }..TextLocation { line: 1, column: 19, offset: 32 }) }], err_no: type__expected_literal } +SyntaxError { message: "Expected literal", range: [SourceLocation { span: Range(TextLocation { line: 1, column: 12, offset: 24 }..TextLocation { line: 1, column: 19, offset: 31 }) }], err_no: type__expected_literal } diff --git a/src/validation/tests/snapshots/rusty__validation__tests__literals_validation_tests__real_literal_casts_are_validated.snap b/src/validation/tests/snapshots/rusty__validation__tests__literals_validation_tests__real_literal_casts_are_validated.snap index f19f9a3f0b..18a43acb91 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__literals_validation_tests__real_literal_casts_are_validated.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__literals_validation_tests__real_literal_casts_are_validated.snap @@ -2,6 +2,6 @@ source: src/validation/tests/literals_validation_tests.rs expression: res --- -SyntaxError { message: "Literal '3.14' is not compatible to REAL", range: [SourceLocation { span: Range(TextLocation { line: 10, column: 12, offset: 180 }..TextLocation { line: 10, column: 23, offset: 191 }) }], err_no: type__incompatible_literal_cast } -SyntaxError { message: "Literal \"3.14\" is not compatible to LREAL", range: [SourceLocation { span: Range(TextLocation { line: 14, column: 12, offset: 252 }..TextLocation { line: 14, column: 24, offset: 264 }) }], err_no: type__incompatible_literal_cast } +SyntaxError { message: "Literal '3.14' is not compatible to REAL", range: [SourceLocation { span: Range(TextLocation { line: 10, column: 12, offset: 168 }..TextLocation { line: 10, column: 23, offset: 179 }) }], err_no: type__incompatible_literal_cast } +SyntaxError { message: "Literal \"3.14\" is not compatible to LREAL", range: [SourceLocation { span: Range(TextLocation { line: 14, column: 12, offset: 239 }..TextLocation { line: 14, column: 24, offset: 251 }) }], err_no: type__incompatible_literal_cast } diff --git a/src/validation/tests/snapshots/rusty__validation__tests__literals_validation_tests__string_literal_casts_are_validated.snap b/src/validation/tests/snapshots/rusty__validation__tests__literals_validation_tests__string_literal_casts_are_validated.snap index 575232aab8..d25d3de01c 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__literals_validation_tests__string_literal_casts_are_validated.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__literals_validation_tests__string_literal_casts_are_validated.snap @@ -2,10 +2,10 @@ source: src/validation/tests/literals_validation_tests.rs expression: res --- -SyntaxError { message: "Literal true is not compatible to STRING", range: [SourceLocation { span: Range(TextLocation { line: 6, column: 12, offset: 102 }..TextLocation { line: 6, column: 23, offset: 113 }) }], err_no: type__incompatible_literal_cast } -SyntaxError { message: "Literal false is not compatible to WSTRING", range: [SourceLocation { span: Range(TextLocation { line: 7, column: 12, offset: 127 }..TextLocation { line: 7, column: 25, offset: 140 }) }], err_no: type__incompatible_literal_cast } -SyntaxError { message: "Literal 22 is not compatible to STRING", range: [SourceLocation { span: Range(TextLocation { line: 9, column: 12, offset: 155 }..TextLocation { line: 9, column: 21, offset: 164 }) }], err_no: type__incompatible_literal_cast } -SyntaxError { message: "Literal 33 is not compatible to WSTRING", range: [SourceLocation { span: Range(TextLocation { line: 10, column: 12, offset: 178 }..TextLocation { line: 10, column: 22, offset: 188 }) }], err_no: type__incompatible_literal_cast } -SyntaxError { message: "Literal 3.14 is not compatible to STRING", range: [SourceLocation { span: Range(TextLocation { line: 12, column: 12, offset: 203 }..TextLocation { line: 12, column: 23, offset: 214 }) }], err_no: type__incompatible_literal_cast } -SyntaxError { message: "Literal 1.0 is not compatible to WSTRING", range: [SourceLocation { span: Range(TextLocation { line: 13, column: 12, offset: 228 }..TextLocation { line: 13, column: 23, offset: 239 }) }], err_no: type__incompatible_literal_cast } +SyntaxError { message: "Literal true is not compatible to STRING", range: [SourceLocation { span: Range(TextLocation { line: 6, column: 12, offset: 90 }..TextLocation { line: 6, column: 23, offset: 101 }) }], err_no: type__incompatible_literal_cast } +SyntaxError { message: "Literal false is not compatible to WSTRING", range: [SourceLocation { span: Range(TextLocation { line: 7, column: 12, offset: 115 }..TextLocation { line: 7, column: 25, offset: 128 }) }], err_no: type__incompatible_literal_cast } +SyntaxError { message: "Literal 22 is not compatible to STRING", range: [SourceLocation { span: Range(TextLocation { line: 9, column: 12, offset: 143 }..TextLocation { line: 9, column: 21, offset: 152 }) }], err_no: type__incompatible_literal_cast } +SyntaxError { message: "Literal 33 is not compatible to WSTRING", range: [SourceLocation { span: Range(TextLocation { line: 10, column: 12, offset: 166 }..TextLocation { line: 10, column: 22, offset: 176 }) }], err_no: type__incompatible_literal_cast } +SyntaxError { message: "Literal 3.14 is not compatible to STRING", range: [SourceLocation { span: Range(TextLocation { line: 12, column: 12, offset: 191 }..TextLocation { line: 12, column: 23, offset: 202 }) }], err_no: type__incompatible_literal_cast } +SyntaxError { message: "Literal 1.0 is not compatible to WSTRING", range: [SourceLocation { span: Range(TextLocation { line: 13, column: 12, offset: 216 }..TextLocation { line: 13, column: 23, offset: 227 }) }], err_no: type__incompatible_literal_cast } diff --git a/src/validation/tests/snapshots/rusty__validation__tests__pou_validation_tests__class_has_implementation.snap b/src/validation/tests/snapshots/rusty__validation__tests__pou_validation_tests__class_has_implementation.snap index 8e5bfb0237..d9b8128c21 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__pou_validation_tests__class_has_implementation.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__pou_validation_tests__class_has_implementation.snap @@ -2,5 +2,5 @@ source: src/validation/tests/pou_validation_tests.rs expression: res --- -SyntaxError { message: "A class cannot have an implementation", range: [SourceLocation { span: Range(TextLocation { line: 5, column: 12, offset: 90 }..TextLocation { line: 6, column: 17, offset: 122 }) }], err_no: syntax__generic_error } +SyntaxError { message: "A class cannot have an implementation", range: [SourceLocation { span: Range(TextLocation { line: 5, column: 12, offset: 88 }..TextLocation { line: 6, column: 17, offset: 120 }) }], err_no: syntax__generic_error } diff --git a/src/validation/tests/snapshots/rusty__validation__tests__recursive_validation_tests__arrays__one_cycle_bcb.snap b/src/validation/tests/snapshots/rusty__validation__tests__recursive_validation_tests__arrays__one_cycle_bcb.snap index 18aa8ff5f4..3529627da3 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__recursive_validation_tests__arrays__one_cycle_bcb.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__recursive_validation_tests__arrays__one_cycle_bcb.snap @@ -2,5 +2,5 @@ source: src/validation/tests/recursive_validation_tests.rs expression: res --- -SemanticError { message: "Recursive data structure `B -> C -> B` has infinite size", range: [SourceLocation { span: Range(TextLocation { line: 5, column: 17, offset: 129 }..TextLocation { line: 5, column: 18, offset: 130 }) }, SourceLocation { span: Range(TextLocation { line: 9, column: 17, offset: 240 }..TextLocation { line: 9, column: 18, offset: 241 }) }], err_no: pou__recursive_data_structure } +SemanticError { message: "Recursive data structure `B -> C -> B` has infinite size", range: [SourceLocation { span: Range(TextLocation { line: 5, column: 17, offset: 117 }..TextLocation { line: 5, column: 18, offset: 118 }) }, SourceLocation { span: Range(TextLocation { line: 9, column: 17, offset: 216 }..TextLocation { line: 9, column: 18, offset: 217 }) }], err_no: pou__recursive_data_structure } diff --git a/src/validation/tests/snapshots/rusty__validation__tests__recursive_validation_tests__arrays__one_cycle_with_multiple_identical_members_aba.snap b/src/validation/tests/snapshots/rusty__validation__tests__recursive_validation_tests__arrays__one_cycle_with_multiple_identical_members_aba.snap index 35de671eeb..3c359549d5 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__recursive_validation_tests__arrays__one_cycle_with_multiple_identical_members_aba.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__recursive_validation_tests__arrays__one_cycle_with_multiple_identical_members_aba.snap @@ -2,5 +2,5 @@ source: src/validation/tests/recursive_validation_tests.rs expression: res --- -SemanticError { message: "Recursive data structure `A -> B -> A` has infinite size", range: [SourceLocation { span: Range(TextLocation { line: 1, column: 17, offset: 18 }..TextLocation { line: 1, column: 18, offset: 19 }) }, SourceLocation { span: Range(TextLocation { line: 7, column: 17, offset: 197 }..TextLocation { line: 7, column: 18, offset: 198 }) }], err_no: pou__recursive_data_structure } +SemanticError { message: "Recursive data structure `A -> B -> A` has infinite size", range: [SourceLocation { span: Range(TextLocation { line: 1, column: 17, offset: 18 }..TextLocation { line: 1, column: 18, offset: 19 }) }, SourceLocation { span: Range(TextLocation { line: 7, column: 17, offset: 196 }..TextLocation { line: 7, column: 18, offset: 197 }) }], err_no: pou__recursive_data_structure } diff --git a/src/validation/tests/snapshots/rusty__validation__tests__recursive_validation_tests__arrays__two_cycles_aa_and_aba.snap b/src/validation/tests/snapshots/rusty__validation__tests__recursive_validation_tests__arrays__two_cycles_aa_and_aba.snap index 31e015a92d..28beaa22eb 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__recursive_validation_tests__arrays__two_cycles_aa_and_aba.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__recursive_validation_tests__arrays__two_cycles_aa_and_aba.snap @@ -3,5 +3,5 @@ source: src/validation/tests/recursive_validation_tests.rs expression: res --- SemanticError { message: "Recursive data structure `A -> A` has infinite size", range: [SourceLocation { span: Range(TextLocation { line: 1, column: 17, offset: 18 }..TextLocation { line: 1, column: 18, offset: 19 }) }], err_no: pou__recursive_data_structure } -SemanticError { message: "Recursive data structure `A -> B -> A` has infinite size", range: [SourceLocation { span: Range(TextLocation { line: 1, column: 17, offset: 18 }..TextLocation { line: 1, column: 18, offset: 19 }) }, SourceLocation { span: Range(TextLocation { line: 6, column: 17, offset: 167 }..TextLocation { line: 6, column: 18, offset: 168 }) }], err_no: pou__recursive_data_structure } +SemanticError { message: "Recursive data structure `A -> B -> A` has infinite size", range: [SourceLocation { span: Range(TextLocation { line: 1, column: 17, offset: 18 }..TextLocation { line: 1, column: 18, offset: 19 }) }, SourceLocation { span: Range(TextLocation { line: 6, column: 17, offset: 155 }..TextLocation { line: 6, column: 18, offset: 156 }) }], err_no: pou__recursive_data_structure } diff --git a/src/validation/tests/snapshots/rusty__validation__tests__recursive_validation_tests__arrays__two_cycles_with_branch_input.snap b/src/validation/tests/snapshots/rusty__validation__tests__recursive_validation_tests__arrays__two_cycles_with_branch_input.snap index a7869f0ca3..5278172cbb 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__recursive_validation_tests__arrays__two_cycles_with_branch_input.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__recursive_validation_tests__arrays__two_cycles_with_branch_input.snap @@ -2,6 +2,6 @@ source: src/validation/tests/recursive_validation_tests.rs expression: res --- -SemanticError { message: "Recursive data structure `F -> G -> H -> I -> F` has infinite size", range: [SourceLocation { span: Range(TextLocation { line: 21, column: 27, offset: 500 }..TextLocation { line: 21, column: 28, offset: 501 }) }, SourceLocation { span: Range(TextLocation { line: 28, column: 17, offset: 667 }..TextLocation { line: 28, column: 18, offset: 668 }) }, SourceLocation { span: Range(TextLocation { line: 32, column: 27, offset: 773 }..TextLocation { line: 32, column: 28, offset: 774 }) }, SourceLocation { span: Range(TextLocation { line: 38, column: 17, offset: 901 }..TextLocation { line: 38, column: 18, offset: 902 }) }], err_no: pou__recursive_data_structure } -SemanticError { message: "Recursive data structure `B -> C -> E -> F -> B` has infinite size", range: [SourceLocation { span: Range(TextLocation { line: 7, column: 17, offset: 156 }..TextLocation { line: 7, column: 18, offset: 157 }) }, SourceLocation { span: Range(TextLocation { line: 11, column: 27, offset: 250 }..TextLocation { line: 11, column: 28, offset: 251 }) }, SourceLocation { span: Range(TextLocation { line: 17, column: 17, offset: 378 }..TextLocation { line: 17, column: 18, offset: 379 }) }, SourceLocation { span: Range(TextLocation { line: 21, column: 27, offset: 500 }..TextLocation { line: 21, column: 28, offset: 501 }) }], err_no: pou__recursive_data_structure } +SemanticError { message: "Recursive data structure `F -> G -> H -> I -> F` has infinite size", range: [SourceLocation { span: Range(TextLocation { line: 21, column: 27, offset: 488 }..TextLocation { line: 21, column: 28, offset: 489 }) }, SourceLocation { span: Range(TextLocation { line: 28, column: 17, offset: 643 }..TextLocation { line: 28, column: 18, offset: 644 }) }, SourceLocation { span: Range(TextLocation { line: 32, column: 27, offset: 737 }..TextLocation { line: 32, column: 28, offset: 738 }) }, SourceLocation { span: Range(TextLocation { line: 38, column: 17, offset: 865 }..TextLocation { line: 38, column: 18, offset: 866 }) }], err_no: pou__recursive_data_structure } +SemanticError { message: "Recursive data structure `B -> C -> E -> F -> B` has infinite size", range: [SourceLocation { span: Range(TextLocation { line: 7, column: 17, offset: 156 }..TextLocation { line: 7, column: 18, offset: 157 }) }, SourceLocation { span: Range(TextLocation { line: 11, column: 27, offset: 250 }..TextLocation { line: 11, column: 28, offset: 251 }) }, SourceLocation { span: Range(TextLocation { line: 17, column: 17, offset: 378 }..TextLocation { line: 17, column: 18, offset: 379 }) }, SourceLocation { span: Range(TextLocation { line: 21, column: 27, offset: 488 }..TextLocation { line: 21, column: 28, offset: 489 }) }], err_no: pou__recursive_data_structure } diff --git a/src/validation/tests/snapshots/rusty__validation__tests__recursive_validation_tests__functionblocks__two_cycles_with_branch_input.snap b/src/validation/tests/snapshots/rusty__validation__tests__recursive_validation_tests__functionblocks__two_cycles_with_branch_input.snap index 9575b9934c..d44e0ed07f 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__recursive_validation_tests__functionblocks__two_cycles_with_branch_input.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__recursive_validation_tests__functionblocks__two_cycles_with_branch_input.snap @@ -2,6 +2,6 @@ source: src/validation/tests/recursive_validation_tests.rs expression: res --- -SemanticError { message: "Recursive data structure `F -> G -> H -> I -> F` has infinite size", range: [SourceLocation { span: Range(TextLocation { line: 25, column: 27, offset: 592 }..TextLocation { line: 25, column: 28, offset: 593 }) }, SourceLocation { span: Range(TextLocation { line: 32, column: 27, offset: 769 }..TextLocation { line: 32, column: 28, offset: 770 }) }, SourceLocation { span: Range(TextLocation { line: 38, column: 27, offset: 919 }..TextLocation { line: 38, column: 28, offset: 920 }) }, SourceLocation { span: Range(TextLocation { line: 44, column: 27, offset: 1057 }..TextLocation { line: 44, column: 28, offset: 1058 }) }], err_no: pou__recursive_data_structure } -SemanticError { message: "Recursive data structure `B -> C -> E -> F -> B` has infinite size", range: [SourceLocation { span: Range(TextLocation { line: 7, column: 27, offset: 166 }..TextLocation { line: 7, column: 28, offset: 167 }) }, SourceLocation { span: Range(TextLocation { line: 13, column: 27, offset: 304 }..TextLocation { line: 13, column: 28, offset: 305 }) }, SourceLocation { span: Range(TextLocation { line: 19, column: 27, offset: 442 }..TextLocation { line: 19, column: 28, offset: 443 }) }, SourceLocation { span: Range(TextLocation { line: 25, column: 27, offset: 592 }..TextLocation { line: 25, column: 28, offset: 593 }) }], err_no: pou__recursive_data_structure } +SemanticError { message: "Recursive data structure `F -> G -> H -> I -> F` has infinite size", range: [SourceLocation { span: Range(TextLocation { line: 25, column: 27, offset: 580 }..TextLocation { line: 25, column: 28, offset: 581 }) }, SourceLocation { span: Range(TextLocation { line: 32, column: 27, offset: 745 }..TextLocation { line: 32, column: 28, offset: 746 }) }, SourceLocation { span: Range(TextLocation { line: 38, column: 27, offset: 883 }..TextLocation { line: 38, column: 28, offset: 884 }) }, SourceLocation { span: Range(TextLocation { line: 44, column: 27, offset: 1021 }..TextLocation { line: 44, column: 28, offset: 1022 }) }], err_no: pou__recursive_data_structure } +SemanticError { message: "Recursive data structure `B -> C -> E -> F -> B` has infinite size", range: [SourceLocation { span: Range(TextLocation { line: 7, column: 27, offset: 166 }..TextLocation { line: 7, column: 28, offset: 167 }) }, SourceLocation { span: Range(TextLocation { line: 13, column: 27, offset: 304 }..TextLocation { line: 13, column: 28, offset: 305 }) }, SourceLocation { span: Range(TextLocation { line: 19, column: 27, offset: 442 }..TextLocation { line: 19, column: 28, offset: 443 }) }, SourceLocation { span: Range(TextLocation { line: 25, column: 27, offset: 580 }..TextLocation { line: 25, column: 28, offset: 581 }) }], err_no: pou__recursive_data_structure } diff --git a/src/validation/tests/snapshots/rusty__validation__tests__recursive_validation_tests__mixed_structs_and_functionblocks__two_cycles_with_branch_input.snap b/src/validation/tests/snapshots/rusty__validation__tests__recursive_validation_tests__mixed_structs_and_functionblocks__two_cycles_with_branch_input.snap index 6b78570d2b..1e2734e00f 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__recursive_validation_tests__mixed_structs_and_functionblocks__two_cycles_with_branch_input.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__recursive_validation_tests__mixed_structs_and_functionblocks__two_cycles_with_branch_input.snap @@ -2,6 +2,6 @@ source: src/validation/tests/recursive_validation_tests.rs expression: res --- -SemanticError { message: "Recursive data structure `F -> G -> H -> I -> F` has infinite size", range: [SourceLocation { span: Range(TextLocation { line: 21, column: 27, offset: 484 }..TextLocation { line: 21, column: 28, offset: 485 }) }, SourceLocation { span: Range(TextLocation { line: 28, column: 17, offset: 651 }..TextLocation { line: 28, column: 18, offset: 652 }) }, SourceLocation { span: Range(TextLocation { line: 32, column: 27, offset: 757 }..TextLocation { line: 32, column: 28, offset: 758 }) }, SourceLocation { span: Range(TextLocation { line: 38, column: 17, offset: 885 }..TextLocation { line: 38, column: 18, offset: 886 }) }], err_no: pou__recursive_data_structure } -SemanticError { message: "Recursive data structure `B -> C -> E -> F -> B` has infinite size", range: [SourceLocation { span: Range(TextLocation { line: 7, column: 17, offset: 156 }..TextLocation { line: 7, column: 18, offset: 157 }) }, SourceLocation { span: Range(TextLocation { line: 11, column: 27, offset: 250 }..TextLocation { line: 11, column: 28, offset: 251 }) }, SourceLocation { span: Range(TextLocation { line: 17, column: 17, offset: 378 }..TextLocation { line: 17, column: 18, offset: 379 }) }, SourceLocation { span: Range(TextLocation { line: 21, column: 27, offset: 484 }..TextLocation { line: 21, column: 28, offset: 485 }) }], err_no: pou__recursive_data_structure } +SemanticError { message: "Recursive data structure `F -> G -> H -> I -> F` has infinite size", range: [SourceLocation { span: Range(TextLocation { line: 21, column: 27, offset: 472 }..TextLocation { line: 21, column: 28, offset: 473 }) }, SourceLocation { span: Range(TextLocation { line: 28, column: 17, offset: 627 }..TextLocation { line: 28, column: 18, offset: 628 }) }, SourceLocation { span: Range(TextLocation { line: 32, column: 27, offset: 721 }..TextLocation { line: 32, column: 28, offset: 722 }) }, SourceLocation { span: Range(TextLocation { line: 38, column: 17, offset: 849 }..TextLocation { line: 38, column: 18, offset: 850 }) }], err_no: pou__recursive_data_structure } +SemanticError { message: "Recursive data structure `B -> C -> E -> F -> B` has infinite size", range: [SourceLocation { span: Range(TextLocation { line: 7, column: 17, offset: 156 }..TextLocation { line: 7, column: 18, offset: 157 }) }, SourceLocation { span: Range(TextLocation { line: 11, column: 27, offset: 250 }..TextLocation { line: 11, column: 28, offset: 251 }) }, SourceLocation { span: Range(TextLocation { line: 17, column: 17, offset: 378 }..TextLocation { line: 17, column: 18, offset: 379 }) }, SourceLocation { span: Range(TextLocation { line: 21, column: 27, offset: 472 }..TextLocation { line: 21, column: 28, offset: 473 }) }], err_no: pou__recursive_data_structure } diff --git a/src/validation/tests/snapshots/rusty__validation__tests__recursive_validation_tests__structs__one_cycle_bcb.snap b/src/validation/tests/snapshots/rusty__validation__tests__recursive_validation_tests__structs__one_cycle_bcb.snap index 882c6e38e8..2fa7035880 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__recursive_validation_tests__structs__one_cycle_bcb.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__recursive_validation_tests__structs__one_cycle_bcb.snap @@ -2,5 +2,5 @@ source: src/validation/tests/recursive_validation_tests.rs expression: res --- -SemanticError { message: "Recursive data structure `B -> C -> B` has infinite size", range: [SourceLocation { span: Range(TextLocation { line: 5, column: 17, offset: 114 }..TextLocation { line: 5, column: 18, offset: 115 }) }, SourceLocation { span: Range(TextLocation { line: 9, column: 17, offset: 210 }..TextLocation { line: 9, column: 18, offset: 211 }) }], err_no: pou__recursive_data_structure } +SemanticError { message: "Recursive data structure `B -> C -> B` has infinite size", range: [SourceLocation { span: Range(TextLocation { line: 5, column: 17, offset: 102 }..TextLocation { line: 5, column: 18, offset: 103 }) }, SourceLocation { span: Range(TextLocation { line: 9, column: 17, offset: 186 }..TextLocation { line: 9, column: 18, offset: 187 }) }], err_no: pou__recursive_data_structure } diff --git a/src/validation/tests/snapshots/rusty__validation__tests__recursive_validation_tests__structs__one_cycle_with_multiple_identical_members_aba.snap b/src/validation/tests/snapshots/rusty__validation__tests__recursive_validation_tests__structs__one_cycle_with_multiple_identical_members_aba.snap index 192e93569b..108c58431d 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__recursive_validation_tests__structs__one_cycle_with_multiple_identical_members_aba.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__recursive_validation_tests__structs__one_cycle_with_multiple_identical_members_aba.snap @@ -2,5 +2,5 @@ source: src/validation/tests/recursive_validation_tests.rs expression: res --- -SemanticError { message: "Recursive data structure `A -> B -> A` has infinite size", range: [SourceLocation { span: Range(TextLocation { line: 1, column: 17, offset: 18 }..TextLocation { line: 1, column: 18, offset: 19 }) }, SourceLocation { span: Range(TextLocation { line: 7, column: 17, offset: 152 }..TextLocation { line: 7, column: 18, offset: 153 }) }], err_no: pou__recursive_data_structure } +SemanticError { message: "Recursive data structure `A -> B -> A` has infinite size", range: [SourceLocation { span: Range(TextLocation { line: 1, column: 17, offset: 18 }..TextLocation { line: 1, column: 18, offset: 19 }) }, SourceLocation { span: Range(TextLocation { line: 7, column: 17, offset: 151 }..TextLocation { line: 7, column: 18, offset: 152 }) }], err_no: pou__recursive_data_structure } diff --git a/src/validation/tests/snapshots/rusty__validation__tests__recursive_validation_tests__structs__two_cycles_aa_and_aba.snap b/src/validation/tests/snapshots/rusty__validation__tests__recursive_validation_tests__structs__two_cycles_aa_and_aba.snap index 8bcfd6106f..58ea13a545 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__recursive_validation_tests__structs__two_cycles_aa_and_aba.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__recursive_validation_tests__structs__two_cycles_aa_and_aba.snap @@ -3,5 +3,5 @@ source: src/validation/tests/recursive_validation_tests.rs expression: res --- SemanticError { message: "Recursive data structure `A -> A` has infinite size", range: [SourceLocation { span: Range(TextLocation { line: 1, column: 17, offset: 18 }..TextLocation { line: 1, column: 18, offset: 19 }) }], err_no: pou__recursive_data_structure } -SemanticError { message: "Recursive data structure `A -> B -> A` has infinite size", range: [SourceLocation { span: Range(TextLocation { line: 1, column: 17, offset: 18 }..TextLocation { line: 1, column: 18, offset: 19 }) }, SourceLocation { span: Range(TextLocation { line: 6, column: 17, offset: 137 }..TextLocation { line: 6, column: 18, offset: 138 }) }], err_no: pou__recursive_data_structure } +SemanticError { message: "Recursive data structure `A -> B -> A` has infinite size", range: [SourceLocation { span: Range(TextLocation { line: 1, column: 17, offset: 18 }..TextLocation { line: 1, column: 18, offset: 19 }) }, SourceLocation { span: Range(TextLocation { line: 6, column: 17, offset: 125 }..TextLocation { line: 6, column: 18, offset: 126 }) }], err_no: pou__recursive_data_structure } diff --git a/src/validation/tests/snapshots/rusty__validation__tests__recursive_validation_tests__structs__two_cycles_branch_cc_and_cec.snap b/src/validation/tests/snapshots/rusty__validation__tests__recursive_validation_tests__structs__two_cycles_branch_cc_and_cec.snap index 9e5b7401df..c8a751145d 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__recursive_validation_tests__structs__two_cycles_branch_cc_and_cec.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__recursive_validation_tests__structs__two_cycles_branch_cc_and_cec.snap @@ -2,6 +2,6 @@ source: src/validation/tests/recursive_validation_tests.rs expression: res --- -SemanticError { message: "Recursive data structure `C -> C` has infinite size", range: [SourceLocation { span: Range(TextLocation { line: 9, column: 17, offset: 210 }..TextLocation { line: 9, column: 18, offset: 211 }) }], err_no: pou__recursive_data_structure } -SemanticError { message: "Recursive data structure `C -> E -> C` has infinite size", range: [SourceLocation { span: Range(TextLocation { line: 9, column: 17, offset: 210 }..TextLocation { line: 9, column: 18, offset: 211 }) }, SourceLocation { span: Range(TextLocation { line: 14, column: 17, offset: 329 }..TextLocation { line: 14, column: 18, offset: 330 }) }], err_no: pou__recursive_data_structure } +SemanticError { message: "Recursive data structure `C -> C` has infinite size", range: [SourceLocation { span: Range(TextLocation { line: 9, column: 17, offset: 186 }..TextLocation { line: 9, column: 18, offset: 187 }) }], err_no: pou__recursive_data_structure } +SemanticError { message: "Recursive data structure `C -> E -> C` has infinite size", range: [SourceLocation { span: Range(TextLocation { line: 9, column: 17, offset: 186 }..TextLocation { line: 9, column: 18, offset: 187 }) }, SourceLocation { span: Range(TextLocation { line: 14, column: 17, offset: 293 }..TextLocation { line: 14, column: 18, offset: 294 }) }], err_no: pou__recursive_data_structure } diff --git a/src/validation/tests/snapshots/rusty__validation__tests__reference_resolve_tests__reference_to_private_variable_in_intermediate_fb.snap b/src/validation/tests/snapshots/rusty__validation__tests__reference_resolve_tests__reference_to_private_variable_in_intermediate_fb.snap index ce077a908b..157f75e045 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__reference_resolve_tests__reference_to_private_variable_in_intermediate_fb.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__reference_resolve_tests__reference_to_private_variable_in_intermediate_fb.snap @@ -2,5 +2,5 @@ source: src/validation/tests/reference_resolve_tests.rs expression: res --- -SyntaxError { message: "Illegal access to private member fb1.f", range: [SourceLocation { span: Range(TextLocation { line: 18, column: 18, offset: 413 }..TextLocation { line: 18, column: 19, offset: 414 }) }], err_no: reference__illegal_access } +SyntaxError { message: "Illegal access to private member fb1.f", range: [SourceLocation { span: Range(TextLocation { line: 18, column: 18, offset: 393 }..TextLocation { line: 18, column: 19, offset: 394 }) }], err_no: reference__illegal_access } diff --git a/src/validation/tests/snapshots/rusty__validation__tests__reference_resolve_tests__reference_to_private_variable_is_illegal.snap b/src/validation/tests/snapshots/rusty__validation__tests__reference_resolve_tests__reference_to_private_variable_is_illegal.snap index de996a85ec..7fb1b20c72 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__reference_resolve_tests__reference_to_private_variable_is_illegal.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__reference_resolve_tests__reference_to_private_variable_is_illegal.snap @@ -2,5 +2,5 @@ source: src/validation/tests/reference_resolve_tests.rs expression: res --- -SyntaxError { message: "Illegal access to private member prg.s", range: [SourceLocation { span: Range(TextLocation { line: 8, column: 20, offset: 175 }..TextLocation { line: 8, column: 21, offset: 176 }) }], err_no: reference__illegal_access } +SyntaxError { message: "Illegal access to private member prg.s", range: [SourceLocation { span: Range(TextLocation { line: 8, column: 20, offset: 174 }..TextLocation { line: 8, column: 21, offset: 175 }) }], err_no: reference__illegal_access } diff --git a/src/validation/tests/snapshots/rusty__validation__tests__reference_resolve_tests__resole_struct_member_access.snap b/src/validation/tests/snapshots/rusty__validation__tests__reference_resolve_tests__resole_struct_member_access.snap index d08c1beecd..f3548e849f 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__reference_resolve_tests__resole_struct_member_access.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__reference_resolve_tests__resole_struct_member_access.snap @@ -2,10 +2,10 @@ source: src/validation/tests/reference_resolve_tests.rs expression: res --- -SyntaxError { message: "Could not resolve reference to field10", range: [SourceLocation { span: Range(TextLocation { line: 27, column: 18, offset: 694 }..TextLocation { line: 27, column: 25, offset: 701 }) }], err_no: reference__unresolved } -SyntaxError { message: "Could not resolve reference to field20", range: [SourceLocation { span: Range(TextLocation { line: 28, column: 18, offset: 721 }..TextLocation { line: 28, column: 25, offset: 728 }) }], err_no: reference__unresolved } -SyntaxError { message: "Could not resolve reference to field30", range: [SourceLocation { span: Range(TextLocation { line: 29, column: 18, offset: 748 }..TextLocation { line: 29, column: 25, offset: 755 }) }], err_no: reference__unresolved } -SyntaxError { message: "Could not resolve reference to subfield10", range: [SourceLocation { span: Range(TextLocation { line: 37, column: 22, offset: 955 }..TextLocation { line: 37, column: 32, offset: 965 }) }], err_no: reference__unresolved } -SyntaxError { message: "Could not resolve reference to subfield20", range: [SourceLocation { span: Range(TextLocation { line: 38, column: 22, offset: 989 }..TextLocation { line: 38, column: 32, offset: 999 }) }], err_no: reference__unresolved } -SyntaxError { message: "Could not resolve reference to subfield30", range: [SourceLocation { span: Range(TextLocation { line: 39, column: 22, offset: 1023 }..TextLocation { line: 39, column: 32, offset: 1033 }) }], err_no: reference__unresolved } +SyntaxError { message: "Could not resolve reference to field10", range: [SourceLocation { span: Range(TextLocation { line: 27, column: 18, offset: 691 }..TextLocation { line: 27, column: 25, offset: 698 }) }], err_no: reference__unresolved } +SyntaxError { message: "Could not resolve reference to field20", range: [SourceLocation { span: Range(TextLocation { line: 28, column: 18, offset: 718 }..TextLocation { line: 28, column: 25, offset: 725 }) }], err_no: reference__unresolved } +SyntaxError { message: "Could not resolve reference to field30", range: [SourceLocation { span: Range(TextLocation { line: 29, column: 18, offset: 745 }..TextLocation { line: 29, column: 25, offset: 752 }) }], err_no: reference__unresolved } +SyntaxError { message: "Could not resolve reference to subfield10", range: [SourceLocation { span: Range(TextLocation { line: 37, column: 22, offset: 951 }..TextLocation { line: 37, column: 32, offset: 961 }) }], err_no: reference__unresolved } +SyntaxError { message: "Could not resolve reference to subfield20", range: [SourceLocation { span: Range(TextLocation { line: 38, column: 22, offset: 985 }..TextLocation { line: 38, column: 32, offset: 995 }) }], err_no: reference__unresolved } +SyntaxError { message: "Could not resolve reference to subfield30", range: [SourceLocation { span: Range(TextLocation { line: 39, column: 22, offset: 1019 }..TextLocation { line: 39, column: 32, offset: 1029 }) }], err_no: reference__unresolved } diff --git a/src/validation/tests/snapshots/rusty__validation__tests__reference_resolve_tests__resolve_function_block_calls_in_structs_and_field_access.snap b/src/validation/tests/snapshots/rusty__validation__tests__reference_resolve_tests__resolve_function_block_calls_in_structs_and_field_access.snap index 141aaf0dda..fe9ebe56b9 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__reference_resolve_tests__resolve_function_block_calls_in_structs_and_field_access.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__reference_resolve_tests__resolve_function_block_calls_in_structs_and_field_access.snap @@ -2,10 +2,10 @@ source: src/validation/tests/reference_resolve_tests.rs expression: res --- -SyntaxError { message: "Could not resolve reference to fb3", range: [SourceLocation { span: Range(TextLocation { line: 24, column: 29, offset: 650 }..TextLocation { line: 24, column: 32, offset: 653 }) }], err_no: reference__unresolved } -SyntaxError { message: "Could not resolve reference to a", range: [SourceLocation { span: Range(TextLocation { line: 24, column: 33, offset: 654 }..TextLocation { line: 24, column: 34, offset: 655 }) }], err_no: reference__unresolved } -SyntaxError { message: "Could not resolve reference to fb3", range: [SourceLocation { span: Range(TextLocation { line: 24, column: 43, offset: 664 }..TextLocation { line: 24, column: 46, offset: 667 }) }], err_no: reference__unresolved } -SyntaxError { message: "Could not resolve reference to b", range: [SourceLocation { span: Range(TextLocation { line: 24, column: 47, offset: 668 }..TextLocation { line: 24, column: 48, offset: 669 }) }], err_no: reference__unresolved } -SyntaxError { message: "Could not resolve reference to fb3", range: [SourceLocation { span: Range(TextLocation { line: 24, column: 57, offset: 678 }..TextLocation { line: 24, column: 60, offset: 681 }) }], err_no: reference__unresolved } -SyntaxError { message: "Could not resolve reference to c", range: [SourceLocation { span: Range(TextLocation { line: 24, column: 61, offset: 682 }..TextLocation { line: 24, column: 62, offset: 683 }) }], err_no: reference__unresolved } +SyntaxError { message: "Could not resolve reference to fb3", range: [SourceLocation { span: Range(TextLocation { line: 24, column: 29, offset: 648 }..TextLocation { line: 24, column: 32, offset: 651 }) }], err_no: reference__unresolved } +SyntaxError { message: "Could not resolve reference to a", range: [SourceLocation { span: Range(TextLocation { line: 24, column: 33, offset: 652 }..TextLocation { line: 24, column: 34, offset: 653 }) }], err_no: reference__unresolved } +SyntaxError { message: "Could not resolve reference to fb3", range: [SourceLocation { span: Range(TextLocation { line: 24, column: 43, offset: 662 }..TextLocation { line: 24, column: 46, offset: 665 }) }], err_no: reference__unresolved } +SyntaxError { message: "Could not resolve reference to b", range: [SourceLocation { span: Range(TextLocation { line: 24, column: 47, offset: 666 }..TextLocation { line: 24, column: 48, offset: 667 }) }], err_no: reference__unresolved } +SyntaxError { message: "Could not resolve reference to fb3", range: [SourceLocation { span: Range(TextLocation { line: 24, column: 57, offset: 676 }..TextLocation { line: 24, column: 60, offset: 679 }) }], err_no: reference__unresolved } +SyntaxError { message: "Could not resolve reference to c", range: [SourceLocation { span: Range(TextLocation { line: 24, column: 61, offset: 680 }..TextLocation { line: 24, column: 62, offset: 681 }) }], err_no: reference__unresolved } diff --git a/src/validation/tests/snapshots/rusty__validation__tests__reference_resolve_tests__resolve_function_members_via_qualifier.snap b/src/validation/tests/snapshots/rusty__validation__tests__reference_resolve_tests__resolve_function_members_via_qualifier.snap index efe8e6dc98..6d0af40985 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__reference_resolve_tests__resolve_function_members_via_qualifier.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__reference_resolve_tests__resolve_function_members_via_qualifier.snap @@ -2,7 +2,7 @@ source: src/validation/tests/reference_resolve_tests.rs expression: res --- -SyntaxError { message: "Could not resolve reference to a", range: [SourceLocation { span: Range(TextLocation { line: 6, column: 20, offset: 181 }..TextLocation { line: 6, column: 21, offset: 182 }) }], err_no: reference__unresolved } -SyntaxError { message: "Could not resolve reference to b", range: [SourceLocation { span: Range(TextLocation { line: 7, column: 20, offset: 217 }..TextLocation { line: 7, column: 21, offset: 218 }) }], err_no: reference__unresolved } -SyntaxError { message: "Could not resolve reference to c", range: [SourceLocation { span: Range(TextLocation { line: 8, column: 20, offset: 253 }..TextLocation { line: 8, column: 21, offset: 254 }) }], err_no: reference__unresolved } +SyntaxError { message: "Could not resolve reference to a", range: [SourceLocation { span: Range(TextLocation { line: 6, column: 20, offset: 180 }..TextLocation { line: 6, column: 21, offset: 181 }) }], err_no: reference__unresolved } +SyntaxError { message: "Could not resolve reference to b", range: [SourceLocation { span: Range(TextLocation { line: 7, column: 20, offset: 216 }..TextLocation { line: 7, column: 21, offset: 217 }) }], err_no: reference__unresolved } +SyntaxError { message: "Could not resolve reference to c", range: [SourceLocation { span: Range(TextLocation { line: 8, column: 20, offset: 252 }..TextLocation { line: 8, column: 21, offset: 253 }) }], err_no: reference__unresolved } diff --git a/src/validation/tests/snapshots/rusty__validation__tests__statement_validation_tests__assign_pointer_to_too_small_type_result_in_an_error.snap b/src/validation/tests/snapshots/rusty__validation__tests__statement_validation_tests__assign_pointer_to_too_small_type_result_in_an_error.snap index 3c854c0028..907136b3db 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__statement_validation_tests__assign_pointer_to_too_small_type_result_in_an_error.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__statement_validation_tests__assign_pointer_to_too_small_type_result_in_an_error.snap @@ -2,6 +2,6 @@ source: src/validation/tests/statement_validation_tests.rs expression: res --- -SyntaxError { message: "The type DWORD 32 is too small to hold a Pointer", range: [SourceLocation { span: Range(TextLocation { line: 8, column: 12, offset: 200 }..TextLocation { line: 8, column: 26, offset: 214 }) }], err_no: type__incompatible_size } -SyntaxError { message: "Invalid assignment: cannot assign '__FOO_ptr' to 'DWORD'", range: [SourceLocation { span: Range(TextLocation { line: 8, column: 12, offset: 200 }..TextLocation { line: 8, column: 26, offset: 214 }) }], err_no: var__invalid_assignment } +SyntaxError { message: "The type DWORD 32 is too small to hold a Pointer", range: [SourceLocation { span: Range(TextLocation { line: 8, column: 12, offset: 174 }..TextLocation { line: 8, column: 26, offset: 188 }) }], err_no: type__incompatible_size } +SyntaxError { message: "Invalid assignment: cannot assign '__FOO_ptr' to 'DWORD'", range: [SourceLocation { span: Range(TextLocation { line: 8, column: 12, offset: 174 }..TextLocation { line: 8, column: 26, offset: 188 }) }], err_no: var__invalid_assignment } diff --git a/src/validation/tests/snapshots/rusty__validation__tests__statement_validation_tests__assign_too_small_type_to_pointer_result_in_an_error.snap b/src/validation/tests/snapshots/rusty__validation__tests__statement_validation_tests__assign_too_small_type_to_pointer_result_in_an_error.snap index b584c1c2a0..b1a4cec19e 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__statement_validation_tests__assign_too_small_type_to_pointer_result_in_an_error.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__statement_validation_tests__assign_too_small_type_to_pointer_result_in_an_error.snap @@ -2,6 +2,6 @@ source: src/validation/tests/statement_validation_tests.rs expression: res --- -SyntaxError { message: "The type DWORD 32 is too small to to be stored in a Pointer", range: [SourceLocation { span: Range(TextLocation { line: 8, column: 12, offset: 200 }..TextLocation { line: 8, column: 26, offset: 214 }) }], err_no: type__incompatible_size } -SyntaxError { message: "Invalid assignment: cannot assign 'DWORD' to '__FOO_ptr'", range: [SourceLocation { span: Range(TextLocation { line: 8, column: 12, offset: 200 }..TextLocation { line: 8, column: 26, offset: 214 }) }], err_no: var__invalid_assignment } +SyntaxError { message: "The type DWORD 32 is too small to to be stored in a Pointer", range: [SourceLocation { span: Range(TextLocation { line: 8, column: 12, offset: 174 }..TextLocation { line: 8, column: 26, offset: 188 }) }], err_no: type__incompatible_size } +SyntaxError { message: "Invalid assignment: cannot assign 'DWORD' to '__FOO_ptr'", range: [SourceLocation { span: Range(TextLocation { line: 8, column: 12, offset: 174 }..TextLocation { line: 8, column: 26, offset: 188 }) }], err_no: var__invalid_assignment } diff --git a/src/validation/tests/snapshots/rusty__validation__tests__statement_validation_tests__assigning_to_rvalue.snap b/src/validation/tests/snapshots/rusty__validation__tests__statement_validation_tests__assigning_to_rvalue.snap index b85714dde6..76ca073189 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__statement_validation_tests__assigning_to_rvalue.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__statement_validation_tests__assigning_to_rvalue.snap @@ -2,7 +2,7 @@ source: src/validation/tests/statement_validation_tests.rs expression: res --- -SyntaxError { message: "Expression is not assignable", range: [SourceLocation { span: Range(TextLocation { line: 11, column: 12, offset: 193 }..TextLocation { line: 11, column: 13, offset: 194 }) }], err_no: reference__expected } -SyntaxError { message: "Expression is not assignable", range: [SourceLocation { span: Range(TextLocation { line: 12, column: 12, offset: 213 }..TextLocation { line: 12, column: 13, offset: 214 }) }], err_no: reference__expected } -SyntaxError { message: "Expression is not assignable", range: [SourceLocation { span: Range(TextLocation { line: 13, column: 17, offset: 238 }..TextLocation { line: 13, column: 18, offset: 239 }) }], err_no: reference__expected } +SyntaxError { message: "Expression is not assignable", range: [SourceLocation { span: Range(TextLocation { line: 11, column: 12, offset: 189 }..TextLocation { line: 11, column: 13, offset: 190 }) }], err_no: reference__expected } +SyntaxError { message: "Expression is not assignable", range: [SourceLocation { span: Range(TextLocation { line: 12, column: 12, offset: 209 }..TextLocation { line: 12, column: 13, offset: 210 }) }], err_no: reference__expected } +SyntaxError { message: "Expression is not assignable", range: [SourceLocation { span: Range(TextLocation { line: 13, column: 17, offset: 234 }..TextLocation { line: 13, column: 18, offset: 235 }) }], err_no: reference__expected } diff --git a/src/validation/tests/snapshots/rusty__validation__tests__statement_validation_tests__assignment_to_enum_literals_results_in_error.snap b/src/validation/tests/snapshots/rusty__validation__tests__statement_validation_tests__assignment_to_enum_literals_results_in_error.snap index 06e1c72dd0..44b88d5242 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__statement_validation_tests__assignment_to_enum_literals_results_in_error.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__statement_validation_tests__assignment_to_enum_literals_results_in_error.snap @@ -2,7 +2,7 @@ source: src/validation/tests/statement_validation_tests.rs expression: res --- -SyntaxError { message: "Cannot assign to CONSTANT '__prg_state.OPEN'", range: [SourceLocation { span: Range(TextLocation { line: 12, column: 12, offset: 230 }..TextLocation { line: 12, column: 16, offset: 234 }) }], err_no: var__cannot_assign_to_const } -SyntaxError { message: "Cannot assign to CONSTANT '__global_g_enum.B'", range: [SourceLocation { span: Range(TextLocation { line: 13, column: 12, offset: 253 }..TextLocation { line: 13, column: 13, offset: 254 }) }], err_no: var__cannot_assign_to_const } -SyntaxError { message: "Cannot assign to CONSTANT 'Color.red'", range: [SourceLocation { span: Range(TextLocation { line: 14, column: 12, offset: 273 }..TextLocation { line: 14, column: 15, offset: 276 }) }], err_no: var__cannot_assign_to_const } +SyntaxError { message: "Cannot assign to CONSTANT '__prg_state.OPEN'", range: [SourceLocation { span: Range(TextLocation { line: 12, column: 12, offset: 228 }..TextLocation { line: 12, column: 16, offset: 232 }) }], err_no: var__cannot_assign_to_const } +SyntaxError { message: "Cannot assign to CONSTANT '__global_g_enum.B'", range: [SourceLocation { span: Range(TextLocation { line: 13, column: 12, offset: 251 }..TextLocation { line: 13, column: 13, offset: 252 }) }], err_no: var__cannot_assign_to_const } +SyntaxError { message: "Cannot assign to CONSTANT 'Color.red'", range: [SourceLocation { span: Range(TextLocation { line: 14, column: 12, offset: 271 }..TextLocation { line: 14, column: 15, offset: 274 }) }], err_no: var__cannot_assign_to_const } diff --git a/src/validation/tests/snapshots/rusty__validation__tests__statement_validation_tests__case_condition_used_outside_case_statement.snap b/src/validation/tests/snapshots/rusty__validation__tests__statement_validation_tests__case_condition_used_outside_case_statement.snap index 2cd30cd4be..2acaacb3ae 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__statement_validation_tests__case_condition_used_outside_case_statement.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__statement_validation_tests__case_condition_used_outside_case_statement.snap @@ -2,6 +2,6 @@ source: src/validation/tests/statement_validation_tests.rs expression: res --- -SyntaxError { message: "Case condition used outside of case statement! Did you mean to use ';'?", range: [SourceLocation { span: Range(TextLocation { line: 5, column: 3, offset: 50 }..TextLocation { line: 5, column: 23, offset: 70 }) }], err_no: case__case_condition_outside_case_statement } -SyntaxError { message: "Case condition used outside of case statement! Did you mean to use ';'?", range: [SourceLocation { span: Range(TextLocation { line: 6, column: 3, offset: 79 }..TextLocation { line: 6, column: 5, offset: 81 }) }], err_no: case__case_condition_outside_case_statement } +SyntaxError { message: "Case condition used outside of case statement! Did you mean to use ';'?", range: [SourceLocation { span: Range(TextLocation { line: 5, column: 12, offset: 86 }..TextLocation { line: 5, column: 32, offset: 106 }) }], err_no: case__case_condition_outside_case_statement } +SyntaxError { message: "Case condition used outside of case statement! Did you mean to use ';'?", range: [SourceLocation { span: Range(TextLocation { line: 6, column: 12, offset: 124 }..TextLocation { line: 6, column: 14, offset: 126 }) }], err_no: case__case_condition_outside_case_statement } diff --git a/src/validation/tests/snapshots/rusty__validation__tests__statement_validation_tests__function_call_parameter_validation.snap b/src/validation/tests/snapshots/rusty__validation__tests__statement_validation_tests__function_call_parameter_validation.snap index 85e81ff127..2d8ed5723e 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__statement_validation_tests__function_call_parameter_validation.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__statement_validation_tests__function_call_parameter_validation.snap @@ -2,12 +2,12 @@ source: src/validation/tests/statement_validation_tests.rs expression: res --- -SyntaxError { message: "Cannot mix implicit and explicit call parameters!", range: [SourceLocation { span: Range(TextLocation { line: 22, column: 24, offset: 360 }..TextLocation { line: 22, column: 28, offset: 364 }) }], err_no: call__invalid_parameter_type } -SyntaxError { message: "Cannot mix implicit and explicit call parameters!", range: [SourceLocation { span: Range(TextLocation { line: 22, column: 30, offset: 366 }..TextLocation { line: 22, column: 34, offset: 370 }) }], err_no: call__invalid_parameter_type } -SyntaxError { message: "Invalid assignment: cannot assign 'STRING' to 'DINT'", range: [SourceLocation { span: Range(TextLocation { line: 24, column: 7, offset: 425 }..TextLocation { line: 24, column: 21, offset: 439 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "The type DINT 32 is too small to hold a Pointer", range: [SourceLocation { span: Range(TextLocation { line: 24, column: 23, offset: 441 }..TextLocation { line: 24, column: 37, offset: 455 }) }], err_no: type__incompatible_size } -SyntaxError { message: "Invalid assignment: cannot assign '__main_var3' to 'DINT'", range: [SourceLocation { span: Range(TextLocation { line: 24, column: 23, offset: 441 }..TextLocation { line: 24, column: 37, offset: 455 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid assignment: cannot assign 'STRING' to 'DINT'", range: [SourceLocation { span: Range(TextLocation { line: 26, column: 7, offset: 605 }..TextLocation { line: 26, column: 11, offset: 609 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "The type DINT 32 is too small to hold a Pointer", range: [SourceLocation { span: Range(TextLocation { line: 26, column: 13, offset: 611 }..TextLocation { line: 26, column: 17, offset: 615 }) }], err_no: type__incompatible_size } -SyntaxError { message: "Invalid assignment: cannot assign '__main_var3' to 'DINT'", range: [SourceLocation { span: Range(TextLocation { line: 26, column: 13, offset: 611 }..TextLocation { line: 26, column: 17, offset: 615 }) }], err_no: var__invalid_assignment } +SyntaxError { message: "Cannot mix implicit and explicit call parameters!", range: [SourceLocation { span: Range(TextLocation { line: 22, column: 33, offset: 507 }..TextLocation { line: 22, column: 37, offset: 511 }) }], err_no: call__invalid_parameter_type } +SyntaxError { message: "Cannot mix implicit and explicit call parameters!", range: [SourceLocation { span: Range(TextLocation { line: 22, column: 39, offset: 513 }..TextLocation { line: 22, column: 43, offset: 517 }) }], err_no: call__invalid_parameter_type } +SyntaxError { message: "Invalid assignment: cannot assign 'STRING' to 'DINT'", range: [SourceLocation { span: Range(TextLocation { line: 24, column: 16, offset: 581 }..TextLocation { line: 24, column: 30, offset: 595 }) }], err_no: var__invalid_assignment } +SyntaxError { message: "The type DINT 32 is too small to hold a Pointer", range: [SourceLocation { span: Range(TextLocation { line: 24, column: 32, offset: 597 }..TextLocation { line: 24, column: 46, offset: 611 }) }], err_no: type__incompatible_size } +SyntaxError { message: "Invalid assignment: cannot assign '__main_var3' to 'DINT'", range: [SourceLocation { span: Range(TextLocation { line: 24, column: 32, offset: 597 }..TextLocation { line: 24, column: 46, offset: 611 }) }], err_no: var__invalid_assignment } +SyntaxError { message: "Invalid assignment: cannot assign 'STRING' to 'DINT'", range: [SourceLocation { span: Range(TextLocation { line: 26, column: 16, offset: 770 }..TextLocation { line: 26, column: 20, offset: 774 }) }], err_no: var__invalid_assignment } +SyntaxError { message: "The type DINT 32 is too small to hold a Pointer", range: [SourceLocation { span: Range(TextLocation { line: 26, column: 22, offset: 776 }..TextLocation { line: 26, column: 26, offset: 780 }) }], err_no: type__incompatible_size } +SyntaxError { message: "Invalid assignment: cannot assign '__main_var3' to 'DINT'", range: [SourceLocation { span: Range(TextLocation { line: 26, column: 22, offset: 776 }..TextLocation { line: 26, column: 26, offset: 780 }) }], err_no: var__invalid_assignment } diff --git a/src/validation/tests/snapshots/rusty__validation__tests__statement_validation_tests__invalid_char_assignments.snap b/src/validation/tests/snapshots/rusty__validation__tests__statement_validation_tests__invalid_char_assignments.snap index abd45b1be1..871ec1d945 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__statement_validation_tests__invalid_char_assignments.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__statement_validation_tests__invalid_char_assignments.snap @@ -2,16 +2,16 @@ source: src/validation/tests/statement_validation_tests.rs expression: res --- -SyntaxError { message: "Value: 'AJK%&/231' exceeds length for type: CHAR", range: [SourceLocation { span: Range(TextLocation { line: 10, column: 3, offset: 124 }..TextLocation { line: 10, column: 19, offset: 140 }) }], err_no: syntax__generic_error } -SyntaxError { message: "Invalid assignment: cannot assign 'STRING' to 'CHAR'", range: [SourceLocation { span: Range(TextLocation { line: 10, column: 3, offset: 124 }..TextLocation { line: 10, column: 19, offset: 140 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Value: '898JKAN' exceeds length for type: WCHAR", range: [SourceLocation { span: Range(TextLocation { line: 11, column: 3, offset: 156 }..TextLocation { line: 11, column: 18, offset: 171 }) }], err_no: syntax__generic_error } -SyntaxError { message: "Invalid assignment: cannot assign 'WSTRING' to 'WCHAR'", range: [SourceLocation { span: Range(TextLocation { line: 11, column: 3, offset: 156 }..TextLocation { line: 11, column: 18, offset: 171 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid assignment: cannot assign 'WCHAR' to 'CHAR'", range: [SourceLocation { span: Range(TextLocation { line: 13, column: 3, offset: 188 }..TextLocation { line: 13, column: 10, offset: 195 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid assignment: cannot assign 'CHAR' to 'WCHAR'", range: [SourceLocation { span: Range(TextLocation { line: 14, column: 3, offset: 211 }..TextLocation { line: 14, column: 10, offset: 218 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid assignment: cannot assign 'INT' to 'CHAR'", range: [SourceLocation { span: Range(TextLocation { line: 17, column: 3, offset: 247 }..TextLocation { line: 17, column: 9, offset: 253 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid assignment: cannot assign 'DINT' to 'CHAR'", range: [SourceLocation { span: Range(TextLocation { line: 18, column: 3, offset: 269 }..TextLocation { line: 18, column: 10, offset: 276 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid assignment: cannot assign 'STRING' to 'CHAR'", range: [SourceLocation { span: Range(TextLocation { line: 21, column: 3, offset: 308 }..TextLocation { line: 21, column: 9, offset: 314 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid assignment: cannot assign 'STRING' to 'WCHAR'", range: [SourceLocation { span: Range(TextLocation { line: 22, column: 3, offset: 330 }..TextLocation { line: 22, column: 10, offset: 337 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid assignment: cannot assign 'CHAR' to 'INT'", range: [SourceLocation { span: Range(TextLocation { line: 24, column: 3, offset: 354 }..TextLocation { line: 24, column: 9, offset: 360 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid assignment: cannot assign 'CHAR' to 'STRING'", range: [SourceLocation { span: Range(TextLocation { line: 25, column: 3, offset: 376 }..TextLocation { line: 25, column: 9, offset: 382 }) }], err_no: var__invalid_assignment } +SyntaxError { message: "Value: 'AJK%&/231' exceeds length for type: CHAR", range: [SourceLocation { span: Range(TextLocation { line: 10, column: 12, offset: 205 }..TextLocation { line: 10, column: 28, offset: 221 }) }], err_no: syntax__generic_error } +SyntaxError { message: "Invalid assignment: cannot assign 'STRING' to 'CHAR'", range: [SourceLocation { span: Range(TextLocation { line: 10, column: 12, offset: 205 }..TextLocation { line: 10, column: 28, offset: 221 }) }], err_no: var__invalid_assignment } +SyntaxError { message: "Value: '898JKAN' exceeds length for type: WCHAR", range: [SourceLocation { span: Range(TextLocation { line: 11, column: 12, offset: 246 }..TextLocation { line: 11, column: 27, offset: 261 }) }], err_no: syntax__generic_error } +SyntaxError { message: "Invalid assignment: cannot assign 'WSTRING' to 'WCHAR'", range: [SourceLocation { span: Range(TextLocation { line: 11, column: 12, offset: 246 }..TextLocation { line: 11, column: 27, offset: 261 }) }], err_no: var__invalid_assignment } +SyntaxError { message: "Invalid assignment: cannot assign 'WCHAR' to 'CHAR'", range: [SourceLocation { span: Range(TextLocation { line: 13, column: 12, offset: 287 }..TextLocation { line: 13, column: 19, offset: 294 }) }], err_no: var__invalid_assignment } +SyntaxError { message: "Invalid assignment: cannot assign 'CHAR' to 'WCHAR'", range: [SourceLocation { span: Range(TextLocation { line: 14, column: 12, offset: 319 }..TextLocation { line: 14, column: 19, offset: 326 }) }], err_no: var__invalid_assignment } +SyntaxError { message: "Invalid assignment: cannot assign 'INT' to 'CHAR'", range: [SourceLocation { span: Range(TextLocation { line: 17, column: 12, offset: 373 }..TextLocation { line: 17, column: 18, offset: 379 }) }], err_no: var__invalid_assignment } +SyntaxError { message: "Invalid assignment: cannot assign 'DINT' to 'CHAR'", range: [SourceLocation { span: Range(TextLocation { line: 18, column: 12, offset: 404 }..TextLocation { line: 18, column: 19, offset: 411 }) }], err_no: var__invalid_assignment } +SyntaxError { message: "Invalid assignment: cannot assign 'STRING' to 'CHAR'", range: [SourceLocation { span: Range(TextLocation { line: 21, column: 12, offset: 461 }..TextLocation { line: 21, column: 18, offset: 467 }) }], err_no: var__invalid_assignment } +SyntaxError { message: "Invalid assignment: cannot assign 'STRING' to 'WCHAR'", range: [SourceLocation { span: Range(TextLocation { line: 22, column: 12, offset: 492 }..TextLocation { line: 22, column: 19, offset: 499 }) }], err_no: var__invalid_assignment } +SyntaxError { message: "Invalid assignment: cannot assign 'CHAR' to 'INT'", range: [SourceLocation { span: Range(TextLocation { line: 24, column: 12, offset: 525 }..TextLocation { line: 24, column: 18, offset: 531 }) }], err_no: var__invalid_assignment } +SyntaxError { message: "Invalid assignment: cannot assign 'CHAR' to 'STRING'", range: [SourceLocation { span: Range(TextLocation { line: 25, column: 12, offset: 556 }..TextLocation { line: 25, column: 18, offset: 562 }) }], err_no: var__invalid_assignment } diff --git a/src/validation/tests/snapshots/rusty__validation__tests__statement_validation_tests__program_call_parameter_validation.snap b/src/validation/tests/snapshots/rusty__validation__tests__statement_validation_tests__program_call_parameter_validation.snap index 405d2c4daf..10d97c65da 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__statement_validation_tests__program_call_parameter_validation.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__statement_validation_tests__program_call_parameter_validation.snap @@ -2,12 +2,12 @@ source: src/validation/tests/statement_validation_tests.rs expression: res --- -SyntaxError { message: "Cannot mix implicit and explicit call parameters!", range: [SourceLocation { span: Range(TextLocation { line: 22, column: 25, offset: 354 }..TextLocation { line: 22, column: 29, offset: 358 }) }], err_no: call__invalid_parameter_type } -SyntaxError { message: "Cannot mix implicit and explicit call parameters!", range: [SourceLocation { span: Range(TextLocation { line: 22, column: 31, offset: 360 }..TextLocation { line: 22, column: 35, offset: 364 }) }], err_no: call__invalid_parameter_type } -SyntaxError { message: "Invalid assignment: cannot assign 'STRING' to 'DINT'", range: [SourceLocation { span: Range(TextLocation { line: 24, column: 8, offset: 420 }..TextLocation { line: 24, column: 22, offset: 434 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "The type DINT 32 is too small to hold a Pointer", range: [SourceLocation { span: Range(TextLocation { line: 24, column: 24, offset: 436 }..TextLocation { line: 24, column: 38, offset: 450 }) }], err_no: type__incompatible_size } -SyntaxError { message: "Invalid assignment: cannot assign '__main_var3' to 'DINT'", range: [SourceLocation { span: Range(TextLocation { line: 24, column: 24, offset: 436 }..TextLocation { line: 24, column: 38, offset: 450 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid assignment: cannot assign 'STRING' to 'DINT'", range: [SourceLocation { span: Range(TextLocation { line: 26, column: 8, offset: 602 }..TextLocation { line: 26, column: 12, offset: 606 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "The type DINT 32 is too small to hold a Pointer", range: [SourceLocation { span: Range(TextLocation { line: 26, column: 14, offset: 608 }..TextLocation { line: 26, column: 18, offset: 612 }) }], err_no: type__incompatible_size } -SyntaxError { message: "Invalid assignment: cannot assign '__main_var3' to 'DINT'", range: [SourceLocation { span: Range(TextLocation { line: 26, column: 14, offset: 608 }..TextLocation { line: 26, column: 18, offset: 612 }) }], err_no: var__invalid_assignment } +SyntaxError { message: "Cannot mix implicit and explicit call parameters!", range: [SourceLocation { span: Range(TextLocation { line: 22, column: 34, offset: 501 }..TextLocation { line: 22, column: 38, offset: 505 }) }], err_no: call__invalid_parameter_type } +SyntaxError { message: "Cannot mix implicit and explicit call parameters!", range: [SourceLocation { span: Range(TextLocation { line: 22, column: 40, offset: 507 }..TextLocation { line: 22, column: 44, offset: 511 }) }], err_no: call__invalid_parameter_type } +SyntaxError { message: "Invalid assignment: cannot assign 'STRING' to 'DINT'", range: [SourceLocation { span: Range(TextLocation { line: 24, column: 17, offset: 576 }..TextLocation { line: 24, column: 31, offset: 590 }) }], err_no: var__invalid_assignment } +SyntaxError { message: "The type DINT 32 is too small to hold a Pointer", range: [SourceLocation { span: Range(TextLocation { line: 24, column: 33, offset: 592 }..TextLocation { line: 24, column: 47, offset: 606 }) }], err_no: type__incompatible_size } +SyntaxError { message: "Invalid assignment: cannot assign '__main_var3' to 'DINT'", range: [SourceLocation { span: Range(TextLocation { line: 24, column: 33, offset: 592 }..TextLocation { line: 24, column: 47, offset: 606 }) }], err_no: var__invalid_assignment } +SyntaxError { message: "Invalid assignment: cannot assign 'STRING' to 'DINT'", range: [SourceLocation { span: Range(TextLocation { line: 26, column: 17, offset: 767 }..TextLocation { line: 26, column: 21, offset: 771 }) }], err_no: var__invalid_assignment } +SyntaxError { message: "The type DINT 32 is too small to hold a Pointer", range: [SourceLocation { span: Range(TextLocation { line: 26, column: 23, offset: 773 }..TextLocation { line: 26, column: 27, offset: 777 }) }], err_no: type__incompatible_size } +SyntaxError { message: "Invalid assignment: cannot assign '__main_var3' to 'DINT'", range: [SourceLocation { span: Range(TextLocation { line: 26, column: 23, offset: 773 }..TextLocation { line: 26, column: 27, offset: 777 }) }], err_no: var__invalid_assignment } diff --git a/src/validation/tests/snapshots/rusty__validation__tests__statement_validation_tests__program_missing_inout_assignment.snap b/src/validation/tests/snapshots/rusty__validation__tests__statement_validation_tests__program_missing_inout_assignment.snap index daa401b9c8..fb6ad8e4bc 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__statement_validation_tests__program_missing_inout_assignment.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__statement_validation_tests__program_missing_inout_assignment.snap @@ -2,8 +2,8 @@ source: src/validation/tests/statement_validation_tests.rs expression: res --- -SyntaxError { message: "Missing inout parameter: inout1", range: [SourceLocation { span: Range(TextLocation { line: 17, column: 3, offset: 216 }..TextLocation { line: 17, column: 7, offset: 220 }) }], err_no: pou__missing_action_container } -SyntaxError { message: "Missing inout parameter: inout1", range: [SourceLocation { span: Range(TextLocation { line: 18, column: 3, offset: 258 }..TextLocation { line: 18, column: 7, offset: 262 }) }], err_no: pou__missing_action_container } -SyntaxError { message: "Missing inout parameter: inout1", range: [SourceLocation { span: Range(TextLocation { line: 19, column: 3, offset: 279 }..TextLocation { line: 19, column: 7, offset: 283 }) }], err_no: pou__missing_action_container } -SyntaxError { message: "Missing inout parameter: inout1", range: [SourceLocation { span: Range(TextLocation { line: 20, column: 3, offset: 294 }..TextLocation { line: 20, column: 7, offset: 298 }) }], err_no: pou__missing_action_container } +SyntaxError { message: "Missing inout parameter: inout1", range: [SourceLocation { span: Range(TextLocation { line: 17, column: 12, offset: 327 }..TextLocation { line: 17, column: 16, offset: 331 }) }], err_no: pou__missing_action_container } +SyntaxError { message: "Missing inout parameter: inout1", range: [SourceLocation { span: Range(TextLocation { line: 18, column: 12, offset: 378 }..TextLocation { line: 18, column: 16, offset: 382 }) }], err_no: pou__missing_action_container } +SyntaxError { message: "Missing inout parameter: inout1", range: [SourceLocation { span: Range(TextLocation { line: 19, column: 12, offset: 408 }..TextLocation { line: 19, column: 16, offset: 412 }) }], err_no: pou__missing_action_container } +SyntaxError { message: "Missing inout parameter: inout1", range: [SourceLocation { span: Range(TextLocation { line: 20, column: 12, offset: 432 }..TextLocation { line: 20, column: 16, offset: 436 }) }], err_no: pou__missing_action_container } diff --git a/src/validation/tests/snapshots/rusty__validation__tests__statement_validation_tests__ref_builtin_function_reports_invalid_param_count.snap b/src/validation/tests/snapshots/rusty__validation__tests__statement_validation_tests__ref_builtin_function_reports_invalid_param_count.snap index f86be4554f..d3c13c2ad3 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__statement_validation_tests__ref_builtin_function_reports_invalid_param_count.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__statement_validation_tests__ref_builtin_function_reports_invalid_param_count.snap @@ -3,5 +3,5 @@ source: src/validation/tests/statement_validation_tests.rs expression: res --- SyntaxError { message: "Invalid parameter count. Received 0 parameters while 1 parameters were expected.", range: [SourceLocation { span: Range(TextLocation { line: 6, column: 12, offset: 134 }..TextLocation { line: 6, column: 15, offset: 137 }) }], err_no: call__invalid_parameter_count } -SyntaxError { message: "Invalid parameter count. Received 4 parameters while 1 parameters were expected.", range: [SourceLocation { span: Range(TextLocation { line: 7, column: 12, offset: 154 }..TextLocation { line: 7, column: 15, offset: 157 }) }], err_no: call__invalid_parameter_count } +SyntaxError { message: "Invalid parameter count. Received 4 parameters while 1 parameters were expected.", range: [SourceLocation { span: Range(TextLocation { line: 7, column: 12, offset: 153 }..TextLocation { line: 7, column: 15, offset: 156 }) }], err_no: call__invalid_parameter_count } diff --git a/src/validation/tests/snapshots/rusty__validation__tests__statement_validation_tests__reference_to_reference_assignments_in_function_arguments.snap b/src/validation/tests/snapshots/rusty__validation__tests__statement_validation_tests__reference_to_reference_assignments_in_function_arguments.snap index 44b98b2b1f..a9b6d99a12 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__statement_validation_tests__reference_to_reference_assignments_in_function_arguments.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__statement_validation_tests__reference_to_reference_assignments_in_function_arguments.snap @@ -5,7 +5,7 @@ expression: res SyntaxError { message: "Invalid assignment: cannot assign '__POINTER_TO_INT' to '__prog_input1'", range: [SourceLocation { span: Range(TextLocation { line: 46, column: 12, offset: 1286 }..TextLocation { line: 46, column: 34, offset: 1308 }) }], err_no: var__invalid_assignment } SyntaxError { message: "Invalid assignment: cannot assign '__POINTER_TO_REAL' to '__prog_input2'", range: [SourceLocation { span: Range(TextLocation { line: 47, column: 12, offset: 1322 }..TextLocation { line: 47, column: 34, offset: 1344 }) }], err_no: var__invalid_assignment } SyntaxError { message: "Invalid assignment: cannot assign '__POINTER_TO_STRING' to '__prog_input3'", range: [SourceLocation { span: Range(TextLocation { line: 48, column: 12, offset: 1358 }..TextLocation { line: 48, column: 34, offset: 1380 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid assignment: cannot assign '__POINTER_TO_INT' to '__prog_input1'", range: [SourceLocation { span: Range(TextLocation { line: 54, column: 12, offset: 1596 }..TextLocation { line: 54, column: 32, offset: 1616 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid assignment: cannot assign '__POINTER_TO_REAL' to '__prog_input2'", range: [SourceLocation { span: Range(TextLocation { line: 55, column: 12, offset: 1630 }..TextLocation { line: 55, column: 32, offset: 1650 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid assignment: cannot assign '__POINTER_TO___global_global6' to '__prog_input3'", range: [SourceLocation { span: Range(TextLocation { line: 56, column: 12, offset: 1664 }..TextLocation { line: 56, column: 32, offset: 1684 }) }], err_no: var__invalid_assignment } +SyntaxError { message: "Invalid assignment: cannot assign '__POINTER_TO_INT' to '__prog_input1'", range: [SourceLocation { span: Range(TextLocation { line: 54, column: 12, offset: 1588 }..TextLocation { line: 54, column: 32, offset: 1608 }) }], err_no: var__invalid_assignment } +SyntaxError { message: "Invalid assignment: cannot assign '__POINTER_TO_REAL' to '__prog_input2'", range: [SourceLocation { span: Range(TextLocation { line: 55, column: 12, offset: 1622 }..TextLocation { line: 55, column: 32, offset: 1642 }) }], err_no: var__invalid_assignment } +SyntaxError { message: "Invalid assignment: cannot assign '__POINTER_TO___global_global6' to '__prog_input3'", range: [SourceLocation { span: Range(TextLocation { line: 56, column: 12, offset: 1656 }..TextLocation { line: 56, column: 32, offset: 1676 }) }], err_no: var__invalid_assignment } diff --git a/src/validation/tests/snapshots/rusty__validation__tests__statement_validation_tests__switch_case_duplicate_integer.snap b/src/validation/tests/snapshots/rusty__validation__tests__statement_validation_tests__switch_case_duplicate_integer.snap index 644d78ef60..59b954d7c1 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__statement_validation_tests__switch_case_duplicate_integer.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__statement_validation_tests__switch_case_duplicate_integer.snap @@ -2,8 +2,8 @@ source: src/validation/tests/statement_validation_tests.rs expression: res --- -SyntaxError { message: "Duplicate condition value: 4. Occurred more than once!", range: [SourceLocation { span: Range(TextLocation { line: 15, column: 4, offset: 227 }..TextLocation { line: 15, column: 10, offset: 233 }) }], err_no: case__duplicate_condition } -SyntaxError { message: "Duplicate condition value: 4. Occurred more than once!", range: [SourceLocation { span: Range(TextLocation { line: 17, column: 4, offset: 254 }..TextLocation { line: 17, column: 13, offset: 263 }) }], err_no: case__duplicate_condition } -SyntaxError { message: "Duplicate condition value: 4. Occurred more than once!", range: [SourceLocation { span: Range(TextLocation { line: 19, column: 4, offset: 284 }..TextLocation { line: 19, column: 12, offset: 292 }) }], err_no: case__duplicate_condition } -SyntaxError { message: "Duplicate condition value: 4. Occurred more than once!", range: [SourceLocation { span: Range(TextLocation { line: 21, column: 4, offset: 313 }..TextLocation { line: 21, column: 7, offset: 316 }) }], err_no: case__duplicate_condition } +SyntaxError { message: "Duplicate condition value: 4. Occurred more than once!", range: [SourceLocation { span: Range(TextLocation { line: 15, column: 16, offset: 332 }..TextLocation { line: 15, column: 22, offset: 338 }) }], err_no: case__duplicate_condition } +SyntaxError { message: "Duplicate condition value: 4. Occurred more than once!", range: [SourceLocation { span: Range(TextLocation { line: 17, column: 16, offset: 386 }..TextLocation { line: 17, column: 25, offset: 395 }) }], err_no: case__duplicate_condition } +SyntaxError { message: "Duplicate condition value: 4. Occurred more than once!", range: [SourceLocation { span: Range(TextLocation { line: 19, column: 16, offset: 443 }..TextLocation { line: 19, column: 24, offset: 451 }) }], err_no: case__duplicate_condition } +SyntaxError { message: "Duplicate condition value: 4. Occurred more than once!", range: [SourceLocation { span: Range(TextLocation { line: 21, column: 16, offset: 499 }..TextLocation { line: 21, column: 19, offset: 502 }) }], err_no: case__duplicate_condition } diff --git a/src/validation/tests/snapshots/rusty__validation__tests__statement_validation_tests__switch_case_duplicate_integer_non_const_var_reference.snap b/src/validation/tests/snapshots/rusty__validation__tests__statement_validation_tests__switch_case_duplicate_integer_non_const_var_reference.snap index 31b16ab83c..1ea41bc5ba 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__statement_validation_tests__switch_case_duplicate_integer_non_const_var_reference.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__statement_validation_tests__switch_case_duplicate_integer_non_const_var_reference.snap @@ -2,8 +2,8 @@ source: src/validation/tests/statement_validation_tests.rs expression: res --- -SyntaxError { message: "'x' is no const reference. Non constant variables are not supported in case conditions", range: [SourceLocation { span: Range(TextLocation { line: 13, column: 4, offset: 165 }..TextLocation { line: 13, column: 5, offset: 166 }) }], err_no: type__invalid_type } -SyntaxError { message: "'y' is no const reference. Non constant variables are not supported in case conditions", range: [SourceLocation { span: Range(TextLocation { line: 15, column: 4, offset: 216 }..TextLocation { line: 15, column: 5, offset: 217 }) }], err_no: type__invalid_type } -SyntaxError { message: "'x' is no const reference. Non constant variables are not supported in case conditions", range: [SourceLocation { span: Range(TextLocation { line: 17, column: 4, offset: 267 }..TextLocation { line: 17, column: 7, offset: 270 }) }], err_no: type__invalid_type } -SyntaxError { message: "'x' is no const reference. Non constant variables are not supported in case conditions", range: [SourceLocation { span: Range(TextLocation { line: 21, column: 4, offset: 346 }..TextLocation { line: 21, column: 11, offset: 353 }) }], err_no: type__invalid_type } +SyntaxError { message: "'x' is no const reference. Non constant variables are not supported in case conditions", range: [SourceLocation { span: Range(TextLocation { line: 13, column: 16, offset: 246 }..TextLocation { line: 13, column: 17, offset: 247 }) }], err_no: type__invalid_type } +SyntaxError { message: "'y' is no const reference. Non constant variables are not supported in case conditions", range: [SourceLocation { span: Range(TextLocation { line: 15, column: 16, offset: 324 }..TextLocation { line: 15, column: 17, offset: 325 }) }], err_no: type__invalid_type } +SyntaxError { message: "'x' is no const reference. Non constant variables are not supported in case conditions", range: [SourceLocation { span: Range(TextLocation { line: 17, column: 16, offset: 402 }..TextLocation { line: 17, column: 19, offset: 405 }) }], err_no: type__invalid_type } +SyntaxError { message: "'x' is no const reference. Non constant variables are not supported in case conditions", range: [SourceLocation { span: Range(TextLocation { line: 21, column: 16, offset: 535 }..TextLocation { line: 21, column: 23, offset: 542 }) }], err_no: type__invalid_type } diff --git a/src/validation/tests/snapshots/rusty__validation__tests__statement_validation_tests__switch_case_invalid_case_conditions.snap b/src/validation/tests/snapshots/rusty__validation__tests__statement_validation_tests__switch_case_invalid_case_conditions.snap index ec0aa5a609..9d1f809b86 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__statement_validation_tests__switch_case_invalid_case_conditions.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__statement_validation_tests__switch_case_invalid_case_conditions.snap @@ -2,7 +2,7 @@ source: src/validation/tests/statement_validation_tests.rs expression: res --- -SyntaxError { message: "Invalid case condition!", range: [SourceLocation { span: Range(TextLocation { line: 10, column: 4, offset: 120 }..TextLocation { line: 10, column: 10, offset: 126 }) }], err_no: case__case_condition_outside_case_statement } -SyntaxError { message: "Cannot resolve constant: CallStatement {\n operator: ReferenceExpr {\n kind: Member(\n Identifier {\n name: \"foo\",\n },\n ),\n base: None,\n },\n parameters: None,\n}. Non constant variables are not supported in case conditions", range: [SourceLocation { span: Range(TextLocation { line: 10, column: 4, offset: 120 }..TextLocation { line: 10, column: 10, offset: 126 }) }], err_no: type__invalid_type } -SyntaxError { message: "Invalid case condition!", range: [SourceLocation { span: Range(TextLocation { line: 12, column: 4, offset: 146 }..TextLocation { line: 12, column: 12, offset: 154 }) }], err_no: case__case_condition_outside_case_statement } +SyntaxError { message: "Invalid case condition!", range: [SourceLocation { span: Range(TextLocation { line: 10, column: 16, offset: 174 }..TextLocation { line: 10, column: 22, offset: 180 }) }], err_no: case__case_condition_outside_case_statement } +SyntaxError { message: "Cannot resolve constant: CallStatement {\n operator: ReferenceExpr {\n kind: Member(\n Identifier {\n name: \"foo\",\n },\n ),\n base: None,\n },\n parameters: None,\n}. Non constant variables are not supported in case conditions", range: [SourceLocation { span: Range(TextLocation { line: 10, column: 16, offset: 174 }..TextLocation { line: 10, column: 22, offset: 180 }) }], err_no: type__invalid_type } +SyntaxError { message: "Invalid case condition!", range: [SourceLocation { span: Range(TextLocation { line: 12, column: 16, offset: 227 }..TextLocation { line: 12, column: 24, offset: 235 }) }], err_no: case__case_condition_outside_case_statement } diff --git a/src/validation/tests/snapshots/rusty__validation__tests__statement_validation_tests__validate_arrays_passed_to_functions.snap b/src/validation/tests/snapshots/rusty__validation__tests__statement_validation_tests__validate_arrays_passed_to_functions.snap index b55402c641..741d7bf9af 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__statement_validation_tests__validate_arrays_passed_to_functions.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__statement_validation_tests__validate_arrays_passed_to_functions.snap @@ -2,12 +2,12 @@ source: src/validation/tests/statement_validation_tests.rs expression: res --- -SyntaxError { message: "Invalid assignment: cannot assign '__main_arr_sint' to '__func_arr_dint'", range: [SourceLocation { span: Range(TextLocation { line: 25, column: 17, offset: 976 }..TextLocation { line: 25, column: 25, offset: 984 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid assignment: cannot assign '__main_arr_int' to '__func_arr_dint'", range: [SourceLocation { span: Range(TextLocation { line: 26, column: 17, offset: 1004 }..TextLocation { line: 26, column: 24, offset: 1011 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid assignment: cannot assign '__main_arr_lint' to '__func_arr_dint'", range: [SourceLocation { span: Range(TextLocation { line: 28, column: 17, offset: 1059 }..TextLocation { line: 28, column: 25, offset: 1067 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid assignment: cannot assign '__main_arr_real' to '__func_arr_dint'", range: [SourceLocation { span: Range(TextLocation { line: 29, column: 17, offset: 1087 }..TextLocation { line: 29, column: 25, offset: 1095 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid assignment: cannot assign '__main_arr_lreal' to '__func_arr_dint'", range: [SourceLocation { span: Range(TextLocation { line: 30, column: 17, offset: 1115 }..TextLocation { line: 30, column: 26, offset: 1124 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid assignment: cannot assign '__main_arr_dint_1_10' to '__func_arr_dint'", range: [SourceLocation { span: Range(TextLocation { line: 35, column: 17, offset: 1317 }..TextLocation { line: 35, column: 30, offset: 1330 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid assignment: cannot assign '__main_arr_dint_10_100' to '__func_arr_dint'", range: [SourceLocation { span: Range(TextLocation { line: 36, column: 17, offset: 1350 }..TextLocation { line: 36, column: 32, offset: 1365 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid assignment: cannot assign '__main_arr_dint_2d' to '__func_arr_dint'", range: [SourceLocation { span: Range(TextLocation { line: 39, column: 17, offset: 1442 }..TextLocation { line: 39, column: 28, offset: 1453 }) }], err_no: var__invalid_assignment } +SyntaxError { message: "Invalid assignment: cannot assign '__main_arr_sint' to '__func_arr_dint'", range: [SourceLocation { span: Range(TextLocation { line: 25, column: 17, offset: 959 }..TextLocation { line: 25, column: 25, offset: 967 }) }], err_no: var__invalid_assignment } +SyntaxError { message: "Invalid assignment: cannot assign '__main_arr_int' to '__func_arr_dint'", range: [SourceLocation { span: Range(TextLocation { line: 26, column: 17, offset: 987 }..TextLocation { line: 26, column: 24, offset: 994 }) }], err_no: var__invalid_assignment } +SyntaxError { message: "Invalid assignment: cannot assign '__main_arr_lint' to '__func_arr_dint'", range: [SourceLocation { span: Range(TextLocation { line: 28, column: 17, offset: 1042 }..TextLocation { line: 28, column: 25, offset: 1050 }) }], err_no: var__invalid_assignment } +SyntaxError { message: "Invalid assignment: cannot assign '__main_arr_real' to '__func_arr_dint'", range: [SourceLocation { span: Range(TextLocation { line: 29, column: 17, offset: 1070 }..TextLocation { line: 29, column: 25, offset: 1078 }) }], err_no: var__invalid_assignment } +SyntaxError { message: "Invalid assignment: cannot assign '__main_arr_lreal' to '__func_arr_dint'", range: [SourceLocation { span: Range(TextLocation { line: 30, column: 17, offset: 1098 }..TextLocation { line: 30, column: 26, offset: 1107 }) }], err_no: var__invalid_assignment } +SyntaxError { message: "Invalid assignment: cannot assign '__main_arr_dint_1_10' to '__func_arr_dint'", range: [SourceLocation { span: Range(TextLocation { line: 35, column: 17, offset: 1300 }..TextLocation { line: 35, column: 30, offset: 1313 }) }], err_no: var__invalid_assignment } +SyntaxError { message: "Invalid assignment: cannot assign '__main_arr_dint_10_100' to '__func_arr_dint'", range: [SourceLocation { span: Range(TextLocation { line: 36, column: 17, offset: 1333 }..TextLocation { line: 36, column: 32, offset: 1348 }) }], err_no: var__invalid_assignment } +SyntaxError { message: "Invalid assignment: cannot assign '__main_arr_dint_2d' to '__func_arr_dint'", range: [SourceLocation { span: Range(TextLocation { line: 39, column: 17, offset: 1425 }..TextLocation { line: 39, column: 28, offset: 1436 }) }], err_no: var__invalid_assignment } diff --git a/src/validation/tests/snapshots/rusty__validation__tests__statement_validation_tests__validate_call_by_ref.snap b/src/validation/tests/snapshots/rusty__validation__tests__statement_validation_tests__validate_call_by_ref.snap index 1dfae2c2e8..9cdfa1bffc 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__statement_validation_tests__validate_call_by_ref.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__statement_validation_tests__validate_call_by_ref.snap @@ -2,12 +2,12 @@ source: src/validation/tests/statement_validation_tests.rs expression: res --- -SyntaxError { message: "Expected a reference for parameter byRefInOut because their type is InOut", range: [SourceLocation { span: Range(TextLocation { line: 22, column: 20, offset: 589 }..TextLocation { line: 22, column: 21, offset: 590 }) }], err_no: call__invalid_parameter_type } -SyntaxError { message: "Expected a reference for parameter byRefOutput because their type is Output", range: [SourceLocation { span: Range(TextLocation { line: 22, column: 23, offset: 592 }..TextLocation { line: 22, column: 24, offset: 593 }) }], err_no: call__invalid_parameter_type } -SyntaxError { message: "Expected a reference for parameter byRefInOut because their type is InOut", range: [SourceLocation { span: Range(TextLocation { line: 23, column: 20, offset: 616 }..TextLocation { line: 23, column: 21, offset: 617 }) }], err_no: call__invalid_parameter_type } -SyntaxError { message: "Expected a reference for parameter byRefOutput because their type is Output", range: [SourceLocation { span: Range(TextLocation { line: 24, column: 23, offset: 646 }..TextLocation { line: 24, column: 24, offset: 647 }) }], err_no: call__invalid_parameter_type } -SyntaxError { message: "Expected a reference for parameter byRefInOut because their type is InOut", range: [SourceLocation { span: Range(TextLocation { line: 26, column: 20, offset: 706 }..TextLocation { line: 26, column: 21, offset: 707 }) }], err_no: call__invalid_parameter_type } -SyntaxError { message: "Expected a reference for parameter byRefOutput because their type is Output", range: [SourceLocation { span: Range(TextLocation { line: 26, column: 23, offset: 709 }..TextLocation { line: 26, column: 24, offset: 710 }) }], err_no: call__invalid_parameter_type } -SyntaxError { message: "Expected a reference for parameter byRefInOut because their type is InOut", range: [SourceLocation { span: Range(TextLocation { line: 27, column: 20, offset: 733 }..TextLocation { line: 27, column: 21, offset: 734 }) }], err_no: call__invalid_parameter_type } -SyntaxError { message: "Expected a reference for parameter byRefOutput because their type is Output", range: [SourceLocation { span: Range(TextLocation { line: 28, column: 23, offset: 763 }..TextLocation { line: 28, column: 24, offset: 764 }) }], err_no: call__invalid_parameter_type } +SyntaxError { message: "Expected a reference for parameter byRefInOut because their type is InOut", range: [SourceLocation { span: Range(TextLocation { line: 22, column: 20, offset: 561 }..TextLocation { line: 22, column: 21, offset: 562 }) }], err_no: call__invalid_parameter_type } +SyntaxError { message: "Expected a reference for parameter byRefOutput because their type is Output", range: [SourceLocation { span: Range(TextLocation { line: 22, column: 23, offset: 564 }..TextLocation { line: 22, column: 24, offset: 565 }) }], err_no: call__invalid_parameter_type } +SyntaxError { message: "Expected a reference for parameter byRefInOut because their type is InOut", range: [SourceLocation { span: Range(TextLocation { line: 23, column: 20, offset: 588 }..TextLocation { line: 23, column: 21, offset: 589 }) }], err_no: call__invalid_parameter_type } +SyntaxError { message: "Expected a reference for parameter byRefOutput because their type is Output", range: [SourceLocation { span: Range(TextLocation { line: 24, column: 23, offset: 618 }..TextLocation { line: 24, column: 24, offset: 619 }) }], err_no: call__invalid_parameter_type } +SyntaxError { message: "Expected a reference for parameter byRefInOut because their type is InOut", range: [SourceLocation { span: Range(TextLocation { line: 26, column: 20, offset: 678 }..TextLocation { line: 26, column: 21, offset: 679 }) }], err_no: call__invalid_parameter_type } +SyntaxError { message: "Expected a reference for parameter byRefOutput because their type is Output", range: [SourceLocation { span: Range(TextLocation { line: 26, column: 23, offset: 681 }..TextLocation { line: 26, column: 24, offset: 682 }) }], err_no: call__invalid_parameter_type } +SyntaxError { message: "Expected a reference for parameter byRefInOut because their type is InOut", range: [SourceLocation { span: Range(TextLocation { line: 27, column: 20, offset: 705 }..TextLocation { line: 27, column: 21, offset: 706 }) }], err_no: call__invalid_parameter_type } +SyntaxError { message: "Expected a reference for parameter byRefOutput because their type is Output", range: [SourceLocation { span: Range(TextLocation { line: 28, column: 23, offset: 735 }..TextLocation { line: 28, column: 24, offset: 736 }) }], err_no: call__invalid_parameter_type } diff --git a/src/validation/tests/snapshots/rusty__validation__tests__statement_validation_tests__validate_call_by_ref_explicit.snap b/src/validation/tests/snapshots/rusty__validation__tests__statement_validation_tests__validate_call_by_ref_explicit.snap index 5df24aab81..7c26fd053e 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__statement_validation_tests__validate_call_by_ref_explicit.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__statement_validation_tests__validate_call_by_ref_explicit.snap @@ -2,9 +2,9 @@ source: src/validation/tests/statement_validation_tests.rs expression: res --- -SyntaxError { message: "Expected a reference for parameter byRefInOut because their type is InOut", range: [SourceLocation { span: Range(TextLocation { line: 22, column: 48, offset: 601 }..TextLocation { line: 22, column: 49, offset: 602 }) }], err_no: call__invalid_parameter_type } -SyntaxError { message: "Expected a reference for parameter byRefInOut because their type is InOut", range: [SourceLocation { span: Range(TextLocation { line: 24, column: 48, offset: 784 }..TextLocation { line: 24, column: 49, offset: 785 }) }], err_no: call__invalid_parameter_type } -SyntaxError { message: "Expected a reference for parameter byRefOutput because their type is Output", range: [SourceLocation { span: Range(TextLocation { line: 24, column: 66, offset: 802 }..TextLocation { line: 24, column: 67, offset: 803 }) }], err_no: call__invalid_parameter_type } -SyntaxError { message: "Expected a reference for parameter byRefInOut because their type is InOut", range: [SourceLocation { span: Range(TextLocation { line: 25, column: 48, offset: 855 }..TextLocation { line: 25, column: 49, offset: 856 }) }], err_no: call__invalid_parameter_type } -SyntaxError { message: "Expected a reference for parameter byRefOutput because their type is Output", range: [SourceLocation { span: Range(TextLocation { line: 26, column: 66, offset: 943 }..TextLocation { line: 26, column: 67, offset: 944 }) }], err_no: call__invalid_parameter_type } +SyntaxError { message: "Expected a reference for parameter byRefInOut because their type is InOut", range: [SourceLocation { span: Range(TextLocation { line: 22, column: 48, offset: 589 }..TextLocation { line: 22, column: 49, offset: 590 }) }], err_no: call__invalid_parameter_type } +SyntaxError { message: "Expected a reference for parameter byRefInOut because their type is InOut", range: [SourceLocation { span: Range(TextLocation { line: 24, column: 48, offset: 772 }..TextLocation { line: 24, column: 49, offset: 773 }) }], err_no: call__invalid_parameter_type } +SyntaxError { message: "Expected a reference for parameter byRefOutput because their type is Output", range: [SourceLocation { span: Range(TextLocation { line: 24, column: 66, offset: 790 }..TextLocation { line: 24, column: 67, offset: 791 }) }], err_no: call__invalid_parameter_type } +SyntaxError { message: "Expected a reference for parameter byRefInOut because their type is InOut", range: [SourceLocation { span: Range(TextLocation { line: 25, column: 48, offset: 842 }..TextLocation { line: 25, column: 49, offset: 843 }) }], err_no: call__invalid_parameter_type } +SyntaxError { message: "Expected a reference for parameter byRefOutput because their type is Output", range: [SourceLocation { span: Range(TextLocation { line: 26, column: 66, offset: 930 }..TextLocation { line: 26, column: 67, offset: 931 }) }], err_no: call__invalid_parameter_type } diff --git a/src/validation/tests/snapshots/rusty__validation__tests__variable_length_array_test__builtins__builtins_called_with_invalid_index.snap b/src/validation/tests/snapshots/rusty__validation__tests__variable_length_array_test__builtins__builtins_called_with_invalid_index.snap index 9cc4047f8e..9c07df33c6 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__variable_length_array_test__builtins__builtins_called_with_invalid_index.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__variable_length_array_test__builtins__builtins_called_with_invalid_index.snap @@ -2,10 +2,10 @@ source: src/validation/tests/variable_length_array_test.rs expression: res --- -SyntaxError { message: "Invalid type nature for generic argument. REAL is no Int.", range: [SourceLocation { span: Range(TextLocation { line: 17, column: 29, offset: 369 }..TextLocation { line: 17, column: 35, offset: 375 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid type nature for generic argument. TIME is no Int.", range: [SourceLocation { span: Range(TextLocation { line: 18, column: 29, offset: 418 }..TextLocation { line: 18, column: 36, offset: 425 }) }], err_no: type__invalid_nature } -SemanticError { message: "Index out of bounds.", range: [SourceLocation { span: Range(TextLocation { line: 19, column: 12, offset: 451 }..TextLocation { line: 19, column: 23, offset: 462 }) }], err_no: vla__dimension_idx_out_of_bounds } -SyntaxError { message: "Invalid type nature for generic argument. REAL is no Int.", range: [SourceLocation { span: Range(TextLocation { line: 21, column: 29, offset: 525 }..TextLocation { line: 21, column: 35, offset: 531 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid type nature for generic argument. TIME is no Int.", range: [SourceLocation { span: Range(TextLocation { line: 22, column: 29, offset: 574 }..TextLocation { line: 22, column: 36, offset: 581 }) }], err_no: type__invalid_nature } -SemanticError { message: "Index out of bounds.", range: [SourceLocation { span: Range(TextLocation { line: 23, column: 12, offset: 607 }..TextLocation { line: 23, column: 23, offset: 618 }) }], err_no: vla__dimension_idx_out_of_bounds } +SyntaxError { message: "Invalid type nature for generic argument. REAL is no Int.", range: [SourceLocation { span: Range(TextLocation { line: 17, column: 29, offset: 361 }..TextLocation { line: 17, column: 35, offset: 367 }) }], err_no: type__invalid_nature } +SyntaxError { message: "Invalid type nature for generic argument. TIME is no Int.", range: [SourceLocation { span: Range(TextLocation { line: 18, column: 29, offset: 410 }..TextLocation { line: 18, column: 36, offset: 417 }) }], err_no: type__invalid_nature } +SemanticError { message: "Index out of bounds.", range: [SourceLocation { span: Range(TextLocation { line: 19, column: 12, offset: 443 }..TextLocation { line: 19, column: 23, offset: 454 }) }], err_no: vla__dimension_idx_out_of_bounds } +SyntaxError { message: "Invalid type nature for generic argument. REAL is no Int.", range: [SourceLocation { span: Range(TextLocation { line: 21, column: 29, offset: 517 }..TextLocation { line: 21, column: 35, offset: 523 }) }], err_no: type__invalid_nature } +SyntaxError { message: "Invalid type nature for generic argument. TIME is no Int.", range: [SourceLocation { span: Range(TextLocation { line: 22, column: 29, offset: 566 }..TextLocation { line: 22, column: 36, offset: 573 }) }], err_no: type__invalid_nature } +SemanticError { message: "Index out of bounds.", range: [SourceLocation { span: Range(TextLocation { line: 23, column: 12, offset: 599 }..TextLocation { line: 23, column: 23, offset: 610 }) }], err_no: vla__dimension_idx_out_of_bounds } diff --git a/src/validation/tests/snapshots/rusty__validation__tests__variable_validation_tests__constant_fb_instances_are_illegal.snap b/src/validation/tests/snapshots/rusty__validation__tests__variable_validation_tests__constant_fb_instances_are_illegal.snap index 544fe4c38c..711eb41551 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__variable_validation_tests__constant_fb_instances_are_illegal.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__variable_validation_tests__constant_fb_instances_are_illegal.snap @@ -2,6 +2,6 @@ source: src/validation/tests/variable_validation_tests.rs expression: res --- -SyntaxError { message: "Invalid constant y - Functionblock- and Class-instances cannot be delcared constant", range: [SourceLocation { span: Range(TextLocation { line: 14, column: 12, offset: 320 }..TextLocation { line: 14, column: 13, offset: 321 }) }], err_no: var__invalid_constant } -SyntaxError { message: "Invalid constant z - Functionblock- and Class-instances cannot be delcared constant", range: [SourceLocation { span: Range(TextLocation { line: 15, column: 12, offset: 342 }..TextLocation { line: 15, column: 13, offset: 343 }) }], err_no: var__invalid_constant } +SyntaxError { message: "Invalid constant y - Functionblock- and Class-instances cannot be delcared constant", range: [SourceLocation { span: Range(TextLocation { line: 14, column: 12, offset: 319 }..TextLocation { line: 14, column: 13, offset: 320 }) }], err_no: var__invalid_constant } +SyntaxError { message: "Invalid constant z - Functionblock- and Class-instances cannot be delcared constant", range: [SourceLocation { span: Range(TextLocation { line: 15, column: 12, offset: 341 }..TextLocation { line: 15, column: 13, offset: 342 }) }], err_no: var__invalid_constant } diff --git a/src/validation/tests/snapshots/rusty__validation__tests__variable_validation_tests__unresolvable_variables_are_reported.snap b/src/validation/tests/snapshots/rusty__validation__tests__variable_validation_tests__unresolvable_variables_are_reported.snap index 3ba3c53a57..7ecc904113 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__variable_validation_tests__unresolvable_variables_are_reported.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__variable_validation_tests__unresolvable_variables_are_reported.snap @@ -2,7 +2,7 @@ source: src/validation/tests/variable_validation_tests.rs expression: res --- -SyntaxError { message: "Unresolved constant 'cx' variable", range: [SourceLocation { span: Range(TextLocation { line: 18, column: 28, offset: 374 }..TextLocation { line: 18, column: 30, offset: 376 }) }], err_no: var__unresolved_constant } -SyntaxError { message: "Could not resolve reference to a", range: [SourceLocation { span: Range(TextLocation { line: 20, column: 29, offset: 455 }..TextLocation { line: 20, column: 30, offset: 456 }) }], err_no: reference__unresolved } -SyntaxError { message: "Unresolved constant 'cai' variable", range: [SourceLocation { span: Range(TextLocation { line: 20, column: 29, offset: 455 }..TextLocation { line: 20, column: 30, offset: 456 }) }], err_no: var__unresolved_constant } +SyntaxError { message: "Unresolved constant 'cx' variable", range: [SourceLocation { span: Range(TextLocation { line: 18, column: 28, offset: 372 }..TextLocation { line: 18, column: 30, offset: 374 }) }], err_no: var__unresolved_constant } +SyntaxError { message: "Could not resolve reference to a", range: [SourceLocation { span: Range(TextLocation { line: 20, column: 29, offset: 453 }..TextLocation { line: 20, column: 30, offset: 454 }) }], err_no: reference__unresolved } +SyntaxError { message: "Unresolved constant 'cai' variable", range: [SourceLocation { span: Range(TextLocation { line: 20, column: 29, offset: 453 }..TextLocation { line: 20, column: 30, offset: 454 }) }], err_no: var__unresolved_constant } diff --git a/src/validation/tests/statement_validation_tests.rs b/src/validation/tests/statement_validation_tests.rs index 72cda6a263..92c16e3226 100644 --- a/src/validation/tests/statement_validation_tests.rs +++ b/src/validation/tests/statement_validation_tests.rs @@ -15,8 +15,8 @@ fn assign_pointer_to_too_small_type_result_in_an_error() { ptr : REF_TO INT; address : DWORD; END_VAR - - address := 16#DEAD_BEEF; + + address := 16#DEAD_BEEF; address := ptr; //should throw error as address is too small to store full pointer END_PROGRAM ", @@ -37,8 +37,8 @@ fn assign_too_small_type_to_pointer_result_in_an_error() { ptr : REF_TO INT; address : DWORD; END_VAR - - address := 16#DEAD_BEEF; + + address := 16#DEAD_BEEF; ptr := address; //should throw error as address is too small to store full pointer END_PROGRAM ", @@ -59,8 +59,8 @@ fn assign_pointer_to_lword() { ptr : REF_TO INT; address : LWORD; END_VAR - - address := 16#DEAD_BEEF; + + address := 16#DEAD_BEEF; address := ptr; END_PROGRAM ", @@ -113,12 +113,12 @@ fn assignment_to_enum_literals_results_in_error() { " TYPE Color: (red, yellow, green); END_TYPE - VAR_GLOBAL + VAR_GLOBAL g_enum: (A, B, C); END_VAR PROGRAM prg - VAR + VAR state: (OPEN, CLOSED); END_VAR @@ -139,40 +139,40 @@ fn invalid_char_assignments() { // WHEN it is validated let diagnostics = parse_and_validate( r#" - PROGRAM mainProg - VAR - c : CHAR; - c2 : CHAR; - wc : WCHAR; - wc2 : WCHAR; - i : INT; - s : STRING; - END_VAR - c := 'AJK%&/231'; // invalid - wc := "898JKAN"; // invalid - - c := wc; // invalid - wc := c; // invalid - - i := 54; - c := i; // invalid - c := 42; // invalid - - s := 'ABC'; - c := s; // invalid - wc := s; // invalid - - i := c; // invalid - s := c; // invalid - - c := 'A'; - c2 := 'B'; - c := c2; - - wc := "A"; - wc2 := "B"; - wc := wc2; - END_PROGRAM"#, + PROGRAM mainProg + VAR + c : CHAR; + c2 : CHAR; + wc : WCHAR; + wc2 : WCHAR; + i : INT; + s : STRING; + END_VAR + c := 'AJK%&/231'; // invalid + wc := "898JKAN"; // invalid + + c := wc; // invalid + wc := c; // invalid + + i := 54; + c := i; // invalid + c := 42; // invalid + + s := 'ABC'; + c := s; // invalid + wc := s; // invalid + + i := c; // invalid + s := c; // invalid + + c := 'A'; + c2 := 'B'; + c := c2; + + wc := "A"; + wc2 := "B"; + wc := wc2; + END_PROGRAM"#, ); // THEN every assignment should be reported @@ -295,32 +295,32 @@ fn switch_case() { // WHEN it is validated let diagnostics = parse_and_validate( r#" - VAR_GLOBAL CONSTANT - BASE : DINT := 1; - END_VAR + VAR_GLOBAL CONSTANT + BASE : DINT := 1; + END_VAR - TYPE myType: ( MYTYPE_A := BASE+1 ); END_TYPE + TYPE myType: ( MYTYPE_A := BASE+1 ); END_TYPE PROGRAM prog - VAR - input, res : DINT; - END_VAR - - CASE input OF - BASE: - res := 1; - MYTYPE_A: - res := 2; - MYTYPE_A+1: - res := 3; - 4: - res := 4; - 2*2+1: - res := 5; + VAR + input, res : DINT; + END_VAR + + CASE input OF + BASE: + res := 1; + MYTYPE_A: + res := 2; + MYTYPE_A+1: + res := 3; + 4: + res := 4; + 2*2+1: + res := 5; (BASE*5)..(BASE*10): - res := 6; - END_CASE - END_PROGRAM + res := 6; + END_CASE + END_PROGRAM "#, ); @@ -334,30 +334,30 @@ fn switch_case_duplicate_integer_non_const_var_reference() { // WHEN it is validated let diagnostics = parse_and_validate( r#" - VAR_GLOBAL CONSTANT - CONST : DINT := 8; - END_VAR + VAR_GLOBAL CONSTANT + CONST : DINT := 8; + END_VAR PROGRAM prog - VAR - input, res, x, y : DINT; - END_VAR - x := 2; - y := x; - - CASE input OF - x: // x is no constant => error - res := 1; - y: // y is no constant => error - res := 2; - 2+x: // x is no constant => error - res := 3; - CONST: - res := 4; - CONST+x: // x is no constant => error - res := 5; - END_CASE - END_PROGRAM + VAR + input, res, x, y : DINT; + END_VAR + x := 2; + y := x; + + CASE input OF + x: // x is no constant => error + res := 1; + y: // y is no constant => error + res := 2; + 2+x: // x is no constant => error + res := 3; + CONST: + res := 4; + CONST+x: // x is no constant => error + res := 5; + END_CASE + END_PROGRAM "#, ); @@ -371,30 +371,30 @@ fn switch_case_duplicate_integer() { // WHEN it is validated let diagnostics = parse_and_validate( r#" - VAR_GLOBAL CONSTANT - BASE : DINT := 2; - GLOB : DINT := 2; - END_VAR + VAR_GLOBAL CONSTANT + BASE : DINT := 2; + GLOB : DINT := 2; + END_VAR - TYPE myType: ( MYTYPE_A := BASE*2 ); END_TYPE + TYPE myType: ( MYTYPE_A := BASE*2 ); END_TYPE PROGRAM prog - VAR - input, res : DINT; - END_VAR - CASE input OF - 4: - res := 1; - BASE*2: - res := 2; - BASE+GLOB: - res := 3; - MYTYPE_A: - res := 4; - 2+2: - res := 5; - END_CASE - END_PROGRAM + VAR + input, res : DINT; + END_VAR + CASE input OF + 4: + res := 1; + BASE*2: + res := 2; + BASE+GLOB: + res := 3; + MYTYPE_A: + res := 4; + 2+2: + res := 5; + END_CASE + END_PROGRAM "#, ); @@ -408,21 +408,21 @@ fn switch_case_invalid_case_conditions() { // WHEN it is validated let diagnostics = parse_and_validate( r#" - FUNCTION foo : DINT - END_FUNCTION + FUNCTION foo : DINT + END_FUNCTION PROGRAM main - VAR - input, res : DINT; - END_VAR - - CASE input OF - foo(): - res := 1; - res := 2: - res := 2; - END_CASE - END_PROGRAM + VAR + input, res : DINT; + END_VAR + + CASE input OF + foo(): + res := 1; + res := 2: + res := 2; + END_CASE + END_PROGRAM "#, ); @@ -436,14 +436,14 @@ fn case_condition_used_outside_case_statement() { // WHEN it is validated let diagnostics = parse_and_validate( r#" - PROGRAM main - VAR - var1 : TOD; - END_VAR - var1 := TOD#20:15:30:123; - 23: - var1 := TOD#20:15:30; - END_PROGRAM + PROGRAM main + VAR + var1 : TOD; + END_VAR + var1 := TOD#20:15:30:123; + 23: + var1 := TOD#20:15:30; + END_PROGRAM "#, ); @@ -458,9 +458,9 @@ fn subrange_compare_function_causes_no_error() { let diagnostics = parse_and_validate( r#" PROGRAM main - VAR + VAR a, b, c, d, e, f : BOOL; - END_VAR + END_VAR VAR_TEMP x,y : INT(0..500); END_VAR @@ -486,9 +486,9 @@ fn aliased_subrange_compare_function_causes_no_error() { r#" TYPE MyInt: INT(0..500); END_TYPE PROGRAM main - VAR + VAR a, b, c, d, e, f : BOOL; - END_VAR + END_VAR VAR_TEMP x,y : MyInt; END_VAR @@ -514,9 +514,9 @@ fn aliased_int_compare_function_causes_no_error() { r#" TYPE MyInt: INT; END_TYPE PROGRAM main - VAR + VAR a, b, c, d, e, f : BOOL; - END_VAR + END_VAR VAR_TEMP x,y : MyInt; END_VAR @@ -539,28 +539,28 @@ fn program_missing_inout_assignment() { // GIVEN let diagnostics = parse_and_validate( " - PROGRAM prog - VAR_INPUT - input1 : DINT; - END_VAR - VAR_OUTPUT - output1 : DINT; - END_VAR - VAR_IN_OUT - inout1 : DINT; - END_VAR - END_PROGRAM - - PROGRAM main - VAR - var1, var2, var3 : DINT; - END_VAR - prog(input1 := var1, output1 => var2); - prog(var1, var2); - prog(var1); - prog(); - END_PROGRAM - ", + PROGRAM prog + VAR_INPUT + input1 : DINT; + END_VAR + VAR_OUTPUT + output1 : DINT; + END_VAR + VAR_IN_OUT + inout1 : DINT; + END_VAR + END_PROGRAM + + PROGRAM main + VAR + var1, var2, var3 : DINT; + END_VAR + prog(input1 := var1, output1 => var2); + prog(var1, var2); + prog(var1); + prog(); + END_PROGRAM + ", ); // THEN assert_validation_snapshot!(&diagnostics); @@ -572,34 +572,34 @@ fn function_call_parameter_validation() { // WHEN let diagnostics = parse_and_validate( r#" - FUNCTION foo : DINT - VAR_INPUT - input1 : DINT; - END_VAR - VAR_IN_OUT - inout1 : DINT; - END_VAR - VAR_OUTPUT - output1 : DINT; - END_VAR - END_FUNCTION - - PROGRAM main - VAR - var1 : DINT; - var2 : STRING; - var3 : REF_TO WSTRING; - var4 : REAL; - END_VAR - foo(input1 := var1, inout1 := var1, output1 => var1); // valid - - foo(output1 => var1, var1, var1); // invalid cannot mix explicit and implicit - - foo(input1 := var2, inout1 := var3, output1 => var4); // invalid types assigned + FUNCTION foo : DINT + VAR_INPUT + input1 : DINT; + END_VAR + VAR_IN_OUT + inout1 : DINT; + END_VAR + VAR_OUTPUT + output1 : DINT; + END_VAR + END_FUNCTION + + PROGRAM main + VAR + var1 : DINT; + var2 : STRING; + var3 : REF_TO WSTRING; + var4 : REAL; + END_VAR + foo(input1 := var1, inout1 := var1, output1 => var1); // valid + + foo(output1 => var1, var1, var1); // invalid cannot mix explicit and implicit + + foo(input1 := var2, inout1 := var3, output1 => var4); // invalid types assigned // ^^^^^^^^^^^^^^^ REAL assignment to DINT is valid - foo(var2, var3, var4); // invalid types assigned + foo(var2, var3, var4); // invalid types assigned // ^^^^ REAL assignment to DINT is valid - END_PROGRAM + END_PROGRAM "#, ); @@ -613,34 +613,34 @@ fn program_call_parameter_validation() { // WHEN let diagnostics = parse_and_validate( r#" - PROGRAM prog - VAR_INPUT - input1 : DINT; - END_VAR - VAR_IN_OUT - inout1 : DINT; - END_VAR - VAR_OUTPUT - output1 : DINT; - END_VAR - END_PROGRAM - - PROGRAM main - VAR - var1 : DINT; - var2 : STRING; - var3 : REF_TO WSTRING; - var4 : REAL; - END_VAR - prog(input1 := var1, inout1 := var1, output1 => var1); // valid - - prog(output1 => var1, var1, var1); // invalid cannot mix explicit and implicit - - prog(input1 := var2, inout1 := var3, output1 => var4); // invalid types assigned + PROGRAM prog + VAR_INPUT + input1 : DINT; + END_VAR + VAR_IN_OUT + inout1 : DINT; + END_VAR + VAR_OUTPUT + output1 : DINT; + END_VAR + END_PROGRAM + + PROGRAM main + VAR + var1 : DINT; + var2 : STRING; + var3 : REF_TO WSTRING; + var4 : REAL; + END_VAR + prog(input1 := var1, inout1 := var1, output1 => var1); // valid + + prog(output1 => var1, var1, var1); // invalid cannot mix explicit and implicit + + prog(input1 := var2, inout1 := var3, output1 => var4); // invalid types assigned // ^^^^^^^^^^^^^^^ REAL assignment to DINT is valid - prog(var2, var3, var4); // invalid types assigned + prog(var2, var3, var4); // invalid types assigned // ^^^^ REAL assignment to DINT is valid - END_PROGRAM + END_PROGRAM "#, ); @@ -701,7 +701,7 @@ fn reference_to_reference_assignments_in_function_arguments() { input2 := REF(global5), input3 := REF(global6), ); - + prog( // NONE of these should be valid because &(...) returns type information and we // explicitly check if pointer assignments are of the same type @@ -725,7 +725,7 @@ fn ref_builtin_function_reports_invalid_param_count() { x: ARRAY[0..1] OF INT; END_VAR REF(x); // valid - REF(); + REF(); REF(x, 1, 2, 'abc'); END_FUNCTION ", @@ -779,21 +779,21 @@ fn validate_call_by_ref() { VAR_INPUT byValInput : INT; END_VAR - + VAR_IN_OUT byRefInOut : INT; END_VAR - + VAR_OUTPUT byRefOutput : INT; END_VAR END_FUNCTION - + PROGRAM main VAR x : INT := 1; END_VAR - + // The second and third arguments are expected to be references, as such // any call to `func` where these two arguments are literals will fail func(1, 2, 3); @@ -833,12 +833,12 @@ fn validate_call_by_ref_explicit() { VAR x : INT := 1; END_VAR - + // The second and third arguments are expected to be references, as such // any call to `func` where these two arguments are literals will fail func(byValInput := 1, byRefInOut := 2, byRefOutput => ); func(byValInput := 1, byRefInOut := x, byRefOutput => ); // Valid (Output assignments are optional) - func(byValInput := 1, byRefInOut := 2, byRefOutput => 3); + func(byValInput := 1, byRefInOut := 2, byRefOutput => 3); func(byValInput := 1, byRefInOut := 2, byRefOutput => x); func(byValInput := 1, byRefInOut := x, byRefOutput => 3); func(byValInput := 1, byRefInOut := x, byRefOutput => x); // Valid @@ -919,7 +919,7 @@ fn function_block_implicit_downcast() { ); END_PROGRAM - FUNCTION_BLOCK fb_t + FUNCTION_BLOCK fb_t VAR_INPUT {ref} in_ref_int : INT; in_ref_dword : DWORD; @@ -965,7 +965,7 @@ fn program_implicit_downcast() { ); END_PROGRAM - PROGRAM prog + PROGRAM prog VAR_INPUT {ref} in_ref_int : INT; in_ref_dword : DWORD; @@ -1009,7 +1009,7 @@ fn action_implicit_downcast() { in2 : STRING; END_VAR END_FUNCTION_BLOCK - + ACTIONS fb_t ACTION foo END_ACTION @@ -1051,13 +1051,13 @@ fn method_implicit_downcast() { END_VAR METHOD testMethod - VAR_INPUT - val : INT; + VAR_INPUT + val : INT; arr : ARRAY[1..3] OF SINT; ref : REF_TO ARRAY[1..3] OF DINT; END_VAR END_METHOD - END_CLASS + END_CLASS "#, ); @@ -1084,8 +1084,8 @@ fn validate_array_elements_passed_to_functions_by_ref() { END_VAR func(x, x); // Invalid because we pass a whole array - func(x[0], x[1]); // Valid because we pass a variable by array access - func(byRefInOut := x[0], byRefOutput := x[1]); // Valid because we pass a variable by array access + func(x[0], x[1]); // Valid because we pass a variable by array access + func(byRefInOut := x[0], byRefOutput := x[1]); // Valid because we pass a variable by array access END_PROGRAM ", ); @@ -1112,11 +1112,11 @@ fn validate_arrays_passed_to_functions() { arr_real : ARRAY[0..1] OF REAL; arr_lreal : ARRAY[0..1] OF LREAL; - arr_dint_1_2 : ARRAY[1..2] OF DINT; + arr_dint_1_2 : ARRAY[1..2] OF DINT; arr_dint_3_4 : ARRAY[3..4] OF DINT; arr_dint_1_10 : ARRAY[1..10] OF DINT; arr_dint_10_100 : ARRAY[10..100] OF DINT; - + arr_dint_2d : ARRAY[0..1] OF ARRAY[0..1] OF DINT; END_VAR @@ -1152,7 +1152,7 @@ fn assigning_to_rvalue() { x : INT; END_VAR END_FUNCTION - + PROGRAM main VAR i : INT; @@ -1171,12 +1171,12 @@ fn assigning_to_rvalue() { fn assigning_to_qualified_references_allowed() { let diagnostics = parse_and_validate( r#" - PROGRAM prg + PROGRAM prg VAR_INPUT x : INT; END_VAR END_PROGRAM - + PROGRAM main prg.x := 1; END_PROGRAM @@ -1290,20 +1290,20 @@ fn bit_access_with_incorrect_operator_causes_warning() { Output.var1.%Wn1.%Bn1.%Xn1 := Input.var1; // OK Output.var1.n1 := Input.var1; // bitaccess without %X -> Warning END_PROGRAM - + TYPE STRUCT1 : STRUCT var1 : DWORD; END_STRUCT END_TYPE - + TYPE ENUM1 : ( n1 := 1, n2 := 2 ); END_TYPE - + TYPE STRUCT2 : STRUCT var1 : BOOL; @@ -1327,7 +1327,7 @@ fn invalid_cast_statement_causes_error() { i := INT#i; // ok i := INT#4; // ok END_PROGRAM - + TYPE STRUCT1 : STRUCT var1 : DWORD; diff --git a/src/validation/tests/variable_length_array_test.rs b/src/validation/tests/variable_length_array_test.rs index cd5c413e9d..998555c2de 100644 --- a/src/validation/tests/variable_length_array_test.rs +++ b/src/validation/tests/variable_length_array_test.rs @@ -211,7 +211,7 @@ mod naming { VAR_GLOBAL vla : ARRAY[*, *] OF DINT; END_VAR - + FUNCTION foo : DINT VAR_IN_OUT arr : ARRAY[*, *] OF DINT; @@ -255,7 +255,7 @@ mod builtins { #[test] fn builtins_called_with_invalid_index() { let diagnostics = parse_and_validate( - " + " FUNCTION main : DINT VAR arr : ARRAY[0..1] OF DINT; @@ -291,7 +291,7 @@ mod builtins { #[test] fn builtins_called_with_aliased_type() { let diagnostics = parse_and_validate( - " + " FUNCTION main : DINT VAR arr : ARRAY[0..1] OF DINT; diff --git a/src/validation/tests/variable_validation_tests.rs b/src/validation/tests/variable_validation_tests.rs index 27a3c4af7a..a054c7d922 100644 --- a/src/validation/tests/variable_validation_tests.rs +++ b/src/validation/tests/variable_validation_tests.rs @@ -6,7 +6,7 @@ use insta::assert_snapshot; fn uninitialized_constants_fall_back_to_the_default() { let diagnostics = parse_and_validate( " - VAR_GLOBAL + VAR_GLOBAL gX : INT; gXi : INT := 7; END_VAR @@ -17,7 +17,7 @@ fn uninitialized_constants_fall_back_to_the_default() { END_VAR PROGRAM prg - VAR + VAR x : INT; xi : INT := 7; END_VAR @@ -37,7 +37,7 @@ fn uninitialized_constants_fall_back_to_the_default() { fn unresolvable_variables_are_reported() { let diagnostics = parse_and_validate( " - VAR_GLOBAL + VAR_GLOBAL gX : INT := 7 + cgX; gXi : INT := 7; END_VAR @@ -48,7 +48,7 @@ fn unresolvable_variables_are_reported() { END_VAR PROGRAM prg - VAR + VAR x : INT; xi : INT := 7; END_VAR @@ -130,7 +130,7 @@ fn constant_fb_instances_are_illegal() { testMethod := 1; END_METHOD END_CLASS - + VAR_GLOBAL CONSTANT x : INT := 1; y : MyFb; @@ -287,7 +287,7 @@ mod overflows { " VAR_GLOBAL CONSTANT a : INT := 16384; // OK - b : INT := 16384; // OK + b : INT := 16384; // OK c : INT := a + b; // Will overflow END_VAR ", @@ -302,8 +302,8 @@ mod overflows { " VAR_GLOBAL a : INT := 16384; // OK - b : INT := 16384; // OK - c : INT := a + b; // Will overflow + b : INT := 16384; // OK + c : INT := a + b; // Will overflow END_VAR ", ); diff --git a/src/validation/variable.rs b/src/validation/variable.rs index 75723101a4..63e498ecbe 100644 --- a/src/validation/variable.rs +++ b/src/validation/variable.rs @@ -169,7 +169,7 @@ mod variable_validator_tests { let diagnostics = parse_and_validate_buffered( " TYPE the_struct : STRUCT END_STRUCT END_TYPE - + PROGRAM prg VAR my_struct : STRUCT @@ -186,7 +186,7 @@ mod variable_validator_tests { let diagnostics = parse_and_validate_buffered( " TYPE my_enum : (); END_TYPE - + PROGRAM prg VAR my_enum : (); @@ -203,7 +203,7 @@ mod variable_validator_tests { "VAR_GLOBAL x : (red, yellow, green) := 2; // error END_VAR - + PROGRAM main VAR y : (metallic := 1, matte := 2, neon := 3) := red; // error diff --git a/tests/correctness/arrays.rs b/tests/correctness/arrays.rs index 384929be61..079198f9fb 100644 --- a/tests/correctness/arrays.rs +++ b/tests/correctness/arrays.rs @@ -449,7 +449,7 @@ fn assigning_global_arrays_in_function_by_passing_references() { FUNCTION foo : DINT VAR_INPUT in : ARRAY[0..3] OF INT; - END_VAR + END_VAR VAR_INPUT {ref} in_ref : ARRAY[0..3] OF INT; END_VAR @@ -460,7 +460,7 @@ fn assigning_global_arrays_in_function_by_passing_references() { glob_arr_in_ref := in_ref; glob_arr_inout := inout; END_FUNCTION - + PROGRAM main VAR arr_in : ARRAY[0..3] OF INT; @@ -473,12 +473,12 @@ fn assigning_global_arrays_in_function_by_passing_references() { c : ARRAY[0..3] OF INT := (9, 10, 11, 12); END_VAR foo(a, b, c); - + arr_in := glob_arr_in; arr_in_ref := glob_arr_in_ref; arr_inout := glob_arr_inout; END_PROGRAM - + VAR_GLOBAL glob_arr_in : ARRAY[0..3] OF INT; glob_arr_in_ref : ARRAY[0..3] OF INT; @@ -505,7 +505,7 @@ fn assigning_global_arrays_in_program_by_passing_references() { PROGRAM prog VAR_INPUT in : ARRAY[0..3] OF INT; - END_VAR + END_VAR VAR_INPUT {ref} in_ref : ARRAY[0..3] OF INT; END_VAR @@ -516,7 +516,7 @@ fn assigning_global_arrays_in_program_by_passing_references() { glob_arr_in_ref := in_ref; glob_arr_inout := inout; END_PROGRAM - + PROGRAM main VAR arr_in : ARRAY[0..3] OF INT; @@ -529,12 +529,12 @@ fn assigning_global_arrays_in_program_by_passing_references() { c : ARRAY[0..3] OF INT := (9, 10, 11, 12); END_VAR prog(a, b, c); - + arr_in := glob_arr_in; arr_in_ref := glob_arr_in_ref; arr_inout := glob_arr_inout; END_PROGRAM - + VAR_GLOBAL glob_arr_in : ARRAY[0..3] OF INT; glob_arr_in_ref : ARRAY[0..3] OF INT; @@ -567,30 +567,30 @@ fn access_arrays_by_ref() { VAR_IN_OUT inout : ARRAY[0..1] OF INT; END_VAR - glob_a0 := in_ref[0]; - glob_a1 := in_ref[1]; - glob_b0 := inout[0]; - glob_b1 := inout[1]; + glob_a0 := in_ref[0]; + glob_a1 := in_ref[1]; + glob_b0 := inout[0]; + glob_b1 := inout[1]; END_FUNCTION - + PROGRAM main VAR - a0, a1, b0, b1 : INT; + a0, a1, b0, b1 : INT; END_VAR VAR_TEMP a : ARRAY[0..1] OF INT := (1, 2); b : ARRAY[0..1] OF INT := (5, 6); END_VAR foo(a, b); - - a0 := glob_a0; - a1 := glob_a1; - b0 := glob_b0; - b1 := glob_b1; + + a0 := glob_a0; + a1 := glob_a1; + b0 := glob_b0; + b1 := glob_b1; END_PROGRAM - + VAR_GLOBAL - glob_a0, glob_a1, glob_b0, glob_b1 : INT; + glob_a0, glob_a1, glob_b0, glob_b1 : INT; END_VAR "#; @@ -655,24 +655,24 @@ fn struct_initialization_with_array_initializer_using_multiplied_statement() { } let source = " - TYPE myStruct : STRUCT - arr : ARRAY[0..63] OF INT; - idx : INT; - END_STRUCT END_TYPE + TYPE myStruct : STRUCT + arr : ARRAY[0..63] OF INT; + idx : INT; + END_STRUCT END_TYPE PROGRAM target - VAR - val : myStruct := (arr := [64(111)], idx := 222); + VAR + val : myStruct := (arr := [64(111)], idx := 222); END_VAR END_PROGRAM - PROGRAM main + PROGRAM main VAR arr : ARRAY[0..63] OF INT; idx : INT := 0; - END_VAR + END_VAR arr := target.val.arr; idx := target.val.idx; - END_PROGRAM - " + END_PROGRAM + " .to_string(); let mut maintype = MainType { arr: [0; 64], idx: 0 }; diff --git a/tests/correctness/bitaccess.rs b/tests/correctness/bitaccess.rs index 427edc91c8..25bb6c581f 100644 --- a/tests/correctness/bitaccess.rs +++ b/tests/correctness/bitaccess.rs @@ -19,7 +19,7 @@ struct MainType { #[test] fn bitaccess_assignment() { let prog = " - PROGRAM main + PROGRAM main VAR a : BYTE := 2#0000_0101; b : WORD := 0; @@ -98,9 +98,9 @@ fn qualified_reference_assignment() { #[test] fn bitaccess_test() { let prog = " - PROGRAM main - VAR - variable : LWORD; + PROGRAM main + VAR + variable : LWORD; access_var : INT; bitTarget : BOOL; bitTarget2 : BOOL; @@ -138,8 +138,8 @@ fn bitaccess_test() { fn bitaccess_with_var_test() { let prog = " PROGRAM main - VAR - variable : LWORD; + VAR + variable : LWORD; access_var : INT; bitTarget : BOOL; bitTarget2 : BOOL; diff --git a/tests/correctness/classes.rs b/tests/correctness/classes.rs index 00df945960..3b92ab3573 100644 --- a/tests/correctness/classes.rs +++ b/tests/correctness/classes.rs @@ -22,11 +22,11 @@ fn class_reference_in_pou() { VAR x, y : INT; END_VAR - + METHOD testMethod : INT VAR_INPUT myMethodArg : INT; END_VAR VAR myMethodLocalVar : INT; END_VAR - + x := myMethodArg; y := x + 1; myMethodLocalVar := y + 1; @@ -34,7 +34,7 @@ fn class_reference_in_pou() { END_METHOD END_CLASS - PROGRAM main + PROGRAM main VAR cl : MyClass; x : INT := 0; diff --git a/tests/correctness/constants.rs b/tests/correctness/constants.rs index 2d6945ac9f..6ae49174d9 100644 --- a/tests/correctness/constants.rs +++ b/tests/correctness/constants.rs @@ -200,15 +200,15 @@ fn constant_expressions_used_in_array_declaration() { #[test] fn global_constant_string_assignment() { let src = r#" - VAR_GLOBAL CONSTANT - const_string : STRING := 'hello'; - END_VAR + VAR_GLOBAL CONSTANT + const_string : STRING := 'hello'; + END_VAR PROGRAM main - VAR - str : STRING[5]; - END_VAR - str := const_string; + VAR + str : STRING[5]; + END_VAR + str := const_string; END_PROGRAM "#; @@ -226,15 +226,15 @@ fn global_constant_string_assignment() { #[test] fn global_constant_array_assignment() { let src = r#" - VAR_GLOBAL CONSTANT - const_arr : ARRAY[0..3] OF INT := (1,2,3,4); - END_VAR + VAR_GLOBAL CONSTANT + const_arr : ARRAY[0..3] OF INT := (1,2,3,4); + END_VAR PROGRAM main - VAR - arr : ARRAY[0..3] OF INT; - END_VAR - arr := const_arr; + VAR + arr : ARRAY[0..3] OF INT; + END_VAR + arr := const_arr; END_PROGRAM "#; @@ -252,26 +252,26 @@ fn global_constant_array_assignment() { #[test] fn global_constant_struct_assignment() { let src = r#" - TYPE Point : - STRUCT - x,y : INT; - END_STRUCT - END_TYPE - - VAR_GLOBAL CONSTANT - const_strct : Point := (x := 1, y := 2); - END_VAR + TYPE Point : + STRUCT + x,y : INT; + END_STRUCT + END_TYPE + + VAR_GLOBAL CONSTANT + const_strct : Point := (x := 1, y := 2); + END_VAR PROGRAM main - VAR_TEMP - strct : Point; - END_VAR - VAR - x,y : INT; - END_VAR - strct := const_strct; - x := strct.x; - y := strct.y; + VAR_TEMP + strct : Point; + END_VAR + VAR + x,y : INT; + END_VAR + strct := const_strct; + x := strct.x; + y := strct.y; END_PROGRAM "#; diff --git a/tests/correctness/control_flow.rs b/tests/correctness/control_flow.rs index 35ceeb23b9..971d830172 100644 --- a/tests/correctness/control_flow.rs +++ b/tests/correctness/control_flow.rs @@ -120,7 +120,7 @@ fn for_continue_test() { FOR main := 1 TO 10 BY 1 DO main := 10; CONTINUE; - main := 200; + main := 200; END_FOR END_FUNCTION "#; @@ -164,7 +164,7 @@ fn for_loop_exit_test() { FUNCTION main : DINT FOR main := 100 TO 1000 BY 7 DO EXIT; - main := 200; + main := 200; END_FOR "#; @@ -206,7 +206,7 @@ fn loop_exit_test() { FUNCTION main : DINT FOR main := 100 TO 1000 BY 7 DO EXIT; - main := 200; + main := 200; END_FOR WHILE main > 50 DO EXIT; @@ -284,7 +284,7 @@ fn for_loop_and_increment_10_times_change_vars() { i, : INT := 0; END_VAR VAR_TEMP - start, end : INT; + start, end : INT; END_VAR main := 100; start := 1; @@ -310,7 +310,7 @@ fn for_loop_overflow() { } let function = r#" - PROGRAM main + PROGRAM main VAR i : INT; ret : DINT; @@ -537,7 +537,7 @@ fn exit_in_for_loop_in_while_loop() { main := main+1; FOR i := 0 TO 10 BY 1 DO EXIT; - END_FOR + END_FOR END_WHILE main := i + main; END_FUNCTION @@ -560,7 +560,7 @@ fn continue_in_for_loop_in_while_loop() { FOR i := 0 TO 10 BY 1 DO CONTINUE; main := 200; - END_FOR + END_FOR END_WHILE main := i + main; END_FUNCTION @@ -582,7 +582,7 @@ fn repeat_loop_no_entry() { REPEAT i := i+1; main := main + 10; - UNTIL i > 0 + UNTIL i > 0 END_REPEAT main := main + (i * 1000); END_FUNCTION @@ -675,7 +675,7 @@ fn case_statement() { ret : INT; END_VAR ret := 1; - + CASE i OF 1,2,3,4,5,6,7,8,9: ret := 101; 10,11,12..19: ret := 201; diff --git a/tests/correctness/custom_datatypes.rs b/tests/correctness/custom_datatypes.rs index 7dc43dbf8e..d16d5d9a31 100644 --- a/tests/correctness/custom_datatypes.rs +++ b/tests/correctness/custom_datatypes.rs @@ -75,8 +75,8 @@ fn using_nested_structs() { }; let testcode = r#" - TYPE MyInnerStruct: - STRUCT + TYPE MyInnerStruct: + STRUCT innerField1 : BYTE; innerField2 : INT; innerField3 : DINT; @@ -99,7 +99,7 @@ fn using_nested_structs() { myS.str1.innerField1 := 11; myS.str1.innerField2 := 12; myS.str1.innerField3 := 13; - + myS.str2.innerField1 := 21; myS.str2.innerField2 := 22; myS.str2.innerField3 := 23; @@ -142,14 +142,14 @@ fn using_enums() { PROGRAM main VAR - tf1 : TrafficLight; - tf2 : TrafficLight; - tf3 : TrafficLight; + tf1 : TrafficLight; + tf2 : TrafficLight; + tf3 : TrafficLight; END_VAR tf1 := Red; tf2 := Yellow; tf3 := Green; - + END_PROGRAM "#; @@ -176,14 +176,14 @@ fn using_inline_enums() { PROGRAM main VAR - tf1 : (White1, Red1, Yellow1, Green1); - tf2 : (White2, Red2, Yellow2, Green2); - tf3 : (White3, Red3, Yellow3, Green3); + tf1 : (White1, Red1, Yellow1, Green1); + tf2 : (White2, Red2, Yellow2, Green2); + tf3 : (White3, Red3, Yellow3, Green3); END_VAR tf1 := Red1; tf2 := Yellow2; tf3 := Green3; - + END_PROGRAM "#; @@ -209,16 +209,16 @@ fn using_duplicate_enums_with_casts() { TYPE MyEnum2: UINT(red := 10, yellow := 11, green := 12); END_TYPE - + TYPE MyEnum3: DINT(red := 22, yellow := 33, green := 44); END_TYPE PROGRAM main VAR - tf1 : MyEnum; - tf2 : MyEnum2; - tf3 : MyEnum3; + tf1 : MyEnum; + tf2 : MyEnum2; + tf3 : MyEnum3; END_VAR tf1 := MyEnum#red; tf2 := MyEnum2#yellow; @@ -244,7 +244,7 @@ fn using_inline_enums_in_structs() { TYPE TrafficLight: (White, Red, Yellow, Green); END_TYPE - + TYPE MyStruct: STRUCT tf1 : TrafficLight; @@ -280,7 +280,7 @@ fn using_inline_arrays_in_structs() { let mut data = MyStruct { arr1: [0; 4], arr2: [0; 8], arr3: [0; 3] }; let testcode = r#" - + TYPE MyStruct: STRUCT arr1 : ARRAY[0..3] OF INT; diff --git a/tests/correctness/datatypes.rs b/tests/correctness/datatypes.rs index 4d1a706764..2f349b3dc7 100644 --- a/tests/correctness/datatypes.rs +++ b/tests/correctness/datatypes.rs @@ -524,7 +524,7 @@ fn unsinged_byte_expansion3() { arg3 : ULINT; result : ULINT; END_VAR - + result := arg1 + (arg2 + arg3) + (arg2 + arg3); END_PROGRAM "#; @@ -559,12 +559,12 @@ fn assign_short_string_to_long_string_variable() { text : STRING; text2 : STRING; END_VAR - + text := 'abc'; text2 := 'abcdefg'; text2 := 'xyz'; - + END_PROGRAM "#; @@ -606,12 +606,12 @@ fn assign_string_to_string() { text : STRING; text2 : STRING; END_VAR - + text := 'abc'; text2 := text; text := 'def'; - + END_PROGRAM "#; @@ -906,7 +906,7 @@ fn function_return_string_by_ref_via_inout() { VAR_IN_OUT ret: STRING; END_VAR - + ret := 'abc'; END_FUNCTION diff --git a/tests/correctness/expressions.rs b/tests/correctness/expressions.rs index 8df580b6d5..ebd02c985d 100644 --- a/tests/correctness/expressions.rs +++ b/tests/correctness/expressions.rs @@ -47,7 +47,7 @@ fn equal_comparison_with_arbitrary_datatypes() { STRING_EQUAL := TRUE; END_FUNCTION - PROGRAM main + PROGRAM main VAR result1 : DINT; result2 : DINT; @@ -193,7 +193,7 @@ fn enums_can_be_compared() { let function = " TYPE MyEnum : BYTE (zero, aa, bb := 7, cc); END_TYPE - PROGRAM main + PROGRAM main VAR a,b,c : BOOL; END_VAR VAR_TEMP @@ -209,11 +209,11 @@ fn enums_can_be_compared() { IF y = 7 THEN b := TRUE; END_IF - + IF z = 8 THEN c := TRUE; END_IF - END_PROGRAM + END_PROGRAM "; let _: i32 = compile_and_run(function, &mut main); assert_eq!([true, true, true], [main.a, main.b, main.c]); @@ -239,7 +239,7 @@ fn amp_as_and_correctness_test() { a := TRUE; b := TRUE; c := FALSE; - + IF a & b THEN d := TRUE; END_IF @@ -272,9 +272,9 @@ fn aliased_ranged_numbers_can_be_compared() { let src = r#" TYPE MyInt: INT(0..500); END_TYPE PROGRAM main - VAR + VAR a, b, c, d, e, f : BOOL; - END_VAR + END_VAR VAR_TEMP x,y : MyInt; END_VAR diff --git a/tests/correctness/functions.rs b/tests/correctness/functions.rs index 5139d63591..9fb9cc106d 100644 --- a/tests/correctness/functions.rs +++ b/tests/correctness/functions.rs @@ -15,15 +15,15 @@ fn max_function() { let function = r#" - FUNCTION MAX : INT - VAR_INPUT + FUNCTION MAX : INT + VAR_INPUT a : INT; b : INT; END_VAR IF a > b THEN MAX := a; - ELSE + ELSE MAX := b; END_IF END_FUNCTION @@ -99,8 +99,8 @@ fn test_or_sideeffects() { res_or : INT; END_VAR - FUNCTION OR_BRANCH : BOOL - VAR_INPUT + FUNCTION OR_BRANCH : BOOL + VAR_INPUT a : BOOL; b : INT; END_VAR @@ -144,8 +144,8 @@ fn test_and_sideeffects() { res_and : INT; END_VAR - FUNCTION AND_BRANCH : BOOL - VAR_INPUT + FUNCTION AND_BRANCH : BOOL + VAR_INPUT a : BOOL; b : INT; END_VAR @@ -189,8 +189,8 @@ fn test_amp_as_and_sideeffects() { res_and : INT; END_VAR - FUNCTION AND_BRANCH : BOOL - VAR_INPUT + FUNCTION AND_BRANCH : BOOL + VAR_INPUT a : BOOL; b : INT; END_VAR @@ -242,10 +242,10 @@ fn function_block_instances_save_state_per_instance() { END_FUNCTION_BLOCK PROGRAM main - VAR + VAR f : foo; j : foo; - END_VAR + END_VAR f(); f(); j(4); @@ -344,9 +344,9 @@ fn functions_can_be_called_out_of_order() { END_FUNCTION PROGRAM main - VAR + VAR r : INT; - END_VAR + END_VAR r:= foo(); END_PROGRAM "#; @@ -377,7 +377,7 @@ fn function_block_instances_save_state_per_instance_2() { j: FooType, } let function = r#" - FUNCTION_BLOCK Baz + FUNCTION_BLOCK Baz VAR_INPUT i : INT; END_VAR @@ -387,16 +387,16 @@ fn function_block_instances_save_state_per_instance_2() { FUNCTION_BLOCK foo VAR_INPUT i : INT; - baz: Baz; + baz: Baz; END_VAR - + END_FUNCTION_BLOCK PROGRAM main - VAR + VAR f : foo; j : foo; - END_VAR + END_VAR f.baz.i := f.baz.i + 1; f.baz.i := f.baz.i + 1; @@ -434,7 +434,7 @@ fn function_call_inout_variable() { param := param * factor; END_PROGRAM - PROGRAM foo + PROGRAM foo VAR_IN_OUT inout : DINT; END_VAR @@ -466,7 +466,7 @@ fn inouts_behave_like_pointers() { p3: i32, } let function = r#" - VAR_GLOBAL + VAR_GLOBAL snap1 : DINT; snap2 : DINT; snap3 : DINT; @@ -514,23 +514,23 @@ fn var_output_assignment() { } let function = r#" - PROGRAM foo + PROGRAM foo VAR_INPUT input1 : DINT; input2 : DINT; END_VAR VAR_OUTPUT - output1 : DINT; - output2 : DINT; + output1 : DINT; + output2 : DINT; END_VAR - output1 := input1; - output2 := input2; + output1 := input1; + output2 := input2; END_PROGRAM PROGRAM main VAR var1 : DINT; - var2 : DINT; + var2 : DINT; END_VAR foo(7, 8, output1 => var1, output2 => var2); END_PROGRAM @@ -581,23 +581,23 @@ fn var_output_assignment_in_functions() { } let function = r#" - FUNCTION foo : INT + FUNCTION foo : INT VAR_INPUT input1 : DINT; input2 : DINT; END_VAR VAR_OUTPUT - output1 : DINT; - output2 : DINT; + output1 : DINT; + output2 : DINT; END_VAR - output1 := input1 + 2; - output2 := input2 + 3; + output1 := input1 + 2; + output2 := input2 + 3; END_PROGRAM PROGRAM main VAR var1 : DINT; - var2 : DINT; + var2 : DINT; END_VAR foo(7, 8, output1 => var1, output2 => var2); END_PROGRAM @@ -617,19 +617,19 @@ fn optional_output_assignment_in_functions() { } let function = r#" - FUNCTION foo : INT + FUNCTION foo : INT VAR_OUTPUT - output1 : DINT; - output2 : DINT; + output1 : DINT; + output2 : DINT; END_VAR - output1 := 1; - output2 := 2; + output1 := 1; + output2 := 2; END_FUNCTION PROGRAM main VAR var1 : DINT; - var2 : DINT; + var2 : DINT; END_VAR foo(output1 =>, output2 => var2); END_PROGRAM @@ -665,22 +665,22 @@ fn direct_call_on_function_block_array_access() { i : INT; END_VAR VAR - x : INT; - END_VAR - x := i; + x : INT; + END_VAR + x := i; END_FUNCTION_BLOCK PROGRAM main - VAR + VAR f : ARRAY[1..2] OF foo; - x : INT; - y : INT; + x : INT; + y : INT; END_VAR - f[1](i := 10); - x := f[1].x; + f[1](i := 10); + x := f[1].x; - f[2](i := 20); - y := f[2].x; + f[2](i := 20); + y := f[2].x; END_PROGRAM "#; @@ -699,16 +699,16 @@ fn nested_calls_in_call_statement() { } let function = r#" - FUNCTION seven : DINT - seven := 7; + FUNCTION seven : DINT + seven := 7; END_FUNCTION - FUNCTION eight : DINT - eight := 8; + FUNCTION eight : DINT + eight := 8; END_FUNCTION - FUNCTION nine : DINT - nine := 9; + FUNCTION nine : DINT + nine := 9; END_FUNCTION FUNCTION sum : DINT @@ -719,7 +719,7 @@ fn nested_calls_in_call_statement() { PROGRAM main VAR var1 : DINT; - var2 : DINT; + var2 : DINT; END_VAR var1 := sum(seven(), eight(), nine()); @@ -745,14 +745,14 @@ fn nested_calls_passing_aggregate_types() { let function = r#" TYPE Arr : ARRAY[0..1] OF DINT := [1, 1]; END_TYPE - FUNCTION getArr : Arr - getArr[0] := 3; - getArr[1] := 4; + FUNCTION getArr : Arr + getArr[0] := 3; + getArr[1] := 4; END_FUNCTION FUNCTION inc : Arr - VAR_INPUT - a: Arr; + VAR_INPUT + a: Arr; index: DINT; END_VAR @@ -806,7 +806,7 @@ fn mux_test() { num,b : DINT := 2; END_VAR b := num; - main := MUX(num,b,5,6,7,8); //Result is 6 + main := MUX(num,b,5,6,7,8); //Result is 6 END_FUNCTION "#; @@ -848,19 +848,19 @@ fn mux_array_ref() { } let function = r#" - PROGRAM main - VAR - arr1 : ARRAY[0..2] OF DINT; - END_VAR - VAR_TEMP - arr2 : ARRAY[0..2] OF DINT := (0, 1, 2); - arr3 : ARRAY[0..2] OF DINT := (3, 4, 5); - arr4 : ARRAY[0..2] OF DINT := (6, 7, 8); - arr5 : ARRAY[0..2] OF DINT := (9, 9, 9); - END_VAR - arr1 := MUX(2, arr2, arr3, arr4, arr5); // arr4 - END_PROGRAM - "#; + PROGRAM main + VAR + arr1 : ARRAY[0..2] OF DINT; + END_VAR + VAR_TEMP + arr2 : ARRAY[0..2] OF DINT := (0, 1, 2); + arr3 : ARRAY[0..2] OF DINT := (3, 4, 5); + arr4 : ARRAY[0..2] OF DINT := (6, 7, 8); + arr5 : ARRAY[0..2] OF DINT := (9, 9, 9); + END_VAR + arr1 := MUX(2, arr2, arr3, arr4, arr5); // arr4 + END_PROGRAM + "#; let mut main = MainType::default(); let _: i32 = compile_and_run(function.to_string(), &mut main); @@ -883,25 +883,25 @@ fn mux_struct_ref() { } let function = r#" - PROGRAM main - VAR - struct1 : myStruct; - END_VAR - VAR_TEMP - struct2 : myStruct := (a := FALSE, b := FALSE); - struct3 : myStruct := (a := FALSE, b := TRUE); - struct4 : myStruct := (a := TRUE, b := FALSE); - struct5 : myStruct := (a := TRUE, b := TRUE); - END_VAR - struct1 := MUX(2, struct2, struct3, struct4, struct5); // struct4 - END_PROGRAM - - TYPE myStruct : STRUCT - a : BOOL; - b : BOOL; - END_STRUCT - END_TYPE - "#; + PROGRAM main + VAR + struct1 : myStruct; + END_VAR + VAR_TEMP + struct2 : myStruct := (a := FALSE, b := FALSE); + struct3 : myStruct := (a := FALSE, b := TRUE); + struct4 : myStruct := (a := TRUE, b := FALSE); + struct5 : myStruct := (a := TRUE, b := TRUE); + END_VAR + struct1 := MUX(2, struct2, struct3, struct4, struct5); // struct4 + END_PROGRAM + + TYPE myStruct : STRUCT + a : BOOL; + b : BOOL; + END_STRUCT + END_TYPE + "#; let mut main = MainType::default(); let _: i32 = compile_and_run(function.to_string(), &mut main); @@ -917,20 +917,20 @@ fn mux_string_ref() { } let function = r#" - PROGRAM main - VAR - str1 : STRING; - END_VAR - VAR_TEMP - str2 : STRING := 'str2 '; - str3 : STRING := 'str3 '; - str4 : STRING := 'str4 '; - str5 : STRING := 'str5 '; - str6 : STRING := 'str6 '; - END_VAR - str1 := MUX(3, str2, str3, str4, str5, str6); // str5 - END_PROGRAM - "#; + PROGRAM main + VAR + str1 : STRING; + END_VAR + VAR_TEMP + str2 : STRING := 'str2 '; + str3 : STRING := 'str3 '; + str4 : STRING := 'str4 '; + str5 : STRING := 'str5 '; + str6 : STRING := 'str6 '; + END_VAR + str1 := MUX(3, str2, str3, str4, str5, str6); // str5 + END_PROGRAM + "#; let mut main = MainType::default(); let _: i32 = compile_and_run(function.to_string(), &mut main); @@ -946,13 +946,13 @@ fn mux_string_literal() { } let function = r#" - PROGRAM main - VAR - str1 : STRING; - END_VAR - str1 := MUX(3, 'hello', 'world', 'foo', 'baz'); // baz - END_PROGRAM - "#; + PROGRAM main + VAR + str1 : STRING; + END_VAR + str1 := MUX(3, 'hello', 'world', 'foo', 'baz'); // baz + END_PROGRAM + "#; let mut main = MainType::default(); let _: i32 = compile_and_run(function.to_string(), &mut main); @@ -977,7 +977,7 @@ fn sel_test_false() { fn sel_test_true() { let function = r#" FUNCTION main : DINT - main := SEL(TRUE,4,5); //Result is 5 + main := SEL(TRUE,4,5); //Result is 5 END_FUNCTION "#; @@ -994,7 +994,7 @@ fn sel_test_true_vars() { VAR a,b : DINT; END_VAR a := 4; b := 5; - main := SEL(TRUE,a,b); //Result is 5 + main := SEL(TRUE,a,b); //Result is 5 END_FUNCTION "#; @@ -1037,23 +1037,23 @@ fn sel_struct_ref() { } let function = r#" - PROGRAM main - VAR - struct1 : myStruct; - END_VAR - VAR_TEMP - struct2 : myStruct := (a := TRUE, b := FALSE); - struct3 : myStruct := (a := FALSE, b := TRUE); - END_VAR - struct1 := SEL(TRUE, struct2, struct3); // struct3 - END_PROGRAM - - TYPE myStruct : STRUCT - a : BOOL; - b : BOOL; - END_STRUCT - END_TYPE - "#; + PROGRAM main + VAR + struct1 : myStruct; + END_VAR + VAR_TEMP + struct2 : myStruct := (a := TRUE, b := FALSE); + struct3 : myStruct := (a := FALSE, b := TRUE); + END_VAR + struct1 := SEL(TRUE, struct2, struct3); // struct3 + END_PROGRAM + + TYPE myStruct : STRUCT + a : BOOL; + b : BOOL; + END_STRUCT + END_TYPE + "#; let mut main = MainType::default(); let _: i32 = compile_and_run(function.to_string(), &mut main); @@ -1070,17 +1070,17 @@ fn sel_array_ref() { } let function = r#" - PROGRAM main - VAR - arr1 : ARRAY[0..2] OF DINT; - END_VAR - VAR_TEMP - arr2 : ARRAY[0..2] OF DINT := (0, 1, 2); - arr3 : ARRAY[0..2] OF DINT := (3, 4, 5); - END_VAR - arr1 := SEL(TRUE, arr2, arr3); // arr3 - END_PROGRAM - "#; + PROGRAM main + VAR + arr1 : ARRAY[0..2] OF DINT; + END_VAR + VAR_TEMP + arr2 : ARRAY[0..2] OF DINT := (0, 1, 2); + arr3 : ARRAY[0..2] OF DINT := (3, 4, 5); + END_VAR + arr1 := SEL(TRUE, arr2, arr3); // arr3 + END_PROGRAM + "#; let mut main = MainType::default(); let _: i32 = compile_and_run(function.to_string(), &mut main); @@ -1096,17 +1096,17 @@ fn sel_string_ref() { } let function = r#" - PROGRAM main - VAR - str1 : STRING; - END_VAR - VAR_TEMP - str2 : STRING := 'hello'; - str3 : STRING := 'world'; - END_VAR - str1 := SEL(TRUE, str2, str3); // str3 - END_PROGRAM - "#; + PROGRAM main + VAR + str1 : STRING; + END_VAR + VAR_TEMP + str2 : STRING := 'hello'; + str3 : STRING := 'world'; + END_VAR + str1 := SEL(TRUE, str2, str3); // str3 + END_PROGRAM + "#; let mut main = MainType::default(); let _: i32 = compile_and_run(function.to_string(), &mut main); @@ -1122,13 +1122,13 @@ fn sel_string_literal() { } let function = r#" - PROGRAM main - VAR - str1 : STRING; - END_VAR - str1 := SEL(TRUE, 'hello', 'world'); // world - END_PROGRAM - "#; + PROGRAM main + VAR + str1 : STRING; + END_VAR + str1 := SEL(TRUE, 'hello', 'world'); // world + END_PROGRAM + "#; let mut main = MainType::default(); let _: i32 = compile_and_run(function.to_string(), &mut main); @@ -1174,13 +1174,13 @@ fn sizeof_test() { TYPE MyStruct : STRUCT a : BYTE; //8bit - offset 0 -> 1 byte b : DWORD; //32bit - offset 32 -> 8 bytes - c : WORD; //16bit - offset 64 -> 10 bytes + c : WORD; //16bit - offset 64 -> 10 bytes d : LWORD; //64bit - offset 128 -> 24 bytes END_STRUCT END_TYPE PROGRAM main - VAR - s1 : SINT; + VAR + s1 : SINT; s2 : INT; s3 : DINT; s4 : LINT; diff --git a/tests/correctness/generic_functions.rs b/tests/correctness/generic_functions.rs index b330be9d47..0bd73bedb9 100644 --- a/tests/correctness/generic_functions.rs +++ b/tests/correctness/generic_functions.rs @@ -77,7 +77,7 @@ fn test_generic_function_implemented_in_st_called() { times_two__REAL := val * 2.0; END_FUNCTION - PROGRAM main + PROGRAM main VAR a : INT; b : REAL; @@ -143,7 +143,7 @@ fn test_generic_function_with_param_by_ref_called() { LEFT_EXT(IN, L, LEFT__STRING); END_FUNCTION - PROGRAM main + PROGRAM main VAR END_VAR END_PROGRAM @@ -186,34 +186,34 @@ fn test_any_real_called_with_ints() { VAR_INPUT val : REAL; END_VAR - times_two__REAL := val * REAL#2.0; + times_two__REAL := val * REAL#2.0; END_FUNCTION FUNCTION times_two__LREAL : LREAL VAR_INPUT val : LREAL; END_VAR - times_two__LREAL := val * LREAL#2.0; + times_two__LREAL := val * LREAL#2.0; END_FUNCTION - PROGRAM main + PROGRAM main VAR a : REAL; b : LREAL; - c : REAL; - d : REAL; - e : REAL; - f : REAL; + c : REAL; + d : REAL; + e : REAL; + f : REAL; + END_VAR + VAR_TEMP + v_dint : DINT := -6; END_VAR - VAR_TEMP - v_dint : DINT := -6; - END_VAR a := times_two(REAL#2); b := times_two(LREAL#3); - c := times_two(SINT#-4); - d := times_two(UINT#5); - e := times_two(v_dint); - f := times_two(ULINT#7); + c := times_two(SINT#-4); + d := times_two(UINT#5); + e := times_two(v_dint); + f := times_two(ULINT#7); END_PROGRAM "; diff --git a/tests/correctness/initial_values.rs b/tests/correctness/initial_values.rs index 38425e6f6a..448ad25112 100644 --- a/tests/correctness/initial_values.rs +++ b/tests/correctness/initial_values.rs @@ -326,15 +326,15 @@ struct ArrayProgram { #[test] fn initial_values_in_single_dimension_array_variable() { let function = r" - VAR_GLOBAL - a : ARRAY[0..2] OF SINT := [1, 2, 3]; - b : ARRAY[0..2] OF INT := [4, 5, 6]; - c : ARRAY[0..2] OF DINT := [7, 8, 9]; - d : ARRAY[0..2] OF LINT := [10, 11, 12]; - _e : ARRAY[0..2] OF USINT := [13, 14, 15]; - f : ARRAY[0..2] OF UINT := [16, 17, 18]; - g : ARRAY[0..2] OF ULINT := [19, 20, 21]; - h : ARRAY[0..2] OF BOOL := [TRUE, FALSE, FALSE]; + VAR_GLOBAL + a : ARRAY[0..2] OF SINT := [1, 2, 3]; + b : ARRAY[0..2] OF INT := [4, 5, 6]; + c : ARRAY[0..2] OF DINT := [7, 8, 9]; + d : ARRAY[0..2] OF LINT := [10, 11, 12]; + _e : ARRAY[0..2] OF USINT := [13, 14, 15]; + f : ARRAY[0..2] OF UINT := [16, 17, 18]; + g : ARRAY[0..2] OF ULINT := [19, 20, 21]; + h : ARRAY[0..2] OF BOOL := [TRUE, FALSE, FALSE]; END_VAR PROGRAM main @@ -416,8 +416,8 @@ struct MultiDimArrayProgram { #[test] fn initial_values_in_multi_dimension_array_variable() { let function = r" - VAR_GLOBAL - a : ARRAY[0..1, 3..4] OF SINT := [1, 2, 3, 4]; + VAR_GLOBAL + a : ARRAY[0..1, 3..4] OF SINT := [1, 2, 3, 4]; END_VAR PROGRAM main @@ -426,8 +426,8 @@ fn initial_values_in_multi_dimension_array_variable() { a1 : SINT; a2 : SINT; a3 : SINT; - END_VAR - + END_VAR + a0 := a[0,3]; a1 := a[0,4]; a2 := a[1,3]; @@ -459,8 +459,8 @@ struct ArrayOfArrayProgram { #[test] fn initial_values_in_array_of_array_variable() { let function = r" - VAR_GLOBAL - a : ARRAY[0..1] OF ARRAY[0..1] OF ARRAY[0..1] OF SINT := [[[1, 2], [3, 4]], [[5, 6], [7, 8]]]; + VAR_GLOBAL + a : ARRAY[0..1] OF ARRAY[0..1] OF ARRAY[0..1] OF SINT := [[[1, 2], [3, 4]], [[5, 6], [7, 8]]]; END_VAR PROGRAM main @@ -473,8 +473,8 @@ fn initial_values_in_array_of_array_variable() { a6 : SINT; a7 : SINT; a8 : SINT; - END_VAR - + END_VAR + a1 := a[0][0][0]; a2 := a[0][0][1]; a3 := a[0][1][0]; @@ -511,7 +511,7 @@ struct RealsAndFloats { #[test] fn real_initial_values_in_array_variable() { let function = r" - VAR_GLOBAL + VAR_GLOBAL f : ARRAY[0..1] OF REAL := [9.1415, 0.001]; r : ARRAY[0..1] OF LREAL := [9.141592653589, 0.000000001]; END_VAR @@ -522,8 +522,8 @@ fn real_initial_values_in_array_variable() { f2 : REAL; r1 : LREAL; r2 : LREAL; - END_VAR - + END_VAR + f1 := f[0]; f2 := f[1]; r1 := r[0]; @@ -557,7 +557,7 @@ fn initialization_of_complex_struct_instance() { y: DINT; END_STRUCT END_TYPE - + TYPE MyStruct: STRUCT point: MyPoint; my_array: ARRAY[0..3] OF INT; @@ -565,12 +565,12 @@ fn initialization_of_complex_struct_instance() { END_STRUCT END_TYPE - VAR_GLOBAL + VAR_GLOBAL a : MyStruct := ( point := (x := 1, y:= 2), my_array := [0,1,2,3], f := 7.89 - ); + ); END_VAR PROGRAM main @@ -580,7 +580,7 @@ fn initialization_of_complex_struct_instance() { arr1 : INT; arr3 : INT; f : REAL; - END_VAR + END_VAR x := a.point.x; y := a.point.y; @@ -611,7 +611,7 @@ fn initialization_of_complex_struct_instance_using_defaults() { y: DINT := 7; END_STRUCT END_TYPE - + TYPE MyStruct: STRUCT point: MyPoint; my_array: ARRAY[0..3] OF INT; @@ -619,11 +619,11 @@ fn initialization_of_complex_struct_instance_using_defaults() { END_STRUCT END_TYPE - VAR_GLOBAL + VAR_GLOBAL a : MyStruct := ( point := (x := 1), my_array := [0,1,2,3] - ); + ); END_VAR PROGRAM main @@ -633,7 +633,7 @@ fn initialization_of_complex_struct_instance_using_defaults() { arr1 : INT; arr3 : INT; f : REAL; - END_VAR + END_VAR x := a.point.x; y := a.point.y; @@ -679,15 +679,15 @@ fn initialization_of_string_variables() { END_TYPE VAR_GLOBAL g : StringStruct; END_VAR - + PROGRAM main VAR - mystring: MyString := 'xxx'; + mystring: MyString := 'xxx'; mystring2: MyString; string1 : STRING := 'xxx'; string2 : STRING := 'xxx'; string3 : STRING[20]; - END_VAR + END_VAR mystring := g.mystring; mystring2 := g.mystring2; @@ -739,7 +739,7 @@ fn initialization_of_function_variables() { a : DINT; b : DINT := 10; c : ARRAY[0..2] OF DINT := [10,20]; - d : ARRAY[0..2] OF DINT; + d : ARRAY[0..2] OF DINT; END_VAR VAR_INPUT index : INT; @@ -750,8 +750,8 @@ fn initialization_of_function_variables() { ELSIF index = 1 THEN other := b; ELSIF index = 2 THEN - other := c[1]; - ELSE + other := c[1]; + ELSE other := d[0]; END_IF END_FUNCTION @@ -761,12 +761,12 @@ fn initialization_of_function_variables() { a : DINT; b : DINT; c : DINT; - d : DINT; + d : DINT; END_VAR a := other(index := 0); b := other(index := 1); c := other(index := 2); - d := other(index := 3); + d := other(index := 3); END_PROGRAM "; @@ -783,13 +783,13 @@ fn initialization_of_function_variables() { #[test] fn initialization_of_struct_in_fb() { let function = r" - TYPE str : STRUCT - a : DINT := 10; b : DINT := 20; c : DINT := 30; d : DINT; + TYPE str : STRUCT + a : DINT := 10; b : DINT := 20; c : DINT := 30; d : DINT; END_STRUCT END_TYPE VAR_GLOBAL fb : other; END_VAR - FUNCTION_BLOCK other + FUNCTION_BLOCK other VAR a : str; END_VAR @@ -800,7 +800,7 @@ fn initialization_of_struct_in_fb() { a : DINT; b : DINT; c : DINT; - d : DINT; + d : DINT; END_VAR a := fb.a.a; b := fb.a.b; @@ -821,10 +821,10 @@ fn initialization_of_struct_in_fb() { #[test] fn initialization_of_struct_in_prg() { let function = r" - TYPE str : STRUCT - a : DINT := 10; b : DINT := 20; c : DINT := 30; d : DINT; + TYPE str : STRUCT + a : DINT := 10; b : DINT := 20; c : DINT := 30; d : DINT; END_STRUCT END_TYPE - PROGRAM other + PROGRAM other VAR a : str; END_VAR @@ -835,7 +835,7 @@ fn initialization_of_struct_in_prg() { a : DINT; b : DINT; c : DINT; - d : DINT; + d : DINT; END_VAR a := other.a.a; b := other.a.b; @@ -857,8 +857,8 @@ fn initialization_of_struct_in_prg() { #[test] fn initialization_of_struct_ref_in_fb_in_function() { let function = r" - TYPE str : STRUCT - a : DINT := 10; b : DINT := 20; c : DINT := 30; d : DINT; + TYPE str : STRUCT + a : DINT := 10; b : DINT := 20; c : DINT := 30; d : DINT; END_STRUCT END_TYPE FUNCTION_BLOCK fb VAR @@ -878,8 +878,8 @@ fn initialization_of_struct_ref_in_fb_in_function() { ELSIF index = 1 THEN other := x.a.b; ELSIF index = 2 THEN - other := x.a.c; - ELSE + other := x.a.c; + ELSE other := x.a.d; END_IF END_FUNCTION @@ -889,12 +889,12 @@ fn initialization_of_struct_ref_in_fb_in_function() { a : DINT; b : DINT; c : DINT; - d : DINT; + d : DINT; END_VAR a := other(index := 0); b := other(index := 1); c := other(index := 2); - d := other(index := 3); + d := other(index := 3); END_PROGRAM "; @@ -910,8 +910,8 @@ fn initialization_of_struct_ref_in_fb_in_function() { #[test] fn initialization_of_struct_ref_in_function() { let function = r" - TYPE str : STRUCT - a : DINT := 10; b : DINT := 20; c : DINT := 30; d : DINT; + TYPE str : STRUCT + a : DINT := 10; b : DINT := 20; c : DINT := 30; d : DINT; END_STRUCT END_TYPE FUNCTION other : DINT VAR @@ -926,8 +926,8 @@ fn initialization_of_struct_ref_in_function() { ELSIF index = 1 THEN other := a.b; ELSIF index = 2 THEN - other := a.c; - ELSE + other := a.c; + ELSE other := a.d; END_IF END_FUNCTION @@ -937,12 +937,12 @@ fn initialization_of_struct_ref_in_function() { a : DINT; b : DINT; c : DINT; - d : DINT; + d : DINT; END_VAR a := other(index := 0); b := other(index := 1); c := other(index := 2); - d := other(index := 3); + d := other(index := 3); END_PROGRAM "; @@ -961,7 +961,7 @@ fn initialization_of_struct_in_function() { let function = r" FUNCTION other : DINT VAR - a : STRUCT a : DINT := 10; b : DINT := 20; c : DINT := 30; d : DINT; END_STRUCT + a : STRUCT a : DINT := 10; b : DINT := 20; c : DINT := 30; d : DINT; END_STRUCT END_VAR VAR_INPUT index : INT; @@ -972,8 +972,8 @@ fn initialization_of_struct_in_function() { ELSIF index = 1 THEN other := a.b; ELSIF index = 2 THEN - other := a.c; - ELSE + other := a.c; + ELSE other := a.d; END_IF END_FUNCTION @@ -983,12 +983,12 @@ fn initialization_of_struct_in_function() { a : DINT; b : DINT; c : DINT; - d : DINT; + d : DINT; END_VAR a := other(index := 0); b := other(index := 1); c := other(index := 2); - d := other(index := 3); + d := other(index := 3); END_PROGRAM "; @@ -1005,12 +1005,12 @@ fn initialization_of_struct_in_function() { #[test] fn initialized_array_in_function() { let function = " - FUNCTION foo : ARRAY[-1..2] OF DINT - VAR - arr_var : ARRAY[-1..2] OF DINT := [77,20,300,4000]; - END_VAR + FUNCTION foo : ARRAY[-1..2] OF DINT + VAR + arr_var : ARRAY[-1..2] OF DINT := [77,20,300,4000]; + END_VAR foo := arr_var; - END_FUNCTION + END_FUNCTION PROGRAM main VAR_INPUT @@ -1040,10 +1040,10 @@ fn array_test() { u,v,w,x : ULINT; END_VAR - FUNCTION foo : ARRAY[-1..2] OF DINT - VAR_INPUT - arr_var : ARRAY[-1..2] OF DINT; - END_VAR + FUNCTION foo : ARRAY[-1..2] OF DINT + VAR_INPUT + arr_var : ARRAY[-1..2] OF DINT; + END_VAR //main := arr_var; //main[-1] := 1; @@ -1053,14 +1053,14 @@ fn array_test() { x := &(arr_var[3])); main.a := 99; - END_FUNCTION + END_FUNCTION PROGRAM main VAR_INPUT a,b,c,d : ULINT; END_VAR VAR_TEMP - arr_var : ARRAY[-1..2] OF DINT := [77,20,300,4000]; + arr_var : ARRAY[-1..2] OF DINT := [77,20,300,4000]; END_VAR a := 1; b:=2; c:=3; d:=4; @@ -1069,7 +1069,7 @@ fn array_test() { a := u; b := v; c := w; - d := x; + d := x; END_PROGRAM "; @@ -1097,7 +1097,7 @@ fn initialized_array_type_in_function() { END_VAR main := arr_var; END_PROGRAM - "; + "; #[allow(dead_code)] struct MainType { arr: [i32; 4], @@ -1110,19 +1110,19 @@ fn initialized_array_type_in_function() { #[test] fn initialized_array_in_program() { let function = " - PROGRAM target - VAR - arr_var : ARRAY[-1..2] OF DINT := [1,2,3,4]; - END_VAR - END_PROGRAM + PROGRAM target + VAR + arr_var : ARRAY[-1..2] OF DINT := [1,2,3,4]; + END_VAR + END_PROGRAM PROGRAM main VAR - arr_var : ARRAY[-1..2] OF DINT; - END_VAR + arr_var : ARRAY[-1..2] OF DINT; + END_VAR arr_var := target.arr_var; END_PROGRAM - "; + "; #[allow(dead_code)] struct MainType { @@ -1138,20 +1138,20 @@ fn initialized_array_type_in_program() { let function = " TYPE arr : ARRAY[-1..2] OF DINT := [1,2,3,4]; END_TYPE - PROGRAM target - VAR - arr_var : arr; - END_VAR - END_PROGRAM + PROGRAM target + VAR + arr_var : arr; + END_VAR + END_PROGRAM PROGRAM main VAR arr_var : ARRAY[-1..2] OF DINT; END_VAR - + arr_var := target.arr_var; END_PROGRAM - "; + "; #[allow(dead_code)] struct MainType { arr: [i32; 4], @@ -1168,8 +1168,8 @@ fn intial_values_diverge_from_type() { TYPE myInt : DINT := 4; END_TYPE PROGRAM target - VAR - arr_var : arr := [5,6,7,8]; + VAR + arr_var : arr := [5,6,7,8]; i : myInt := 5; END_VAR END_PROGRAM @@ -1182,7 +1182,7 @@ fn intial_values_diverge_from_type() { arr_var := target.arr_var; i := target.i; END_PROGRAM - "; + "; #[allow(dead_code)] struct MainType { arr: [i32; 4], @@ -1201,7 +1201,7 @@ fn initial_value_of_function_return_dint() { // WHEN I only increment the function's return before returning it let function = " - + TYPE myInt : DINT := 4; END_TYPE FUNCTION target : myInt @@ -1212,10 +1212,10 @@ fn initial_value_of_function_return_dint() { VAR i : DINT; END_VAR - + i := target(); END_PROGRAM - "; + "; #[allow(dead_code)] struct MainType { i: i32, @@ -1246,7 +1246,7 @@ fn initial_value_of_function_return_array() { END_VAR arr := target(); END_PROGRAM - "; + "; #[allow(dead_code)] #[repr(C)] @@ -1269,11 +1269,11 @@ fn initial_value_of_function_return_struct() { // WHEN I only increment a by 1, b by 2 and c by 3 before returning it let function = " - - TYPE myStruct : STRUCT - a : DINT := 10; - b : DINT := 20; - c : DINT := 30; + + TYPE myStruct : STRUCT + a : DINT := 10; + b : DINT := 20; + c : DINT := 30; END_STRUCT END_TYPE @@ -1288,13 +1288,13 @@ fn initial_value_of_function_return_struct() { a,b,c : DINT; str : myStruct; END_VAR - + str := target(); a := str.a; b := str.b; c := str.c; END_PROGRAM - "; + "; #[allow(dead_code)] struct MainType { @@ -1351,35 +1351,35 @@ fn initial_value_of_enums() { #[test] fn initial_value_in_array_of_struct() { let function = " - TYPE myStruct : STRUCT - a, b : DINT; - c : ARRAY[0..1] OF DINT; - END_STRUCT - END_TYPE - - VAR_GLOBAL CONSTANT - str : myStruct := (a := 50, b := 60, c := [70, 80]); - END_VAR - - PROGRAM main - VAR_TEMP - arr : ARRAY[0..1] OF myStruct := [(a := 10, b := 20, c := [30, 40]), str]; - END_VAR - VAR - a, b, c, d : DINT; - e, f, g, h : DINT; - END_VAR - a := arr[0].a; - b := arr[0].b; - c := arr[0].c[0]; - d := arr[0].c[1]; - - e := arr[1].a; - f := arr[1].b; - g := arr[1].c[0]; - h := arr[1].c[1]; - END_PROGRAM - "; + TYPE myStruct : STRUCT + a, b : DINT; + c : ARRAY[0..1] OF DINT; + END_STRUCT + END_TYPE + + VAR_GLOBAL CONSTANT + str : myStruct := (a := 50, b := 60, c := [70, 80]); + END_VAR + + PROGRAM main + VAR_TEMP + arr : ARRAY[0..1] OF myStruct := [(a := 10, b := 20, c := [30, 40]), str]; + END_VAR + VAR + a, b, c, d : DINT; + e, f, g, h : DINT; + END_VAR + a := arr[0].a; + b := arr[0].b; + c := arr[0].c[0]; + d := arr[0].c[1]; + + e := arr[1].a; + f := arr[1].b; + g := arr[1].c[0]; + h := arr[1].c[1]; + END_PROGRAM + "; #[allow(dead_code)] #[derive(Default)] diff --git a/tests/correctness/math_operators/addition.rs b/tests/correctness/math_operators/addition.rs index a7ec45e1b7..79fb3f5d61 100644 --- a/tests/correctness/math_operators/addition.rs +++ b/tests/correctness/math_operators/addition.rs @@ -19,7 +19,7 @@ fn adds_in_result_dint_type() { foo := 10 + 50; END_FUNCTION - PROGRAM main + PROGRAM main VAR i1, i2: DINT; END_VAR i1 := 22 + 18; diff --git a/tests/correctness/methods.rs b/tests/correctness/methods.rs index 77351ce2ac..ebd7b87c25 100644 --- a/tests/correctness/methods.rs +++ b/tests/correctness/methods.rs @@ -6,7 +6,7 @@ use crate::{compile_and_run, MainType}; #[ignore = "class/method support postponed"] fn fb_vars_can_be_accessed_from_method() { let src = " -FUNCTION main : DINT +FUNCTION main : DINT prg(); main := prg.y; END_FUNCTION @@ -38,7 +38,7 @@ END_FUNCTION_BLOCK #[ignore = "class support postponed"] fn class_vars_can_be_accessed() { let src = " -FUNCTION main : DINT +FUNCTION main : DINT prg(); main := prg.y; END_FUNCTION @@ -73,8 +73,8 @@ fn method_can_resolve_non_class_functions() { FUNCTION foo : DINT foo := 42; END_FUNCTION - - CLASS baz + + CLASS baz METHOD test : DINT test := foo(); END_METHOD @@ -86,7 +86,7 @@ fn method_can_resolve_non_class_functions() { y := x.test(); END_PROGRAM - FUNCTION main : DINT + FUNCTION main : DINT prg(); main := prg.y; END_FUNCTION diff --git a/tests/correctness/pointers.rs b/tests/correctness/pointers.rs index 1bed05d88d..c81e44f82b 100644 --- a/tests/correctness/pointers.rs +++ b/tests/correctness/pointers.rs @@ -10,16 +10,16 @@ TYPE MyStruct: STRUCT x: DINT; y: DINT; END_STRUCT END_TYPE TYPE MyRef : REF_TO REF_TO DINT; END_TYPE FUNCTION main : DINT - main := foo(); + main := foo(); END_FUNCTION FUNCTION foo : DINT VAR - x : DINT; - s : MyStruct; - u,y : REF_TO DINT; - z : REF_TO REF_TO DINT; - v : MyRef; + x : DINT; + s : MyStruct; + u,y : REF_TO DINT; + z : REF_TO REF_TO DINT; + v : MyRef; END_VAR u := REF(s.x); @@ -47,16 +47,16 @@ TYPE MyStruct: STRUCT x: DINT; y: DINT; END_STRUCT END_TYPE TYPE MyRef : REF_TO REF_TO DINT; END_TYPE FUNCTION main : DINT - main := foo(); + main := foo(); END_FUNCTION FUNCTION foo : DINT VAR - x : DINT; - s : MyStruct; - u,y : REF_TO DINT; - z : REF_TO REF_TO DINT; - v : MyRef; + x : DINT; + s : MyStruct; + u,y : REF_TO DINT; + z : REF_TO REF_TO DINT; + v : MyRef; END_VAR u := &s.x; @@ -97,46 +97,46 @@ fn binary_expressions_for_pointers() { } let function = " - PROGRAM main - VAR - a : CHAR; - b : CHAR; - c : CHAR; - d : CHAR; - e : CHAR; - equal : BOOL; - not_equal : BOOL; - less : BOOL; - greater : BOOL; - less_or_equal : BOOL; - greater_or_equal : BOOL; - END_VAR - VAR_TEMP - arr : ARRAY[0..3] OF CHAR := ['a','b','c','d']; - ptr : REF_TO CHAR; - negative : INT := -1; - END_VAR - ptr := &(arr); - - ptr := ptr + 1 + 1; - a := ptr^; - ptr := ptr + 1; - b := ptr^; - ptr := ptr - 1; - c := ptr^; - ptr := ptr + negative; - d := ptr^; - ptr := ptr - negative; - e := ptr^; - - equal := ptr = ptr; - not_equal := ptr <> ptr; - less := ptr < ptr + 1; - greater := ptr > ptr - 1; - less_or_equal := ptr <= ptr; - greater_or_equal := ptr >= ptr; - END_PROGRAM - "; + PROGRAM main + VAR + a : CHAR; + b : CHAR; + c : CHAR; + d : CHAR; + e : CHAR; + equal : BOOL; + not_equal : BOOL; + less : BOOL; + greater : BOOL; + less_or_equal : BOOL; + greater_or_equal : BOOL; + END_VAR + VAR_TEMP + arr : ARRAY[0..3] OF CHAR := ['a','b','c','d']; + ptr : REF_TO CHAR; + negative : INT := -1; + END_VAR + ptr := &(arr); + + ptr := ptr + 1 + 1; + a := ptr^; + ptr := ptr + 1; + b := ptr^; + ptr := ptr - 1; + c := ptr^; + ptr := ptr + negative; + d := ptr^; + ptr := ptr - negative; + e := ptr^; + + equal := ptr = ptr; + not_equal := ptr <> ptr; + less := ptr < ptr + 1; + greater := ptr > ptr - 1; + less_or_equal := ptr <= ptr; + greater_or_equal := ptr >= ptr; + END_PROGRAM + "; let mut main = Main::default(); let _: i32 = compile_and_run(function, &mut main); assert_eq!(main.a, "c".as_bytes()[0]); @@ -165,25 +165,25 @@ fn binary_expressions_for_pointers_with_function_return() { FUNCTION len : INT len := 1; END_FUNCTION - PROGRAM main - VAR - a : CHAR; + PROGRAM main + VAR + a : CHAR; b : CHAR; c : CHAR; - END_VAR - VAR_TEMP - arr : ARRAY[0..2] OF CHAR := ['a','b', 'c']; - ptr : REF_TO CHAR; - END_VAR - ptr := &arr; - - a := ptr^; - ptr := &arr[0] + len() + 1; - b := ptr^; - ptr := ptr - len() - 1; - c := ptr^; - END_PROGRAM - "; + END_VAR + VAR_TEMP + arr : ARRAY[0..2] OF CHAR := ['a','b', 'c']; + ptr : REF_TO CHAR; + END_VAR + ptr := &arr; + + a := ptr^; + ptr := &arr[0] + len() + 1; + b := ptr^; + ptr := ptr - len() - 1; + c := ptr^; + END_PROGRAM + "; let mut main = Main::default(); let _: i32 = compile_and_run(function, &mut main); assert_eq!(main.a, "a".as_bytes()[0]); @@ -212,30 +212,30 @@ fn value_behind_function_block_pointer_is_assigned_to_correctly() { } let src = r#" - FUNCTION_BLOCK file_t - VAR_INPUT - var1 : BOOL; - var2 : BOOL; - END_VAR - VAR_OUTPUT - out1 : BOOL; - out2 : BOOL; - END_VAR - out1 := var1; - out2 := var2; - END_FUNCTION_BLOCK - - PROGRAM main - VAR - a: BOOL; - b: BOOL; - file : file_t; + FUNCTION_BLOCK file_t + VAR_INPUT + var1 : BOOL; + var2 : BOOL; + END_VAR + VAR_OUTPUT + out1 : BOOL; + out2 : BOOL; + END_VAR + out1 := var1; + out2 := var2; + END_FUNCTION_BLOCK + + PROGRAM main + VAR + a: BOOL; + b: BOOL; + file : file_t; FileOpen : REF_TO file_t; END_VAR - FileOpen := &file; - FileOpen^(var1 := FALSE, var2:=TRUE, out1 => a, out2 => b); + FileOpen := &file; + FileOpen^(var1 := FALSE, var2:=TRUE, out1 => a, out2 => b); END_PROGRAM - "#; + "#; let mut maintype = MainType::default(); let _: i32 = compile_and_run(src, &mut maintype); diff --git a/tests/correctness/pointers/references.rs b/tests/correctness/pointers/references.rs index 01f5bf56d8..86d04a9dae 100644 --- a/tests/correctness/pointers/references.rs +++ b/tests/correctness/pointers/references.rs @@ -45,7 +45,7 @@ fn new() -> MainType { #[test] fn reference_call() { let function = r" - + FUNCTION_BLOCK fbTest VAR_INPUT reference : REF_TO BOOL; (* REF_TO *) @@ -84,7 +84,7 @@ fn reference_call() { in_out2^ := TRUE; END_FUNCTION - + PROGRAM main VAR test: fbTest; @@ -123,7 +123,7 @@ fn reference_call() { r_a^ := FALSE; r_b^:= FALSE; p_c^ := FALSE; p_d^:= FALSE; test(reference := r_a, p := p_c, in_out1 := r_b, in_out2 := p_d); b_result_d := r_a^; b_result_e := r_b^; b_result_f := p_c^; b_result_g := p_d^; - + r_a^ := FALSE; r_b^:= FALSE; p_c^ := FALSE; p_d^:= FALSE; other(reference := r_a, p := p_c, in_out1 := r_b, in_out2 := p_d); b_result_h := r_a^; b_result_i := r_b^; b_result_j := p_c^; b_result_k := p_d^; @@ -241,7 +241,7 @@ fn reference_call_struct() { ref_a : REF_TO MyStruct; (* REF_TO *) ref_b : REF_TO MyStruct; (* REF_TO *) p_a : POINTER TO MyStruct; - p_b : POINTER TO MyStruct; + p_b : POINTER TO MyStruct; b_result_a : BOOL := FALSE; b_result_b : INT := 0; b_result_c : BOOL := FALSE; @@ -253,22 +253,22 @@ fn reference_call_struct() { END_VAR a.field1 := FALSE; a.field2 := 0; b.field1 := FALSE; b.field2 := 0; - + ref_a := &a; ref_b := &b; p_a := &a; p_b := &b; other(reference := ref_a, p:= p_a, in_out1 := ref_b, in_out2 := p_b); - b_result_a := a.field1; + b_result_a := a.field1; b_result_b := a.field2; - b_result_c := b.field1; + b_result_c := b.field1; b_result_d := b.field2; a.field1 := FALSE; a.field2 := 0; b.field1 := FALSE; b.field2 := 0; test(reference := ref_a, p := ref_a, in_out1 := ref_b, in_out2 := ref_b); - b_result_e := a.field1; + b_result_e := a.field1; b_result_f := a.field2; - b_result_g := b.field1; + b_result_g := b.field1; b_result_h := b.field2; END_PROGRAM @@ -375,8 +375,8 @@ fn reference_call_array() { ref_a : REF_TO ARRAY[1..2] OF INT; (* REF_TO *) ref_b : REF_TO ARRAY[1..2] OF INT; (* REF_TO *) p_c : POINTER TO ARRAY[1..2] OF INT; - - p_d : POINTER TO ARRAY[1..2] OF INT; + + p_d : POINTER TO ARRAY[1..2] OF INT; b_result_a : INT := 0; b_result_b : INT := 0; b_result_c : INT := 0; @@ -385,28 +385,28 @@ fn reference_call_array() { b_result_f : INT := 0; b_result_g : INT := 0; b_result_h : INT := 0; - b_result_i : INT := 0; - b_result_j : INT := 0; - b_result_k : INT := 0; - b_result_l : INT := 0; - b_result_m : INT := 0; - b_result_n : INT := 0; - b_result_o : INT := 0; - b_result_p : INT := 0; + b_result_i : INT := 0; + b_result_j : INT := 0; + b_result_k : INT := 0; + b_result_l : INT := 0; + b_result_m : INT := 0; + b_result_n : INT := 0; + b_result_o : INT := 0; + b_result_p : INT := 0; END_VAR ref_a := &a; ref_b := &b; p_c := &c; p_d := &d; - + a[1] := 0; a[2] := 0; b[1] := 0; b[2] := 0; c[1] := 0; c[2] := 0; d[1] := 0; d[2] := 0; - + other(reference := ref_a, p:= p_c, in_out1 := ref_b, in_out2 := p_d); b_result_a := a[1]; b_result_b := a[2]; - b_result_c := b[1]; + b_result_c := b[1]; b_result_d := b[2]; b_result_e := c[1]; b_result_f := c[2]; @@ -417,11 +417,11 @@ fn reference_call_array() { b[1] := 0; b[2] := 0; c[1] := 0; c[2] := 0; d[1] := 0; d[2] := 0; - + test(reference := ref_a, p := p_c, in_out1 := ref_b, in_out2 := p_d); b_result_i := a[1]; b_result_j := a[2]; - b_result_k := b[1]; + b_result_k := b[1]; b_result_l := b[2]; b_result_m := c[1]; b_result_n := c[2]; @@ -467,7 +467,7 @@ fn multiple_pointer_dereference() { END_VAR VAR_TEMP c: REF_TO BYTE; - d: REF_TO REF_TO BYTE; + d: REF_TO REF_TO BYTE; e: BYTE; END_VAR c := &a; diff --git a/tests/correctness/strings.rs b/tests/correctness/strings.rs index 0366123921..58c420d083 100644 --- a/tests/correctness/strings.rs +++ b/tests/correctness/strings.rs @@ -13,9 +13,9 @@ use std::ffi::CStr; fn string_assignment_from_smaller_literal() { let src = r#" PROGRAM main - VAR - x : STRING[6]; - y : WSTRING[6]; + VAR + x : STRING[6]; + y : WSTRING[6]; END_VAR x := 'hello'; y := "hello"; @@ -39,7 +39,7 @@ fn string_assignment_from_smaller_literal() { fn string_assignment_from_bigger_literal() { let src = r#" PROGRAM main - VAR + VAR x : STRING[4]; y : WSTRING[4]; END_VAR @@ -64,10 +64,10 @@ fn string_assignment_from_bigger_literal() { #[test] fn string_assignment_from_smaller_string() { let src = r#" - PROGRAM main - VAR - x : STRING[6]; y : STRING[5]; - u : WSTRING[6]; v : WSTRING[5]; + PROGRAM main + VAR + x : STRING[6]; y : STRING[5]; + u : WSTRING[6]; v : WSTRING[5]; END_VAR y := 'hello'; x := y; @@ -95,9 +95,9 @@ fn string_assignment_from_smaller_string() { fn string_assignment_from_bigger_string() { let src = r#" PROGRAM main - VAR + VAR x : STRING[4]; y : STRING[5]; - u : WSTRING[4]; v : WSTRING[5]; + u : WSTRING[4]; v : WSTRING[5]; END_VAR y := 'hello'; x := y; @@ -295,11 +295,11 @@ fn initialization_of_string_arrays() { PROGRAM main VAR x,y,z : STRING[10]; END_VAR - + x := texts[0]; y := texts[1]; z := texts[2]; - + END_PROGRAM "; @@ -368,10 +368,10 @@ fn string_as_function_parameters_internal() { END_FUNCTION PROGRAM main - VAR - res : STRING; - END_VAR - res := func('hello'); + VAR + res : STRING; + END_VAR + res := func('hello'); END_PROGRAM "; @@ -396,10 +396,10 @@ fn string_as_function_parameters() { END_FUNCTION PROGRAM main - VAR - res : STRING; - END_VAR - res := func('hello'); + VAR + res : STRING; + END_VAR + res := func('hello'); END_PROGRAM "; @@ -427,10 +427,10 @@ fn wstring_as_function_parameters() { END_FUNCTION PROGRAM main - VAR - res : WSTRING; - END_VAR - res := func("hello"); + VAR + res : WSTRING; + END_VAR + res := func("hello"); END_PROGRAM "#; @@ -465,10 +465,10 @@ fn string_as_function_parameters_cast() { END_FUNCTION PROGRAM main - VAR - res : STRING; - END_VAR - res := func(STRING#'hello'); + VAR + res : STRING; + END_VAR + res := func(STRING#'hello'); END_PROGRAM "; @@ -501,10 +501,10 @@ fn wstring_as_function_parameters_cast() { END_FUNCTION PROGRAM main - VAR - res : WSTRING; - END_VAR - res := func(WSTRING#"hello"); + VAR + res : WSTRING; + END_VAR + res := func(WSTRING#"hello"); END_PROGRAM "#; @@ -531,14 +531,14 @@ fn wstring_as_function_parameters_cast() { fn string_as_function_return_type_does_not_truncate() { let src = " FUNCTION foo : STRING[100] - VAR_INPUT + VAR_INPUT str_param : STRING[100]; END_VAR foo := str_param; END_FUNCTION PROGRAM main - VAR + VAR x : STRING[100] END_VAR x := foo(' this is a very long sentence with plenty of characters and weird spacing.') @@ -564,7 +564,7 @@ fn string_as_function_return_type_does_not_truncate() { fn string_ref_returned_from_wrapper_function_does_not_truncate() { let src = " FUNCTION foo : STRING[100] - VAR_INPUT + VAR_INPUT str_param : STRING[100]; END_VAR bar(str_param, foo); @@ -581,7 +581,7 @@ fn string_ref_returned_from_wrapper_function_does_not_truncate() { END_FUNCTION PROGRAM main - VAR + VAR x : STRING[100] END_VAR x := foo(' this is a very long sentence with plenty of characters and weird spacing.') @@ -609,7 +609,7 @@ fn string_returned_from_generic_wrapper_function_does_not_truncate() { FUNCTION foo : T VAR_INPUT {ref} in : T; - END_VAR + END_VAR END_FUNCTION FUNCTION foo__STRING : STRING[100] @@ -629,8 +629,8 @@ fn string_returned_from_generic_wrapper_function_does_not_truncate() { out := in; END_FUNCTION - PROGRAM main - VAR + PROGRAM main + VAR param : STRING[100]; x : STRING[100]; END_VAR @@ -657,7 +657,7 @@ fn string_returned_from_generic_wrapper_function_does_not_truncate() { fn string_returned_from_main_does_not_truncate() { let src = " FUNCTION main : STRING[100] - VAR + VAR param : STRING[100]; END_VAR param := ' this is a very long sentence with plenty of characters and weird spacing.'; @@ -668,9 +668,9 @@ fn string_returned_from_main_does_not_truncate() { let _: u32 = compile_and_run(src, &mut res); assert_eq!( - format!("{res:?}"), + format!("{res:?}"), format!( - "{:?}", + "{:?}", " this is a very long sentence with plenty of characters and weird spacing.\0".as_bytes() ) ) @@ -682,7 +682,7 @@ fn when_function_returns_value_from_generic_function_call_then_string_does_not_t FUNCTION foo : T VAR_INPUT {ref} in : T; - END_VAR + END_VAR END_FUNCTION FUNCTION foo__STRING : STRING[100] @@ -703,20 +703,20 @@ fn when_function_returns_value_from_generic_function_call_then_string_does_not_t END_FUNCTION FUNCTION main : STRING[100] - VAR + VAR param : STRING[100]; END_VAR param := ' this is a very long sentence with plenty of characters and weird spacing.'; - main := foo(param); + main := foo(param); END_FUNCTION "; let mut res: [u8; 101] = [0; 101]; let _: () = compile_and_run(src, &mut res); assert_eq!( - format!("{res:?}"), + format!("{res:?}"), format!( - "{:?}", + "{:?}", " this is a very long sentence with plenty of characters and weird spacing.\0".as_bytes() ) ) @@ -743,20 +743,20 @@ fn when_function_returns_value_from_function_call_string_does_not_truncate() { END_FUNCTION FUNCTION main : STRING[100] - VAR + VAR param : STRING[100]; END_VAR param := ' this is a very long sentence with plenty of characters and weird spacing.'; - main := foo(param); + main := foo(param); END_FUNCTION "; let mut res: [u8; 101] = [0; 101]; let _: () = compile_and_run(src, &mut res); assert_eq!( - format!("{res:?}"), + format!("{res:?}"), format!( - "{:?}", + "{:?}", " this is a very long sentence with plenty of characters and weird spacing.\0".as_bytes() ) ) @@ -765,21 +765,21 @@ fn when_function_returns_value_from_function_call_string_does_not_truncate() { #[test] fn program_string_output() { let src = r#" - PROGRAM prog - VAR_OUTPUT - output1 : STRING; - output2 : WSTRING; - END_VAR - output1 := 'string'; - output2 := "wstring"; - END_PROGRAM + PROGRAM prog + VAR_OUTPUT + output1 : STRING; + output2 : WSTRING; + END_VAR + output1 := 'string'; + output2 := "wstring"; + END_PROGRAM PROGRAM main - VAR - x : STRING[6]; - y : WSTRING[7]; - END_VAR - prog(x, y); + VAR + x : STRING[6]; + y : WSTRING[7]; + END_VAR + prog(x, y); END_PROGRAM "#; @@ -799,7 +799,7 @@ fn program_string_output() { #[test] fn assigning_global_strings_in_function_by_passing_references() { let src = r#" - FUNCTION foo : DINT + FUNCTION foo : DINT VAR_INPUT in : STRING; END_VAR @@ -857,7 +857,7 @@ fn assigning_global_strings_in_function_by_passing_references() { #[test] fn assigning_global_strings_in_function_by_passing_sized_strings() { let src = r#" - FUNCTION foo : DINT + FUNCTION foo : DINT VAR_INPUT in : STRING; END_VAR @@ -915,7 +915,7 @@ fn assigning_global_strings_in_function_by_passing_sized_strings() { #[test] fn assigning_global_strings_in_function_by_passing_literals() { let src = r#" - FUNCTION foo : DINT + FUNCTION foo : DINT VAR_INPUT in : STRING; END_VAR @@ -959,7 +959,7 @@ fn assigning_global_strings_in_function_by_passing_literals() { #[test] fn assigning_by_ref_string_parameters_in_function() { let src = r#" - FUNCTION foo : DINT + FUNCTION foo : DINT VAR_INPUT in : STRING; END_VAR @@ -1011,7 +1011,7 @@ fn assigning_by_ref_string_parameters_in_function() { #[test] fn reassign_strings_after_function_call() { let src = r#" - FUNCTION foo : DINT + FUNCTION foo : DINT VAR_INPUT in : STRING; END_VAR @@ -1063,7 +1063,7 @@ fn reassign_strings_after_function_call() { #[test] fn assigning_global_strings_in_program_by_passing_references() { let src = r#" - PROGRAM prog + PROGRAM prog VAR_INPUT in : STRING; END_VAR @@ -1123,7 +1123,7 @@ fn assigning_global_strings_in_program_by_passing_references() { #[test] fn assigning_global_strings_in_program_by_passing_sized_strigs() { let src = r#" - PROGRAM prog + PROGRAM prog VAR_INPUT in : STRING; END_VAR @@ -1182,7 +1182,7 @@ fn assigning_global_strings_in_program_by_passing_sized_strigs() { #[test] fn assigning_global_strings_in_program_by_passing_literals() { let src = r#" - PROGRAM prog + PROGRAM prog VAR_INPUT in : STRING; END_VAR diff --git a/tests/correctness/sub_range_types.rs b/tests/correctness/sub_range_types.rs index f9a20995a6..95cf13fea4 100644 --- a/tests/correctness/sub_range_types.rs +++ b/tests/correctness/sub_range_types.rs @@ -40,7 +40,7 @@ fn sub_range_chooses_right_implementation() { VAR_INPUT v: ULINT; low: ULINT; up: ULINT; END_VAR CheckLRangeUnsigned := 77; END_FUNCTION - + PROGRAM main VAR a : BYTE(0 .. 100); diff --git a/tests/correctness/vla.rs b/tests/correctness/vla.rs index 2d6f125281..fa60c1324d 100644 --- a/tests/correctness/vla.rs +++ b/tests/correctness/vla.rs @@ -76,7 +76,7 @@ fn variable_length_array_multi_dimension_access() { a := arr[0, 0]; b := arr[0, 1]; c := arr[1, 0]; - d := arr[1, 1]; + d := arr[1, 1]; END_PROGRAM FUNCTION foo : DINT @@ -87,7 +87,7 @@ fn variable_length_array_multi_dimension_access() { vla[0, 0] := 0; vla[0, 1] := 2; vla[1, 0] := 4; - vla[1, 1] := 8; + vla[1, 1] := 8; END_FUNCTION "#; @@ -128,9 +128,9 @@ fn variable_length_array_multi_dimension_read_write() { vla : ARRAY[ *, *, *, *] OF LINT; END_VAR - vla[1, 2, 1, 8] := -7; - vla[2, 1, 1, 6] := 72; - vla[3, 1, 1, 4] := 11; + vla[1, 2, 1, 8] := -7; + vla[2, 1, 1, 6] := 72; + vla[3, 1, 1, 4] := 11; END_FUNCTION "#; @@ -168,7 +168,7 @@ fn variable_length_array_multi_dimension_read_write_with_offsets() { END_PROGRAM FUNCTION foo : DINT - VAR_INPUT + VAR_INPUT vla : ARRAY[ *, *, *, * ] OF LINT; END_VAR @@ -226,7 +226,7 @@ fn consecutive_calls_with_differently_sized_arrays() { END_PROGRAM FUNCTION foo : DINT - VAR_INPUT + VAR_INPUT vla : ARRAY[ *, * ] OF LINT; END_VAR @@ -378,7 +378,7 @@ fn variable_length_array_by_ref_param_access() { e := arr[4]; END_PROGRAM - FUNCTION foo : DINT + FUNCTION foo : DINT VAR_IN_OUT vla : ARRAY[ * ] OF DINT; END_VAR @@ -429,7 +429,7 @@ fn variable_length_array_output_param_access() { e := arr[4]; END_PROGRAM - FUNCTION foo : DINT + FUNCTION foo : DINT VAR_OUTPUT vla : ARRAY[ * ] OF DINT; END_VAR @@ -507,7 +507,7 @@ fn variable_length_array_multi_dimension_with_strings() { a := arr[0, 0]; b := arr[0, 1]; c := arr[1, 0]; - d := arr[1, 1]; + d := arr[1, 1]; END_PROGRAM FUNCTION foo : DINT @@ -518,7 +518,7 @@ fn variable_length_array_multi_dimension_with_strings() { vla[0, 0] := 'brave '; vla[0, 1] := 'new '; vla[1, 0] := 'world '; - vla[1, 1] := '📖'; + vla[1, 1] := '📖'; END_FUNCTION "#; @@ -563,12 +563,12 @@ fn variable_length_array_of_array() { a := arr[0, 0][0]; b := arr[0, 0][1]; c := arr[0, 1][0]; - d := arr[0, 1][1]; - e := arr[1, 0][0]; - f := arr[1, 0][1]; - g := arr[1, 1][0]; - h := arr[1, 1][1]; - + d := arr[0, 1][1]; + e := arr[1, 0][0]; + f := arr[1, 0][1]; + g := arr[1, 1][0]; + h := arr[1, 1][1]; + END_PROGRAM FUNCTION foo : DINT @@ -580,10 +580,10 @@ fn variable_length_array_of_array() { vla[0, 0][1] := 1; vla[0, 1][0] := 2; vla[0, 1][1] := 3; - vla[1, 0][0] := 4; - vla[1, 0][1] := 5; - vla[1, 1][0] := 6; - vla[1, 1][1] := 7; + vla[1, 0][0] := 4; + vla[1, 0][1] := 5; + vla[1, 1][0] := 6; + vla[1, 1][1] := 7; END_FUNCTION "#; @@ -617,7 +617,7 @@ mod builtins { VAR_INPUT {ref} array_1d : ARRAY[*] OF DINT; END_VAR - + foo[0] := LOWER_BOUND(array_1d, 1); foo[1] := UPPER_BOUND(array_1d, 1); END_FUNCTION @@ -632,8 +632,8 @@ mod builtins { array_1d : ARRAY[-5..5] OF DINT; END_VAR - res := foo(array_1d); - + res := foo(array_1d); + lower_1d := res[0]; upper_1d := res[1]; END_PROGRAM @@ -662,7 +662,7 @@ mod builtins { VAR_TEMP i : DINT := 1; END_VAR - + foo[0] := LOWER_BOUND(array_1d, i); foo[1] := UPPER_BOUND(array_1d, i); END_FUNCTION @@ -677,8 +677,8 @@ mod builtins { array_1d : ARRAY[-5..5] OF DINT; END_VAR - res := foo(array_1d); - + res := foo(array_1d); + lower_1d := res[0]; upper_1d := res[1]; END_PROGRAM @@ -705,7 +705,7 @@ mod builtins { VAR_INPUT {ref} arr : ARRAY[*, *] OF DINT; END_VAR - + foo[0] := LOWER_BOUND(arr, 1); foo[1] := UPPER_BOUND(arr, 1); foo[2] := LOWER_BOUND(arr, 2); @@ -723,8 +723,8 @@ mod builtins { array_2d : ARRAY[-5..5, -10..10] OF DINT; END_VAR - res := foo(array_2d); - + res := foo(array_2d); + lower_2d_1 := res[0]; upper_2d_1 := res[1]; lower_2d_2 := res[2]; @@ -760,7 +760,7 @@ mod builtins { i : DINT := 1; j : DINT := 2; END_VAR - + foo[0] := LOWER_BOUND(arr, i); foo[1] := UPPER_BOUND(arr, i); foo[2] := LOWER_BOUND(arr, j); @@ -778,8 +778,8 @@ mod builtins { array_2d : ARRAY[-5..5, -10..10] OF DINT; END_VAR - res := foo(array_2d); - + res := foo(array_2d); + lower_2d_1 := res[0]; upper_2d_1 := res[1]; lower_2d_2 := res[2]; @@ -912,30 +912,30 @@ mod builtins { A1 : ARRAY [1..10] OF INT := [10(1)]; A2 : ARRAY [1..20, -2..2] OF INT := [20(5(1))]; END_VAR - + FUNCTION sum : DINT VAR_IN_OUT A: ARRAY [*] OF INT; END_VAR - + VAR i, sum2 : DINT; END_VAR - + sum2 := 0; FOR i:= LOWER_BOUND(A, 1) TO UPPER_BOUND(A, 1) DO sum2 := sum2 + A[i]; END_FOR - + sum := sum2; END_FUNCTION - + PROGRAM main VAR sum_a1 : DINT; sum_a2 : DINT; END_VAR - + sum_a1 := sum(A1); // sum_a2 := SUM(A2[2]); END_PROGRAM @@ -959,7 +959,7 @@ mod builtins { MY_CONST : DINT := 10; END_VAR - PROGRAM main + PROGRAM main VAR a, b: DINT; END_VAR @@ -970,14 +970,14 @@ mod builtins { b := upper(x); END_FUNCTION - FUNCTION lower : DINT + FUNCTION lower : DINT VAR_INPUT vla : ARRAY[*] OF DINT; END_VAR lower := LOWER_BOUND(vla, MY_CONST - 9); END_FUNCTION - FUNCTION upper : DINT + FUNCTION upper : DINT VAR_INPUT vla : ARRAY[*] OF DINT; END_VAR diff --git a/tests/integration/data/cfc/actions.cfc b/tests/integration/data/cfc/actions.cfc index 34a53e4393..d73e30db99 100644 --- a/tests/integration/data/cfc/actions.cfc +++ b/tests/integration/data/cfc/actions.cfc @@ -7,7 +7,7 @@ PROGRAM main VAR - a,b : DINT; + a,b : DINT; END_VAR @@ -59,21 +59,21 @@ END_VAR - - - - - - - a - - - - - - - 0 - + + + + + + + a + + + + + + + 0 + diff --git a/tests/integration/data/cfc/assigning.st b/tests/integration/data/cfc/assigning.st index c8ee1cd6e2..bee5c2523b 100644 --- a/tests/integration/data/cfc/assigning.st +++ b/tests/integration/data/cfc/assigning.st @@ -7,4 +7,4 @@ END_VAR pt.a := x; pt.b := y; main := pt.a + pt.b -END_PROGRAM \ No newline at end of file +END_PROGRAM diff --git a/tests/integration/data/cfc/chained_calls.cfc b/tests/integration/data/cfc/chained_calls.cfc index 7999894425..5d2c647c1c 100644 --- a/tests/integration/data/cfc/chained_calls.cfc +++ b/tests/integration/data/cfc/chained_calls.cfc @@ -8,7 +8,7 @@ FUNCTION_BLOCK myAdder VAR - x, y: DINT; + x, y: DINT; END_VAR VAR_OUTPUT @@ -18,7 +18,7 @@ END_VAR VAR END_VAR - + diff --git a/tests/integration/data/cfc/chained_calls.st b/tests/integration/data/cfc/chained_calls.st index e6b5d26835..8e9c2d0ceb 100644 --- a/tests/integration/data/cfc/chained_calls.st +++ b/tests/integration/data/cfc/chained_calls.st @@ -17,7 +17,7 @@ END_PROGRAM FUNCTION myAdd : DINT VAR_INPUT - a, b : DINT; + a, b : DINT; END_VAR myAdd := a + b; -END_FUNCTION \ No newline at end of file +END_FUNCTION diff --git a/tests/integration/data/cfc/chained_calls_galore.cfc b/tests/integration/data/cfc/chained_calls_galore.cfc index 1b974c3d83..0b393c0350 100644 --- a/tests/integration/data/cfc/chained_calls_galore.cfc +++ b/tests/integration/data/cfc/chained_calls_galore.cfc @@ -298,4 +298,4 @@ END_VAR - \ No newline at end of file + diff --git a/tests/integration/data/cfc/chained_calls_galore.st b/tests/integration/data/cfc/chained_calls_galore.st index e6ad0aacd1..787175208a 100644 --- a/tests/integration/data/cfc/chained_calls_galore.st +++ b/tests/integration/data/cfc/chained_calls_galore.st @@ -11,7 +11,7 @@ END_PROGRAM FUNCTION myAdd : DINT VAR_INPUT - a, b : DINT; + a, b : DINT; END_VAR myAdd := a + b; -END_FUNCTION \ No newline at end of file +END_FUNCTION diff --git a/tests/integration/data/cfc/conditional_return.cfc b/tests/integration/data/cfc/conditional_return.cfc index 822d88de38..961b299828 100644 --- a/tests/integration/data/cfc/conditional_return.cfc +++ b/tests/integration/data/cfc/conditional_return.cfc @@ -64,4 +64,4 @@ - \ No newline at end of file + diff --git a/tests/integration/data/cfc/conditional_return_block.cfc b/tests/integration/data/cfc/conditional_return_block.cfc index e54c57eb01..97ed161982 100644 --- a/tests/integration/data/cfc/conditional_return_block.cfc +++ b/tests/integration/data/cfc/conditional_return_block.cfc @@ -86,4 +86,4 @@ - \ No newline at end of file + diff --git a/tests/integration/data/cfc/conditional_return_block_evaluating_false.st b/tests/integration/data/cfc/conditional_return_block_evaluating_false.st index c652aef6ac..2f98c2d579 100644 --- a/tests/integration/data/cfc/conditional_return_block_evaluating_false.st +++ b/tests/integration/data/cfc/conditional_return_block_evaluating_false.st @@ -12,13 +12,13 @@ FUNCTION main : DINT END_FUNCTION FUNCTION MyGT : BOOL - VAR_INPUT - a, b : DINT; - END_VAR + VAR_INPUT + a, b : DINT; + END_VAR - IF a > b THEN - MyGT := TRUE; - ELSE - MyGT := FALSE; - END_IF -END_FUNCTION \ No newline at end of file + IF a > b THEN + MyGT := TRUE; + ELSE + MyGT := FALSE; + END_IF +END_FUNCTION diff --git a/tests/integration/data/cfc/conditional_return_block_evaluating_true.st b/tests/integration/data/cfc/conditional_return_block_evaluating_true.st index f22166eb2d..eaccc3eddf 100644 --- a/tests/integration/data/cfc/conditional_return_block_evaluating_true.st +++ b/tests/integration/data/cfc/conditional_return_block_evaluating_true.st @@ -12,13 +12,13 @@ FUNCTION main : DINT END_FUNCTION FUNCTION MyGT : BOOL - VAR_INPUT - a, b : DINT; - END_VAR + VAR_INPUT + a, b : DINT; + END_VAR - IF a > b THEN - MyGT := TRUE; - ELSE - MyGT := FALSE; - END_IF -END_FUNCTION \ No newline at end of file + IF a > b THEN + MyGT := TRUE; + ELSE + MyGT := FALSE; + END_IF +END_FUNCTION diff --git a/tests/integration/data/cfc/conditional_return_evaluating_false.st b/tests/integration/data/cfc/conditional_return_evaluating_false.st index 41fb9249ff..e7eed61d8f 100644 --- a/tests/integration/data/cfc/conditional_return_evaluating_false.st +++ b/tests/integration/data/cfc/conditional_return_evaluating_false.st @@ -8,4 +8,4 @@ FUNCTION main : DINT conditional(); main := conditional.val; -END_FUNCTION \ No newline at end of file +END_FUNCTION diff --git a/tests/integration/data/cfc/conditional_return_evaluating_true.st b/tests/integration/data/cfc/conditional_return_evaluating_true.st index c6af0a9147..fb3631f5c1 100644 --- a/tests/integration/data/cfc/conditional_return_evaluating_true.st +++ b/tests/integration/data/cfc/conditional_return_evaluating_true.st @@ -8,4 +8,4 @@ FUNCTION main : DINT conditional(); main := conditional.val; -END_FUNCTION \ No newline at end of file +END_FUNCTION diff --git a/tests/integration/data/cfc/conditional_return_evaluating_true_negated.st b/tests/integration/data/cfc/conditional_return_evaluating_true_negated.st index c6af0a9147..fb3631f5c1 100644 --- a/tests/integration/data/cfc/conditional_return_evaluating_true_negated.st +++ b/tests/integration/data/cfc/conditional_return_evaluating_true_negated.st @@ -8,4 +8,4 @@ FUNCTION main : DINT conditional(); main := conditional.val; -END_FUNCTION \ No newline at end of file +END_FUNCTION diff --git a/tests/integration/data/cfc/conditional_return_negated.cfc b/tests/integration/data/cfc/conditional_return_negated.cfc index 39ebf1c1bc..4c827c9d1c 100644 --- a/tests/integration/data/cfc/conditional_return_negated.cfc +++ b/tests/integration/data/cfc/conditional_return_negated.cfc @@ -8,7 +8,7 @@ FUNCTION_BLOCK conditional_return VAR_INPUT - val : DINT; + val : DINT; END_VAR diff --git a/tests/integration/data/cfc/connection.st b/tests/integration/data/cfc/connection.st index eefd89f938..9cedc9b622 100644 --- a/tests/integration/data/cfc/connection.st +++ b/tests/integration/data/cfc/connection.st @@ -1,14 +1,14 @@ FUNCTION main : DINT VAR - value : DINT := 2; + value : DINT := 2; END_VAR - main := myConnection(value); + main := myConnection(value); ; END_FUNCTION FUNCTION myAdd : DINT VAR_INPUT - a, b : DINT; + a, b : DINT; END_VAR - myAdd := a + b; -END_FUNCTION \ No newline at end of file + myAdd := a + b; +END_FUNCTION diff --git a/tests/integration/data/cfc/connection_block_source_multi_sink.cfc b/tests/integration/data/cfc/connection_block_source_multi_sink.cfc index 400436cb08..56b2abf5e8 100644 --- a/tests/integration/data/cfc/connection_block_source_multi_sink.cfc +++ b/tests/integration/data/cfc/connection_block_source_multi_sink.cfc @@ -8,12 +8,12 @@ FUNCTION myConnection : DINT VAR_INPUT - x: DINT; + x: DINT; END_VAR VAR_TEMP - y: DINT; + y: DINT; END_VAR - + diff --git a/tests/integration/data/cfc/connection_var_source_multi_sink.cfc b/tests/integration/data/cfc/connection_var_source_multi_sink.cfc index 7bd768b038..a7787ca0a0 100644 --- a/tests/integration/data/cfc/connection_var_source_multi_sink.cfc +++ b/tests/integration/data/cfc/connection_var_source_multi_sink.cfc @@ -107,4 +107,4 @@ - \ No newline at end of file + diff --git a/tests/integration/data/cfc/duplicate_label.cfc b/tests/integration/data/cfc/duplicate_label.cfc index bf063401d5..6ab8858b8a 100644 --- a/tests/integration/data/cfc/duplicate_label.cfc +++ b/tests/integration/data/cfc/duplicate_label.cfc @@ -1,120 +1,120 @@ - - - - - - - - -FUNCTION main : DINT -VAR - x: BOOL := FALSE; - a: DINT := 0; -END_VAR - - - - - - - - - - - - - x - - - - - - - - - - - - - - - - - - - - - - a - - - - - - - 2 - - - - - - - - a - - - - - - - a + 3 - - - - - - - TRUE - - - - - - - - x - - - - -
Set the jump to false, a should be 5 at the end
-
-
- - - -
This should not be skipped
-
-
- - - - - - - main - - - - - - - a - -
- -
+ + + + + + + + +FUNCTION main : DINT +VAR + x: BOOL := FALSE; + a: DINT := 0; +END_VAR + + + + + + + + + + + + + x + + + + + + + + + + + + + + + + + + + + + + a + + + + + + + 2 + + + + + + + + a + + + + + + + a + 3 + + + + + + + TRUE + + + + + + + + x + + + + +
Set the jump to false, a should be 5 at the end
+
+
+ + + +
This should not be skipped
+
+
+ + + + + + + main + + + + + + + a + +
+ +
diff --git a/tests/integration/data/cfc/function_block_call_fb.cfc b/tests/integration/data/cfc/function_block_call_fb.cfc index 1f43edea3f..7488bb7ab5 100644 --- a/tests/integration/data/cfc/function_block_call_fb.cfc +++ b/tests/integration/data/cfc/function_block_call_fb.cfc @@ -21,7 +21,7 @@ END_VAR VAR END_VAR - + diff --git a/tests/integration/data/cfc/function_block_call_main.cfc b/tests/integration/data/cfc/function_block_call_main.cfc index d5237e8ca8..224ca93c49 100644 --- a/tests/integration/data/cfc/function_block_call_main.cfc +++ b/tests/integration/data/cfc/function_block_call_main.cfc @@ -10,7 +10,7 @@ PROGRAM main VAR fb0 : myFb; END_VAR - + diff --git a/tests/integration/data/cfc/function_returns.cfc b/tests/integration/data/cfc/function_returns.cfc index c1e5eac1b2..403d04fd71 100644 --- a/tests/integration/data/cfc/function_returns.cfc +++ b/tests/integration/data/cfc/function_returns.cfc @@ -38,4 +38,4 @@ END_VAR - \ No newline at end of file + diff --git a/tests/integration/data/cfc/function_returns.st b/tests/integration/data/cfc/function_returns.st index b88418f09a..504dd23a79 100644 --- a/tests/integration/data/cfc/function_returns.st +++ b/tests/integration/data/cfc/function_returns.st @@ -1,3 +1,3 @@ FUNCTION main : DINT main := FuncyReturn(111); -END_FUNCTION \ No newline at end of file +END_FUNCTION diff --git a/tests/integration/data/cfc/jump_false.cfc b/tests/integration/data/cfc/jump_false.cfc index ad357ced66..6261c80f46 100644 --- a/tests/integration/data/cfc/jump_false.cfc +++ b/tests/integration/data/cfc/jump_false.cfc @@ -1,117 +1,117 @@ - - - - - - - - -FUNCTION main : DINT -VAR - x: BOOL := FALSE; - a: DINT := 0; -END_VAR - - - - - - - - - - - - - x - - - - - - - - - - - - - - - - - - - - - a - - - - - - - 2 - - - - - - - - a - - - - - - - a + 3 - - - - - - - FALSE - - - - - - - - x - - - - -
Set the jump to false, a should be 5 at the end
-
-
- - - -
This should not be skipped
-
-
- - - - - - - main - - - - - - - a - -
- -
+ + + + + + + + +FUNCTION main : DINT +VAR + x: BOOL := FALSE; + a: DINT := 0; +END_VAR + + + + + + + + + + + + + x + + + + + + + + + + + + + + + + + + + + + a + + + + + + + 2 + + + + + + + + a + + + + + + + a + 3 + + + + + + + FALSE + + + + + + + + x + + + + +
Set the jump to false, a should be 5 at the end
+
+
+ + + +
This should not be skipped
+
+
+ + + + + + + main + + + + + + + a + +
+ +
diff --git a/tests/integration/data/cfc/jump_missing_label.cfc b/tests/integration/data/cfc/jump_missing_label.cfc index ccbbd5a731..ceb58d46a5 100644 --- a/tests/integration/data/cfc/jump_missing_label.cfc +++ b/tests/integration/data/cfc/jump_missing_label.cfc @@ -1,117 +1,117 @@ - - - - - - - - -FUNCTION main : DINT -VAR - x: BOOL := FALSE; - a: DINT := 0; -END_VAR - - - - - - - - - - - - - x - - - - - - - - - - - - - - - - - - - - - a - - - - - - - 2 - - - - - - - - a - - - - - - - a + 3 - - - - - - - TRUE - - - - - - - - x - - - - -
Set the jump to false, a should be 5 at the end
-
-
- - - -
This should not be skipped
-
-
- - - - - - - main - - - - - - - a - -
- -
+ + + + + + + + +FUNCTION main : DINT +VAR + x: BOOL := FALSE; + a: DINT := 0; +END_VAR + + + + + + + + + + + + + x + + + + + + + + + + + + + + + + + + + + + a + + + + + + + 2 + + + + + + + + a + + + + + + + a + 3 + + + + + + + TRUE + + + + + + + + x + + + + +
Set the jump to false, a should be 5 at the end
+
+
+ + + +
This should not be skipped
+
+
+ + + + + + + main + + + + + + + a + +
+ +
diff --git a/tests/integration/data/cfc/jump_no_label.cfc b/tests/integration/data/cfc/jump_no_label.cfc index 32c3838fb6..5b401f61d2 100644 --- a/tests/integration/data/cfc/jump_no_label.cfc +++ b/tests/integration/data/cfc/jump_no_label.cfc @@ -1,114 +1,114 @@ - - - - - - - - -FUNCTION main : DINT + + + + + + + + +FUNCTION main : DINT VAR - x: BOOL := FALSE; - a: DINT := 0; -END_VAR - - - - - - - - - - - - - x - - - - - - - - - - - - - - - - - - - - a - - - - - - - 2 - - - - - - - - a - - - - - - - 3 - - - - - - - TRUE - - - - - - - - x - - - - -
Set the jump to false, a should be 5 at the end
-
-
- - - -
This should not be skipped
-
-
- - - - - - - main - - - - - - - a - -
- -
+ x: BOOL := FALSE; + a: DINT := 0; +END_VAR +
+
+
+
+
+ + + + + + + + x + + + + + + + + + + + + + + + + + + + + a + + + + + + + 2 + + + + + + + + a + + + + + + + 3 + + + + + + + TRUE + + + + + + + + x + + + + +
Set the jump to false, a should be 5 at the end
+
+
+ + + +
This should not be skipped
+
+
+ + + + + + + main + + + + + + + a + +
+ +
diff --git a/tests/integration/data/cfc/jump_true.cfc b/tests/integration/data/cfc/jump_true.cfc index c3622bcad5..3a6f1e362c 100644 --- a/tests/integration/data/cfc/jump_true.cfc +++ b/tests/integration/data/cfc/jump_true.cfc @@ -1,117 +1,117 @@ - - - - - - - - -FUNCTION main : DINT -VAR - x: BOOL := FALSE; - a: DINT := 0; -END_VAR - - - - - - - - - - - - - x - - - - - - - - - - - - - - - - - - - - - a - - - - - - - 2 - - - - - - - - a - - - - - - - a + 3 - - - - - - - TRUE - - - - - - - - x - - - - -
Set the jump to false, a should be 5 at the end
-
-
- - - -
This should not be skipped
-
-
- - - - - - - main - - - - - - - a - -
- -
+ + + + + + + + +FUNCTION main : DINT +VAR + x: BOOL := FALSE; + a: DINT := 0; +END_VAR + + + + + + + + + + + + + x + + + + + + + + + + + + + + + + + + + + + a + + + + + + + 2 + + + + + + + + a + + + + + + + a + 3 + + + + + + + TRUE + + + + + + + + x + + + + +
Set the jump to false, a should be 5 at the end
+
+
+ + + +
This should not be skipped
+
+
+ + + + + + + main + + + + + + + a + +
+ +
diff --git a/tests/integration/data/cfc/multi_labels.cfc b/tests/integration/data/cfc/multi_labels.cfc index 74baa8c040..b07705ea55 100644 --- a/tests/integration/data/cfc/multi_labels.cfc +++ b/tests/integration/data/cfc/multi_labels.cfc @@ -1,120 +1,120 @@ - - - - - - - - -FUNCTION main : DINT -VAR - x: BOOL := FALSE; - a: DINT := 0; -END_VAR - - - - - - - - - - - - - x - - - - - - - - - - - - - - - - - - - - - - a - - - - - - - 2 - - - - - - - - a - - - - - - - a + 3 - - - - - - - TRUE - - - - - - - - x - - - - -
Set the jump to false, a should be 5 at the end
-
-
- - - -
This should not be skipped
-
-
- - - - - - - main - - - - - - - a - -
- -
+ + + + + + + + +FUNCTION main : DINT +VAR + x: BOOL := FALSE; + a: DINT := 0; +END_VAR + + + + + + + + + + + + + x + + + + + + + + + + + + + + + + + + + + + + a + + + + + + + 2 + + + + + + + + a + + + + + + + a + 3 + + + + + + + TRUE + + + + + + + + x + + + + +
Set the jump to false, a should be 5 at the end
+
+
+ + + +
This should not be skipped
+
+
+ + + + + + + main + + + + + + + a + +
+ +
diff --git a/tests/integration/data/cfc/my_add.cfc b/tests/integration/data/cfc/my_add.cfc index f9fcb55ca2..50d33f827c 100644 --- a/tests/integration/data/cfc/my_add.cfc +++ b/tests/integration/data/cfc/my_add.cfc @@ -8,7 +8,7 @@ FUNCTION_BLOCK myAdder VAR - x, y: DINT; + x, y: DINT; END_VAR VAR_OUTPUT @@ -18,7 +18,7 @@ END_VAR VAR END_VAR - + diff --git a/tests/integration/data/cfc/my_add.st b/tests/integration/data/cfc/my_add.st index ebd7360332..e6b159c6bf 100644 --- a/tests/integration/data/cfc/my_add.st +++ b/tests/integration/data/cfc/my_add.st @@ -14,7 +14,7 @@ END_PROGRAM FUNCTION myAdd : DINT VAR_INPUT - a, b : DINT; + a, b : DINT; END_VAR myAdd := a + b; -END_FUNCTION \ No newline at end of file +END_FUNCTION diff --git a/tests/integration/data/cfc/select.cfc b/tests/integration/data/cfc/select.cfc index bbb6ce3f9e..544082399f 100644 --- a/tests/integration/data/cfc/select.cfc +++ b/tests/integration/data/cfc/select.cfc @@ -9,12 +9,12 @@ FUNCTION_BLOCK select VAR_INPUT - a, b : DINT; + a, b : DINT; END_VAR VAR - selected: DINT; + selected: DINT; END_VAR - + diff --git a/tests/integration/data/cfc/select.st b/tests/integration/data/cfc/select.st index 8df01a4db6..a1c4364a7f 100644 --- a/tests/integration/data/cfc/select.st +++ b/tests/integration/data/cfc/select.st @@ -8,4 +8,4 @@ END_VAR selector(x, y); // expecting y main := selector.selected; -END_PROGRAM \ No newline at end of file +END_PROGRAM diff --git a/tests/integration/data/cfc/variable_assignment.cfc b/tests/integration/data/cfc/variable_assignment.cfc index 9d0a394e68..e3316beb05 100644 --- a/tests/integration/data/cfc/variable_assignment.cfc +++ b/tests/integration/data/cfc/variable_assignment.cfc @@ -34,4 +34,4 @@ END_VAR - \ No newline at end of file + diff --git a/tests/integration/data/cfc/variable_assignment.st b/tests/integration/data/cfc/variable_assignment.st index 99a9d9175a..5e7393372c 100644 --- a/tests/integration/data/cfc/variable_assignment.st +++ b/tests/integration/data/cfc/variable_assignment.st @@ -9,4 +9,4 @@ END_VAR assign(); // b := a main := assign.b; -END_FUNCTION \ No newline at end of file +END_FUNCTION diff --git a/tests/integration/data/command_line.st b/tests/integration/data/command_line.st index 0eb2a1dbca..469acbf435 100644 --- a/tests/integration/data/command_line.st +++ b/tests/integration/data/command_line.st @@ -1,5 +1,5 @@ FUNCTION myFunc : DINT VAR_INPUT - a,b,c : DINT; + a,b,c : DINT; END_VAR END_FUNCTION diff --git a/tests/integration/data/io.st b/tests/integration/data/io.st index 83f9f5e496..17bb8ee574 100644 --- a/tests/integration/data/io.st +++ b/tests/integration/data/io.st @@ -1,6 +1,6 @@ PROGRAM a VAR - binvar AT %IX7.8 : BOOL; + binvar AT %IX7.8 : BOOL; sinvar AT %IB4.8 : BYTE; winvar AT %IW3.1 : WORD; dinvar AT %ID1.7 : DWORD; diff --git a/tests/integration/data/json/build_cc_linker.json b/tests/integration/data/json/build_cc_linker.json index 17af4a4fd0..f1310a4908 100644 --- a/tests/integration/data/json/build_cc_linker.json +++ b/tests/integration/data/json/build_cc_linker.json @@ -4,4 +4,4 @@ "simple_program.st" ], "compile_type": "Shared" -} \ No newline at end of file +} diff --git a/tests/integration/data/json/build_clang_windows.json b/tests/integration/data/json/build_clang_windows.json index d45121baea..327163c390 100644 --- a/tests/integration/data/json/build_clang_windows.json +++ b/tests/integration/data/json/build_clang_windows.json @@ -14,4 +14,4 @@ ] } ] -} \ No newline at end of file +} diff --git a/tests/integration/data/json/build_to_temp.json b/tests/integration/data/json/build_to_temp.json index 5907686b2b..53e390dca6 100644 --- a/tests/integration/data/json/build_to_temp.json +++ b/tests/integration/data/json/build_to_temp.json @@ -23,4 +23,4 @@ } ], "output": "proj.so" -} \ No newline at end of file +} diff --git a/tests/integration/data/json/build_without_sysroot.json b/tests/integration/data/json/build_without_sysroot.json index 492c9dfd5b..a2f2dc9f38 100644 --- a/tests/integration/data/json/build_without_sysroot.json +++ b/tests/integration/data/json/build_without_sysroot.json @@ -5,4 +5,4 @@ ], "compile_type": "Shared", "output": "proj.so" -} \ No newline at end of file +} diff --git a/tests/integration/data/json/multi_target_and_sysroot.json b/tests/integration/data/json/multi_target_and_sysroot.json index 492c9dfd5b..a2f2dc9f38 100644 --- a/tests/integration/data/json/multi_target_and_sysroot.json +++ b/tests/integration/data/json/multi_target_and_sysroot.json @@ -5,4 +5,4 @@ ], "compile_type": "Shared", "output": "proj.so" -} \ No newline at end of file +} diff --git a/tests/integration/data/json/separate_build_and_lib.json b/tests/integration/data/json/separate_build_and_lib.json index 03713a4236..6e59d2076c 100644 --- a/tests/integration/data/json/separate_build_and_lib.json +++ b/tests/integration/data/json/separate_build_and_lib.json @@ -23,4 +23,4 @@ } ], "output": "proj.so" -} \ No newline at end of file +} diff --git a/tests/integration/data/json/simple_program.st b/tests/integration/data/json/simple_program.st index 3f89442478..4d45f7e3f6 100644 --- a/tests/integration/data/json/simple_program.st +++ b/tests/integration/data/json/simple_program.st @@ -1,8 +1,8 @@ PROGRAM prg VAR - a : INT; - b : REAL; + a : INT; + b : REAL; END_VAR - b := 1.5; - a := b; + b := 1.5; + a := b; END_PROGRAM diff --git a/tests/integration/data/linking/consts.st b/tests/integration/data/linking/consts.st index 362fc47864..17e9c05522 100644 --- a/tests/integration/data/linking/consts.st +++ b/tests/integration/data/linking/consts.st @@ -1,4 +1,3 @@ VAR_GLOBAL CONSTANT - myValue : BOOL := TRUE; + myValue : BOOL := TRUE; END_VAR - diff --git a/tests/integration/data/linking/file1.st b/tests/integration/data/linking/file1.st index b0b2e2c902..32cc235445 100644 --- a/tests/integration/data/linking/file1.st +++ b/tests/integration/data/linking/file1.st @@ -3,6 +3,5 @@ FUNCTION func2 : DINT END_FUNCTION FUNCTION func1 : DINT - func2(); + func2(); END_FUNCTION - diff --git a/tests/integration/data/linking/file2.st b/tests/integration/data/linking/file2.st index 583792532f..ddd53a4647 100644 --- a/tests/integration/data/linking/file2.st +++ b/tests/integration/data/linking/file2.st @@ -3,6 +3,5 @@ FUNCTION func1 : DINT END_FUNCTION FUNCTION func2 : DINT - func1(); + func1(); END_FUNCTION - diff --git a/tests/integration/data/linking/folder1/vars.st b/tests/integration/data/linking/folder1/vars.st index 362fc47864..17e9c05522 100644 --- a/tests/integration/data/linking/folder1/vars.st +++ b/tests/integration/data/linking/folder1/vars.st @@ -1,4 +1,3 @@ VAR_GLOBAL CONSTANT - myValue : BOOL := TRUE; + myValue : BOOL := TRUE; END_VAR - diff --git a/tests/integration/data/linking/folder2/vars.st b/tests/integration/data/linking/folder2/vars.st index 06ca4f07f0..2850c62564 100644 --- a/tests/integration/data/linking/folder2/vars.st +++ b/tests/integration/data/linking/folder2/vars.st @@ -1,4 +1,3 @@ VAR_GLOBAL CONSTANT - myValue2 : BOOL := TRUE; + myValue2 : BOOL := TRUE; END_VAR - diff --git a/tests/integration/data/linking/init.st b/tests/integration/data/linking/init.st index e7ba69f434..7308791155 100644 --- a/tests/integration/data/linking/init.st +++ b/tests/integration/data/linking/init.st @@ -1,5 +1,5 @@ -TYPE myStruct : STRUCT - a : INT := 5; - b : DINT := 6; +TYPE myStruct : STRUCT + a : INT := 5; + b : DINT := 6; END_STRUCT END_TYPE diff --git a/tests/integration/data/linking/init2.st b/tests/integration/data/linking/init2.st index 584d322a3a..8fac7f64df 100644 --- a/tests/integration/data/linking/init2.st +++ b/tests/integration/data/linking/init2.st @@ -1,5 +1,5 @@ FUNCTION_BLOCK myFB - VAR - myS : myStruct := (a := 2); - END_VAR + VAR + myS : myStruct := (a := 2); + END_VAR END_FUNCTION_BLOCK diff --git a/tests/integration/data/linking/init3.st b/tests/integration/data/linking/init3.st index 5f339743eb..d1fb1ce4a6 100644 --- a/tests/integration/data/linking/init3.st +++ b/tests/integration/data/linking/init3.st @@ -1,5 +1,5 @@ FUNCTION_BLOCK myFb2 - VAR - fb : myFb; - END_VAR + VAR + fb : myFb; + END_VAR END_FUNCTION_BLOCK diff --git a/tests/integration/data/multi/concat_date.st b/tests/integration/data/multi/concat_date.st index dc85ca0107..d939a626fd 100644 --- a/tests/integration/data/multi/concat_date.st +++ b/tests/integration/data/multi/concat_date.st @@ -1,8 +1,8 @@ {external} FUNCTION CONCAT_DATE : DATE VAR_INPUT - year : T; - month : T; - day : T; + year : T; + month : T; + day : T; END_VAR -END_FUNCTION \ No newline at end of file +END_FUNCTION diff --git a/tests/integration/data/multi/concat_date_prg1.st b/tests/integration/data/multi/concat_date_prg1.st index 74957761a0..407cbb441e 100644 --- a/tests/integration/data/multi/concat_date_prg1.st +++ b/tests/integration/data/multi/concat_date_prg1.st @@ -1,3 +1,3 @@ FUNCTION foo1 : LINT foo1 := CONCAT_DATE(INT#1, SINT#2, SINT#3); -END_FUNCTION \ No newline at end of file +END_FUNCTION diff --git a/tests/integration/data/multi/concat_date_prg2.st b/tests/integration/data/multi/concat_date_prg2.st index cd636909d5..9827a155f9 100644 --- a/tests/integration/data/multi/concat_date_prg2.st +++ b/tests/integration/data/multi/concat_date_prg2.st @@ -1,3 +1,3 @@ FUNCTION foo2 : LINT foo2 := CONCAT_DATE(INT#4, SINT#5, SINT#6); -END_FUNCTION \ No newline at end of file +END_FUNCTION diff --git a/tests/integration/data/multi/prog.st b/tests/integration/data/multi/prog.st index 50572fe223..cafd17dc7d 100644 --- a/tests/integration/data/multi/prog.st +++ b/tests/integration/data/multi/prog.st @@ -1,6 +1,6 @@ PROGRAM mainProg VAR - a: DINT := 0; + a: DINT := 0; END_VAR a := 42; END_PROGRAM diff --git a/xtask/.gitignore b/xtask/.gitignore index 5f32e705c4..14ee5009d7 100644 --- a/xtask/.gitignore +++ b/xtask/.gitignore @@ -1,2 +1,2 @@ target/ -.env \ No newline at end of file +.env diff --git a/xtask/README.md b/xtask/README.md index 0716eac56b..c7d2524f60 100644 --- a/xtask/README.md +++ b/xtask/README.md @@ -9,4 +9,4 @@ This directory contains the following [xtasks](https://github.com/matklad/cargo-
-
\ No newline at end of file + diff --git a/xtask/migrations/20230620132156_benchmarks.sql b/xtask/migrations/20230620132156_benchmarks.sql index 132f8b75cb..c5c5de0bd1 100644 --- a/xtask/migrations/20230620132156_benchmarks.sql +++ b/xtask/migrations/20230620132156_benchmarks.sql @@ -16,10 +16,10 @@ CREATE TABLE Report( ); CREATE TABLE Metric ( - id SERIAL, - name TEXT NOT NULL, - `time` BIGINT UNSIGNED NOT NULL, + id SERIAL, + name TEXT NOT NULL, + `time` BIGINT UNSIGNED NOT NULL, report_id BIGINT UNSIGNED NOT NULL, - CONSTRAINT Metric_pk PRIMARY KEY (id), - CONSTRAINT Metric_FK FOREIGN KEY (report_id) REFERENCES Report(id) ON DELETE CASCADE ON UPDATE CASCADE -); \ No newline at end of file + CONSTRAINT Metric_pk PRIMARY KEY (id), + CONSTRAINT Metric_FK FOREIGN KEY (report_id) REFERENCES Report(id) ON DELETE CASCADE ON UPDATE CASCADE +); diff --git a/xtask/res/ARCH.drawio b/xtask/res/ARCH.drawio index e6d511a221..95083510fe 100644 --- a/xtask/res/ARCH.drawio +++ b/xtask/res/ARCH.drawio @@ -1 +1 @@ -3VhNT+MwEP01kXYPVPls02MpBQ6gRRQJcUJO4iYG145sp1+/fu3ESRrSlrJQWvZU+2U8tt/MPI9qOMPp4oqBNLmlEcSGbUYLw7kwbNsyXV/+KGRZIJ5nFUDMUKSNamCMVrBcqdEMRZA3DAWlWKC0CYaUEBiKBgYYo/Om2YTi5q4piGELGIcAt9FHFImkQH27V+PXEMVJubPV7RdfpqA01jfhCYjofA1yRoYzZJSKYjRdDCFW5JW8FOsut3ytDsYgEfsseGCr0bh38fT8FN0nj6tZL3gYnDmFlxnAmb6wPqxYlgzASBKip5SJhMaUADyq0XNGMxJBtY0pZ7XNDaWpBC0JvkAhljq6IBNUQomYYv212FNttPVuGuI0YyHccaEyRwCLodhhZ1cRkKkL6RQKtpTrGMRAoFnzHEDnUFzZ1TTLgWb6A6yXyb1G+wNDcQwZ30j/DQhkWTUoAxjFRI5DyRBkEphBJpDM24H+MEVRVEQHcrQCQe5PxSeliIj8Rt654V1U9CsHcGFsKCq9uE7l9cBsT6s2u9q72bHdwtGysd3e5GvPd+omtduKVu31rN/0QCcTLnPibfCq830inq1w3mU8yaUqVwKuQvQ2sHXVqHjOEyTgOAV5cs+llm6qkA0hatXIVtb9Jjt2T8/ntaxZZYCTNUnzzANVgffDpcbeU2rco0pNOzfvM/KfyIz3jsyYVrd3CKHpHktneifxXEMSDVRrJaeEElggl0jdJXd5hBrbIn3fU2N2Kyq30i8KZZWZj5S9TrDkyu5ieYHzQD4E3ViNfl0hcZ0F0mYQCkTJ76O/EKf3RLgtZkOZCepRXQjAX9XjWjJ9ZO7ck+Ou/8OfV3fP0vc/WfqbNd42m/H0fLfpoji/XnUAqW+LypBiLJ9JpSoigfkVeYbV/K20ABKpk6ap1GVlTolqRLtgqvKeBDytIvXTO4D+zqI8ky1At2wB/jUhyoL+rkfebwVea1znhVPSChtPQKqG4RIjWbvMeV/ugqLKb4IKAOFrnNf+n0xIN1DjvChzy/sijez7nZ7XKCvHb8ukb3e8tk5a1qGE0jqKUq41USEGnKOw0Ufl9EvtE22jHF4z+0LNtfxvEt3PBaxdIpdMahzMZW9Xp3UHYnh6fZZrVRn/Xrfgeh/m1FDklH8yFiJV/1XrjP4C \ No newline at end of file +3VhNT+MwEP01kXYPVPls02MpBQ6gRRQJcUJO4iYG145sp1+/fu3ESRrSlrJQWvZU+2U8tt/MPI9qOMPp4oqBNLmlEcSGbUYLw7kwbNsyXV/+KGRZIJ5nFUDMUKSNamCMVrBcqdEMRZA3DAWlWKC0CYaUEBiKBgYYo/Om2YTi5q4piGELGIcAt9FHFImkQH27V+PXEMVJubPV7RdfpqA01jfhCYjofA1yRoYzZJSKYjRdDCFW5JW8FOsut3ytDsYgEfsseGCr0bh38fT8FN0nj6tZL3gYnDmFlxnAmb6wPqxYlgzASBKip5SJhMaUADyq0XNGMxJBtY0pZ7XNDaWpBC0JvkAhljq6IBNUQomYYv212FNttPVuGuI0YyHccaEyRwCLodhhZ1cRkKkL6RQKtpTrGMRAoFnzHEDnUFzZ1TTLgWb6A6yXyb1G+wNDcQwZ30j/DQhkWTUoAxjFRI5DyRBkEphBJpDM24H+MEVRVEQHcrQCQe5PxSeliIj8Rt654V1U9CsHcGFsKCq9uE7l9cBsT6s2u9q72bHdwtGysd3e5GvPd+omtduKVu31rN/0QCcTLnPibfCq830inq1w3mU8yaUqVwKuQvQ2sHXVqHjOEyTgOAV5cs+llm6qkA0hatXIVtb9Jjt2T8/ntaxZZYCTNUnzzANVgffDpcbeU2rco0pNOzfvM/KfyIz3jsyYVrd3CKHpHktneifxXEMSDVRrJaeEElggl0jdJXd5hBrbIn3fU2N2Kyq30i8KZZWZj5S9TrDkyu5ieYHzQD4E3ViNfl0hcZ0F0mYQCkTJ76O/EKf3RLgtZkOZCepRXQjAX9XjWjJ9ZO7ck+Ou/8OfV3fP0vc/WfqbNd42m/H0fLfpoji/XnUAqW+LypBiLJ9JpSoigfkVeYbV/K20ABKpk6ap1GVlTolqRLtgqvKeBDytIvXTO4D+zqI8ky1At2wB/jUhyoL+rkfebwVea1znhVPSChtPQKqG4RIjWbvMeV/ugqLKb4IKAOFrnNf+n0xIN1DjvChzy/sijez7nZ7XKCvHb8ukb3e8tk5a1qGE0jqKUq41USEGnKOw0Ufl9EvtE22jHF4z+0LNtfxvEt3PBaxdIpdMahzMZW9Xp3UHYnh6fZZrVRn/Xrfgeh/m1FDklH8yFiJV/1XrjP4C diff --git a/xtask/res/ARCH.svg b/xtask/res/ARCH.svg index 95cd93475b..6573a5358f 100644 --- a/xtask/res/ARCH.svg +++ b/xtask/res/ARCH.svg @@ -1,4 +1,4 @@ -
Triggers
Triggers
Push to master
Push to master
Runs
Runs
Metrics Workflow
(GitHub Action)
Metrics Workflow...
cargo xtask metrics
cargo xtask metrics
Collects the results
and appends onto 
Collects the results...
metrics.json
metrics.json
Frontend
(GitHub Page)
Frontend...
Text is not SVG - cannot display
\ No newline at end of file +
Triggers
Triggers
Push to master
Push to master
Runs
Runs
Metrics Workflow
(GitHub Action)
Metrics Workflow...
cargo xtask metrics
cargo xtask metrics
Collects the results
and appends onto 
Collects the results...
metrics.json
metrics.json
Frontend
(GitHub Page)
Frontend...
Text is not SVG - cannot display
diff --git a/xtask/res/combined.st b/xtask/res/combined.st index 146c26124b..697875f6b6 100644 --- a/xtask/res/combined.st +++ b/xtask/res/combined.st @@ -6,8 +6,8 @@ {external} FUNCTION CONCAT_DATE_TOD : DT VAR_INPUT - date_input : DATE; - tod_input : TOD; + date_input : DATE; + tod_input : TOD; END_VAR END_FUNCTION @@ -18,10 +18,10 @@ END_FUNCTION ******************** *) FUNCTION CONCAT_DATE_LTOD : DT VAR_INPUT - date_input : DATE; - tod_input : LTOD; + date_input : DATE; + tod_input : LTOD; END_VAR - CONCAT_DATE_LTOD := CONCAT_DATE_TOD(date_input, tod_input); + CONCAT_DATE_LTOD := CONCAT_DATE_TOD(date_input, tod_input); END_FUNCTION (******************** @@ -32,9 +32,9 @@ END_FUNCTION {external} FUNCTION CONCAT_DATE < T : ANY_INT > : DATE VAR_INPUT - year : T; - month : T; - day : T; + year : T; + month : T; + day : T; END_VAR END_FUNCTION @@ -46,10 +46,10 @@ END_FUNCTION {external} FUNCTION CONCAT_TOD < T : ANY_INT > : TOD VAR_INPUT - hour : T; - minute : T; - second : T; - millisecond : T; + hour : T; + minute : T; + second : T; + millisecond : T; END_VAR END_FUNCTION @@ -60,99 +60,99 @@ END_FUNCTION ******************** *) FUNCTION CONCAT_LTOD < T : ANY_INT > : LTOD VAR_INPUT - hour : T; - minute : T; - second : T; - millisecond : T; + hour : T; + minute : T; + second : T; + millisecond : T; END_VAR END_FUNCTION (* Specialized implementation of CONCAT_LTOD for SINT *) FUNCTION CONCAT_LTOD__SINT : LTOD VAR_INPUT - hour : SINT; - minute : SINT; - second : SINT; - millisecond : SINT; + hour : SINT; + minute : SINT; + second : SINT; + millisecond : SINT; END_VAR - CONCAT_LTOD__SINT := CONCAT_TOD(hour, minute, second, millisecond); + CONCAT_LTOD__SINT := CONCAT_TOD(hour, minute, second, millisecond); END_FUNCTION (* Specialized implementation of CONCAT_LTOD for USINT *) FUNCTION CONCAT_LTOD__USINT : LTOD VAR_INPUT - hour : USINT; - minute : USINT; - second : USINT; - millisecond : USINT; + hour : USINT; + minute : USINT; + second : USINT; + millisecond : USINT; END_VAR - CONCAT_LTOD__USINT := CONCAT_TOD(hour, minute, second, millisecond); + CONCAT_LTOD__USINT := CONCAT_TOD(hour, minute, second, millisecond); END_FUNCTION (* Specialized implementation of CONCAT_LTOD for INT *) FUNCTION CONCAT_LTOD__INT : LTOD VAR_INPUT - hour : INT; - minute : INT; - second : INT; - millisecond : INT; + hour : INT; + minute : INT; + second : INT; + millisecond : INT; END_VAR - CONCAT_LTOD__INT := CONCAT_TOD(hour, minute, second, millisecond); + CONCAT_LTOD__INT := CONCAT_TOD(hour, minute, second, millisecond); END_FUNCTION (* Specialized implementation of CONCAT_LTOD for UINT *) FUNCTION CONCAT_LTOD__UINT : LTOD VAR_INPUT - hour : UINT; - minute : UINT; - second : UINT; - millisecond : UINT; + hour : UINT; + minute : UINT; + second : UINT; + millisecond : UINT; END_VAR - CONCAT_LTOD__UINT := CONCAT_TOD(hour, minute, second, millisecond); + CONCAT_LTOD__UINT := CONCAT_TOD(hour, minute, second, millisecond); END_FUNCTION (* Specialized implementation of CONCAT_LTOD for DINT *) FUNCTION CONCAT_LTOD__DINT : LTOD VAR_INPUT - hour : DINT; - minute : DINT; - second : DINT; - millisecond : DINT; + hour : DINT; + minute : DINT; + second : DINT; + millisecond : DINT; END_VAR - CONCAT_LTOD__DINT := CONCAT_TOD(hour, minute, second, millisecond); + CONCAT_LTOD__DINT := CONCAT_TOD(hour, minute, second, millisecond); END_FUNCTION (* Specialized implementation of CONCAT_LTOD for UDINT *) FUNCTION CONCAT_LTOD__UDINT : LTOD VAR_INPUT - hour : UDINT; - minute : UDINT; - second : UDINT; - millisecond : UDINT; + hour : UDINT; + minute : UDINT; + second : UDINT; + millisecond : UDINT; END_VAR - CONCAT_LTOD__UDINT := CONCAT_TOD(hour, minute, second, millisecond); + CONCAT_LTOD__UDINT := CONCAT_TOD(hour, minute, second, millisecond); END_FUNCTION (* Specialized implementation of CONCAT_LTOD for LINT *) FUNCTION CONCAT_LTOD__LINT : LTOD VAR_INPUT - hour : LINT; - minute : LINT; - second : LINT; - millisecond : LINT; + hour : LINT; + minute : LINT; + second : LINT; + millisecond : LINT; END_VAR - CONCAT_LTOD__LINT := CONCAT_TOD(hour, minute, second, millisecond); + CONCAT_LTOD__LINT := CONCAT_TOD(hour, minute, second, millisecond); END_FUNCTION (* Specialized implementation of CONCAT_LTOD for ULINT *) FUNCTION CONCAT_LTOD__ULINT : LTOD VAR_INPUT - hour : ULINT; - minute : ULINT; - second : ULINT; - millisecond : ULINT; + hour : ULINT; + minute : ULINT; + second : ULINT; + millisecond : ULINT; END_VAR - CONCAT_LTOD__ULINT := CONCAT_TOD(hour, minute, second, millisecond); + CONCAT_LTOD__ULINT := CONCAT_TOD(hour, minute, second, millisecond); END_FUNCTION (******************** @@ -162,98 +162,98 @@ END_FUNCTION ******************** *) FUNCTION CONCAT_DT < T : ANY_INT > : DT VAR_INPUT - year : T; - month : T; - day : T; - hour : T; - minute : T; - second : T; - millisecond : T; + year : T; + month : T; + day : T; + hour : T; + minute : T; + second : T; + millisecond : T; END_VAR END_FUNCTION (* Specialized implementation of CONCAT_DT for INT *) FUNCTION CONCAT_DT__INT : DT VAR_INPUT - year : INT; - month : INT; - day : INT; - hour : INT; - minute : INT; - second : INT; - millisecond : INT; + year : INT; + month : INT; + day : INT; + hour : INT; + minute : INT; + second : INT; + millisecond : INT; END_VAR - CONCAT_DT__INT := CONCAT_DATE_TOD(CONCAT_DATE(year, month, day), CONCAT_TOD(hour, minute, second, millisecond)); + CONCAT_DT__INT := CONCAT_DATE_TOD(CONCAT_DATE(year, month, day), CONCAT_TOD(hour, minute, second, millisecond)); END_FUNCTION (* Specialized implementation of CONCAT_DT for UINT *) FUNCTION CONCAT_DT__UINT : DT VAR_INPUT - year : UINT; - month : UINT; - day : UINT; - hour : UINT; - minute : UINT; - second : UINT; - millisecond : UINT; + year : UINT; + month : UINT; + day : UINT; + hour : UINT; + minute : UINT; + second : UINT; + millisecond : UINT; END_VAR - CONCAT_DT__UINT := CONCAT_DATE_TOD(CONCAT_DATE(year, month, day), CONCAT_TOD(hour, minute, second, millisecond)); + CONCAT_DT__UINT := CONCAT_DATE_TOD(CONCAT_DATE(year, month, day), CONCAT_TOD(hour, minute, second, millisecond)); END_FUNCTION (* Specialized implementation of CONCAT_DT for DINT *) FUNCTION CONCAT_DT__DINT : DT VAR_INPUT - year : DINT; - month : DINT; - day : DINT; - hour : DINT; - minute : DINT; - second : DINT; - millisecond : DINT; + year : DINT; + month : DINT; + day : DINT; + hour : DINT; + minute : DINT; + second : DINT; + millisecond : DINT; END_VAR - CONCAT_DT__DINT := CONCAT_DATE_TOD(CONCAT_DATE(year, month, day), CONCAT_TOD(hour, minute, second, millisecond)); + CONCAT_DT__DINT := CONCAT_DATE_TOD(CONCAT_DATE(year, month, day), CONCAT_TOD(hour, minute, second, millisecond)); END_FUNCTION (* Specialized implementation of CONCAT_DT for UDINT *) FUNCTION CONCAT_DT__UDINT : DT VAR_INPUT - year : UDINT; - month : UDINT; - day : UDINT; - hour : UDINT; - minute : UDINT; - second : UDINT; - millisecond : UDINT; + year : UDINT; + month : UDINT; + day : UDINT; + hour : UDINT; + minute : UDINT; + second : UDINT; + millisecond : UDINT; END_VAR - CONCAT_DT__UDINT := CONCAT_DATE_TOD(CONCAT_DATE(year, month, day), CONCAT_TOD(hour, minute, second, millisecond)); + CONCAT_DT__UDINT := CONCAT_DATE_TOD(CONCAT_DATE(year, month, day), CONCAT_TOD(hour, minute, second, millisecond)); END_FUNCTION (* Specialized implementation of CONCAT_DT for LINT *) FUNCTION CONCAT_DT__LINT : DT VAR_INPUT - year : LINT; - month : LINT; - day : LINT; - hour : LINT; - minute : LINT; - second : LINT; - millisecond : LINT; + year : LINT; + month : LINT; + day : LINT; + hour : LINT; + minute : LINT; + second : LINT; + millisecond : LINT; END_VAR - CONCAT_DT__LINT := CONCAT_DATE_TOD(CONCAT_DATE(year, month, day), CONCAT_TOD(hour, minute, second, millisecond)); + CONCAT_DT__LINT := CONCAT_DATE_TOD(CONCAT_DATE(year, month, day), CONCAT_TOD(hour, minute, second, millisecond)); END_FUNCTION (* Specialized implementation of CONCAT_DT for ULINT *) FUNCTION CONCAT_DT__ULINT : DT VAR_INPUT - year : ULINT; - month : ULINT; - day : ULINT; - hour : ULINT; - minute : ULINT; - second : ULINT; - millisecond : ULINT; + year : ULINT; + month : ULINT; + day : ULINT; + hour : ULINT; + minute : ULINT; + second : ULINT; + millisecond : ULINT; END_VAR - CONCAT_DT__ULINT := CONCAT_DATE_TOD(CONCAT_DATE(year, month, day), CONCAT_TOD(hour, minute, second, millisecond)); + CONCAT_DT__ULINT := CONCAT_DATE_TOD(CONCAT_DATE(year, month, day), CONCAT_TOD(hour, minute, second, millisecond)); END_FUNCTION (******************** @@ -263,98 +263,98 @@ END_FUNCTION ******************** *) FUNCTION CONCAT_LDT < T : ANY_INT > : LDT VAR_INPUT - year : T; - month : T; - day : T; - hour : T; - minute : T; - second : T; - millisecond : T; + year : T; + month : T; + day : T; + hour : T; + minute : T; + second : T; + millisecond : T; END_VAR END_FUNCTION (* Specialized implementation of CONCAT_LDT for INT *) FUNCTION CONCAT_LDT__INT : LDT VAR_INPUT - year : INT; - month : INT; - day : INT; - hour : INT; - minute : INT; - second : INT; - millisecond : INT; + year : INT; + month : INT; + day : INT; + hour : INT; + minute : INT; + second : INT; + millisecond : INT; END_VAR - CONCAT_LDT__INT := CONCAT_DATE_LTOD(CONCAT_DATE(year, month, day), CONCAT_LTOD(hour, minute, second, millisecond)); + CONCAT_LDT__INT := CONCAT_DATE_LTOD(CONCAT_DATE(year, month, day), CONCAT_LTOD(hour, minute, second, millisecond)); END_FUNCTION (* Specialized implementation of CONCAT_LDT for UINT *) FUNCTION CONCAT_LDT__UINT : LDT VAR_INPUT - year : UINT; - month : UINT; - day : UINT; - hour : UINT; - minute : UINT; - second : UINT; - millisecond : UINT; + year : UINT; + month : UINT; + day : UINT; + hour : UINT; + minute : UINT; + second : UINT; + millisecond : UINT; END_VAR - CONCAT_LDT__UINT := CONCAT_DATE_LTOD(CONCAT_DATE(year, month, day), CONCAT_LTOD(hour, minute, second, millisecond)); + CONCAT_LDT__UINT := CONCAT_DATE_LTOD(CONCAT_DATE(year, month, day), CONCAT_LTOD(hour, minute, second, millisecond)); END_FUNCTION (* Specialized implementation of CONCAT_LDT for DINT *) FUNCTION CONCAT_LDT__DINT : LDT VAR_INPUT - year : DINT; - month : DINT; - day : DINT; - hour : DINT; - minute : DINT; - second : DINT; - millisecond : DINT; + year : DINT; + month : DINT; + day : DINT; + hour : DINT; + minute : DINT; + second : DINT; + millisecond : DINT; END_VAR - CONCAT_LDT__DINT := CONCAT_DATE_LTOD(CONCAT_DATE(year, month, day), CONCAT_LTOD(hour, minute, second, millisecond)); + CONCAT_LDT__DINT := CONCAT_DATE_LTOD(CONCAT_DATE(year, month, day), CONCAT_LTOD(hour, minute, second, millisecond)); END_FUNCTION (* Specialized implementation of CONCAT_LDT for UDINT *) FUNCTION CONCAT_LDT__UDINT : LDT VAR_INPUT - year : UDINT; - month : UDINT; - day : UDINT; - hour : UDINT; - minute : UDINT; - second : UDINT; - millisecond : UDINT; + year : UDINT; + month : UDINT; + day : UDINT; + hour : UDINT; + minute : UDINT; + second : UDINT; + millisecond : UDINT; END_VAR - CONCAT_LDT__UDINT := CONCAT_DATE_LTOD(CONCAT_DATE(year, month, day), CONCAT_LTOD(hour, minute, second, millisecond)); + CONCAT_LDT__UDINT := CONCAT_DATE_LTOD(CONCAT_DATE(year, month, day), CONCAT_LTOD(hour, minute, second, millisecond)); END_FUNCTION (* Specialized implementation of CONCAT_LDT for LINT *) FUNCTION CONCAT_LDT__LINT : LDT VAR_INPUT - year : LINT; - month : LINT; - day : LINT; - hour : LINT; - minute : LINT; - second : LINT; - millisecond : LINT; + year : LINT; + month : LINT; + day : LINT; + hour : LINT; + minute : LINT; + second : LINT; + millisecond : LINT; END_VAR - CONCAT_LDT__LINT := CONCAT_DATE_LTOD(CONCAT_DATE(year, month, day), CONCAT_LTOD(hour, minute, second, millisecond)); + CONCAT_LDT__LINT := CONCAT_DATE_LTOD(CONCAT_DATE(year, month, day), CONCAT_LTOD(hour, minute, second, millisecond)); END_FUNCTION (* Specialized implementation of CONCAT_LDT for ULINT *) FUNCTION CONCAT_LDT__ULINT : LDT VAR_INPUT - year : ULINT; - month : ULINT; - day : ULINT; - hour : ULINT; - minute : ULINT; - second : ULINT; - millisecond : ULINT; + year : ULINT; + month : ULINT; + day : ULINT; + hour : ULINT; + minute : ULINT; + second : ULINT; + millisecond : ULINT; END_VAR - CONCAT_LDT__ULINT := CONCAT_DATE_LTOD(CONCAT_DATE(year, month, day), CONCAT_LTOD(hour, minute, second, millisecond)); + CONCAT_LDT__ULINT := CONCAT_DATE_LTOD(CONCAT_DATE(year, month, day), CONCAT_LTOD(hour, minute, second, millisecond)); END_FUNCTION (******************** @@ -364,12 +364,12 @@ END_FUNCTION ******************** *) FUNCTION SPLIT_DATE < T : ANY_INT > : INT VAR_INPUT - in : DATE; + in : DATE; END_VAR VAR_OUTPUT - year : T; - month : T; - day : T; + year : T; + month : T; + day : T; END_VAR END_FUNCTION @@ -377,12 +377,12 @@ END_FUNCTION {external} FUNCTION SPLIT_DATE__INT : INT VAR_INPUT - in : DATE; + in : DATE; END_VAR VAR_OUTPUT - year : INT; - month : INT; - day : INT; + year : INT; + month : INT; + day : INT; END_VAR END_FUNCTION @@ -390,12 +390,12 @@ END_FUNCTION {external} FUNCTION SPLIT_DATE__UINT : INT VAR_INPUT - in : DATE; + in : DATE; END_VAR VAR_OUTPUT - year : UINT; - month : UINT; - day : UINT; + year : UINT; + month : UINT; + day : UINT; END_VAR END_FUNCTION @@ -403,12 +403,12 @@ END_FUNCTION {external} FUNCTION SPLIT_DATE__DINT : INT VAR_INPUT - in : DATE; + in : DATE; END_VAR VAR_OUTPUT - year : DINT; - month : DINT; - day : DINT; + year : DINT; + month : DINT; + day : DINT; END_VAR END_FUNCTION @@ -416,12 +416,12 @@ END_FUNCTION {external} FUNCTION SPLIT_DATE__UDINT : INT VAR_INPUT - in : DATE; + in : DATE; END_VAR VAR_OUTPUT - year : UDINT; - month : UDINT; - day : UDINT; + year : UDINT; + month : UDINT; + day : UDINT; END_VAR END_FUNCTION @@ -429,12 +429,12 @@ END_FUNCTION {external} FUNCTION SPLIT_DATE__LINT : INT VAR_INPUT - in : DATE; + in : DATE; END_VAR VAR_OUTPUT - year : LINT; - month : LINT; - day : LINT; + year : LINT; + month : LINT; + day : LINT; END_VAR END_FUNCTION @@ -442,12 +442,12 @@ END_FUNCTION {external} FUNCTION SPLIT_DATE__ULINT : INT VAR_INPUT - in : DATE; + in : DATE; END_VAR VAR_OUTPUT - year : ULINT; - month : ULINT; - day : ULINT; + year : ULINT; + month : ULINT; + day : ULINT; END_VAR END_FUNCTION @@ -458,13 +458,13 @@ END_FUNCTION ******************** *) FUNCTION SPLIT_TOD < T : ANY_INT > : INT VAR_INPUT - in : TOD; + in : TOD; END_VAR VAR_OUTPUT - hour : T; - minute : T; - second : T; - millisecond : T; + hour : T; + minute : T; + second : T; + millisecond : T; END_VAR END_FUNCTION @@ -472,13 +472,13 @@ END_FUNCTION {external} FUNCTION SPLIT_TOD__INT : INT VAR_INPUT - in : TOD; + in : TOD; END_VAR VAR_OUTPUT - hour : INT; - minute : INT; - second : INT; - millisecond : INT; + hour : INT; + minute : INT; + second : INT; + millisecond : INT; END_VAR END_FUNCTION @@ -486,13 +486,13 @@ END_FUNCTION {external} FUNCTION SPLIT_TOD__UINT : INT VAR_INPUT - in : TOD; + in : TOD; END_VAR VAR_OUTPUT - hour : UINT; - minute : UINT; - second : UINT; - millisecond : UINT; + hour : UINT; + minute : UINT; + second : UINT; + millisecond : UINT; END_VAR END_FUNCTION @@ -500,13 +500,13 @@ END_FUNCTION {external} FUNCTION SPLIT_TOD__DINT : INT VAR_INPUT - in : TOD; + in : TOD; END_VAR VAR_OUTPUT - hour : DINT; - minute : DINT; - second : DINT; - millisecond : DINT; + hour : DINT; + minute : DINT; + second : DINT; + millisecond : DINT; END_VAR END_FUNCTION @@ -514,13 +514,13 @@ END_FUNCTION {external} FUNCTION SPLIT_TOD__UDINT : INT VAR_INPUT - in : TOD; + in : TOD; END_VAR VAR_OUTPUT - hour : UDINT; - minute : UDINT; - second : UDINT; - millisecond : UDINT; + hour : UDINT; + minute : UDINT; + second : UDINT; + millisecond : UDINT; END_VAR END_FUNCTION @@ -528,13 +528,13 @@ END_FUNCTION {external} FUNCTION SPLIT_TOD__LINT : INT VAR_INPUT - in : TOD; + in : TOD; END_VAR VAR_OUTPUT - hour : LINT; - minute : LINT; - second : LINT; - millisecond : LINT; + hour : LINT; + minute : LINT; + second : LINT; + millisecond : LINT; END_VAR END_FUNCTION @@ -542,13 +542,13 @@ END_FUNCTION {external} FUNCTION SPLIT_TOD__ULINT : INT VAR_INPUT - in : TOD; + in : TOD; END_VAR VAR_OUTPUT - hour : ULINT; - minute : ULINT; - second : ULINT; - millisecond : ULINT; + hour : ULINT; + minute : ULINT; + second : ULINT; + millisecond : ULINT; END_VAR END_FUNCTION @@ -559,98 +559,98 @@ END_FUNCTION ******************** *) FUNCTION SPLIT_LTOD < T : ANY_INT > : INT VAR_INPUT - in : LTOD; + in : LTOD; END_VAR VAR_OUTPUT - hour : T; - minute : T; - second : T; - millisecond : T; + hour : T; + minute : T; + second : T; + millisecond : T; END_VAR END_FUNCTION (* Specialized implementation of SPLIT_LTOD for INT *) FUNCTION SPLIT_LTOD__INT : INT VAR_INPUT - in : LTOD; + in : LTOD; END_VAR VAR_OUTPUT - hour : INT; - minute : INT; - second : INT; - millisecond : INT; + hour : INT; + minute : INT; + second : INT; + millisecond : INT; END_VAR - SPLIT_LTOD__INT := SPLIT_TOD__INT(in, hour, minute, second, millisecond); + SPLIT_LTOD__INT := SPLIT_TOD__INT(in, hour, minute, second, millisecond); END_FUNCTION (* Specialized implementation of SPLIT_LTOD for UINT *) FUNCTION SPLIT_LTOD__UINT : INT VAR_INPUT - in : LTOD; + in : LTOD; END_VAR VAR_OUTPUT - hour : UINT; - minute : UINT; - second : UINT; - millisecond : UINT; + hour : UINT; + minute : UINT; + second : UINT; + millisecond : UINT; END_VAR - SPLIT_LTOD__UINT := SPLIT_TOD__UINT(in, hour, minute, second, millisecond); + SPLIT_LTOD__UINT := SPLIT_TOD__UINT(in, hour, minute, second, millisecond); END_FUNCTION (* Specialized implementation of SPLIT_LTOD for DINT *) FUNCTION SPLIT_LTOD__DINT : INT VAR_INPUT - in : LTOD; + in : LTOD; END_VAR VAR_OUTPUT - hour : DINT; - minute : DINT; - second : DINT; - millisecond : DINT; + hour : DINT; + minute : DINT; + second : DINT; + millisecond : DINT; END_VAR - SPLIT_LTOD__DINT := SPLIT_TOD__DINT(in, hour, minute, second, millisecond); + SPLIT_LTOD__DINT := SPLIT_TOD__DINT(in, hour, minute, second, millisecond); END_FUNCTION (* Specialized implementation of SPLIT_LTOD for UDINT *) FUNCTION SPLIT_LTOD__UDINT : INT VAR_INPUT - in : LTOD; + in : LTOD; END_VAR VAR_OUTPUT - hour : UDINT; - minute : UDINT; - second : UDINT; - millisecond : UDINT; + hour : UDINT; + minute : UDINT; + second : UDINT; + millisecond : UDINT; END_VAR - SPLIT_LTOD__UDINT := SPLIT_TOD__UDINT(in, hour, minute, second, millisecond); + SPLIT_LTOD__UDINT := SPLIT_TOD__UDINT(in, hour, minute, second, millisecond); END_FUNCTION (* Specialized implementation of SPLIT_LTOD for LINT *) FUNCTION SPLIT_LTOD__LINT : INT VAR_INPUT - in : LTOD; + in : LTOD; END_VAR VAR_OUTPUT - hour : LINT; - minute : LINT; - second : LINT; - millisecond : LINT; + hour : LINT; + minute : LINT; + second : LINT; + millisecond : LINT; END_VAR - SPLIT_LTOD__LINT := SPLIT_TOD__LINT(in, hour, minute, second, millisecond); + SPLIT_LTOD__LINT := SPLIT_TOD__LINT(in, hour, minute, second, millisecond); END_FUNCTION (* Specialized implementation of SPLIT_LTOD for ULINT *) FUNCTION SPLIT_LTOD__ULINT : INT VAR_INPUT - in : LTOD; + in : LTOD; END_VAR VAR_OUTPUT - hour : ULINT; - minute : ULINT; - second : ULINT; - millisecond : ULINT; + hour : ULINT; + minute : ULINT; + second : ULINT; + millisecond : ULINT; END_VAR - SPLIT_LTOD__ULINT := SPLIT_TOD__ULINT(in, hour, minute, second, millisecond); + SPLIT_LTOD__ULINT := SPLIT_TOD__ULINT(in, hour, minute, second, millisecond); END_FUNCTION (******************** @@ -660,16 +660,16 @@ END_FUNCTION ******************** *) FUNCTION SPLIT_DT < T : ANY_INT > : INT VAR_INPUT - in : DT; + in : DT; END_VAR VAR_OUTPUT - year : T; - month : T; - day : T; - hour : T; - minute : T; - second : T; - millisecond : T; + year : T; + month : T; + day : T; + hour : T; + minute : T; + second : T; + millisecond : T; END_VAR END_FUNCTION @@ -677,16 +677,16 @@ END_FUNCTION {external} FUNCTION SPLIT_DT__INT : INT VAR_INPUT - in : DT; + in : DT; END_VAR VAR_OUTPUT - year : INT; - month : INT; - day : INT; - hour : INT; - minute : INT; - second : INT; - millisecond : INT; + year : INT; + month : INT; + day : INT; + hour : INT; + minute : INT; + second : INT; + millisecond : INT; END_VAR END_FUNCTION @@ -694,16 +694,16 @@ END_FUNCTION {external} FUNCTION SPLIT_DT__UINT : INT VAR_INPUT - in : DT; + in : DT; END_VAR VAR_OUTPUT - year : UINT; - month : UINT; - day : UINT; - hour : UINT; - minute : UINT; - second : UINT; - millisecond : UINT; + year : UINT; + month : UINT; + day : UINT; + hour : UINT; + minute : UINT; + second : UINT; + millisecond : UINT; END_VAR END_FUNCTION @@ -711,16 +711,16 @@ END_FUNCTION {external} FUNCTION SPLIT_DT__DINT : INT VAR_INPUT - in : DT; + in : DT; END_VAR VAR_OUTPUT - year : DINT; - month : DINT; - day : DINT; - hour : DINT; - minute : DINT; - second : DINT; - millisecond : DINT; + year : DINT; + month : DINT; + day : DINT; + hour : DINT; + minute : DINT; + second : DINT; + millisecond : DINT; END_VAR END_FUNCTION @@ -728,16 +728,16 @@ END_FUNCTION {external} FUNCTION SPLIT_DT__UDINT : INT VAR_INPUT - in : DT; + in : DT; END_VAR VAR_OUTPUT - year : UDINT; - month : UDINT; - day : UDINT; - hour : UDINT; - minute : UDINT; - second : UDINT; - millisecond : UDINT; + year : UDINT; + month : UDINT; + day : UDINT; + hour : UDINT; + minute : UDINT; + second : UDINT; + millisecond : UDINT; END_VAR END_FUNCTION @@ -745,16 +745,16 @@ END_FUNCTION {external} FUNCTION SPLIT_DT__LINT : INT VAR_INPUT - in : DT; + in : DT; END_VAR VAR_OUTPUT - year : LINT; - month : LINT; - day : LINT; - hour : LINT; - minute : LINT; - second : LINT; - millisecond : LINT; + year : LINT; + month : LINT; + day : LINT; + hour : LINT; + minute : LINT; + second : LINT; + millisecond : LINT; END_VAR END_FUNCTION @@ -762,16 +762,16 @@ END_FUNCTION {external} FUNCTION SPLIT_DT__ULINT : INT VAR_INPUT - in : DT; + in : DT; END_VAR VAR_OUTPUT - year : ULINT; - month : ULINT; - day : ULINT; - hour : ULINT; - minute : ULINT; - second : ULINT; - millisecond : ULINT; + year : ULINT; + month : ULINT; + day : ULINT; + hour : ULINT; + minute : ULINT; + second : ULINT; + millisecond : ULINT; END_VAR END_FUNCTION @@ -782,16 +782,16 @@ END_FUNCTION ******************** *) FUNCTION SPLIT_LDT < T : ANY_INT > : INT VAR_INPUT - in : LDT; + in : LDT; END_VAR VAR_OUTPUT - year : T; - month : T; - day : T; - hour : T; - minute : T; - second : T; - millisecond : T; + year : T; + month : T; + day : T; + hour : T; + minute : T; + second : T; + millisecond : T; END_VAR END_FUNCTION @@ -799,108 +799,108 @@ END_FUNCTION {external} FUNCTION SPLIT_LDT__INT : INT VAR_INPUT - in : LDT; + in : LDT; END_VAR VAR_OUTPUT - year : INT; - month : INT; - day : INT; - hour : INT; - minute : INT; - second : INT; - millisecond : INT; + year : INT; + month : INT; + day : INT; + hour : INT; + minute : INT; + second : INT; + millisecond : INT; END_VAR - SPLIT_LDT__INT := SPLIT_DT__INT(in, year, month, day, hour, minute, second, millisecond); + SPLIT_LDT__INT := SPLIT_DT__INT(in, year, month, day, hour, minute, second, millisecond); END_FUNCTION (* Specialized implementation of SPLIT_LDT for UINT *) {external} FUNCTION SPLIT_LDT__UINT : INT VAR_INPUT - in : LDT; + in : LDT; END_VAR VAR_OUTPUT - year : UINT; - month : UINT; - day : UINT; - hour : UINT; - minute : UINT; - second : UINT; - millisecond : UINT; + year : UINT; + month : UINT; + day : UINT; + hour : UINT; + minute : UINT; + second : UINT; + millisecond : UINT; END_VAR - SPLIT_LDT__UINT := SPLIT_DT__UINT(in, year, month, day, hour, minute, second, millisecond); + SPLIT_LDT__UINT := SPLIT_DT__UINT(in, year, month, day, hour, minute, second, millisecond); END_FUNCTION (* Specialized implementation of SPLIT_LDT for DINT *) {external} FUNCTION SPLIT_LDT__DINT : INT VAR_INPUT - in : LDT; + in : LDT; END_VAR VAR_OUTPUT - year : DINT; - month : DINT; - day : DINT; - hour : DINT; - minute : DINT; - second : DINT; - millisecond : DINT; + year : DINT; + month : DINT; + day : DINT; + hour : DINT; + minute : DINT; + second : DINT; + millisecond : DINT; END_VAR - SPLIT_LDT__DINT := SPLIT_DT__DINT(in, year, month, day, hour, minute, second, millisecond); + SPLIT_LDT__DINT := SPLIT_DT__DINT(in, year, month, day, hour, minute, second, millisecond); END_FUNCTION (* Specialized implementation of SPLIT_LDT for UDINT *) {external} FUNCTION SPLIT_LDT__UDINT : INT VAR_INPUT - in : LDT; + in : LDT; END_VAR VAR_OUTPUT - year : UDINT; - month : UDINT; - day : UDINT; - hour : UDINT; - minute : UDINT; - second : UDINT; - millisecond : UDINT; + year : UDINT; + month : UDINT; + day : UDINT; + hour : UDINT; + minute : UDINT; + second : UDINT; + millisecond : UDINT; END_VAR - SPLIT_LDT__UDINT := SPLIT_DT__UDINT(in, year, month, day, hour, minute, second, millisecond); + SPLIT_LDT__UDINT := SPLIT_DT__UDINT(in, year, month, day, hour, minute, second, millisecond); END_FUNCTION (* Specialized implementation of SPLIT_LDT for LINT *) {external} FUNCTION SPLIT_LDT__LINT : INT VAR_INPUT - in : LDT; + in : LDT; END_VAR VAR_OUTPUT - year : LINT; - month : LINT; - day : LINT; - hour : LINT; - minute : LINT; - second : LINT; - millisecond : LINT; + year : LINT; + month : LINT; + day : LINT; + hour : LINT; + minute : LINT; + second : LINT; + millisecond : LINT; END_VAR - SPLIT_LDT__LINT := SPLIT_DT__LINT(in, year, month, day, hour, minute, second, millisecond); + SPLIT_LDT__LINT := SPLIT_DT__LINT(in, year, month, day, hour, minute, second, millisecond); END_FUNCTION (* Specialized implementation of SPLIT_LDT for ULINT *) {external} FUNCTION SPLIT_LDT__ULINT : INT VAR_INPUT - in : LDT; + in : LDT; END_VAR VAR_OUTPUT - year : ULINT; - month : ULINT; - day : ULINT; - hour : ULINT; - minute : ULINT; - second : ULINT; - millisecond : ULINT; + year : ULINT; + month : ULINT; + day : ULINT; + hour : ULINT; + minute : ULINT; + second : ULINT; + millisecond : ULINT; END_VAR - SPLIT_LDT__ULINT := SPLIT_DT__ULINT(in, year, month, day, hour, minute, second, millisecond); + SPLIT_LDT__ULINT := SPLIT_DT__ULINT(in, year, month, day, hour, minute, second, millisecond); END_FUNCTION (******************** @@ -912,7 +912,7 @@ END_FUNCTION {external} FUNCTION DAY_OF_WEEK : SINT VAR_INPUT - in : DATE; + in : DATE; END_VAR END_FUNCTION (* ************************* * @@ -925,8 +925,8 @@ END_FUNCTION (* ************************* {external} FUNCTION SHL < T : ANY_BIT > : T VAR_INPUT - IN : T; - n : UDINT; + IN : T; + n : UDINT; END_VAR END_FUNCTION @@ -944,8 +944,8 @@ END_FUNCTION {external} FUNCTION SHR < T : ANY_BIT > : T VAR_INPUT - IN : T; - n : UDINT; + IN : T; + n : UDINT; END_VAR END_FUNCTION @@ -961,8 +961,8 @@ END_FUNCTION {external} FUNCTION ROL < T : ANY_BIT > : T VAR_INPUT - IN : T; - n : UDINT; + IN : T; + n : UDINT; END_VAR END_FUNCTION @@ -978,8 +978,8 @@ END_FUNCTION {external} FUNCTION ROR < T : ANY_BIT > : T VAR_INPUT - IN : T; - n : UDINT; + IN : T; + n : UDINT; END_VAR END_FUNCTION @@ -990,9 +990,9 @@ END_FUNCTION ******************** *) FUNCTION LWORD_TO_DWORD : DWORD VAR_INPUT - in : LWORD; + in : LWORD; END_VAR - LWORD_TO_DWORD := in; + LWORD_TO_DWORD := in; END_FUNCTION (******************** @@ -1002,9 +1002,9 @@ END_FUNCTION ******************** *) FUNCTION LWORD_TO_WORD : WORD VAR_INPUT - in : LWORD; + in : LWORD; END_VAR - LWORD_TO_WORD := in; + LWORD_TO_WORD := in; END_FUNCTION (******************** @@ -1014,9 +1014,9 @@ END_FUNCTION ******************** *) FUNCTION LWORD_TO_BYTE : BYTE VAR_INPUT - in : LWORD; + in : LWORD; END_VAR - LWORD_TO_BYTE := in; + LWORD_TO_BYTE := in; END_FUNCTION (******************** @@ -1026,9 +1026,9 @@ END_FUNCTION ******************** *) FUNCTION LWORD_TO_BOOL : BOOL VAR_INPUT - in : LWORD; + in : LWORD; END_VAR - LWORD_TO_BOOL := in.0; + LWORD_TO_BOOL := in.0; END_FUNCTION (******************** @@ -1038,9 +1038,9 @@ END_FUNCTION ******************** *) FUNCTION DWORD_TO_LWORD : LWORD VAR_INPUT - in : DWORD; + in : DWORD; END_VAR - DWORD_TO_LWORD := in; + DWORD_TO_LWORD := in; END_FUNCTION (******************** @@ -1050,9 +1050,9 @@ END_FUNCTION ******************** *) FUNCTION DWORD_TO_WORD : WORD VAR_INPUT - in : DWORD; + in : DWORD; END_VAR - DWORD_TO_WORD := in; + DWORD_TO_WORD := in; END_FUNCTION (******************** @@ -1062,9 +1062,9 @@ END_FUNCTION ******************** *) FUNCTION DWORD_TO_BYTE : BYTE VAR_INPUT - in : DWORD; + in : DWORD; END_VAR - DWORD_TO_BYTE := in; + DWORD_TO_BYTE := in; END_FUNCTION (******************** @@ -1074,9 +1074,9 @@ END_FUNCTION ******************** *) FUNCTION DWORD_TO_BOOL : BOOL VAR_INPUT - in : DWORD; + in : DWORD; END_VAR - DWORD_TO_BOOL := in.0; + DWORD_TO_BOOL := in.0; END_FUNCTION (******************** @@ -1086,9 +1086,9 @@ END_FUNCTION ******************** *) FUNCTION WORD_TO_LWORD : LWORD VAR_INPUT - in : WORD; + in : WORD; END_VAR - WORD_TO_LWORD := in; + WORD_TO_LWORD := in; END_FUNCTION (******************** @@ -1098,9 +1098,9 @@ END_FUNCTION ******************** *) FUNCTION WORD_TO_DWORD : DWORD VAR_INPUT - in : WORD; + in : WORD; END_VAR - WORD_TO_DWORD := in; + WORD_TO_DWORD := in; END_FUNCTION (******************** @@ -1110,9 +1110,9 @@ END_FUNCTION ******************** *) FUNCTION WORD_TO_BYTE : BYTE VAR_INPUT - in : WORD; + in : WORD; END_VAR - WORD_TO_BYTE := in; + WORD_TO_BYTE := in; END_FUNCTION (******************** @@ -1122,9 +1122,9 @@ END_FUNCTION ******************** *) FUNCTION WORD_TO_BOOL : BOOL VAR_INPUT - in : WORD; + in : WORD; END_VAR - WORD_TO_BOOL := in.0; + WORD_TO_BOOL := in.0; END_FUNCTION (******************** @@ -1134,9 +1134,9 @@ END_FUNCTION ******************** *) FUNCTION BYTE_TO_LWORD : LWORD VAR_INPUT - in : BYTE; + in : BYTE; END_VAR - BYTE_TO_LWORD := in; + BYTE_TO_LWORD := in; END_FUNCTION (******************** @@ -1146,9 +1146,9 @@ END_FUNCTION ******************** *) FUNCTION BYTE_TO_DWORD : DWORD VAR_INPUT - in : BYTE; + in : BYTE; END_VAR - BYTE_TO_DWORD := in; + BYTE_TO_DWORD := in; END_FUNCTION (******************** @@ -1158,9 +1158,9 @@ END_FUNCTION ******************** *) FUNCTION BYTE_TO_WORD : WORD VAR_INPUT - in : BYTE; + in : BYTE; END_VAR - BYTE_TO_WORD := in; + BYTE_TO_WORD := in; END_FUNCTION (******************** @@ -1170,9 +1170,9 @@ END_FUNCTION ******************** *) FUNCTION BYTE_TO_BOOL : BOOL VAR_INPUT - in : BYTE; + in : BYTE; END_VAR - BYTE_TO_BOOL := in.0; + BYTE_TO_BOOL := in.0; END_FUNCTION (******************** @@ -1182,13 +1182,13 @@ END_FUNCTION ******************** *) FUNCTION BYTE_TO_CHAR : CHAR VAR_INPUT - in : BYTE; + in : BYTE; END_VAR VAR - ptr : REF_TO CHAR; + ptr : REF_TO CHAR; END_VAR - ptr := ∈ - BYTE_TO_CHAR := ptr^; + ptr := ∈ + BYTE_TO_CHAR := ptr^; END_FUNCTION (******************** @@ -1198,13 +1198,13 @@ END_FUNCTION ******************** *) FUNCTION BOOL_TO_LWORD : LWORD VAR_INPUT - in : BOOL; + in : BOOL; END_VAR - IF in <> 0 THEN - BOOL_TO_LWORD := 1; - ELSE - BOOL_TO_LWORD := 0; - END_IF; + IF in <> 0 THEN + BOOL_TO_LWORD := 1; + ELSE + BOOL_TO_LWORD := 0; + END_IF; END_FUNCTION (******************** @@ -1214,13 +1214,13 @@ END_FUNCTION ******************** *) FUNCTION BOOL_TO_DWORD : DWORD VAR_INPUT - in : BOOL; + in : BOOL; END_VAR - IF in <> 0 THEN - BOOL_TO_DWORD := 1; - ELSE - BOOL_TO_DWORD := 0; - END_IF; + IF in <> 0 THEN + BOOL_TO_DWORD := 1; + ELSE + BOOL_TO_DWORD := 0; + END_IF; END_FUNCTION (******************** @@ -1230,13 +1230,13 @@ END_FUNCTION ******************** *) FUNCTION BOOL_TO_WORD : WORD VAR_INPUT - in : BOOL; + in : BOOL; END_VAR - IF in <> 0 THEN - BOOL_TO_WORD := 1; - ELSE - BOOL_TO_WORD := 0; - END_IF; + IF in <> 0 THEN + BOOL_TO_WORD := 1; + ELSE + BOOL_TO_WORD := 0; + END_IF; END_FUNCTION (******************** @@ -1246,13 +1246,13 @@ END_FUNCTION ******************** *) FUNCTION BOOL_TO_BYTE : BYTE VAR_INPUT - in : BOOL; + in : BOOL; END_VAR - IF in <> 0 THEN - BOOL_TO_BYTE := 1; - ELSE - BOOL_TO_BYTE := 0; - END_IF; + IF in <> 0 THEN + BOOL_TO_BYTE := 1; + ELSE + BOOL_TO_BYTE := 0; + END_IF; END_FUNCTION (******************** @@ -1262,13 +1262,13 @@ END_FUNCTION ******************** *) FUNCTION CHAR_TO_BYTE : BYTE VAR_INPUT - in : CHAR; + in : CHAR; END_VAR VAR - ptr : REF_TO BYTE; + ptr : REF_TO BYTE; END_VAR - ptr := ∈ - CHAR_TO_BYTE := ptr^; + ptr := ∈ + CHAR_TO_BYTE := ptr^; END_FUNCTION (******************** @@ -1278,9 +1278,9 @@ END_FUNCTION ******************** *) FUNCTION CHAR_TO_WORD : WORD VAR_INPUT - in : CHAR; + in : CHAR; END_VAR - CHAR_TO_WORD := CHAR_TO_BYTE(in); + CHAR_TO_WORD := CHAR_TO_BYTE(in); END_FUNCTION (******************** @@ -1290,9 +1290,9 @@ END_FUNCTION ******************** *) FUNCTION CHAR_TO_DWORD : DWORD VAR_INPUT - in : CHAR; + in : CHAR; END_VAR - CHAR_TO_DWORD := CHAR_TO_BYTE(in); + CHAR_TO_DWORD := CHAR_TO_BYTE(in); END_FUNCTION (******************** @@ -1302,9 +1302,9 @@ END_FUNCTION ******************** *) FUNCTION CHAR_TO_LWORD : LWORD VAR_INPUT - in : CHAR; + in : CHAR; END_VAR - CHAR_TO_LWORD := CHAR_TO_BYTE(in); + CHAR_TO_LWORD := CHAR_TO_BYTE(in); END_FUNCTION (******************** @@ -1314,13 +1314,13 @@ END_FUNCTION ******************** *) FUNCTION WCHAR_TO_WORD : WORD VAR_INPUT - in : WCHAR; + in : WCHAR; END_VAR VAR - ptr : REF_TO WORD; + ptr : REF_TO WORD; END_VAR - ptr := ∈ - WCHAR_TO_WORD := ptr^; + ptr := ∈ + WCHAR_TO_WORD := ptr^; END_FUNCTION (******************** @@ -1330,9 +1330,9 @@ END_FUNCTION ******************** *) FUNCTION WCHAR_TO_DWORD : DWORD VAR_INPUT - in : WCHAR; + in : WCHAR; END_VAR - WCHAR_TO_DWORD := WCHAR_TO_WORD(in); + WCHAR_TO_DWORD := WCHAR_TO_WORD(in); END_FUNCTION (******************** @@ -1342,9 +1342,9 @@ END_FUNCTION ******************** *) FUNCTION WCHAR_TO_LWORD : LWORD VAR_INPUT - in : WCHAR; + in : WCHAR; END_VAR - WCHAR_TO_LWORD := WCHAR_TO_WORD(in); + WCHAR_TO_LWORD := WCHAR_TO_WORD(in); END_FUNCTION (* ***************************************************************************** Description: Validation function for ANY_REAL Input: @@ -1356,7 +1356,7 @@ Return: {external} FUNCTION IS_VALID < T : ANY_REAL > : BOOL VAR_INPUT - IN : T; + IN : T; END_VAR END_FUNCTION @@ -1373,7 +1373,7 @@ Return: {external} FUNCTION IS_VALID_BCD < T : ANY_BIT > : BOOL VAR_INPUT - IN : T; + IN : T; END_VAR END_FUNCTION (* ***************************************************************************** Description: Bistable function, set dominant @@ -1387,11 +1387,11 @@ Return: Output is used as return {external} FUNCTION_BLOCK SR VAR_INPUT - SET1 : BOOL; - RESET : BOOL; + SET1 : BOOL; + RESET : BOOL; END_VAR VAR_OUTPUT - Q1 : BOOL; + Q1 : BOOL; END_VAR END_FUNCTION_BLOCK @@ -1407,11 +1407,11 @@ Return: Output is used as return {external} FUNCTION_BLOCK RS VAR_INPUT - SET : BOOL; - RESET1 : BOOL; + SET : BOOL; + RESET1 : BOOL; END_VAR VAR_OUTPUT - Q1 : BOOL; + Q1 : BOOL; END_VAR END_FUNCTION_BLOCK (* ******************* * @@ -1420,18 +1420,18 @@ END_FUNCTION_BLOCK (* ******************* ******************** *) FUNCTION WSTRING_TO_STRING : STRING[__STRING_LENGTH] VAR_INPUT {ref} - in : WSTRING[__STRING_LENGTH]; + in : WSTRING[__STRING_LENGTH]; END_VAR - WSTRING_TO_STRING_EXT(in, WSTRING_TO_STRING); + WSTRING_TO_STRING_EXT(in, WSTRING_TO_STRING); END_FUNCTION {external} FUNCTION WSTRING_TO_STRING_EXT : DINT VAR_INPUT {ref} - in : WSTRING[__STRING_LENGTH]; + in : WSTRING[__STRING_LENGTH]; END_VAR VAR_IN_OUT - out : STRING[__STRING_LENGTH]; + out : STRING[__STRING_LENGTH]; END_VAR END_FUNCTION @@ -1442,13 +1442,13 @@ END_FUNCTION ******************** *) FUNCTION WSTRING_TO_WCHAR : WCHAR VAR_INPUT {ref} - in : WSTRING; + in : WSTRING; END_VAR VAR - ptr : REF_TO WCHAR; + ptr : REF_TO WCHAR; END_VAR - ptr := ∈ - WSTRING_TO_WCHAR := ptr^; + ptr := ∈ + WSTRING_TO_WCHAR := ptr^; END_FUNCTION (******************** @@ -1459,18 +1459,18 @@ END_FUNCTION ******************** *) FUNCTION STRING_TO_WSTRING : WSTRING[__STRING_LENGTH] VAR_INPUT {ref} - in : STRING[__STRING_LENGTH]; + in : STRING[__STRING_LENGTH]; END_VAR - STRING_TO_WSTRING_EXT(in, STRING_TO_WSTRING); + STRING_TO_WSTRING_EXT(in, STRING_TO_WSTRING); END_FUNCTION {external} FUNCTION STRING_TO_WSTRING_EXT : DINT VAR_INPUT {ref} - in : STRING[__STRING_LENGTH]; + in : STRING[__STRING_LENGTH]; END_VAR VAR_IN_OUT - out : WSTRING[__STRING_LENGTH]; + out : WSTRING[__STRING_LENGTH]; END_VAR END_FUNCTION @@ -1481,13 +1481,13 @@ END_FUNCTION ******************** *) FUNCTION STRING_TO_CHAR : CHAR VAR_INPUT {ref} - in : STRING; + in : STRING; END_VAR VAR - ptr : REF_TO CHAR; + ptr : REF_TO CHAR; END_VAR - ptr := ∈ - STRING_TO_CHAR := ptr^; + ptr := ∈ + STRING_TO_CHAR := ptr^; END_FUNCTION (******************** @@ -1497,13 +1497,13 @@ END_FUNCTION ******************** *) FUNCTION WCHAR_TO_WSTRING : WSTRING VAR_INPUT - in : WCHAR; + in : WCHAR; END_VAR VAR - ptr : REF_TO WSTRING; + ptr : REF_TO WSTRING; END_VAR - ptr := ∈ - WCHAR_TO_WSTRING := ptr^; + ptr := ∈ + WCHAR_TO_WSTRING := ptr^; END_FUNCTION (******************** @@ -1514,7 +1514,7 @@ END_FUNCTION {external} FUNCTION WCHAR_TO_CHAR : CHAR VAR_INPUT - in : WCHAR; + in : WCHAR; END_VAR END_FUNCTION @@ -1525,13 +1525,13 @@ END_FUNCTION ******************** *) FUNCTION CHAR_TO_STRING : STRING VAR_INPUT - in : CHAR; + in : CHAR; END_VAR VAR - ptr : REF_TO STRING; + ptr : REF_TO STRING; END_VAR - ptr := ∈ - CHAR_TO_STRING := ptr^; + ptr := ∈ + CHAR_TO_STRING := ptr^; END_FUNCTION (******************** @@ -1542,7 +1542,7 @@ END_FUNCTION {external} FUNCTION CHAR_TO_WCHAR : WCHAR VAR_INPUT - in : CHAR; + in : CHAR; END_VAR END_FUNCTION (* ************************* * @@ -1680,12 +1680,12 @@ Return: Output variables are used for return. ***************************************************************************** *) FUNCTION_BLOCK TON VAR_INPUT - IN : BOOL; - PT : TIME; + IN : BOOL; + PT : TIME; END_VAR VAR_OUTPUT - Q : BOOL; - ET : TIME; + Q : BOOL; + ET : TIME; END_VAR VAR __signal__ : BOOL; (* Value representing the internal signal *) @@ -1706,12 +1706,12 @@ Return: Output variables are used for return. ***************************************************************************** *) FUNCTION_BLOCK TON_TIME VAR_INPUT - IN : BOOL; - PT : TIME; + IN : BOOL; + PT : TIME; END_VAR VAR_OUTPUT - Q : BOOL; - ET : TIME; + Q : BOOL; + ET : TIME; END_VAR VAR __signal__ : BOOL; (* Value representing the internal signal *) @@ -1732,12 +1732,12 @@ Return: Output variables are used for return. ***************************************************************************** *) FUNCTION_BLOCK TON_LTIME VAR_INPUT - IN : BOOL; - PT : LTIME; + IN : BOOL; + PT : LTIME; END_VAR VAR_OUTPUT - Q : BOOL; - ET : TIME; + Q : BOOL; + ET : TIME; END_VAR VAR __signal__ : BOOL; (* Value representing the internal signal *) @@ -1758,12 +1758,12 @@ Return: Output variables are used for return. ***************************************************************************** *) FUNCTION_BLOCK TOF VAR_INPUT - IN : BOOL; - PT : TIME; + IN : BOOL; + PT : TIME; END_VAR VAR_OUTPUT - Q : BOOL; - ET : TIME; + Q : BOOL; + ET : TIME; END_VAR VAR __signal__ : BOOL; (* Value representing the internal signal *) @@ -1784,12 +1784,12 @@ Return: Output variables are used for return. ***************************************************************************** *) FUNCTION_BLOCK TOF_TIME VAR_INPUT - IN : BOOL; - PT : TIME; + IN : BOOL; + PT : TIME; END_VAR VAR_OUTPUT - Q : BOOL; - ET : TIME; + Q : BOOL; + ET : TIME; END_VAR VAR __signal__ : BOOL; (* Value representing the internal signal *) @@ -1810,12 +1810,12 @@ Return: Output variables are used for return. ***************************************************************************** *) FUNCTION_BLOCK TOF_LTIME VAR_INPUT - IN : BOOL; - PT : LTIME; + IN : BOOL; + PT : LTIME; END_VAR VAR_OUTPUT - Q : BOOL; - ET : LTIME; + Q : BOOL; + ET : LTIME; END_VAR VAR __signal__ : BOOL; (* Value representing the internal signal *) @@ -1829,7 +1829,7 @@ END_FUNCTION_BLOCK (* ******************* {external} FUNCTION DATE_AND_TIME_TO_DATE : DATE VAR_INPUT - in : DT; + in : DT; END_VAR END_FUNCTION @@ -1841,7 +1841,7 @@ END_FUNCTION {external} FUNCTION DATE_AND_TIME_TO_TIME_OF_DAY : TOD VAR_INPUT - in : DT; + in : DT; END_VAR END_FUNCTION @@ -1852,9 +1852,9 @@ END_FUNCTION ******************** *) FUNCTION LTIME_TO_TIME : TIME VAR_INPUT - in : LTIME; + in : LTIME; END_VAR - LTIME_TO_TIME := in; + LTIME_TO_TIME := in; END_FUNCTION (******************** @@ -1864,9 +1864,9 @@ END_FUNCTION ******************** *) FUNCTION TIME_TO_LTIME : LTIME VAR_INPUT - in : TIME; + in : TIME; END_VAR - TIME_TO_LTIME := in; + TIME_TO_LTIME := in; END_FUNCTION (******************** @@ -1876,9 +1876,9 @@ END_FUNCTION ******************** *) FUNCTION LDT_TO_DT : DT VAR_INPUT - in : LDT; + in : LDT; END_VAR - LDT_TO_DT := in; + LDT_TO_DT := in; END_FUNCTION (******************** @@ -1888,9 +1888,9 @@ END_FUNCTION ******************** *) FUNCTION LDT_TO_DATE : DATE VAR_INPUT - in : LDT; + in : LDT; END_VAR - LDT_TO_DATE := DATE_AND_TIME_TO_DATE(in); + LDT_TO_DATE := DATE_AND_TIME_TO_DATE(in); END_FUNCTION (******************** @@ -1900,9 +1900,9 @@ END_FUNCTION ******************** *) FUNCTION LDT_TO_LTOD : LTOD VAR_INPUT - in : LDT; + in : LDT; END_VAR - LDT_TO_LTOD := DATE_AND_TIME_TO_TIME_OF_DAY(in); + LDT_TO_LTOD := DATE_AND_TIME_TO_TIME_OF_DAY(in); END_FUNCTION (******************** @@ -1912,9 +1912,9 @@ END_FUNCTION ******************** *) FUNCTION LDT_TO_TOD : TOD VAR_INPUT - in : LDT; + in : LDT; END_VAR - LDT_TO_TOD := DATE_AND_TIME_TO_TIME_OF_DAY(in); + LDT_TO_TOD := DATE_AND_TIME_TO_TIME_OF_DAY(in); END_FUNCTION (******************** @@ -1924,9 +1924,9 @@ END_FUNCTION ******************** *) FUNCTION DT_TO_LDT : LDT VAR_INPUT - in : DT; + in : DT; END_VAR - DT_TO_LDT := in; + DT_TO_LDT := in; END_FUNCTION (******************** @@ -1936,9 +1936,9 @@ END_FUNCTION ******************** *) FUNCTION DT_TO_DATE : DATE VAR_INPUT - in : DT; + in : DT; END_VAR - DT_TO_DATE := DATE_AND_TIME_TO_DATE(in); + DT_TO_DATE := DATE_AND_TIME_TO_DATE(in); END_FUNCTION (******************** @@ -1948,9 +1948,9 @@ END_FUNCTION ******************** *) FUNCTION DT_TO_LTOD : LTOD VAR_INPUT - in : DT; + in : DT; END_VAR - DT_TO_LTOD := DATE_AND_TIME_TO_TIME_OF_DAY(in); + DT_TO_LTOD := DATE_AND_TIME_TO_TIME_OF_DAY(in); END_FUNCTION (******************** @@ -1960,9 +1960,9 @@ END_FUNCTION ******************** *) FUNCTION DT_TO_TOD : TOD VAR_INPUT - in : DT; + in : DT; END_VAR - DT_TO_TOD := DATE_AND_TIME_TO_TIME_OF_DAY(in); + DT_TO_TOD := DATE_AND_TIME_TO_TIME_OF_DAY(in); END_FUNCTION (******************** @@ -1972,9 +1972,9 @@ END_FUNCTION ******************** *) FUNCTION LTOD_TO_TOD : TOD VAR_INPUT - in : LTOD; + in : LTOD; END_VAR - LTOD_TO_TOD := in; + LTOD_TO_TOD := in; END_FUNCTION (******************** @@ -1984,9 +1984,9 @@ END_FUNCTION ******************** *) FUNCTION TOD_TO_LTOD : LTOD VAR_INPUT - in : TOD; + in : TOD; END_VAR - TOD_TO_LTOD := in; + TOD_TO_LTOD := in; END_FUNCTION (* ******************* * * This operator returns the value of adding up the operands. @@ -1994,18 +1994,18 @@ END_FUNCTION (* ******************* ******************** *) FUNCTION ADD < T1 : ANY, T2 : ANY > : T1 VAR_INPUT - IN1 : T1; - IN2 : T2; + IN1 : T1; + IN2 : T2; END_VAR END_FUNCTION (* Specialized implementation of ADD for TIME *) FUNCTION ADD__TIME__TIME : TIME VAR_INPUT - IN1 : TIME; - IN2 : TIME; + IN1 : TIME; + IN2 : TIME; END_VAR - ADD__TIME__TIME := ADD_TIME(IN1, IN2); + ADD__TIME__TIME := ADD_TIME(IN1, IN2); END_FUNCTION (******************** @@ -2016,8 +2016,8 @@ END_FUNCTION {external} FUNCTION ADD_TIME : TIME VAR_INPUT - IN1 : TIME; - IN2 : TIME; + IN1 : TIME; + IN2 : TIME; END_VAR END_FUNCTION @@ -2028,19 +2028,19 @@ END_FUNCTION ******************** *) FUNCTION ADD_LTIME : LTIME VAR_INPUT - IN1 : LTIME; - IN2 : LTIME; + IN1 : LTIME; + IN2 : LTIME; END_VAR - ADD_LTIME := ADD_TIME(IN1, IN2); + ADD_LTIME := ADD_TIME(IN1, IN2); END_FUNCTION (* Specialized implementation of ADD for TOD *) FUNCTION ADD__TIME_OF_DAY__TIME : TOD VAR_INPUT - IN1 : TOD; - IN2 : TIME; + IN1 : TOD; + IN2 : TIME; END_VAR - ADD__TIME_OF_DAY__TIME := ADD_TOD_TIME(IN1, IN2); + ADD__TIME_OF_DAY__TIME := ADD_TOD_TIME(IN1, IN2); END_FUNCTION (******************** @@ -2052,8 +2052,8 @@ END_FUNCTION {external} FUNCTION ADD_TOD_TIME : TOD VAR_INPUT - IN1 : TOD; - IN2 : TIME; + IN1 : TOD; + IN2 : TIME; END_VAR END_FUNCTION @@ -2065,19 +2065,19 @@ END_FUNCTION ******************** *) FUNCTION ADD_LTOD_LTIME : LTOD VAR_INPUT - IN1 : LTOD; - IN2 : LTIME; + IN1 : LTOD; + IN2 : LTIME; END_VAR - ADD_LTOD_LTIME := ADD_TOD_TIME(IN1, IN2); + ADD_LTOD_LTIME := ADD_TOD_TIME(IN1, IN2); END_FUNCTION (* Specialized implementation of ADD for DT *) FUNCTION ADD__DATE_AND_TIME__TIME : DT VAR_INPUT - IN1 : DT; - IN2 : TIME; + IN1 : DT; + IN2 : TIME; END_VAR - ADD__DATE_AND_TIME__TIME := ADD_DT_TIME(IN1, IN2); + ADD__DATE_AND_TIME__TIME := ADD_DT_TIME(IN1, IN2); END_FUNCTION (******************** @@ -2089,8 +2089,8 @@ END_FUNCTION {external} FUNCTION ADD_DT_TIME : DT VAR_INPUT - IN1 : DT; - IN2 : TIME; + IN1 : DT; + IN2 : TIME; END_VAR END_FUNCTION @@ -2102,10 +2102,10 @@ END_FUNCTION ******************** *) FUNCTION ADD_LDT_LTIME : LDT VAR_INPUT - IN1 : LDT; - IN2 : LTIME; + IN1 : LDT; + IN2 : LTIME; END_VAR - ADD_LDT_LTIME := ADD_DT_TIME(IN1, IN2); + ADD_LDT_LTIME := ADD_DT_TIME(IN1, IN2); END_FUNCTION (******************** @@ -2115,18 +2115,18 @@ END_FUNCTION ******************** *) FUNCTION SUB < T1 : ANY, T2 : ANY > : T1 VAR_INPUT - IN1 : T1; - IN2 : T2; + IN1 : T1; + IN2 : T2; END_VAR END_FUNCTION (* Specialized implementation of SUB for TIME *) FUNCTION SUB__TIME__TIME : TIME VAR_INPUT - IN1 : TIME; - IN2 : TIME; + IN1 : TIME; + IN2 : TIME; END_VAR - SUB__TIME__TIME := SUB_TIME(IN1, IN2); + SUB__TIME__TIME := SUB_TIME(IN1, IN2); END_FUNCTION (******************** @@ -2137,8 +2137,8 @@ END_FUNCTION {external} FUNCTION SUB_TIME : TIME VAR_INPUT - IN1 : TIME; - IN2 : TIME; + IN1 : TIME; + IN2 : TIME; END_VAR END_FUNCTION @@ -2149,19 +2149,19 @@ END_FUNCTION ******************** *) FUNCTION SUB_LTIME : LTIME VAR_INPUT - IN1 : LTIME; - IN2 : LTIME; + IN1 : LTIME; + IN2 : LTIME; END_VAR - SUB_LTIME := SUB_TIME(IN1, IN2); + SUB_LTIME := SUB_TIME(IN1, IN2); END_FUNCTION (* Specialized implementation of SUB for DATE *) FUNCTION SUB__DATE__DATE : TIME VAR_INPUT - IN1 : DATE; - IN2 : DATE; + IN1 : DATE; + IN2 : DATE; END_VAR - SUB__DATE__DATE := SUB_DATE_DATE(IN1, IN2); + SUB__DATE__DATE := SUB_DATE_DATE(IN1, IN2); END_FUNCTION (******************** @@ -2173,8 +2173,8 @@ END_FUNCTION {external} FUNCTION SUB_DATE_DATE : TIME VAR_INPUT - IN1 : DATE; - IN2 : DATE; + IN1 : DATE; + IN2 : DATE; END_VAR END_FUNCTION @@ -2186,19 +2186,19 @@ END_FUNCTION ******************** *) FUNCTION SUB_LDATE_LDATE : LTIME VAR_INPUT - IN1 : LDATE; - IN2 : LDATE; + IN1 : LDATE; + IN2 : LDATE; END_VAR - SUB_LDATE_LDATE := SUB_DATE_DATE(IN1, IN2); + SUB_LDATE_LDATE := SUB_DATE_DATE(IN1, IN2); END_FUNCTION (* Specialized implementation of SUB for TOD and TIME *) FUNCTION SUB__TIME_OF_DAY__TIME : TOD VAR_INPUT - IN1 : TOD; - IN2 : TIME; + IN1 : TOD; + IN2 : TIME; END_VAR - SUB__TIME_OF_DAY__TIME := SUB_TOD_TIME(IN1, IN2); + SUB__TIME_OF_DAY__TIME := SUB_TOD_TIME(IN1, IN2); END_FUNCTION (******************** @@ -2210,8 +2210,8 @@ END_FUNCTION {external} FUNCTION SUB_TOD_TIME : TOD VAR_INPUT - IN1 : TOD; - IN2 : TIME; + IN1 : TOD; + IN2 : TIME; END_VAR END_FUNCTION @@ -2223,19 +2223,19 @@ END_FUNCTION ******************** *) FUNCTION SUB_LTOD_LTIME : LTOD VAR_INPUT - IN1 : LTOD; - IN2 : LTIME; + IN1 : LTOD; + IN2 : LTIME; END_VAR - SUB_LTOD_LTIME := SUB_TOD_TIME(IN1, IN2); + SUB_LTOD_LTIME := SUB_TOD_TIME(IN1, IN2); END_FUNCTION (* Specialized implementation of SUB for TOD *) FUNCTION SUB__TIME_OF_DAY__TIME_OF_DAY : TIME VAR_INPUT - IN1 : TOD; - IN2 : TOD; + IN1 : TOD; + IN2 : TOD; END_VAR - SUB__TIME_OF_DAY__TIME_OF_DAY := SUB_TOD_TOD(IN1, IN2); + SUB__TIME_OF_DAY__TIME_OF_DAY := SUB_TOD_TOD(IN1, IN2); END_FUNCTION (******************** @@ -2247,8 +2247,8 @@ END_FUNCTION {external} FUNCTION SUB_TOD_TOD : TIME VAR_INPUT - IN1 : TOD; - IN2 : TOD; + IN1 : TOD; + IN2 : TOD; END_VAR END_FUNCTION @@ -2260,19 +2260,19 @@ END_FUNCTION ******************** *) FUNCTION SUB_LTOD_LTOD : LTIME VAR_INPUT - IN1 : LTOD; - IN2 : LTOD; + IN1 : LTOD; + IN2 : LTOD; END_VAR - SUB_LTOD_LTOD := SUB_TOD_TOD(IN1, IN2); + SUB_LTOD_LTOD := SUB_TOD_TOD(IN1, IN2); END_FUNCTION (* Specialized implementation of SUB for DT and TIME *) FUNCTION SUB__DATE_AND_TIME__TIME : DT VAR_INPUT - IN1 : DT; - IN2 : TIME; + IN1 : DT; + IN2 : TIME; END_VAR - SUB__DATE_AND_TIME__TIME := SUB_DT_TIME(IN1, IN2); + SUB__DATE_AND_TIME__TIME := SUB_DT_TIME(IN1, IN2); END_FUNCTION (******************** @@ -2284,8 +2284,8 @@ END_FUNCTION {external} FUNCTION SUB_DT_TIME : DT VAR_INPUT - IN1 : DT; - IN2 : TIME; + IN1 : DT; + IN2 : TIME; END_VAR END_FUNCTION @@ -2297,19 +2297,19 @@ END_FUNCTION ******************** *) FUNCTION SUB_LDT_LTIME : LDT VAR_INPUT - IN1 : LDT; - IN2 : LTIME; + IN1 : LDT; + IN2 : LTIME; END_VAR - SUB_LDT_LTIME := SUB_DT_TIME(IN1, IN2); + SUB_LDT_LTIME := SUB_DT_TIME(IN1, IN2); END_FUNCTION (* Specialized implementation of SUB for DT *) FUNCTION SUB__DATE_AND_TIME__DATE_AND_TIME : TIME VAR_INPUT - IN1 : DT; - IN2 : DT; + IN1 : DT; + IN2 : DT; END_VAR - SUB__DATE_AND_TIME__DATE_AND_TIME := SUB_DT_DT(IN1, IN2); + SUB__DATE_AND_TIME__DATE_AND_TIME := SUB_DT_DT(IN1, IN2); END_FUNCTION (******************** @@ -2321,8 +2321,8 @@ END_FUNCTION {external} FUNCTION SUB_DT_DT : TIME VAR_INPUT - IN1 : DT; - IN2 : DT; + IN1 : DT; + IN2 : DT; END_VAR END_FUNCTION @@ -2334,10 +2334,10 @@ END_FUNCTION ******************** *) FUNCTION SUB_LDT_LDT : LTIME VAR_INPUT - IN1 : LDT; - IN2 : LDT; + IN1 : LDT; + IN2 : LDT; END_VAR - SUB_LDT_LDT := SUB_DT_DT(IN1, IN2); + SUB_LDT_LDT := SUB_DT_DT(IN1, IN2); END_FUNCTION (******************** @@ -2347,8 +2347,8 @@ END_FUNCTION ******************** *) FUNCTION MUL < T1 : ANY, T2 : ANY > : T1 VAR_INPUT - IN1 : T1; - IN2 : T2; + IN1 : T1; + IN2 : T2; END_VAR END_FUNCTION @@ -2359,8 +2359,8 @@ END_FUNCTION ******************** *) FUNCTION MUL_TIME < T : ANY_NUM > : TIME VAR_INPUT - IN1 : TIME; - IN2 : T; + IN1 : TIME; + IN2 : T; END_VAR END_FUNCTION @@ -2371,8 +2371,8 @@ END_FUNCTION ******************** *) FUNCTION MUL_LTIME < T : ANY_NUM > : LTIME VAR_INPUT - IN1 : LTIME; - IN2 : T; + IN1 : LTIME; + IN2 : T; END_VAR END_FUNCTION @@ -2383,8 +2383,8 @@ END_FUNCTION ******************** *) FUNCTION DIV < T1 : ANY, T2 : ANY > : T1 VAR_INPUT - IN1 : T1; - IN2 : T2; + IN1 : T1; + IN2 : T2; END_VAR END_FUNCTION @@ -2395,8 +2395,8 @@ END_FUNCTION ******************** *) FUNCTION DIV_TIME < T : ANY_NUM > : TIME VAR_INPUT - IN1 : TIME; - IN2 : T; + IN1 : TIME; + IN2 : T; END_VAR END_FUNCTION @@ -2407,8 +2407,8 @@ END_FUNCTION ******************** *) FUNCTION DIV_LTIME < T : ANY_NUM > : LTIME VAR_INPUT - IN1 : LTIME; - IN2 : T; + IN1 : LTIME; + IN2 : T; END_VAR END_FUNCTION (* ******************* * @@ -2417,9 +2417,9 @@ END_FUNCTION (* ******************* ******************** *) FUNCTION LREAL_TO_REAL : REAL VAR_INPUT - in : LREAL; + in : LREAL; END_VAR - LREAL_TO_REAL := in; + LREAL_TO_REAL := in; END_FUNCTION (******************** @@ -2429,9 +2429,9 @@ END_FUNCTION ******************** *) FUNCTION LREAL_TO_LINT : LINT VAR_INPUT - in : LREAL; + in : LREAL; END_VAR - LREAL_TO_LINT := ROUND(in); + LREAL_TO_LINT := ROUND(in); END_FUNCTION (******************** @@ -2441,9 +2441,9 @@ END_FUNCTION ******************** *) FUNCTION LREAL_TO_DINT : DINT VAR_INPUT - in : LREAL; + in : LREAL; END_VAR - LREAL_TO_DINT := ROUND(in); + LREAL_TO_DINT := ROUND(in); END_FUNCTION (******************** @@ -2453,9 +2453,9 @@ END_FUNCTION ******************** *) FUNCTION LREAL_TO_INT : INT VAR_INPUT - in : LREAL; + in : LREAL; END_VAR - LREAL_TO_INT := ROUND(in); + LREAL_TO_INT := ROUND(in); END_FUNCTION (******************** @@ -2465,9 +2465,9 @@ END_FUNCTION ******************** *) FUNCTION LREAL_TO_SINT : SINT VAR_INPUT - in : LREAL; + in : LREAL; END_VAR - LREAL_TO_SINT := ROUND(in); + LREAL_TO_SINT := ROUND(in); END_FUNCTION (******************** @@ -2477,9 +2477,9 @@ END_FUNCTION ******************** *) FUNCTION LREAL_TO_ULINT : ULINT VAR_INPUT - in : LREAL; + in : LREAL; END_VAR - LREAL_TO_ULINT := ROUND(in); + LREAL_TO_ULINT := ROUND(in); END_FUNCTION (******************** @@ -2489,9 +2489,9 @@ END_FUNCTION ******************** *) FUNCTION LREAL_TO_UDINT : UDINT VAR_INPUT - in : LREAL; + in : LREAL; END_VAR - LREAL_TO_UDINT := ROUND(in); + LREAL_TO_UDINT := ROUND(in); END_FUNCTION (******************** @@ -2501,9 +2501,9 @@ END_FUNCTION ******************** *) FUNCTION LREAL_TO_UINT : UINT VAR_INPUT - in : LREAL; + in : LREAL; END_VAR - LREAL_TO_UINT := ROUND(in); + LREAL_TO_UINT := ROUND(in); END_FUNCTION (******************** @@ -2513,9 +2513,9 @@ END_FUNCTION ******************** *) FUNCTION LREAL_TO_USINT : USINT VAR_INPUT - in : LREAL; + in : LREAL; END_VAR - LREAL_TO_USINT := ROUND(in); + LREAL_TO_USINT := ROUND(in); END_FUNCTION (******************** @@ -2525,9 +2525,9 @@ END_FUNCTION ******************** *) FUNCTION REAL_TO_LREAL : LREAL VAR_INPUT - in : REAL; + in : REAL; END_VAR - REAL_TO_LREAL := in; + REAL_TO_LREAL := in; END_FUNCTION (******************** @@ -2537,9 +2537,9 @@ END_FUNCTION ******************** *) FUNCTION REAL_TO_LINT : LINT VAR_INPUT - in : REAL; + in : REAL; END_VAR - REAL_TO_LINT := ROUND(in); + REAL_TO_LINT := ROUND(in); END_FUNCTION (******************** @@ -2549,9 +2549,9 @@ END_FUNCTION ******************** *) FUNCTION REAL_TO_DINT : DINT VAR_INPUT - in : REAL; + in : REAL; END_VAR - REAL_TO_DINT := ROUND(in); + REAL_TO_DINT := ROUND(in); END_FUNCTION (******************** @@ -2561,9 +2561,9 @@ END_FUNCTION ******************** *) FUNCTION REAL_TO_INT : INT VAR_INPUT - in : REAL; + in : REAL; END_VAR - REAL_TO_INT := ROUND(in); + REAL_TO_INT := ROUND(in); END_FUNCTION (******************** @@ -2573,9 +2573,9 @@ END_FUNCTION ******************** *) FUNCTION REAL_TO_SINT : SINT VAR_INPUT - in : REAL; + in : REAL; END_VAR - REAL_TO_SINT := ROUND(in); + REAL_TO_SINT := ROUND(in); END_FUNCTION (******************** @@ -2585,9 +2585,9 @@ END_FUNCTION ******************** *) FUNCTION REAL_TO_ULINT : ULINT VAR_INPUT - in : REAL; + in : REAL; END_VAR - REAL_TO_ULINT := ROUND(in); + REAL_TO_ULINT := ROUND(in); END_FUNCTION (******************** @@ -2597,9 +2597,9 @@ END_FUNCTION ******************** *) FUNCTION REAL_TO_UDINT : UDINT VAR_INPUT - in : REAL; + in : REAL; END_VAR - REAL_TO_UDINT := ROUND(in); + REAL_TO_UDINT := ROUND(in); END_FUNCTION (******************** @@ -2609,9 +2609,9 @@ END_FUNCTION ******************** *) FUNCTION REAL_TO_UINT : UINT VAR_INPUT - in : REAL; + in : REAL; END_VAR - REAL_TO_UINT := ROUND(in); + REAL_TO_UINT := ROUND(in); END_FUNCTION (******************** @@ -2621,9 +2621,9 @@ END_FUNCTION ******************** *) FUNCTION REAL_TO_USINT : USINT VAR_INPUT - in : REAL; + in : REAL; END_VAR - REAL_TO_USINT := ROUND(in); + REAL_TO_USINT := ROUND(in); END_FUNCTION (******************** @@ -2633,9 +2633,9 @@ END_FUNCTION ******************** *) FUNCTION LINT_TO_LREAL : LREAL VAR_INPUT - in : LINT; + in : LINT; END_VAR - LINT_TO_LREAL := in; + LINT_TO_LREAL := in; END_FUNCTION (******************** @@ -2645,9 +2645,9 @@ END_FUNCTION ******************** *) FUNCTION LINT_TO_REAL : REAL VAR_INPUT - in : LINT; + in : LINT; END_VAR - LINT_TO_REAL := in; + LINT_TO_REAL := in; END_FUNCTION (******************** @@ -2657,9 +2657,9 @@ END_FUNCTION ******************** *) FUNCTION LINT_TO_DINT : DINT VAR_INPUT - in : LINT; + in : LINT; END_VAR - LINT_TO_DINT := in; + LINT_TO_DINT := in; END_FUNCTION (******************** @@ -2669,9 +2669,9 @@ END_FUNCTION ******************** *) FUNCTION LINT_TO_INT : INT VAR_INPUT - in : LINT; + in : LINT; END_VAR - LINT_TO_INT := in; + LINT_TO_INT := in; END_FUNCTION (******************** @@ -2681,9 +2681,9 @@ END_FUNCTION ******************** *) FUNCTION LINT_TO_SINT : SINT VAR_INPUT - in : LINT; + in : LINT; END_VAR - LINT_TO_SINT := in; + LINT_TO_SINT := in; END_FUNCTION (******************** @@ -2693,9 +2693,9 @@ END_FUNCTION ******************** *) FUNCTION LINT_TO_ULINT : ULINT VAR_INPUT - in : LINT; + in : LINT; END_VAR - LINT_TO_ULINT := in; + LINT_TO_ULINT := in; END_FUNCTION (******************** @@ -2705,9 +2705,9 @@ END_FUNCTION ******************** *) FUNCTION LINT_TO_UDINT : UDINT VAR_INPUT - in : LINT; + in : LINT; END_VAR - LINT_TO_UDINT := in; + LINT_TO_UDINT := in; END_FUNCTION (******************** @@ -2717,9 +2717,9 @@ END_FUNCTION ******************** *) FUNCTION LINT_TO_UINT : UINT VAR_INPUT - in : LINT; + in : LINT; END_VAR - LINT_TO_UINT := in; + LINT_TO_UINT := in; END_FUNCTION (******************** @@ -2729,9 +2729,9 @@ END_FUNCTION ******************** *) FUNCTION LINT_TO_USINT : USINT VAR_INPUT - in : LINT; + in : LINT; END_VAR - LINT_TO_USINT := in; + LINT_TO_USINT := in; END_FUNCTION (******************** @@ -2741,9 +2741,9 @@ END_FUNCTION ******************** *) FUNCTION DINT_TO_LREAL : LREAL VAR_INPUT - in : DINT; + in : DINT; END_VAR - DINT_TO_LREAL := in; + DINT_TO_LREAL := in; END_FUNCTION (******************** @@ -2753,9 +2753,9 @@ END_FUNCTION ******************** *) FUNCTION DINT_TO_REAL : REAL VAR_INPUT - in : DINT; + in : DINT; END_VAR - DINT_TO_REAL := in; + DINT_TO_REAL := in; END_FUNCTION (******************** @@ -2765,9 +2765,9 @@ END_FUNCTION ******************** *) FUNCTION DINT_TO_LINT : LINT VAR_INPUT - in : DINT; + in : DINT; END_VAR - DINT_TO_LINT := in; + DINT_TO_LINT := in; END_FUNCTION (******************** @@ -2777,9 +2777,9 @@ END_FUNCTION ******************** *) FUNCTION DINT_TO_INT : INT VAR_INPUT - in : DINT; + in : DINT; END_VAR - DINT_TO_INT := in; + DINT_TO_INT := in; END_FUNCTION (******************** @@ -2789,9 +2789,9 @@ END_FUNCTION ******************** *) FUNCTION DINT_TO_SINT : SINT VAR_INPUT - in : DINT; + in : DINT; END_VAR - DINT_TO_SINT := in; + DINT_TO_SINT := in; END_FUNCTION (******************** @@ -2801,9 +2801,9 @@ END_FUNCTION ******************** *) FUNCTION DINT_TO_ULINT : ULINT VAR_INPUT - in : DINT; + in : DINT; END_VAR - DINT_TO_ULINT := in; + DINT_TO_ULINT := in; END_FUNCTION (******************** @@ -2813,9 +2813,9 @@ END_FUNCTION ******************** *) FUNCTION DINT_TO_UDINT : UDINT VAR_INPUT - in : DINT; + in : DINT; END_VAR - DINT_TO_UDINT := in; + DINT_TO_UDINT := in; END_FUNCTION (******************** @@ -2825,9 +2825,9 @@ END_FUNCTION ******************** *) FUNCTION DINT_TO_UINT : UINT VAR_INPUT - in : DINT; + in : DINT; END_VAR - DINT_TO_UINT := in; + DINT_TO_UINT := in; END_FUNCTION (******************** @@ -2837,9 +2837,9 @@ END_FUNCTION ******************** *) FUNCTION DINT_TO_USINT : USINT VAR_INPUT - in : DINT; + in : DINT; END_VAR - DINT_TO_USINT := in; + DINT_TO_USINT := in; END_FUNCTION (******************** @@ -2849,9 +2849,9 @@ END_FUNCTION ******************** *) FUNCTION INT_TO_LREAL : LREAL VAR_INPUT - in : INT; + in : INT; END_VAR - INT_TO_LREAL := in; + INT_TO_LREAL := in; END_FUNCTION (******************** @@ -2861,9 +2861,9 @@ END_FUNCTION ******************** *) FUNCTION INT_TO_REAL : REAL VAR_INPUT - in : INT; + in : INT; END_VAR - INT_TO_REAL := in; + INT_TO_REAL := in; END_FUNCTION (******************** @@ -2873,9 +2873,9 @@ END_FUNCTION ******************** *) FUNCTION INT_TO_LINT : LINT VAR_INPUT - in : INT; + in : INT; END_VAR - INT_TO_LINT := in; + INT_TO_LINT := in; END_FUNCTION (******************** @@ -2885,9 +2885,9 @@ END_FUNCTION ******************** *) FUNCTION INT_TO_DINT : DINT VAR_INPUT - in : INT; + in : INT; END_VAR - INT_TO_DINT := in; + INT_TO_DINT := in; END_FUNCTION (******************** @@ -2897,9 +2897,9 @@ END_FUNCTION ******************** *) FUNCTION INT_TO_SINT : SINT VAR_INPUT - in : INT; + in : INT; END_VAR - INT_TO_SINT := in; + INT_TO_SINT := in; END_FUNCTION (******************** @@ -2909,9 +2909,9 @@ END_FUNCTION ******************** *) FUNCTION INT_TO_ULINT : ULINT VAR_INPUT - in : INT; + in : INT; END_VAR - INT_TO_ULINT := in; + INT_TO_ULINT := in; END_FUNCTION (******************** @@ -2921,9 +2921,9 @@ END_FUNCTION ******************** *) FUNCTION INT_TO_UDINT : UDINT VAR_INPUT - in : INT; + in : INT; END_VAR - INT_TO_UDINT := in; + INT_TO_UDINT := in; END_FUNCTION (******************** @@ -2933,9 +2933,9 @@ END_FUNCTION ******************** *) FUNCTION INT_TO_UINT : UINT VAR_INPUT - in : INT; + in : INT; END_VAR - INT_TO_UINT := in; + INT_TO_UINT := in; END_FUNCTION (******************** @@ -2945,9 +2945,9 @@ END_FUNCTION ******************** *) FUNCTION INT_TO_USINT : USINT VAR_INPUT - in : INT; + in : INT; END_VAR - INT_TO_USINT := in; + INT_TO_USINT := in; END_FUNCTION (******************** @@ -2957,9 +2957,9 @@ END_FUNCTION ******************** *) FUNCTION SINT_TO_LREAL : LREAL VAR_INPUT - in : SINT; + in : SINT; END_VAR - SINT_TO_LREAL := in; + SINT_TO_LREAL := in; END_FUNCTION (******************** @@ -2969,9 +2969,9 @@ END_FUNCTION ******************** *) FUNCTION SINT_TO_REAL : REAL VAR_INPUT - in : SINT; + in : SINT; END_VAR - SINT_TO_REAL := in; + SINT_TO_REAL := in; END_FUNCTION (******************** @@ -2981,9 +2981,9 @@ END_FUNCTION ******************** *) FUNCTION SINT_TO_LINT : LINT VAR_INPUT - in : SINT; + in : SINT; END_VAR - SINT_TO_LINT := in; + SINT_TO_LINT := in; END_FUNCTION (******************** @@ -2993,9 +2993,9 @@ END_FUNCTION ******************** *) FUNCTION SINT_TO_DINT : DINT VAR_INPUT - in : SINT; + in : SINT; END_VAR - SINT_TO_DINT := in; + SINT_TO_DINT := in; END_FUNCTION (******************** @@ -3005,9 +3005,9 @@ END_FUNCTION ******************** *) FUNCTION SINT_TO_INT : INT VAR_INPUT - in : SINT; + in : SINT; END_VAR - SINT_TO_INT := in; + SINT_TO_INT := in; END_FUNCTION (******************** @@ -3017,9 +3017,9 @@ END_FUNCTION ******************** *) FUNCTION SINT_TO_ULINT : ULINT VAR_INPUT - in : SINT; + in : SINT; END_VAR - SINT_TO_ULINT := in; + SINT_TO_ULINT := in; END_FUNCTION (******************** @@ -3029,9 +3029,9 @@ END_FUNCTION ******************** *) FUNCTION SINT_TO_UDINT : UDINT VAR_INPUT - in : SINT; + in : SINT; END_VAR - SINT_TO_UDINT := in; + SINT_TO_UDINT := in; END_FUNCTION (******************** @@ -3041,9 +3041,9 @@ END_FUNCTION ******************** *) FUNCTION SINT_TO_UINT : UINT VAR_INPUT - in : SINT; + in : SINT; END_VAR - SINT_TO_UINT := in; + SINT_TO_UINT := in; END_FUNCTION (******************** @@ -3053,9 +3053,9 @@ END_FUNCTION ******************** *) FUNCTION SINT_TO_USINT : USINT VAR_INPUT - in : SINT; + in : SINT; END_VAR - SINT_TO_USINT := in; + SINT_TO_USINT := in; END_FUNCTION (******************** @@ -3065,9 +3065,9 @@ END_FUNCTION ******************** *) FUNCTION ULINT_TO_LREAL : LREAL VAR_INPUT - in : ULINT; + in : ULINT; END_VAR - ULINT_TO_LREAL := in; + ULINT_TO_LREAL := in; END_FUNCTION (******************** @@ -3077,9 +3077,9 @@ END_FUNCTION ******************** *) FUNCTION ULINT_TO_REAL : REAL VAR_INPUT - in : ULINT; + in : ULINT; END_VAR - ULINT_TO_REAL := in; + ULINT_TO_REAL := in; END_FUNCTION (******************** @@ -3089,9 +3089,9 @@ END_FUNCTION ******************** *) FUNCTION ULINT_TO_LINT : LINT VAR_INPUT - in : ULINT; + in : ULINT; END_VAR - ULINT_TO_LINT := in; + ULINT_TO_LINT := in; END_FUNCTION (******************** @@ -3101,9 +3101,9 @@ END_FUNCTION ******************** *) FUNCTION ULINT_TO_DINT : DINT VAR_INPUT - in : ULINT; + in : ULINT; END_VAR - ULINT_TO_DINT := in; + ULINT_TO_DINT := in; END_FUNCTION (******************** @@ -3113,9 +3113,9 @@ END_FUNCTION ******************** *) FUNCTION ULINT_TO_INT : INT VAR_INPUT - in : ULINT; + in : ULINT; END_VAR - ULINT_TO_INT := in; + ULINT_TO_INT := in; END_FUNCTION (******************** @@ -3125,9 +3125,9 @@ END_FUNCTION ******************** *) FUNCTION ULINT_TO_SINT : SINT VAR_INPUT - in : ULINT; + in : ULINT; END_VAR - ULINT_TO_SINT := in; + ULINT_TO_SINT := in; END_FUNCTION (******************** @@ -3137,9 +3137,9 @@ END_FUNCTION ******************** *) FUNCTION ULINT_TO_UDINT : UDINT VAR_INPUT - in : ULINT; + in : ULINT; END_VAR - ULINT_TO_UDINT := in; + ULINT_TO_UDINT := in; END_FUNCTION (******************** @@ -3149,9 +3149,9 @@ END_FUNCTION ******************** *) FUNCTION ULINT_TO_UINT : UINT VAR_INPUT - in : ULINT; + in : ULINT; END_VAR - ULINT_TO_UINT := in; + ULINT_TO_UINT := in; END_FUNCTION (******************** @@ -3161,9 +3161,9 @@ END_FUNCTION ******************** *) FUNCTION ULINT_TO_USINT : USINT VAR_INPUT - in : ULINT; + in : ULINT; END_VAR - ULINT_TO_USINT := in; + ULINT_TO_USINT := in; END_FUNCTION (******************** @@ -3173,9 +3173,9 @@ END_FUNCTION ******************** *) FUNCTION UDINT_TO_LREAL : LREAL VAR_INPUT - in : UDINT; + in : UDINT; END_VAR - UDINT_TO_LREAL := in; + UDINT_TO_LREAL := in; END_FUNCTION (******************** @@ -3185,9 +3185,9 @@ END_FUNCTION ******************** *) FUNCTION UDINT_TO_REAL : REAL VAR_INPUT - in : UDINT; + in : UDINT; END_VAR - UDINT_TO_REAL := in; + UDINT_TO_REAL := in; END_FUNCTION (******************** @@ -3197,9 +3197,9 @@ END_FUNCTION ******************** *) FUNCTION UDINT_TO_LINT : LINT VAR_INPUT - in : UDINT; + in : UDINT; END_VAR - UDINT_TO_LINT := in; + UDINT_TO_LINT := in; END_FUNCTION (******************** @@ -3209,9 +3209,9 @@ END_FUNCTION ******************** *) FUNCTION UDINT_TO_DINT : DINT VAR_INPUT - in : UDINT; + in : UDINT; END_VAR - UDINT_TO_DINT := in; + UDINT_TO_DINT := in; END_FUNCTION (******************** @@ -3221,9 +3221,9 @@ END_FUNCTION ******************** *) FUNCTION UDINT_TO_INT : INT VAR_INPUT - in : UDINT; + in : UDINT; END_VAR - UDINT_TO_INT := in; + UDINT_TO_INT := in; END_FUNCTION (******************** @@ -3233,9 +3233,9 @@ END_FUNCTION ******************** *) FUNCTION UDINT_TO_SINT : SINT VAR_INPUT - in : UDINT; + in : UDINT; END_VAR - UDINT_TO_SINT := in; + UDINT_TO_SINT := in; END_FUNCTION (******************** @@ -3245,9 +3245,9 @@ END_FUNCTION ******************** *) FUNCTION UDINT_TO_ULINT : ULINT VAR_INPUT - in : UDINT; + in : UDINT; END_VAR - UDINT_TO_ULINT := in; + UDINT_TO_ULINT := in; END_FUNCTION (******************** @@ -3257,9 +3257,9 @@ END_FUNCTION ******************** *) FUNCTION UDINT_TO_UINT : UINT VAR_INPUT - in : UDINT; + in : UDINT; END_VAR - UDINT_TO_UINT := in; + UDINT_TO_UINT := in; END_FUNCTION (******************** @@ -3269,9 +3269,9 @@ END_FUNCTION ******************** *) FUNCTION UDINT_TO_USINT : USINT VAR_INPUT - in : UDINT; + in : UDINT; END_VAR - UDINT_TO_USINT := in; + UDINT_TO_USINT := in; END_FUNCTION (******************** @@ -3281,9 +3281,9 @@ END_FUNCTION ******************** *) FUNCTION UINT_TO_LREAL : LREAL VAR_INPUT - in : UINT; + in : UINT; END_VAR - UINT_TO_LREAL := in; + UINT_TO_LREAL := in; END_FUNCTION (******************** @@ -3293,9 +3293,9 @@ END_FUNCTION ******************** *) FUNCTION UINT_TO_REAL : REAL VAR_INPUT - in : UINT; + in : UINT; END_VAR - UINT_TO_REAL := in; + UINT_TO_REAL := in; END_FUNCTION (******************** @@ -3305,9 +3305,9 @@ END_FUNCTION ******************** *) FUNCTION UINT_TO_LINT : LINT VAR_INPUT - in : UINT; + in : UINT; END_VAR - UINT_TO_LINT := in; + UINT_TO_LINT := in; END_FUNCTION (******************** @@ -3317,9 +3317,9 @@ END_FUNCTION ******************** *) FUNCTION UINT_TO_DINT : DINT VAR_INPUT - in : UINT; + in : UINT; END_VAR - UINT_TO_DINT := in; + UINT_TO_DINT := in; END_FUNCTION (******************** @@ -3329,9 +3329,9 @@ END_FUNCTION ******************** *) FUNCTION UINT_TO_INT : INT VAR_INPUT - in : UINT; + in : UINT; END_VAR - UINT_TO_INT := in; + UINT_TO_INT := in; END_FUNCTION (******************** @@ -3341,9 +3341,9 @@ END_FUNCTION ******************** *) FUNCTION UINT_TO_SINT : SINT VAR_INPUT - in : UINT; + in : UINT; END_VAR - UINT_TO_SINT := in; + UINT_TO_SINT := in; END_FUNCTION (******************** @@ -3353,9 +3353,9 @@ END_FUNCTION ******************** *) FUNCTION UINT_TO_ULINT : ULINT VAR_INPUT - in : UINT; + in : UINT; END_VAR - UINT_TO_ULINT := in; + UINT_TO_ULINT := in; END_FUNCTION (******************** @@ -3365,9 +3365,9 @@ END_FUNCTION ******************** *) FUNCTION UINT_TO_UDINT : UDINT VAR_INPUT - in : UINT; + in : UINT; END_VAR - UINT_TO_UDINT := in; + UINT_TO_UDINT := in; END_FUNCTION (******************** @@ -3377,9 +3377,9 @@ END_FUNCTION ******************** *) FUNCTION UINT_TO_USINT : USINT VAR_INPUT - in : UINT; + in : UINT; END_VAR - UINT_TO_USINT := in; + UINT_TO_USINT := in; END_FUNCTION (******************** @@ -3389,9 +3389,9 @@ END_FUNCTION ******************** *) FUNCTION USINT_TO_LREAL : LREAL VAR_INPUT - in : USINT; + in : USINT; END_VAR - USINT_TO_LREAL := in; + USINT_TO_LREAL := in; END_FUNCTION (******************** @@ -3401,9 +3401,9 @@ END_FUNCTION ******************** *) FUNCTION USINT_TO_REAL : REAL VAR_INPUT - in : USINT; + in : USINT; END_VAR - USINT_TO_REAL := in; + USINT_TO_REAL := in; END_FUNCTION (******************** @@ -3413,9 +3413,9 @@ END_FUNCTION ******************** *) FUNCTION USINT_TO_LINT : LINT VAR_INPUT - in : USINT; + in : USINT; END_VAR - USINT_TO_LINT := in; + USINT_TO_LINT := in; END_FUNCTION (******************** @@ -3425,9 +3425,9 @@ END_FUNCTION ******************** *) FUNCTION USINT_TO_DINT : DINT VAR_INPUT - in : USINT; + in : USINT; END_VAR - USINT_TO_DINT := in; + USINT_TO_DINT := in; END_FUNCTION (******************** @@ -3437,9 +3437,9 @@ END_FUNCTION ******************** *) FUNCTION USINT_TO_INT : INT VAR_INPUT - in : USINT; + in : USINT; END_VAR - USINT_TO_INT := in; + USINT_TO_INT := in; END_FUNCTION (******************** @@ -3449,9 +3449,9 @@ END_FUNCTION ******************** *) FUNCTION USINT_TO_SINT : SINT VAR_INPUT - in : USINT; + in : USINT; END_VAR - USINT_TO_SINT := in; + USINT_TO_SINT := in; END_FUNCTION (******************** @@ -3461,9 +3461,9 @@ END_FUNCTION ******************** *) FUNCTION USINT_TO_ULINT : ULINT VAR_INPUT - in : USINT; + in : USINT; END_VAR - USINT_TO_ULINT := in; + USINT_TO_ULINT := in; END_FUNCTION (******************** @@ -3473,9 +3473,9 @@ END_FUNCTION ******************** *) FUNCTION USINT_TO_UDINT : UDINT VAR_INPUT - in : USINT; + in : USINT; END_VAR - USINT_TO_UDINT := in; + USINT_TO_UDINT := in; END_FUNCTION (******************** @@ -3485,9 +3485,9 @@ END_FUNCTION ******************** *) FUNCTION USINT_TO_UINT : UINT VAR_INPUT - in : USINT; + in : USINT; END_VAR - USINT_TO_UINT := in; + USINT_TO_UINT := in; END_FUNCTION (* ***************************************************************************** Description: Rising Edge detection Input: @@ -3499,13 +3499,13 @@ Return: Output variable are used for return. {external} FUNCTION_BLOCK R_TRIG VAR_INPUT - CLK : BOOL; + CLK : BOOL; END_VAR VAR_OUTPUT - Q : BOOL; + Q : BOOL; END_VAR VAR - M : BOOL; + M : BOOL; END_VAR END_FUNCTION_BLOCK @@ -3520,13 +3520,13 @@ Return: Output variable is used for return. {external} FUNCTION_BLOCK F_TRIG VAR_INPUT - CLK : BOOL; + CLK : BOOL; END_VAR VAR_OUTPUT - Q : BOOL; + Q : BOOL; END_VAR VAR - M : BOOL; + M : BOOL; END_VAR END_FUNCTION_BLOCK (* ***************************************************************************** * @@ -4639,16 +4639,16 @@ Return: Output is used as return value {external} FUNCTION_BLOCK CTU VAR_INPUT - CU : BOOL; - R : BOOL; - PV : INT; + CU : BOOL; + R : BOOL; + PV : INT; END_VAR VAR_OUTPUT - Q : BOOL; - CV : INT; + Q : BOOL; + CV : INT; END_VAR VAR - M : BOOL; + M : BOOL; END_VAR END_FUNCTION_BLOCK @@ -4666,16 +4666,16 @@ Return: Output is used as return value {external} FUNCTION_BLOCK CTU_INT VAR_INPUT - CU : BOOL; - R : BOOL; - PV : INT; + CU : BOOL; + R : BOOL; + PV : INT; END_VAR VAR_OUTPUT - Q : BOOL; - CV : INT; + Q : BOOL; + CV : INT; END_VAR VAR - M : BOOL; + M : BOOL; END_VAR END_FUNCTION_BLOCK @@ -4693,16 +4693,16 @@ Return: Output is used as return value {external} FUNCTION_BLOCK CTU_DINT VAR_INPUT - CU : BOOL; - R : BOOL; - PV : DINT; + CU : BOOL; + R : BOOL; + PV : DINT; END_VAR VAR_OUTPUT - Q : BOOL; - CV : DINT; + Q : BOOL; + CV : DINT; END_VAR VAR - M : BOOL; + M : BOOL; END_VAR END_FUNCTION_BLOCK @@ -4720,16 +4720,16 @@ Return: Output is used as return value {external} FUNCTION_BLOCK CTU_UDINT VAR_INPUT - CU : BOOL; - R : BOOL; - PV : UDINT; + CU : BOOL; + R : BOOL; + PV : UDINT; END_VAR VAR_OUTPUT - Q : BOOL; - CV : UDINT; + Q : BOOL; + CV : UDINT; END_VAR VAR - M : BOOL; + M : BOOL; END_VAR END_FUNCTION_BLOCK @@ -4747,16 +4747,16 @@ Return: Output is used as return value {external} FUNCTION_BLOCK CTU_LINT VAR_INPUT - CU : BOOL; - R : BOOL; - PV : LINT; + CU : BOOL; + R : BOOL; + PV : LINT; END_VAR VAR_OUTPUT - Q : BOOL; - CV : LINT; + Q : BOOL; + CV : LINT; END_VAR VAR - M : BOOL; + M : BOOL; END_VAR END_FUNCTION_BLOCK @@ -4774,16 +4774,16 @@ Return: Output is used as return value {external} FUNCTION_BLOCK CTU_ULINT VAR_INPUT - CU : BOOL; - R : BOOL; - PV : ULINT; + CU : BOOL; + R : BOOL; + PV : ULINT; END_VAR VAR_OUTPUT - Q : BOOL; - CV : ULINT; + Q : BOOL; + CV : ULINT; END_VAR VAR - M : BOOL; + M : BOOL; END_VAR END_FUNCTION_BLOCK @@ -4801,16 +4801,16 @@ Return: Output is used as return value {external} FUNCTION_BLOCK CTD VAR_INPUT - CD : BOOL; - LD : BOOL; - PV : INT; + CD : BOOL; + LD : BOOL; + PV : INT; END_VAR VAR_OUTPUT - Q : BOOL; - CV : INT; + Q : BOOL; + CV : INT; END_VAR VAR - M : BOOL; + M : BOOL; END_VAR END_FUNCTION_BLOCK @@ -4828,16 +4828,16 @@ Return: Output is used as return value {external} FUNCTION_BLOCK CTD_INT VAR_INPUT - CD : BOOL; - LD : BOOL; - PV : INT; + CD : BOOL; + LD : BOOL; + PV : INT; END_VAR VAR_OUTPUT - Q : BOOL; - CV : INT; + Q : BOOL; + CV : INT; END_VAR VAR - M : BOOL; + M : BOOL; END_VAR END_FUNCTION_BLOCK @@ -4855,16 +4855,16 @@ Return: Output is used as return value {external} FUNCTION_BLOCK CTD_DINT VAR_INPUT - CD : BOOL; - LD : BOOL; - PV : DINT; + CD : BOOL; + LD : BOOL; + PV : DINT; END_VAR VAR_OUTPUT - Q : BOOL; - CV : DINT; + Q : BOOL; + CV : DINT; END_VAR VAR - M : BOOL; + M : BOOL; END_VAR END_FUNCTION_BLOCK @@ -4882,16 +4882,16 @@ Return: Output is used as return value {external} FUNCTION_BLOCK CTD_UDINT VAR_INPUT - CD : BOOL; - LD : BOOL; - PV : UDINT; + CD : BOOL; + LD : BOOL; + PV : UDINT; END_VAR VAR_OUTPUT - Q : BOOL; - CV : UDINT; + Q : BOOL; + CV : UDINT; END_VAR VAR - M : BOOL; + M : BOOL; END_VAR END_FUNCTION_BLOCK @@ -4909,16 +4909,16 @@ Return: Output is used as return value {external} FUNCTION_BLOCK CTD_LINT VAR_INPUT - CD : BOOL; - LD : BOOL; - PV : LINT; + CD : BOOL; + LD : BOOL; + PV : LINT; END_VAR VAR_OUTPUT - Q : BOOL; - CV : LINT; + Q : BOOL; + CV : LINT; END_VAR VAR - M : BOOL; + M : BOOL; END_VAR END_FUNCTION_BLOCK @@ -4936,16 +4936,16 @@ Return: Output is used as return value {external} FUNCTION_BLOCK CTD_ULINT VAR_INPUT - CD : BOOL; - LD : BOOL; - PV : ULINT; + CD : BOOL; + LD : BOOL; + PV : ULINT; END_VAR VAR_OUTPUT - Q : BOOL; - CV : ULINT; + Q : BOOL; + CV : ULINT; END_VAR VAR - M : BOOL; + M : BOOL; END_VAR END_FUNCTION_BLOCK @@ -4966,20 +4966,20 @@ Return: Output is used as return value {external} FUNCTION_BLOCK CTUD VAR_INPUT - CU : BOOL; - CD : BOOL; - R : BOOL; - LD : BOOL; - PV : INT; + CU : BOOL; + CD : BOOL; + R : BOOL; + LD : BOOL; + PV : INT; END_VAR VAR_OUTPUT - QU : BOOL; - QD : BOOL; - CV : INT; + QU : BOOL; + QD : BOOL; + CV : INT; END_VAR VAR - MU : BOOL; - MD : BOOL; + MU : BOOL; + MD : BOOL; END_VAR END_FUNCTION_BLOCK @@ -5000,20 +5000,20 @@ Return: Output is used as return value {external} FUNCTION_BLOCK CTUD_INT VAR_INPUT - CU : BOOL; - CD : BOOL; - R : BOOL; - LD : BOOL; - PV : INT; + CU : BOOL; + CD : BOOL; + R : BOOL; + LD : BOOL; + PV : INT; END_VAR VAR_OUTPUT - QU : BOOL; - QD : BOOL; - CV : INT; + QU : BOOL; + QD : BOOL; + CV : INT; END_VAR VAR - MU : BOOL; - MD : BOOL; + MU : BOOL; + MD : BOOL; END_VAR END_FUNCTION_BLOCK @@ -5034,20 +5034,20 @@ Return: Output is used as return value {external} FUNCTION_BLOCK CTUD_DINT VAR_INPUT - CU : BOOL; - CD : BOOL; - R : BOOL; - LD : BOOL; - PV : DINT; + CU : BOOL; + CD : BOOL; + R : BOOL; + LD : BOOL; + PV : DINT; END_VAR VAR_OUTPUT - QU : BOOL; - QD : BOOL; - CV : DINT; + QU : BOOL; + QD : BOOL; + CV : DINT; END_VAR VAR - MU : BOOL; - MD : BOOL; + MU : BOOL; + MD : BOOL; END_VAR END_FUNCTION_BLOCK @@ -5068,20 +5068,20 @@ Return: Output is used as return value {external} FUNCTION_BLOCK CTUD_UDINT VAR_INPUT - CU : BOOL; - CD : BOOL; - R : BOOL; - LD : BOOL; - PV : UDINT; + CU : BOOL; + CD : BOOL; + R : BOOL; + LD : BOOL; + PV : UDINT; END_VAR VAR_OUTPUT - QU : BOOL; - QD : BOOL; - CV : UDINT; + QU : BOOL; + QD : BOOL; + CV : UDINT; END_VAR VAR - MU : BOOL; - MD : BOOL; + MU : BOOL; + MD : BOOL; END_VAR END_FUNCTION_BLOCK @@ -5102,20 +5102,20 @@ Return: Output is used as return value {external} FUNCTION_BLOCK CTUD_LINT VAR_INPUT - CU : BOOL; - CD : BOOL; - R : BOOL; - LD : BOOL; - PV : LINT; + CU : BOOL; + CD : BOOL; + R : BOOL; + LD : BOOL; + PV : LINT; END_VAR VAR_OUTPUT - QU : BOOL; - QD : BOOL; - CV : LINT; + QU : BOOL; + QD : BOOL; + CV : LINT; END_VAR VAR - MU : BOOL; - MD : BOOL; + MU : BOOL; + MD : BOOL; END_VAR END_FUNCTION_BLOCK @@ -5136,20 +5136,20 @@ Return: Output is used as return value {external} FUNCTION_BLOCK CTUD_ULINT VAR_INPUT - CU : BOOL; - CD : BOOL; - R : BOOL; - LD : BOOL; - PV : ULINT; + CU : BOOL; + CD : BOOL; + R : BOOL; + LD : BOOL; + PV : ULINT; END_VAR VAR_OUTPUT - QU : BOOL; - QD : BOOL; - CV : ULINT; + QU : BOOL; + QD : BOOL; + CV : ULINT; END_VAR VAR - MU : BOOL; - MD : BOOL; + MU : BOOL; + MD : BOOL; END_VAR END_FUNCTION_BLOCK (* ******************* * @@ -5159,7 +5159,7 @@ END_FUNCTION_BLOCK (* ******************* {external} FUNCTION TO_BIG_ENDIAN < T : ANY > : T VAR_INPUT - in : T; + in : T; END_VAR END_FUNCTION @@ -5171,7 +5171,7 @@ END_FUNCTION {external} FUNCTION TO_LITTLE_ENDIAN < T : ANY > : T VAR_INPUT - in : T; + in : T; END_VAR END_FUNCTION @@ -5183,7 +5183,7 @@ END_FUNCTION {external} FUNCTION FROM_BIG_ENDIAN < T : ANY > : T VAR_INPUT - in : T; + in : T; END_VAR END_FUNCTION @@ -5195,7 +5195,7 @@ END_FUNCTION {external} FUNCTION FROM_LITTLE_ENDIAN < T : ANY > : T VAR_INPUT - in : T; + in : T; END_VAR END_FUNCTION @@ -5207,7 +5207,7 @@ END_FUNCTION {external} FUNCTION LWORD_TO_LREAL : LREAL VAR_INPUT - in : LWORD; + in : LWORD; END_VAR END_FUNCTION @@ -5218,9 +5218,9 @@ END_FUNCTION ******************** *) FUNCTION LWORD_TO_LINT : LINT VAR_INPUT - in : LWORD; + in : LWORD; END_VAR - LWORD_TO_LINT := in; + LWORD_TO_LINT := in; END_FUNCTION (******************** @@ -5230,9 +5230,9 @@ END_FUNCTION ******************** *) FUNCTION LWORD_TO_DINT : DINT VAR_INPUT - in : LWORD; + in : LWORD; END_VAR - LWORD_TO_DINT := in; + LWORD_TO_DINT := in; END_FUNCTION (******************** @@ -5242,9 +5242,9 @@ END_FUNCTION ******************** *) FUNCTION LWORD_TO_INT : INT VAR_INPUT - in : LWORD; + in : LWORD; END_VAR - LWORD_TO_INT := in; + LWORD_TO_INT := in; END_FUNCTION (******************** @@ -5254,9 +5254,9 @@ END_FUNCTION ******************** *) FUNCTION LWORD_TO_SINT : SINT VAR_INPUT - in : LWORD; + in : LWORD; END_VAR - LWORD_TO_SINT := in; + LWORD_TO_SINT := in; END_FUNCTION (******************** @@ -5266,9 +5266,9 @@ END_FUNCTION ******************** *) FUNCTION LWORD_TO_ULINT : ULINT VAR_INPUT - in : LWORD; + in : LWORD; END_VAR - LWORD_TO_ULINT := in; + LWORD_TO_ULINT := in; END_FUNCTION (******************** @@ -5278,9 +5278,9 @@ END_FUNCTION ******************** *) FUNCTION LWORD_TO_UDINT : UDINT VAR_INPUT - in : LWORD; + in : LWORD; END_VAR - LWORD_TO_UDINT := in; + LWORD_TO_UDINT := in; END_FUNCTION (******************** @@ -5290,9 +5290,9 @@ END_FUNCTION ******************** *) FUNCTION LWORD_TO_UINT : UINT VAR_INPUT - in : LWORD; + in : LWORD; END_VAR - LWORD_TO_UINT := in; + LWORD_TO_UINT := in; END_FUNCTION (******************** @@ -5302,9 +5302,9 @@ END_FUNCTION ******************** *) FUNCTION LWORD_TO_USINT : USINT VAR_INPUT - in : LWORD; + in : LWORD; END_VAR - LWORD_TO_USINT := in; + LWORD_TO_USINT := in; END_FUNCTION (******************** @@ -5315,7 +5315,7 @@ END_FUNCTION {external} FUNCTION DWORD_TO_REAL : REAL VAR_INPUT - in : DWORD; + in : DWORD; END_VAR END_FUNCTION @@ -5326,9 +5326,9 @@ END_FUNCTION ******************** *) FUNCTION DWORD_TO_LINT : LINT VAR_INPUT - in : DWORD; + in : DWORD; END_VAR - DWORD_TO_LINT := in; + DWORD_TO_LINT := in; END_FUNCTION (******************** @@ -5338,9 +5338,9 @@ END_FUNCTION ******************** *) FUNCTION DWORD_TO_DINT : DINT VAR_INPUT - in : DWORD; + in : DWORD; END_VAR - DWORD_TO_DINT := in; + DWORD_TO_DINT := in; END_FUNCTION (******************** @@ -5350,9 +5350,9 @@ END_FUNCTION ******************** *) FUNCTION DWORD_TO_INT : INT VAR_INPUT - in : DWORD; + in : DWORD; END_VAR - DWORD_TO_INT := in; + DWORD_TO_INT := in; END_FUNCTION (******************** @@ -5362,9 +5362,9 @@ END_FUNCTION ******************** *) FUNCTION DWORD_TO_SINT : SINT VAR_INPUT - in : DWORD; + in : DWORD; END_VAR - DWORD_TO_SINT := in; + DWORD_TO_SINT := in; END_FUNCTION (******************** @@ -5374,9 +5374,9 @@ END_FUNCTION ******************** *) FUNCTION DWORD_TO_ULINT : ULINT VAR_INPUT - in : DWORD; + in : DWORD; END_VAR - DWORD_TO_ULINT := in; + DWORD_TO_ULINT := in; END_FUNCTION (******************** @@ -5386,9 +5386,9 @@ END_FUNCTION ******************** *) FUNCTION DWORD_TO_UDINT : UDINT VAR_INPUT - in : DWORD; + in : DWORD; END_VAR - DWORD_TO_UDINT := in; + DWORD_TO_UDINT := in; END_FUNCTION (******************** @@ -5398,9 +5398,9 @@ END_FUNCTION ******************** *) FUNCTION DWORD_TO_UINT : UINT VAR_INPUT - in : DWORD; + in : DWORD; END_VAR - DWORD_TO_UINT := in; + DWORD_TO_UINT := in; END_FUNCTION (******************** @@ -5410,9 +5410,9 @@ END_FUNCTION ******************** *) FUNCTION DWORD_TO_USINT : USINT VAR_INPUT - in : DWORD; + in : DWORD; END_VAR - DWORD_TO_USINT := in; + DWORD_TO_USINT := in; END_FUNCTION (******************** @@ -5422,9 +5422,9 @@ END_FUNCTION ******************** *) FUNCTION WORD_TO_LINT : LINT VAR_INPUT - in : WORD; + in : WORD; END_VAR - WORD_TO_LINT := in; + WORD_TO_LINT := in; END_FUNCTION (******************** @@ -5434,9 +5434,9 @@ END_FUNCTION ******************** *) FUNCTION WORD_TO_DINT : DINT VAR_INPUT - in : WORD; + in : WORD; END_VAR - WORD_TO_DINT := in; + WORD_TO_DINT := in; END_FUNCTION (******************** @@ -5446,9 +5446,9 @@ END_FUNCTION ******************** *) FUNCTION WORD_TO_INT : INT VAR_INPUT - in : WORD; + in : WORD; END_VAR - WORD_TO_INT := in; + WORD_TO_INT := in; END_FUNCTION (******************** @@ -5458,9 +5458,9 @@ END_FUNCTION ******************** *) FUNCTION WORD_TO_SINT : SINT VAR_INPUT - in : WORD; + in : WORD; END_VAR - WORD_TO_SINT := in; + WORD_TO_SINT := in; END_FUNCTION (******************** @@ -5470,9 +5470,9 @@ END_FUNCTION ******************** *) FUNCTION WORD_TO_ULINT : ULINT VAR_INPUT - in : WORD; + in : WORD; END_VAR - WORD_TO_ULINT := in; + WORD_TO_ULINT := in; END_FUNCTION (******************** @@ -5482,9 +5482,9 @@ END_FUNCTION ******************** *) FUNCTION WORD_TO_UDINT : UDINT VAR_INPUT - in : WORD; + in : WORD; END_VAR - WORD_TO_UDINT := in; + WORD_TO_UDINT := in; END_FUNCTION (******************** @@ -5494,9 +5494,9 @@ END_FUNCTION ******************** *) FUNCTION WORD_TO_UINT : UINT VAR_INPUT - in : WORD; + in : WORD; END_VAR - WORD_TO_UINT := in; + WORD_TO_UINT := in; END_FUNCTION (******************** @@ -5506,9 +5506,9 @@ END_FUNCTION ******************** *) FUNCTION WORD_TO_USINT : USINT VAR_INPUT - in : WORD; + in : WORD; END_VAR - WORD_TO_USINT := in; + WORD_TO_USINT := in; END_FUNCTION (******************** @@ -5518,9 +5518,9 @@ END_FUNCTION ******************** *) FUNCTION BYTE_TO_LINT : LINT VAR_INPUT - in : BYTE; + in : BYTE; END_VAR - BYTE_TO_LINT := in; + BYTE_TO_LINT := in; END_FUNCTION (******************** @@ -5530,9 +5530,9 @@ END_FUNCTION ******************** *) FUNCTION BYTE_TO_DINT : DINT VAR_INPUT - in : BYTE; + in : BYTE; END_VAR - BYTE_TO_DINT := in; + BYTE_TO_DINT := in; END_FUNCTION (******************** @@ -5542,9 +5542,9 @@ END_FUNCTION ******************** *) FUNCTION BYTE_TO_INT : INT VAR_INPUT - in : BYTE; + in : BYTE; END_VAR - BYTE_TO_INT := in; + BYTE_TO_INT := in; END_FUNCTION (******************** @@ -5554,9 +5554,9 @@ END_FUNCTION ******************** *) FUNCTION BYTE_TO_SINT : SINT VAR_INPUT - in : BYTE; + in : BYTE; END_VAR - BYTE_TO_SINT := in; + BYTE_TO_SINT := in; END_FUNCTION (******************** @@ -5566,9 +5566,9 @@ END_FUNCTION ******************** *) FUNCTION BYTE_TO_ULINT : ULINT VAR_INPUT - in : BYTE; + in : BYTE; END_VAR - BYTE_TO_ULINT := in; + BYTE_TO_ULINT := in; END_FUNCTION (******************** @@ -5578,9 +5578,9 @@ END_FUNCTION ******************** *) FUNCTION BYTE_TO_UDINT : UDINT VAR_INPUT - in : BYTE; + in : BYTE; END_VAR - BYTE_TO_UDINT := in; + BYTE_TO_UDINT := in; END_FUNCTION (******************** @@ -5590,9 +5590,9 @@ END_FUNCTION ******************** *) FUNCTION BYTE_TO_UINT : UINT VAR_INPUT - in : BYTE; + in : BYTE; END_VAR - BYTE_TO_UINT := in; + BYTE_TO_UINT := in; END_FUNCTION (******************** @@ -5602,9 +5602,9 @@ END_FUNCTION ******************** *) FUNCTION BYTE_TO_USINT : USINT VAR_INPUT - in : BYTE; + in : BYTE; END_VAR - BYTE_TO_USINT := in; + BYTE_TO_USINT := in; END_FUNCTION (******************** @@ -5614,9 +5614,9 @@ END_FUNCTION ******************** *) FUNCTION BOOL_TO_LINT : LINT VAR_INPUT - in : BOOL; + in : BOOL; END_VAR - BOOL_TO_LINT := in; + BOOL_TO_LINT := in; END_FUNCTION (******************** @@ -5626,9 +5626,9 @@ END_FUNCTION ******************** *) FUNCTION BOOL_TO_DINT : DINT VAR_INPUT - in : BOOL; + in : BOOL; END_VAR - BOOL_TO_DINT := in; + BOOL_TO_DINT := in; END_FUNCTION (******************** @@ -5638,9 +5638,9 @@ END_FUNCTION ******************** *) FUNCTION BOOL_TO_INT : INT VAR_INPUT - in : BOOL; + in : BOOL; END_VAR - BOOL_TO_INT := in; + BOOL_TO_INT := in; END_FUNCTION (******************** @@ -5650,9 +5650,9 @@ END_FUNCTION ******************** *) FUNCTION BOOL_TO_SINT : SINT VAR_INPUT - in : BOOL; + in : BOOL; END_VAR - BOOL_TO_SINT := in; + BOOL_TO_SINT := in; END_FUNCTION (******************** @@ -5662,9 +5662,9 @@ END_FUNCTION ******************** *) FUNCTION BOOL_TO_ULINT : ULINT VAR_INPUT - in : BOOL; + in : BOOL; END_VAR - BOOL_TO_ULINT := in; + BOOL_TO_ULINT := in; END_FUNCTION (******************** @@ -5674,9 +5674,9 @@ END_FUNCTION ******************** *) FUNCTION BOOL_TO_UDINT : UDINT VAR_INPUT - in : BOOL; + in : BOOL; END_VAR - BOOL_TO_UDINT := in; + BOOL_TO_UDINT := in; END_FUNCTION (******************** @@ -5686,9 +5686,9 @@ END_FUNCTION ******************** *) FUNCTION BOOL_TO_UINT : UINT VAR_INPUT - in : BOOL; + in : BOOL; END_VAR - BOOL_TO_UINT := in; + BOOL_TO_UINT := in; END_FUNCTION (******************** @@ -5698,9 +5698,9 @@ END_FUNCTION ******************** *) FUNCTION BOOL_TO_USINT : USINT VAR_INPUT - in : BOOL; + in : BOOL; END_VAR - BOOL_TO_USINT := in; + BOOL_TO_USINT := in; END_FUNCTION (******************** @@ -5711,7 +5711,7 @@ END_FUNCTION {external} FUNCTION LREAL_TO_LWORD : LWORD VAR_INPUT - in : LREAL; + in : LREAL; END_VAR END_FUNCTION @@ -5723,7 +5723,7 @@ END_FUNCTION {external} FUNCTION REAL_TO_DWORD : DWORD VAR_INPUT - in : REAL; + in : REAL; END_VAR END_FUNCTION @@ -5734,9 +5734,9 @@ END_FUNCTION ******************** *) FUNCTION LINT_TO_LWORD : LWORD VAR_INPUT - in : LINT; + in : LINT; END_VAR - LINT_TO_LWORD := in; + LINT_TO_LWORD := in; END_FUNCTION (******************** @@ -5746,9 +5746,9 @@ END_FUNCTION ******************** *) FUNCTION LINT_TO_DWORD : DWORD VAR_INPUT - in : LINT; + in : LINT; END_VAR - LINT_TO_DWORD := in; + LINT_TO_DWORD := in; END_FUNCTION (******************** @@ -5758,9 +5758,9 @@ END_FUNCTION ******************** *) FUNCTION LINT_TO_WORD : WORD VAR_INPUT - in : LINT; + in : LINT; END_VAR - LINT_TO_WORD := in; + LINT_TO_WORD := in; END_FUNCTION (******************** @@ -5770,9 +5770,9 @@ END_FUNCTION ******************** *) FUNCTION LINT_TO_BYTE : BYTE VAR_INPUT - in : LINT; + in : LINT; END_VAR - LINT_TO_BYTE := in; + LINT_TO_BYTE := in; END_FUNCTION (******************** @@ -5782,9 +5782,9 @@ END_FUNCTION ******************** *) FUNCTION DINT_TO_LWORD : LWORD VAR_INPUT - in : DINT; + in : DINT; END_VAR - DINT_TO_LWORD := in; + DINT_TO_LWORD := in; END_FUNCTION (******************** @@ -5794,9 +5794,9 @@ END_FUNCTION ******************** *) FUNCTION DINT_TO_DWORD : DWORD VAR_INPUT - in : DINT; + in : DINT; END_VAR - DINT_TO_DWORD := in; + DINT_TO_DWORD := in; END_FUNCTION (******************** @@ -5806,9 +5806,9 @@ END_FUNCTION ******************** *) FUNCTION DINT_TO_WORD : WORD VAR_INPUT - in : DINT; + in : DINT; END_VAR - DINT_TO_WORD := in; + DINT_TO_WORD := in; END_FUNCTION (******************** @@ -5818,9 +5818,9 @@ END_FUNCTION ******************** *) FUNCTION DINT_TO_BYTE : BYTE VAR_INPUT - in : DINT; + in : DINT; END_VAR - DINT_TO_BYTE := in; + DINT_TO_BYTE := in; END_FUNCTION (******************** @@ -5830,9 +5830,9 @@ END_FUNCTION ******************** *) FUNCTION INT_TO_LWORD : LWORD VAR_INPUT - in : INT; + in : INT; END_VAR - INT_TO_LWORD := in; + INT_TO_LWORD := in; END_FUNCTION (******************** @@ -5842,9 +5842,9 @@ END_FUNCTION ******************** *) FUNCTION INT_TO_DWORD : DWORD VAR_INPUT - in : INT; + in : INT; END_VAR - INT_TO_DWORD := in; + INT_TO_DWORD := in; END_FUNCTION (******************** @@ -5854,9 +5854,9 @@ END_FUNCTION ******************** *) FUNCTION INT_TO_WORD : WORD VAR_INPUT - in : INT; + in : INT; END_VAR - INT_TO_WORD := in; + INT_TO_WORD := in; END_FUNCTION (******************** @@ -5866,9 +5866,9 @@ END_FUNCTION ******************** *) FUNCTION INT_TO_BYTE : BYTE VAR_INPUT - in : INT; + in : INT; END_VAR - INT_TO_BYTE := in; + INT_TO_BYTE := in; END_FUNCTION (******************** @@ -5878,9 +5878,9 @@ END_FUNCTION ******************** *) FUNCTION SINT_TO_LWORD : LWORD VAR_INPUT - in : SINT; + in : SINT; END_VAR - SINT_TO_LWORD := in; + SINT_TO_LWORD := in; END_FUNCTION (******************** @@ -5890,9 +5890,9 @@ END_FUNCTION ******************** *) FUNCTION SINT_TO_DWORD : DWORD VAR_INPUT - in : SINT; + in : SINT; END_VAR - SINT_TO_DWORD := in; + SINT_TO_DWORD := in; END_FUNCTION (******************** @@ -5902,9 +5902,9 @@ END_FUNCTION ******************** *) FUNCTION SINT_TO_WORD : WORD VAR_INPUT - in : SINT; + in : SINT; END_VAR - SINT_TO_WORD := in; + SINT_TO_WORD := in; END_FUNCTION (******************** @@ -5914,9 +5914,9 @@ END_FUNCTION ******************** *) FUNCTION SINT_TO_BYTE : BYTE VAR_INPUT - in : SINT; + in : SINT; END_VAR - SINT_TO_BYTE := in; + SINT_TO_BYTE := in; END_FUNCTION (******************** @@ -5926,9 +5926,9 @@ END_FUNCTION ******************** *) FUNCTION ULINT_TO_LWORD : LWORD VAR_INPUT - in : ULINT; + in : ULINT; END_VAR - ULINT_TO_LWORD := in; + ULINT_TO_LWORD := in; END_FUNCTION (******************** @@ -5938,9 +5938,9 @@ END_FUNCTION ******************** *) FUNCTION ULINT_TO_DWORD : DWORD VAR_INPUT - in : ULINT; + in : ULINT; END_VAR - ULINT_TO_DWORD := in; + ULINT_TO_DWORD := in; END_FUNCTION (******************** @@ -5950,9 +5950,9 @@ END_FUNCTION ******************** *) FUNCTION ULINT_TO_WORD : WORD VAR_INPUT - in : ULINT; + in : ULINT; END_VAR - ULINT_TO_WORD := in; + ULINT_TO_WORD := in; END_FUNCTION (******************** @@ -5962,9 +5962,9 @@ END_FUNCTION ******************** *) FUNCTION ULINT_TO_BYTE : BYTE VAR_INPUT - in : ULINT; + in : ULINT; END_VAR - ULINT_TO_BYTE := in; + ULINT_TO_BYTE := in; END_FUNCTION (******************** @@ -5974,9 +5974,9 @@ END_FUNCTION ******************** *) FUNCTION UDINT_TO_LWORD : LWORD VAR_INPUT - in : UDINT; + in : UDINT; END_VAR - UDINT_TO_LWORD := in; + UDINT_TO_LWORD := in; END_FUNCTION (******************** @@ -5986,9 +5986,9 @@ END_FUNCTION ******************** *) FUNCTION UDINT_TO_DWORD : DWORD VAR_INPUT - in : UDINT; + in : UDINT; END_VAR - UDINT_TO_DWORD := in; + UDINT_TO_DWORD := in; END_FUNCTION (******************** @@ -5998,9 +5998,9 @@ END_FUNCTION ******************** *) FUNCTION UDINT_TO_WORD : WORD VAR_INPUT - in : UDINT; + in : UDINT; END_VAR - UDINT_TO_WORD := in; + UDINT_TO_WORD := in; END_FUNCTION (******************** @@ -6010,9 +6010,9 @@ END_FUNCTION ******************** *) FUNCTION UDINT_TO_BYTE : BYTE VAR_INPUT - in : UDINT; + in : UDINT; END_VAR - UDINT_TO_BYTE := in; + UDINT_TO_BYTE := in; END_FUNCTION (******************** @@ -6022,9 +6022,9 @@ END_FUNCTION ******************** *) FUNCTION UINT_TO_LWORD : LWORD VAR_INPUT - in : UINT; + in : UINT; END_VAR - UINT_TO_LWORD := in; + UINT_TO_LWORD := in; END_FUNCTION (******************** @@ -6034,9 +6034,9 @@ END_FUNCTION ******************** *) FUNCTION UINT_TO_DWORD : DWORD VAR_INPUT - in : UINT; + in : UINT; END_VAR - UINT_TO_DWORD := in; + UINT_TO_DWORD := in; END_FUNCTION (******************** @@ -6046,9 +6046,9 @@ END_FUNCTION ******************** *) FUNCTION UINT_TO_WORD : WORD VAR_INPUT - in : UINT; + in : UINT; END_VAR - UINT_TO_WORD := in; + UINT_TO_WORD := in; END_FUNCTION (******************** @@ -6058,9 +6058,9 @@ END_FUNCTION ******************** *) FUNCTION UINT_TO_BYTE : BYTE VAR_INPUT - in : UINT; + in : UINT; END_VAR - UINT_TO_BYTE := in; + UINT_TO_BYTE := in; END_FUNCTION (******************** @@ -6070,9 +6070,9 @@ END_FUNCTION ******************** *) FUNCTION USINT_TO_LWORD : LWORD VAR_INPUT - in : USINT; + in : USINT; END_VAR - USINT_TO_LWORD := in; + USINT_TO_LWORD := in; END_FUNCTION (******************** @@ -6082,9 +6082,9 @@ END_FUNCTION ******************** *) FUNCTION USINT_TO_DWORD : DWORD VAR_INPUT - in : USINT; + in : USINT; END_VAR - USINT_TO_DWORD := in; + USINT_TO_DWORD := in; END_FUNCTION (******************** @@ -6094,9 +6094,9 @@ END_FUNCTION ******************** *) FUNCTION USINT_TO_WORD : WORD VAR_INPUT - in : USINT; + in : USINT; END_VAR - USINT_TO_WORD := in; + USINT_TO_WORD := in; END_FUNCTION (******************** @@ -6106,9 +6106,9 @@ END_FUNCTION ******************** *) FUNCTION USINT_TO_BYTE : BYTE VAR_INPUT - in : USINT; + in : USINT; END_VAR - USINT_TO_BYTE := in; + USINT_TO_BYTE := in; END_FUNCTIONVAR_GLOBAL CONSTANT __STRING_LENGTH : DINT := 2048; END_VAR @@ -6122,7 +6122,7 @@ Return: String length {external} FUNCTION LEN < T : ANY_STRING > : DINT VAR_INPUT {ref} - IN : T; + IN : T; END_VAR END_FUNCTION @@ -6135,7 +6135,7 @@ Return: A substring consisting of the leftmost L characters of IN ***************************************************************************** *) FUNCTION LEFT < T : ANY_STRING > : T VAR_INPUT {ref} - IN : T; + IN : T; END_VAR VAR_INPUT L : DINT; @@ -6145,7 +6145,7 @@ END_FUNCTION {external} FUNCTION LEFT_EXT < T : ANY_STRING > : DINT VAR_INPUT {ref} - IN : T; + IN : T; END_VAR VAR_INPUT L : DINT; @@ -6157,7 +6157,7 @@ END_FUNCTION FUNCTION LEFT__STRING : STRING[__STRING_LENGTH] VAR_INPUT {ref} - IN : STRING[__STRING_LENGTH]; + IN : STRING[__STRING_LENGTH]; END_VAR VAR_INPUT L : DINT; @@ -6167,7 +6167,7 @@ END_FUNCTION FUNCTION LEFT__WSTRING : WSTRING[__STRING_LENGTH] VAR_INPUT {ref} - IN : WSTRING[__STRING_LENGTH]; + IN : WSTRING[__STRING_LENGTH]; END_VAR VAR_INPUT L : DINT; @@ -6178,7 +6178,7 @@ END_FUNCTION {external} FUNCTION LEFT_EXT__STRING : DINT VAR_INPUT {ref} - IN : STRING[__STRING_LENGTH]; + IN : STRING[__STRING_LENGTH]; END_VAR VAR_INPUT L : DINT; @@ -6191,7 +6191,7 @@ END_FUNCTION {external} FUNCTION LEFT_EXT__WSTRING : DINT VAR_INPUT {ref} - IN : WSTRING[__STRING_LENGTH]; + IN : WSTRING[__STRING_LENGTH]; END_VAR VAR_INPUT L : DINT; @@ -6210,7 +6210,7 @@ Return: A substring consisting of the rightmost L characters of IN ***************************************************************************** *) FUNCTION RIGHT < T : ANY_STRING > : T VAR_INPUT {ref} - IN : T; + IN : T; END_VAR VAR_INPUT L : DINT; @@ -6220,7 +6220,7 @@ END_FUNCTION {external} FUNCTION RIGHT_EXT < T : ANY_STRING > : DINT VAR_INPUT {ref} - IN : T; + IN : T; END_VAR VAR_INPUT L : DINT; @@ -6232,7 +6232,7 @@ END_FUNCTION FUNCTION RIGHT__STRING : STRING[__STRING_LENGTH] VAR_INPUT {ref} - IN : STRING[__STRING_LENGTH]; + IN : STRING[__STRING_LENGTH]; END_VAR VAR_INPUT L : DINT; @@ -6242,7 +6242,7 @@ END_FUNCTION FUNCTION RIGHT__WSTRING : WSTRING[__STRING_LENGTH] VAR_INPUT {ref} - IN : WSTRING[__STRING_LENGTH]; + IN : WSTRING[__STRING_LENGTH]; END_VAR VAR_INPUT L : DINT; @@ -6253,7 +6253,7 @@ END_FUNCTION {external} FUNCTION RIGHT_EXT__STRING : DINT VAR_INPUT {ref} - IN : STRING[__STRING_LENGTH]; + IN : STRING[__STRING_LENGTH]; END_VAR VAR_INPUT L : DINT; @@ -6266,7 +6266,7 @@ END_FUNCTION {external} FUNCTION RIGHT_EXT__WSTRING : DINT VAR_INPUT {ref} - IN : WSTRING[__STRING_LENGTH]; + IN : WSTRING[__STRING_LENGTH]; END_VAR VAR_INPUT L : DINT; @@ -6288,7 +6288,7 @@ Return: ***************************************************************************** *) FUNCTION MID < T : ANY_STRING > : T VAR_INPUT {ref} - IN : T; + IN : T; END_VAR VAR_INPUT L : DINT; @@ -6299,7 +6299,7 @@ END_FUNCTION {external} FUNCTION MID_EXT < T : ANY_STRING > : DINT VAR_INPUT {ref} - IN : T; + IN : T; END_VAR VAR_INPUT L : DINT; @@ -6312,7 +6312,7 @@ END_FUNCTION FUNCTION MID__STRING : STRING[__STRING_LENGTH] VAR_INPUT {ref} - IN : STRING[__STRING_LENGTH]; + IN : STRING[__STRING_LENGTH]; END_VAR VAR_INPUT L : DINT; @@ -6323,7 +6323,7 @@ END_FUNCTION FUNCTION MID__WSTRING : WSTRING[__STRING_LENGTH] VAR_INPUT {ref} - IN : WSTRING[__STRING_LENGTH]; + IN : WSTRING[__STRING_LENGTH]; END_VAR VAR_INPUT L : DINT; @@ -6335,7 +6335,7 @@ END_FUNCTION {external} FUNCTION MID_EXT__STRING : DINT VAR_INPUT {ref} - IN : STRING[__STRING_LENGTH]; + IN : STRING[__STRING_LENGTH]; END_VAR VAR_INPUT L : DINT; @@ -6349,7 +6349,7 @@ END_FUNCTION {external} FUNCTION MID_EXT__WSTRING : DINT VAR_INPUT {ref} - IN : WSTRING[__STRING_LENGTH]; + IN : WSTRING[__STRING_LENGTH]; END_VAR VAR_INPUT L : DINT; @@ -6372,20 +6372,20 @@ Return: {external} FUNCTION CONCAT__STRING : STRING[2048] VAR_INPUT {ref} - args : {sized} STRING...; + args : {sized} STRING...; END_VAR END_FUNCTION {external} FUNCTION CONCAT__WSTRING : WSTRING[2048] VAR_INPUT {ref} - args : {sized} WSTRING...; + args : {sized} WSTRING...; END_VAR END_FUNCTION FUNCTION CONCAT < T : ANY_STRING > : T VAR_INPUT {ref} - args : {sized} T...; + args : {sized} T...; END_VAR END_FUNCTION @@ -6410,7 +6410,7 @@ Return: ***************************************************************************** *) FUNCTION INSERT < T : ANY_STRING > : T VAR_INPUT {ref} - IN1 : T; + IN1 : T; IN2 : T; END_VAR VAR_INPUT @@ -6421,7 +6421,7 @@ END_FUNCTION {external} FUNCTION INSERT_EXT < T : ANY_STRING > : DINT VAR_INPUT {ref} - IN1 : T; + IN1 : T; IN2 : T; END_VAR VAR_INPUT @@ -6434,7 +6434,7 @@ END_FUNCTION FUNCTION INSERT__STRING : STRING[__STRING_LENGTH] VAR_INPUT {ref} - IN1 : STRING[__STRING_LENGTH]; + IN1 : STRING[__STRING_LENGTH]; IN2 : STRING[__STRING_LENGTH]; END_VAR VAR_INPUT @@ -6445,7 +6445,7 @@ END_FUNCTION FUNCTION INSERT__WSTRING : WSTRING[__STRING_LENGTH] VAR_INPUT {ref} - IN1 : WSTRING[__STRING_LENGTH]; + IN1 : WSTRING[__STRING_LENGTH]; IN2 : WSTRING[__STRING_LENGTH]; END_VAR VAR_INPUT @@ -6457,7 +6457,7 @@ END_FUNCTION {external} FUNCTION INSERT_EXT__STRING : DINT VAR_INPUT {ref} - IN1 : STRING[__STRING_LENGTH]; + IN1 : STRING[__STRING_LENGTH]; IN2 : STRING[__STRING_LENGTH]; END_VAR VAR_INPUT @@ -6471,7 +6471,7 @@ END_FUNCTION {external} FUNCTION INSERT_EXT__WSTRING : DINT VAR_INPUT {ref} - IN1 : WSTRING[__STRING_LENGTH]; + IN1 : WSTRING[__STRING_LENGTH]; IN2 : WSTRING[__STRING_LENGTH]; END_VAR VAR_INPUT @@ -6492,7 +6492,7 @@ Return: A new string with L characters deleted from P onwards ***************************************************************************** *) FUNCTION DELETE < T : ANY_STRING > : T VAR_INPUT {ref} - IN : T; + IN : T; END_VAR VAR_INPUT L : DINT; @@ -6503,7 +6503,7 @@ END_FUNCTION {external} FUNCTION DELETE_EXT < T : ANY_STRING > : DINT VAR_INPUT {ref} - IN : T; + IN : T; END_VAR VAR_INPUT L : DINT; @@ -6516,7 +6516,7 @@ END_FUNCTION FUNCTION DELETE__STRING : STRING[__STRING_LENGTH] VAR_INPUT {ref} - IN : STRING[__STRING_LENGTH]; + IN : STRING[__STRING_LENGTH]; END_VAR VAR_INPUT L : DINT; @@ -6527,7 +6527,7 @@ END_FUNCTION FUNCTION DELETE__WSTRING : WSTRING[__STRING_LENGTH] VAR_INPUT {ref} - IN : WSTRING[__STRING_LENGTH]; + IN : WSTRING[__STRING_LENGTH]; END_VAR VAR_INPUT L : DINT; @@ -6539,7 +6539,7 @@ END_FUNCTION {external} FUNCTION DELETE_EXT__STRING : DINT VAR_INPUT {ref} - IN : STRING[__STRING_LENGTH]; + IN : STRING[__STRING_LENGTH]; END_VAR VAR_INPUT L : DINT; @@ -6553,7 +6553,7 @@ END_FUNCTION {external} FUNCTION DELETE_EXT__WSTRING : DINT VAR_INPUT {ref} - IN : WSTRING[__STRING_LENGTH]; + IN : WSTRING[__STRING_LENGTH]; END_VAR VAR_INPUT L : DINT; @@ -6574,7 +6574,7 @@ Return: A new string which has L characters replaced by IN2 from position P onwa ***************************************************************************** *) FUNCTION REPLACE < T : ANY_STRING > : T VAR_INPUT {ref} - IN1 : T; + IN1 : T; IN2 : T; END_VAR VAR_INPUT @@ -6600,7 +6600,7 @@ END_FUNCTION FUNCTION REPLACE__STRING : STRING[__STRING_LENGTH] VAR_INPUT {ref} - IN1 : STRING[__STRING_LENGTH]; + IN1 : STRING[__STRING_LENGTH]; IN2 : STRING[__STRING_LENGTH]; END_VAR VAR_INPUT @@ -6663,7 +6663,7 @@ Return: The character index of the first match. 0 if there are no matches. {external} FUNCTION FIND < T : ANY_STRING > : DINT VAR_INPUT {ref} - IN1 : T; + IN1 : T; IN2 : T; END_VAR END_FUNCTION @@ -6678,7 +6678,7 @@ Return: {external} FUNCTION GT < T : ANY_STRING > : BOOL VAR_INPUT {ref} - IN1 : {sized} T...; + IN1 : {sized} T...; END_VAR END_FUNCTION @@ -6706,7 +6706,7 @@ Return: {external} FUNCTION GE < T : ANY_STRING > : BOOL VAR_INPUT {ref} - IN1 : {sized} T...; + IN1 : {sized} T...; END_VAR END_FUNCTION @@ -6720,7 +6720,7 @@ Return: {external} FUNCTION EQ < T : ANY_STRING > : BOOL VAR_INPUT {ref} - IN1 : {sized} T...; + IN1 : {sized} T...; END_VAR END_FUNCTION @@ -6748,7 +6748,7 @@ Return: {external} FUNCTION LE < T : ANY_STRING > : BOOL VAR_INPUT {ref} - IN1 : {sized} T...; + IN1 : {sized} T...; END_VAR END_FUNCTION @@ -6762,7 +6762,7 @@ Return: {external} FUNCTION LT < T : ANY_STRING > : BOOL VAR_INPUT {ref} - IN1 : {sized} T...; + IN1 : {sized} T...; END_VAR END_FUNCTION @@ -6790,28 +6790,28 @@ Return: {external} FUNCTION NE < T : ANY_STRING > : BOOL VAR_INPUT {ref} - IN1 : T; + IN1 : T; IN2 : T; END_VAR END_FUNCTION (* Definitions of arithmetic functions defined by the IEC61131-3 standard *) {external} VAR_GLOBAL - PI_REAL : REAL; - PI_LREAL : LREAL; - FRAC_PI_2_REAL : REAL; - FRAC_PI_2_LREAL : LREAL; - FRAC_PI_4_REAL : REAL; - FRAC_PI_4_LREAL : LREAL; - E_REAL : REAL; - E_LREAL : LREAL; + PI_REAL : REAL; + PI_LREAL : LREAL; + FRAC_PI_2_REAL : REAL; + FRAC_PI_2_LREAL : LREAL; + FRAC_PI_4_REAL : REAL; + FRAC_PI_4_LREAL : LREAL; + E_REAL : REAL; + E_LREAL : LREAL; END_VAR (* Calculates the square root of a given value *) {external} FUNCTION SQRT < T : ANY_REAL > : T VAR_INPUT - in : T; + in : T; END_VAR END_FUNCTION @@ -6822,7 +6822,7 @@ END_FUNCTION {external} FUNCTION LN < T : ANY_REAL > : T VAR_INPUT - in : T; + in : T; END_VAR END_FUNCTION @@ -6831,7 +6831,7 @@ END_FUNCTION {external} FUNCTION LOG < T : ANY_REAL > : T VAR_INPUT - in : T; + in : T; END_VAR END_FUNCTION @@ -6839,7 +6839,7 @@ END_FUNCTION {external} FUNCTION EXP < T : ANY_REAL > : T VAR_INPUT - in : T; + in : T; END_VAR END_FUNCTION @@ -6850,7 +6850,7 @@ END_FUNCTION {external} FUNCTION SIN < T : ANY_REAL > : T VAR_INPUT - rad : T; + rad : T; END_VAR END_FUNCTION @@ -6858,7 +6858,7 @@ END_FUNCTION {external} FUNCTION COS < T : ANY_REAL > : T VAR_INPUT - rad : T; + rad : T; END_VAR END_FUNCTION @@ -6866,7 +6866,7 @@ END_FUNCTION {external} FUNCTION TAN < T : ANY_REAL > : T VAR_INPUT - rad : T; + rad : T; END_VAR END_FUNCTION @@ -6874,7 +6874,7 @@ END_FUNCTION {external} FUNCTION ASIN < T : ANY_REAL > : T VAR_INPUT - in : T; + in : T; END_VAR END_FUNCTION @@ -6882,7 +6882,7 @@ END_FUNCTION {external} FUNCTION ACOS < T : ANY_REAL > : T VAR_INPUT - in : T; + in : T; END_VAR END_FUNCTION @@ -6890,7 +6890,7 @@ END_FUNCTION {external} FUNCTION ATAN < T : ANY_REAL > : T VAR_INPUT - in : T; + in : T; END_VAR END_FUNCTION @@ -6898,32 +6898,32 @@ END_FUNCTION {external} FUNCTION ATAN2 < T : ANY_REAL > : T VAR_INPUT - y : T; - x : T; + y : T; + x : T; END_VAR END_FUNCTION {external} FUNCTION EXPT < T : ANY_REAL, U : ANY_NUM > : T VAR_INPUT - in1 : T; - in2 : U; + in1 : T; + in2 : U; END_VAR END_FUNCTION {external} FUNCTION EXPT__REAL__DINT : REAL VAR_INPUT - in1 : REAL; - in2 : DINT; + in1 : REAL; + in2 : DINT; END_VAR END_FUNCTION {external} FUNCTION EXPT__REAL__REAL : REAL VAR_INPUT - in1 : REAL; - in2 : REAL; + in1 : REAL; + in2 : REAL; END_VAR END_FUNCTION @@ -6933,143 +6933,143 @@ END_FUNCTION {external} FUNCTION EXPT__REAL__LREAL : REAL VAR_INPUT - in1 : REAL; - in2 : LREAL; + in1 : REAL; + in2 : LREAL; END_VAR END_FUNCTION {external} FUNCTION EXPT__LREAL__DINT : LREAL VAR_INPUT - in1 : LREAL; - in2 : DINT; + in1 : LREAL; + in2 : DINT; END_VAR END_FUNCTION {external} FUNCTION EXPT__LREAL__REAL : LREAL VAR_INPUT - in1 : LREAL; - in2 : REAL; + in1 : LREAL; + in2 : REAL; END_VAR END_FUNCTION {external} FUNCTION EXPT__LREAL__LREAL : LREAL VAR_INPUT - in1 : LREAL; - in2 : LREAL; + in1 : LREAL; + in2 : LREAL; END_VAR END_FUNCTION FUNCTION EXPT__REAL__USINT : REAL VAR_INPUT - in1 : REAL; - in2 : USINT; + in1 : REAL; + in2 : USINT; END_VAR EXPT__REAL__USINT := EXPT__REAL__DINT(in1, in2); END_FUNCTION FUNCTION EXPT__REAL__UINT : REAL VAR_INPUT - in1 : REAL; - in2 : UINT; + in1 : REAL; + in2 : UINT; END_VAR EXPT__REAL__UINT := EXPT__REAL__DINT(in1, in2); END_FUNCTION FUNCTION EXPT__REAL__UDINT : REAL VAR_INPUT - in1 : REAL; - in2 : UDINT; + in1 : REAL; + in2 : UDINT; END_VAR EXPT__REAL__UDINT := EXPT__REAL__DINT(in1, in2); END_FUNCTION FUNCTION EXPT__REAL__ULINT : REAL VAR_INPUT - in1 : REAL; - in2 : ULINT; + in1 : REAL; + in2 : ULINT; END_VAR EXPT__REAL__ULINT := EXPT__REAL__DINT(in1, in2); END_FUNCTION FUNCTION EXPT__REAL__SINT : REAL VAR_INPUT - in1 : REAL; - in2 : SINT; + in1 : REAL; + in2 : SINT; END_VAR EXPT__REAL__SINT := EXPT__REAL__DINT(in1, in2); END_FUNCTION FUNCTION EXPT__REAL__INT : REAL VAR_INPUT - in1 : REAL; - in2 : INT; + in1 : REAL; + in2 : INT; END_VAR EXPT__REAL__INT := EXPT__REAL__DINT(in1, in2); END_FUNCTION FUNCTION EXPT__REAL__LINT : REAL VAR_INPUT - in1 : REAL; - in2 : LINT; + in1 : REAL; + in2 : LINT; END_VAR EXPT__REAL__LINT := EXPT__REAL__DINT(in1, in2); END_FUNCTION FUNCTION EXPT__LREAL__USINT : LREAL VAR_INPUT - in1 : LREAL; - in2 : USINT; + in1 : LREAL; + in2 : USINT; END_VAR EXPT__LREAL__USINT := EXPT__LREAL__DINT(in1, in2); END_FUNCTION FUNCTION EXPT__LREAL__UINT : LREAL VAR_INPUT - in1 : LREAL; - in2 : UINT; + in1 : LREAL; + in2 : UINT; END_VAR EXPT__LREAL__UINT := EXPT__LREAL__DINT(in1, in2); END_FUNCTION FUNCTION EXPT__LREAL__UDINT : LREAL VAR_INPUT - in1 : LREAL; - in2 : UDINT; + in1 : LREAL; + in2 : UDINT; END_VAR EXPT__LREAL__UDINT := EXPT__LREAL__DINT(in1, in2); END_FUNCTION FUNCTION EXPT__LREAL__ULINT : LREAL VAR_INPUT - in1 : LREAL; - in2 : ULINT; + in1 : LREAL; + in2 : ULINT; END_VAR EXPT__LREAL__ULINT := EXPT__LREAL__DINT(in1, in2); END_FUNCTION FUNCTION EXPT__LREAL__SINT : LREAL VAR_INPUT - in1 : LREAL; - in2 : SINT; + in1 : LREAL; + in2 : SINT; END_VAR EXPT__LREAL__SINT := EXPT__LREAL__DINT(in1, in2); END_FUNCTION FUNCTION EXPT__LREAL__INT : LREAL VAR_INPUT - in1 : LREAL; - in2 : INT; + in1 : LREAL; + in2 : INT; END_VAR EXPT__LREAL__INT := EXPT__LREAL__DINT(in1, in2); END_FUNCTION FUNCTION EXPT__LREAL__LINT : LREAL VAR_INPUT - in1 : LREAL; - in2 : LINT; + in1 : LREAL; + in2 : LINT; END_VAR EXPT__LREAL__LINT := EXPT__LREAL__DINT(in1, in2); END_FUNCTION @@ -7080,7 +7080,7 @@ END_FUNCTION ************************ *) FUNCTION ABS < T : ANY_NUM > : T VAR_INPUT - IN : T; + IN : T; END_VAR END_FUNCTION @@ -7089,58 +7089,58 @@ END_FUNCTION /* FUNCTION ABS__DINT : DINT */ FUNCTION ABS__DINT : DINT VAR_INPUT - IN : DINT; + IN : DINT; END_VAR - ABS__DINT := IN; - IF ABS__DINT < 0 THEN - ABS__DINT := - 1 * ABS__DINT; - END_IF + ABS__DINT := IN; + IF ABS__DINT < 0 THEN + ABS__DINT := - 1 * ABS__DINT; + END_IF END_FUNCTION (* Specialized implementation of ABS for SINT *) FUNCTION ABS__SINT : SINT VAR_INPUT - IN : SINT; + IN : SINT; END_VAR - ABS__SINT := ABS__DINT(IN); + ABS__SINT := ABS__DINT(IN); END_FUNCTION (* Specialized implementation of ABS for INT *) FUNCTION ABS__INT : INT VAR_INPUT - IN : INT; + IN : INT; END_VAR - ABS__INT := ABS__DINT(IN); + ABS__INT := ABS__DINT(IN); END_FUNCTION (* Specialized implementation of ABS for LINT *) FUNCTION ABS__LINT : LINT VAR_INPUT - IN : LINT; + IN : LINT; END_VAR - ABS__LINT := IN; - IF ABS__LINT < 0 THEN - ABS__LINT := - 1 * ABS__LINT; - END_IF + ABS__LINT := IN; + IF ABS__LINT < 0 THEN + ABS__LINT := - 1 * ABS__LINT; + END_IF END_FUNCTION (* Specialized implementation of ABS for REAL *) FUNCTION ABS__REAL : REAL VAR_INPUT - IN : REAL; + IN : REAL; END_VAR - ABS__REAL := ABS__LREAL(IN); + ABS__REAL := ABS__LREAL(IN); END_FUNCTION (* Specialized implementation of ABS for LREAL *) FUNCTION ABS__LREAL : LREAL VAR_INPUT - IN : LREAL; + IN : LREAL; END_VAR - ABS__LREAL := IN; - IF ABS__LREAL < 0 THEN - ABS__LREAL := - 1.0 * ABS__LREAL; - END_IF + ABS__LREAL := IN; + IF ABS__LREAL < 0 THEN + ABS__LREAL := - 1.0 * ABS__LREAL; + END_IF END_FUNCTION (************************** @@ -7152,7 +7152,7 @@ END_FUNCTION {external} FUNCTION ROUND < T : ANY_REAL > : T VAR_INPUT - in : T; + in : T; END_VAR END_FUNCTION CLASS MyClass @@ -7170,15 +7170,15 @@ END_CLASSPROGRAM name (1 + 2) * (3 + 4); END_PROGRAM FUNCTION smaller_than_ten : BOOL - VAR_INPUT - n : INT; - END_VAR + VAR_INPUT + n : INT; + END_VAR - IF n < 10 THEN - smaller_than_ten := TRUE; - RETURN; - END_IF; - smaller_than_ten := FALSE; + IF n < 10 THEN + smaller_than_ten := TRUE; + RETURN; + END_IF; + smaller_than_ten := FALSE; END_FUNCTION PROGRAM hello VAR @@ -7200,7 +7200,7 @@ FUNCTION a : DINT END_FUNCTION y^.1 := 3; z^[0] := 4; z^[1].1 := 5; - a() := 5; + a() := 5; END_PROGRAM @EXTERNAL FUNCTION LOG : DINT VAR_INPUT @@ -7217,7 +7217,7 @@ END_FUNCTION FUNCTION main : DINT - main := LOG(100); + main := LOG(100); PRINTF('Log value %d\n', main); END_FUNCTION FUNCTION main : DINT @@ -7231,15 +7231,15 @@ END_FUNCTION TYPE MyStruct : STRUCT x : DINT; y : DINT; END_STRUCT END_TYPE FUNCTION main : DINT - main := foo(); + main := foo(); END_FUNCTION FUNCTION foo : DINT VAR - x : DINT; - s : MyStruct; - u, y : REF_TO DINT; - z : REF_TO REF_TO DINT; + x : DINT; + s : MyStruct; + u, y : REF_TO DINT; + z : REF_TO REF_TO DINT; END_VAR u := NULL; @@ -7260,7 +7260,7 @@ END_VAR END_FUNCTION FUNCTION main : DINT - puts('hello, world!$N'); + puts('hello, world!$N'); END_FUNCTION PROGRAM hello VAR @@ -7280,14 +7280,14 @@ END_IF; END_PROGRAM PROGRAM exp a AND NOT b OR c XOR d; END_PROGRAMPROGRAM prg VAR - a : INT; - b : REAL; + a : INT; + b : REAL; END_VAR - b := 1.5; - a := b; + b := 1.5; + a := b; END_PROGRAM PROGRAM a -(* C�mment *) +(* Comment *) END_PROGRAM PROGRAM a VAR @@ -7309,11 +7309,11 @@ PROGRAM a END_VAR END_PROGRAM PROGRAM a -(* Cömment *) +(* Comment *) END_PROGRAM FUNCTION myFunc : DINT VAR_INPUT - a, b, c : DINT; + a, b, c : DINT; END_VAR END_FUNCTION FUNCTION foo2 : LINT @@ -7321,9 +7321,9 @@ FUNCTION foo2 : LINT END_FUNCTION{external} FUNCTION CONCAT_DATE < T : ANY_INT > : DATE VAR_INPUT - year : T; - month : T; - day : T; + year : T; + month : T; + day : T; END_VAR END_FUNCTION @@ -7341,47 +7341,47 @@ main := mainProg.a; END_FUNCTION PROGRAM mainProg VAR - a : DINT := 0; + a : DINT := 0; END_VAR a := 42; END_PROGRAM FUNCTION foo1 : LINT foo1 := CONCAT_DATE(INT#1, SINT#2, SINT#3); END_FUNCTIONVAR_GLOBAL CONSTANT - myValue : BOOL := TRUE; + myValue : BOOL := TRUE; END_VAR FUNCTION_BLOCK myFb2 - VAR - fb : myFb; - END_VAR + VAR + fb : myFb; + END_VAR END_FUNCTION_BLOCK VAR_GLOBAL CONSTANT - myValue2 : BOOL := TRUE; + myValue2 : BOOL := TRUE; END_VAR VAR_GLOBAL CONSTANT - myValue : BOOL := TRUE; + myValue : BOOL := TRUE; END_VAR FUNCTION_BLOCK myFB - VAR - myS : myStruct := (a := 2); - END_VAR + VAR + myS : myStruct := (a := 2); + END_VAR END_FUNCTION_BLOCK {external} FUNCTION func1 : DINT END_FUNCTION FUNCTION func2 : DINT - func1(); + func1(); END_FUNCTION FUNCTION relative : DINT END_FUNCTION TYPE myStruct : STRUCT - a : INT := 5; - b : DINT := 6; + a : INT := 5; + b : DINT := 6; END_STRUCT END_TYPE {external} @@ -7389,7 +7389,7 @@ FUNCTION func2 : DINT END_FUNCTION FUNCTION func1 : DINT - func2(); + func2(); END_FUNCTION PROGRAM name @@ -7406,11 +7406,11 @@ END_VAR END_PROGRAM PROGRAM prg VAR - a : INT; - b : REAL; + a : INT; + b : REAL; END_VAR - b := 1.5; - a := b; + b := 1.5; + a := b; END_PROGRAM VAR_GLOBAL flags : ARRAY[1..500_000_000] OF BOOL; @@ -7463,4 +7463,4 @@ PROGRAM mainProg node : ARRAY[0..15] OF struc2 := ((param1 := 1, param2 := 2), (param1 := 3, param2 := 4)); // node : ARRAY[0..15] OF struct2 := [(param1 := 1, param2 := 2), (param1 := 3, param2 := 4)]; END_VAR -END_PROGRAM \ No newline at end of file +END_PROGRAM diff --git a/xtask/res/sieve.st b/xtask/res/sieve.st index 56b4c982b9..bb98240f7e 100644 --- a/xtask/res/sieve.st +++ b/xtask/res/sieve.st @@ -37,4 +37,4 @@ END_FUNCTION FUNCTION printf : DINT VAR_INPUT {ref} format : STRING; END_VAR VAR_INPUT args : ...; END_VAR -END_FUNCTION \ No newline at end of file +END_FUNCTION diff --git a/xtask/src/task/lexer.rs b/xtask/src/task/lexer.rs index 966037f995..83a7eebd10 100644 --- a/xtask/src/task/lexer.rs +++ b/xtask/src/task/lexer.rs @@ -26,7 +26,7 @@ impl Task for Lexer { let elapsed = now.elapsed(); assert_eq!(lexer.token, plc::lexer::Token::End); - assert_eq!(lexer.last_range, 139145..139156); + assert_eq!(lexer.last_range, 143145..143156); Ok(elapsed) } From cf34cf60e0ea434d2f89097138ae2202161c217c Mon Sep 17 00:00:00 2001 From: Michael <78988079+mhasel@users.noreply.github.com> Date: Fri, 1 Dec 2023 10:12:41 +0100 Subject: [PATCH 12/33] feat(builtins): Symbols as builtins (#1012) * variadic add builtin function * index on builtin-arithmetics: * move arith func correctness tests in own folder * add tests, fix sized variadic test naming conflict * - adds comparison operators as builtin-functions. - annotates call-statements with `ReplacementAst` statements - temporary name-conflict fix for string-comparison overloads * fix comparison function logic. (GT(a, b, c) == a > b && b > c && c > d) add test to make sure AST is the same whether using symbols or calls * fix function overloads for string comparison * refactor part of `visit_call_statement` moved to its own function so it can be redirected to * refactor builtin annotations to reduce necessary ast-replacement checks during codegen. fix type-hints for nested binary-expr. with builtin-calls * fix st-header formatting * fix string header signature mismatch * param count validation --- Cargo.lock | 38 +- compiler/plc_driver/src/runner.rs | 11 + .../date_time_numeric_functions.st | 224 +++---- libs/stdlib/iec61131-st/string_functions.st | 599 ++++++++---------- libs/stdlib/src/string_functions.rs | 212 +------ libs/stdlib/tests/common/mod.rs | 18 +- .../date_time_numeric_functions_tests.rs | 52 ++ src/builtins.rs | 409 +++++++++++- .../generators/expression_generator.rs | 8 + .../tests/compare_instructions_tests.rs | 79 +++ src/codegen/tests/expression_tests.rs | 206 ++++++ ...uctions_tests__compare_datetime_types.snap | 44 ++ ...uction_functions_with_different_types.snap | 128 ++++ ...__expression_tests__builtin_add_float.snap | 31 + ...s__expression_tests__builtin_add_ints.snap | 36 ++ ...__expression_tests__builtin_add_mixed.snap | 32 + ...__expression_tests__builtin_div_float.snap | 23 + ...s__expression_tests__builtin_div_ints.snap | 23 + ...__expression_tests__builtin_div_mixed.snap | 24 + ...__expression_tests__builtin_mul_float.snap | 31 + ...s__expression_tests__builtin_mul_ints.snap | 36 ++ ...__expression_tests__builtin_mul_mixed.snap | 32 + ...__expression_tests__builtin_sub_float.snap | 23 + ...s__expression_tests__builtin_sub_ints.snap | 23 + ...__expression_tests__builtin_sub_mixed.snap | 24 + src/resolver.rs | 238 +++---- .../tests/resolve_expressions_tests.rs | 152 +++++ src/resolver/tests/resolve_generic_calls.rs | 15 +- ...ns_tests__builtin_add_replacement_ast.snap | 49 ++ ...ons_tests__builtin_eq_replacement_ast.snap | 69 ++ ...ons_tests__builtin_ge_replacement_ast.snap | 69 ++ ...ons_tests__builtin_gt_replacement_ast.snap | 69 ++ ...ons_tests__builtin_le_replacement_ast.snap | 69 ++ ...ons_tests__builtin_lt_replacement_ast.snap | 69 ++ ...ons_tests__builtin_ne_replacement_ast.snap | 69 ++ ...tion_sharing_a_datatype_name_resolves.snap | 19 + src/validation/array.rs | 28 +- src/validation/statement.rs | 12 +- src/validation/tests.rs | 1 + .../tests/builtin_validation_tests.rs | 105 +++ ...ltins_called_with_invalid_param_count.snap | 10 + ...ltins_called_with_invalid_param_count.snap | 8 + .../arithmetic_functions/addition.rs | 51 ++ .../arithmetic_functions/division.rs | 58 ++ .../arithmetic_functions/multiplication.rs | 53 ++ .../arithmetic_functions/substraction.rs | 50 ++ .../correctness/comparison_functions/equal.rs | 102 +++ .../comparison_functions/greater_than.rs | 102 +++ .../greater_than_or_equal.rs | 102 +++ .../comparison_functions/less_than.rs | 102 +++ .../less_than_or_equal.rs | 102 +++ .../comparison_functions/not_equal.rs | 102 +++ tests/correctness/expressions.rs | 36 ++ tests/correctness/external_functions.rs | 8 +- tests/correctness/math_operators/addition.rs | 3 +- tests/tests.rs | 16 +- 56 files changed, 3462 insertions(+), 842 deletions(-) create mode 100644 src/codegen/tests/snapshots/rusty__codegen__tests__compare_instructions_tests__compare_datetime_types.snap create mode 100644 src/codegen/tests/snapshots/rusty__codegen__tests__compare_instructions_tests__compare_instruction_functions_with_different_types.snap create mode 100644 src/codegen/tests/snapshots/rusty__codegen__tests__expression_tests__builtin_add_float.snap create mode 100644 src/codegen/tests/snapshots/rusty__codegen__tests__expression_tests__builtin_add_ints.snap create mode 100644 src/codegen/tests/snapshots/rusty__codegen__tests__expression_tests__builtin_add_mixed.snap create mode 100644 src/codegen/tests/snapshots/rusty__codegen__tests__expression_tests__builtin_div_float.snap create mode 100644 src/codegen/tests/snapshots/rusty__codegen__tests__expression_tests__builtin_div_ints.snap create mode 100644 src/codegen/tests/snapshots/rusty__codegen__tests__expression_tests__builtin_div_mixed.snap create mode 100644 src/codegen/tests/snapshots/rusty__codegen__tests__expression_tests__builtin_mul_float.snap create mode 100644 src/codegen/tests/snapshots/rusty__codegen__tests__expression_tests__builtin_mul_ints.snap create mode 100644 src/codegen/tests/snapshots/rusty__codegen__tests__expression_tests__builtin_mul_mixed.snap create mode 100644 src/codegen/tests/snapshots/rusty__codegen__tests__expression_tests__builtin_sub_float.snap create mode 100644 src/codegen/tests/snapshots/rusty__codegen__tests__expression_tests__builtin_sub_ints.snap create mode 100644 src/codegen/tests/snapshots/rusty__codegen__tests__expression_tests__builtin_sub_mixed.snap create mode 100644 src/resolver/tests/snapshots/rusty__resolver__tests__resolve_expressions_tests__builtin_add_replacement_ast.snap create mode 100644 src/resolver/tests/snapshots/rusty__resolver__tests__resolve_expressions_tests__builtin_eq_replacement_ast.snap create mode 100644 src/resolver/tests/snapshots/rusty__resolver__tests__resolve_expressions_tests__builtin_ge_replacement_ast.snap create mode 100644 src/resolver/tests/snapshots/rusty__resolver__tests__resolve_expressions_tests__builtin_gt_replacement_ast.snap create mode 100644 src/resolver/tests/snapshots/rusty__resolver__tests__resolve_expressions_tests__builtin_le_replacement_ast.snap create mode 100644 src/resolver/tests/snapshots/rusty__resolver__tests__resolve_expressions_tests__builtin_lt_replacement_ast.snap create mode 100644 src/resolver/tests/snapshots/rusty__resolver__tests__resolve_expressions_tests__builtin_ne_replacement_ast.snap create mode 100644 src/resolver/tests/snapshots/rusty__resolver__tests__resolve_generic_calls__generic_function_sharing_a_datatype_name_resolves.snap create mode 100644 src/validation/tests/builtin_validation_tests.rs create mode 100644 src/validation/tests/snapshots/rusty__validation__tests__builtin_validation_tests__arithmetic_builtins_called_with_invalid_param_count.snap create mode 100644 src/validation/tests/snapshots/rusty__validation__tests__builtin_validation_tests__comparison_builtins_called_with_invalid_param_count.snap create mode 100644 tests/correctness/arithmetic_functions/addition.rs create mode 100644 tests/correctness/arithmetic_functions/division.rs create mode 100644 tests/correctness/arithmetic_functions/multiplication.rs create mode 100644 tests/correctness/arithmetic_functions/substraction.rs create mode 100644 tests/correctness/comparison_functions/equal.rs create mode 100644 tests/correctness/comparison_functions/greater_than.rs create mode 100644 tests/correctness/comparison_functions/greater_than_or_equal.rs create mode 100644 tests/correctness/comparison_functions/less_than.rs create mode 100644 tests/correctness/comparison_functions/less_than_or_equal.rs create mode 100644 tests/correctness/comparison_functions/not_equal.rs diff --git a/Cargo.lock b/Cargo.lock index 8e252c885d..9ac7b9a128 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -342,9 +342,9 @@ checksum = "a3e2c3daef883ecc1b5d58c15adae93470a91d425f3532ba1695849656af3fc1" [[package]] name = "bytecount" -version = "0.6.4" +version = "0.6.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ad152d03a2c813c80bb94fedbf3a3f02b28f793e39e7c214c8a0bcc196343de7" +checksum = "e1e5f035d16fc623ae5f74981db80a439803888314e3a555fd6f04acd51a3205" [[package]] name = "byteorder" @@ -638,9 +638,12 @@ dependencies = [ [[package]] name = "deranged" -version = "0.3.8" +version = "0.3.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f2696e8a945f658fd14dc3b87242e6b80cd0f36ff04ea560fa39082368847946" +checksum = "0f32d04922c60427da6f9fef14d042d9edddef64cb9d4ce0d64d0685fbeb1fd3" +dependencies = [ + "powerfmt", +] [[package]] name = "diff" @@ -1300,9 +1303,9 @@ dependencies = [ [[package]] name = "ipnet" -version = "2.8.0" +version = "2.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "28b29a3cd74f0f4598934efe3aeba42bae0eb4680554128851ebbecb02af14e6" +checksum = "8f518f335dce6725a761382244631d86cf0ccb2863413590b31338feb467f9c3" [[package]] name = "is-terminal" @@ -1996,6 +1999,12 @@ dependencies = [ "windows-sys 0.48.0", ] +[[package]] +name = "powerfmt" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "439ee305def115ba05938db6eb1644ff94165c5ab5e9420d1c1bcedbba909391" + [[package]] name = "ppv-lite86" version = "0.2.17" @@ -2876,11 +2885,12 @@ dependencies = [ [[package]] name = "time" -version = "0.3.29" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "426f806f4089c493dcac0d24c29c01e2c38baf8e30f1b716ee37e83d200b18fe" +checksum = "c4a34ab300f2dee6e562c10a046fc05e358b29f9bf92277f30c3c8d82275f6f5" dependencies = [ "deranged", + "powerfmt", "serde", "time-core", "time-macros", @@ -2918,9 +2928,9 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" [[package]] name = "tokio" -version = "1.32.0" +version = "1.33.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "17ed6077ed6cd6c74735e21f37eb16dc3935f96878b1fe961074089cc80893f9" +checksum = "4f38200e3ef7995e5ef13baec2f432a6da0aa9ac495b2c0e8f3b7eec2c92d653" dependencies = [ "backtrace", "bytes", @@ -2934,9 +2944,9 @@ dependencies = [ [[package]] name = "tokio-util" -version = "0.7.9" +version = "0.7.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d68074620f57a0b21594d9735eb2e98ab38b17f80d3fcb189fca266771ca60d" +checksum = "5419f34732d9eb6ee4c3578b7989078579b7f039cbbb9ca2c4da015749371e15" dependencies = [ "bytes", "futures-core", @@ -3076,9 +3086,9 @@ checksum = "711b9620af191e0cdc7468a8d14e709c3dcdb115b36f838e601583af800a370a" [[package]] name = "uuid" -version = "1.4.1" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "79daa5ed5740825c40b389c5e50312b9c86df53fccd33f281df655642b43869d" +checksum = "88ad59a7560b41a70d191093a945f0b87bc1deeda46fb237479708a1d6b6cdfc" [[package]] name = "value-bag" diff --git a/compiler/plc_driver/src/runner.rs b/compiler/plc_driver/src/runner.rs index 88a2876827..4a20a18d4d 100644 --- a/compiler/plc_driver/src/runner.rs +++ b/compiler/plc_driver/src/runner.rs @@ -50,3 +50,14 @@ pub fn compile_and_run(source: S, params: &mut T) -> U { module.print_to_stderr(); module.run::("main", params) } + +/// +/// A Convenience method to compile and then run the given source +/// without external parameters +/// +pub fn compile_and_run_no_params(source: S) -> U { + let context: CodegenContext = CodegenContext::create(); + let module = compile(&context, source); + module.print_to_stderr(); + module.run_no_param::("main") +} diff --git a/libs/stdlib/iec61131-st/date_time_numeric_functions.st b/libs/stdlib/iec61131-st/date_time_numeric_functions.st index 9dc5586280..89a52d0b2f 100644 --- a/libs/stdlib/iec61131-st/date_time_numeric_functions.st +++ b/libs/stdlib/iec61131-st/date_time_numeric_functions.st @@ -1,20 +1,21 @@ (******************** * * This operator returns the value of adding up the operands. +* It overloads the variadic builtin implementation of ADD, which is impemented for ANY_NUM * *********************) -FUNCTION ADD : T1 +FUNCTION ADD < T1: ANY, T2: ANY >: T1 VAR_INPUT - IN1 : T1; - IN2 : T2; + IN1: T1; + IN2: T2; END_VAR END_FUNCTION (* Specialized implementation of ADD for TIME *) -FUNCTION ADD__TIME__TIME : TIME +FUNCTION ADD__TIME__TIME: TIME VAR_INPUT - IN1 : TIME; - IN2 : TIME; + IN1: TIME; + IN2: TIME; END_VAR ADD__TIME__TIME := ADD_TIME(IN1, IN2); END_FUNCTION @@ -25,10 +26,10 @@ END_FUNCTION * *********************) {external} -FUNCTION ADD_TIME : TIME +FUNCTION ADD_TIME: TIME VAR_INPUT - IN1 : TIME; - IN2 : TIME; + IN1: TIME; + IN2: TIME; END_VAR END_FUNCTION @@ -37,19 +38,19 @@ END_FUNCTION * This operator returns the value of adding up two LTIME operands. * *********************) -FUNCTION ADD_LTIME : LTIME +FUNCTION ADD_LTIME: LTIME VAR_INPUT - IN1 : LTIME; - IN2 : LTIME; + IN1: LTIME; + IN2: LTIME; END_VAR ADD_LTIME := ADD_TIME(IN1, IN2); END_FUNCTION (* Specialized implementation of ADD for TOD *) -FUNCTION ADD__TIME_OF_DAY__TIME : TOD +FUNCTION ADD__TIME_OF_DAY__TIME: TOD VAR_INPUT - IN1 : TOD; - IN2 : TIME; + IN1: TOD; + IN2: TIME; END_VAR ADD__TIME_OF_DAY__TIME := ADD_TOD_TIME(IN1, IN2); END_FUNCTION @@ -61,10 +62,10 @@ END_FUNCTION * *********************) {external} -FUNCTION ADD_TOD_TIME : TOD +FUNCTION ADD_TOD_TIME: TOD VAR_INPUT - IN1 : TOD; - IN2 : TIME; + IN1: TOD; + IN2: TIME; END_VAR END_FUNCTION @@ -74,19 +75,19 @@ END_FUNCTION * Panic on overflow * *********************) -FUNCTION ADD_LTOD_LTIME : LTOD +FUNCTION ADD_LTOD_LTIME: LTOD VAR_INPUT - IN1 : LTOD; - IN2 : LTIME; + IN1: LTOD; + IN2: LTIME; END_VAR ADD_LTOD_LTIME := ADD_TOD_TIME(IN1, IN2); END_FUNCTION (* Specialized implementation of ADD for DT *) -FUNCTION ADD__DATE_AND_TIME__TIME : DT +FUNCTION ADD__DATE_AND_TIME__TIME: DT VAR_INPUT - IN1 : DT; - IN2 : TIME; + IN1: DT; + IN2: TIME; END_VAR ADD__DATE_AND_TIME__TIME := ADD_DT_TIME(IN1, IN2); END_FUNCTION @@ -98,10 +99,10 @@ END_FUNCTION * *********************) {external} -FUNCTION ADD_DT_TIME : DT +FUNCTION ADD_DT_TIME: DT VAR_INPUT - IN1 : DT; - IN2 : TIME; + IN1: DT; + IN2: TIME; END_VAR END_FUNCTION @@ -111,31 +112,19 @@ END_FUNCTION * Panic on overflow * *********************) -FUNCTION ADD_LDT_LTIME : LDT +FUNCTION ADD_LDT_LTIME: LDT VAR_INPUT - IN1 : LDT; - IN2 : LTIME; + IN1: LDT; + IN2: LTIME; END_VAR ADD_LDT_LTIME := ADD_DT_TIME(IN1, IN2); END_FUNCTION -(******************** -* -* This operator produces the subtraction of the operands. -* -*********************) -FUNCTION SUB : T1 -VAR_INPUT - IN1 : T1; - IN2 : T2; -END_VAR -END_FUNCTION - (* Specialized implementation of SUB for TIME *) -FUNCTION SUB__TIME__TIME : TIME +FUNCTION SUB__TIME__TIME: TIME VAR_INPUT - IN1 : TIME; - IN2 : TIME; + IN1: TIME; + IN2: TIME; END_VAR SUB__TIME__TIME := SUB_TIME(IN1, IN2); END_FUNCTION @@ -146,10 +135,10 @@ END_FUNCTION * *********************) {external} -FUNCTION SUB_TIME : TIME +FUNCTION SUB_TIME: TIME VAR_INPUT - IN1 : TIME; - IN2 : TIME; + IN1: TIME; + IN2: TIME; END_VAR END_FUNCTION @@ -158,19 +147,19 @@ END_FUNCTION * This operator produces the subtraction of two LTIME operands * *********************) -FUNCTION SUB_LTIME : LTIME +FUNCTION SUB_LTIME: LTIME VAR_INPUT - IN1 : LTIME; - IN2 : LTIME; + IN1: LTIME; + IN2: LTIME; END_VAR SUB_LTIME := SUB_TIME(IN1, IN2); END_FUNCTION (* Specialized implementation of SUB for DATE *) -FUNCTION SUB__DATE__DATE : TIME +FUNCTION SUB__DATE__DATE: TIME VAR_INPUT - IN1 : DATE; - IN2 : DATE; + IN1: DATE; + IN2: DATE; END_VAR SUB__DATE__DATE := SUB_DATE_DATE(IN1, IN2); END_FUNCTION @@ -182,10 +171,10 @@ END_FUNCTION * *********************) {external} -FUNCTION SUB_DATE_DATE : TIME +FUNCTION SUB_DATE_DATE: TIME VAR_INPUT - IN1 : DATE; - IN2 : DATE; + IN1: DATE; + IN2: DATE; END_VAR END_FUNCTION @@ -195,19 +184,19 @@ END_FUNCTION * Panic on overflow * *********************) -FUNCTION SUB_LDATE_LDATE : LTIME +FUNCTION SUB_LDATE_LDATE: LTIME VAR_INPUT - IN1 : LDATE; - IN2 : LDATE; + IN1: LDATE; + IN2: LDATE; END_VAR SUB_LDATE_LDATE := SUB_DATE_DATE(IN1, IN2); END_FUNCTION (* Specialized implementation of SUB for TOD and TIME *) -FUNCTION SUB__TIME_OF_DAY__TIME : TOD +FUNCTION SUB__TIME_OF_DAY__TIME: TOD VAR_INPUT - IN1 : TOD; - IN2 : TIME; + IN1: TOD; + IN2: TIME; END_VAR SUB__TIME_OF_DAY__TIME := SUB_TOD_TIME(IN1, IN2); END_FUNCTION @@ -219,10 +208,10 @@ END_FUNCTION * *********************) {external} -FUNCTION SUB_TOD_TIME : TOD +FUNCTION SUB_TOD_TIME: TOD VAR_INPUT - IN1 : TOD; - IN2 : TIME; + IN1: TOD; + IN2: TIME; END_VAR END_FUNCTION @@ -232,19 +221,19 @@ END_FUNCTION * Panic on overflow * *********************) -FUNCTION SUB_LTOD_LTIME : LTOD +FUNCTION SUB_LTOD_LTIME: LTOD VAR_INPUT - IN1 : LTOD; - IN2 : LTIME; + IN1: LTOD; + IN2: LTIME; END_VAR SUB_LTOD_LTIME := SUB_TOD_TIME(IN1, IN2); END_FUNCTION (* Specialized implementation of SUB for TOD *) -FUNCTION SUB__TIME_OF_DAY__TIME_OF_DAY : TIME +FUNCTION SUB__TIME_OF_DAY__TIME_OF_DAY: TIME VAR_INPUT - IN1 : TOD; - IN2 : TOD; + IN1: TOD; + IN2: TOD; END_VAR SUB__TIME_OF_DAY__TIME_OF_DAY := SUB_TOD_TOD(IN1, IN2); END_FUNCTION @@ -256,10 +245,10 @@ END_FUNCTION * *********************) {external} -FUNCTION SUB_TOD_TOD : TIME +FUNCTION SUB_TOD_TOD: TIME VAR_INPUT - IN1 : TOD; - IN2 : TOD; + IN1: TOD; + IN2: TOD; END_VAR END_FUNCTION @@ -269,19 +258,19 @@ END_FUNCTION * Panic on overflow * *********************) -FUNCTION SUB_LTOD_LTOD : LTIME +FUNCTION SUB_LTOD_LTOD: LTIME VAR_INPUT - IN1 : LTOD; - IN2 : LTOD; + IN1: LTOD; + IN2: LTOD; END_VAR SUB_LTOD_LTOD := SUB_TOD_TOD(IN1, IN2); END_FUNCTION (* Specialized implementation of SUB for DT and TIME *) -FUNCTION SUB__DATE_AND_TIME__TIME : DT +FUNCTION SUB__DATE_AND_TIME__TIME: DT VAR_INPUT - IN1 : DT; - IN2 : TIME; + IN1: DT; + IN2: TIME; END_VAR SUB__DATE_AND_TIME__TIME := SUB_DT_TIME(IN1, IN2); END_FUNCTION @@ -293,10 +282,10 @@ END_FUNCTION * *********************) {external} -FUNCTION SUB_DT_TIME : DT +FUNCTION SUB_DT_TIME: DT VAR_INPUT - IN1 : DT; - IN2 : TIME; + IN1: DT; + IN2: TIME; END_VAR END_FUNCTION @@ -306,19 +295,19 @@ END_FUNCTION * Panic on overflow * *********************) -FUNCTION SUB_LDT_LTIME : LDT +FUNCTION SUB_LDT_LTIME: LDT VAR_INPUT - IN1 : LDT; - IN2 : LTIME; + IN1: LDT; + IN2: LTIME; END_VAR SUB_LDT_LTIME := SUB_DT_TIME(IN1, IN2); END_FUNCTION (* Specialized implementation of SUB for DT *) -FUNCTION SUB__DATE_AND_TIME__DATE_AND_TIME : TIME +FUNCTION SUB__DATE_AND_TIME__DATE_AND_TIME: TIME VAR_INPUT - IN1 : DT; - IN2 : DT; + IN1: DT; + IN2: DT; END_VAR SUB__DATE_AND_TIME__DATE_AND_TIME := SUB_DT_DT(IN1, IN2); END_FUNCTION @@ -330,10 +319,10 @@ END_FUNCTION * *********************) {external} -FUNCTION SUB_DT_DT : TIME +FUNCTION SUB_DT_DT: TIME VAR_INPUT - IN1 : DT; - IN2 : DT; + IN1: DT; + IN2: DT; END_VAR END_FUNCTION @@ -343,10 +332,10 @@ END_FUNCTION * Panic on overflow * *********************) -FUNCTION SUB_LDT_LDT : LTIME +FUNCTION SUB_LDT_LDT: LTIME VAR_INPUT - IN1 : LDT; - IN2 : LDT; + IN1: LDT; + IN2: LDT; END_VAR SUB_LDT_LDT := SUB_DT_DT(IN1, IN2); END_FUNCTION @@ -354,12 +343,13 @@ END_FUNCTION (******************** * * This operator produces the multiplication of the operands. +* It overloads the variadic builtin implementation of MUL, which is impemented for ANY_NUM * *********************) -FUNCTION MUL : T1 +FUNCTION MUL < T1: ANY, T2: ANY >: T1 VAR_INPUT - IN1 : T1; - IN2 : T2; + IN1: T1; + IN2: T2; END_VAR END_FUNCTION @@ -368,10 +358,10 @@ END_FUNCTION * This operator produces the multiplication of TIME and ANY_NUM. * *********************) -FUNCTION MUL_TIME : TIME +FUNCTION MUL_TIME < T: ANY_NUM >: TIME VAR_INPUT - IN1 : TIME; - IN2 : T; + IN1: TIME; + IN2: T; END_VAR END_FUNCTION @@ -380,22 +370,10 @@ END_FUNCTION * This operator produces the multiplication of LTIME and ANY_NUM. * *********************) -FUNCTION MUL_LTIME : LTIME -VAR_INPUT - IN1 : LTIME; - IN2 : T; -END_VAR -END_FUNCTION - -(******************** -* -* This operator produces the division of the operands. -* -*********************) -FUNCTION DIV : T1 +FUNCTION MUL_LTIME < T: ANY_NUM >: LTIME VAR_INPUT - IN1 : T1; - IN2 : T2; + IN1: LTIME; + IN2: T; END_VAR END_FUNCTION @@ -404,10 +382,10 @@ END_FUNCTION * This operator produces the division of TIME and ANY_NUM. * *********************) -FUNCTION DIV_TIME : TIME +FUNCTION DIV_TIME < T: ANY_NUM >: TIME VAR_INPUT - IN1 : TIME; - IN2 : T; + IN1: TIME; + IN2: T; END_VAR END_FUNCTION @@ -416,9 +394,9 @@ END_FUNCTION * This operator produces the division of LTIME and ANY_NUM. * *********************) -FUNCTION DIV_LTIME : LTIME +FUNCTION DIV_LTIME < T: ANY_NUM >: LTIME VAR_INPUT - IN1 : LTIME; - IN2 : T; + IN1: LTIME; + IN2: T; END_VAR END_FUNCTION diff --git a/libs/stdlib/iec61131-st/string_functions.st b/libs/stdlib/iec61131-st/string_functions.st index 01af032984..4a546c943b 100644 --- a/libs/stdlib/iec61131-st/string_functions.st +++ b/libs/stdlib/iec61131-st/string_functions.st @@ -1,756 +1,665 @@ VAR_GLOBAL CONSTANT - __STRING_LENGTH : DINT := 2048; + __STRING_LENGTH: DINT := 2048; END_VAR -(****************************************************************************** +(* ***************************************************************************** Description: String character length Input: - - IN: A character string + - IN: A character string Return: String length -******************************************************************************) +***************************************************************************** *) {external} -FUNCTION LEN : DINT +FUNCTION LEN < T: ANY_STRING >: DINT VAR_INPUT {ref} - IN : T; + IN: T; END_VAR END_FUNCTION -(****************************************************************************** +(* ***************************************************************************** Description: Left Input: - - IN: A character string - - L: The length of the substring + - IN: A character string + - L: The length of the substring Return: A substring consisting of the leftmost L characters of IN -******************************************************************************) -FUNCTION LEFT : T +***************************************************************************** *) +FUNCTION LEFT < T: ANY_STRING >: T VAR_INPUT {ref} - IN : T; + IN: T; END_VAR VAR_INPUT - L : DINT; + L: DINT; END_VAR END_FUNCTION {external} -FUNCTION LEFT_EXT : DINT +FUNCTION LEFT_EXT < T: ANY_STRING >: DINT VAR_INPUT {ref} - IN : T; + IN: T; END_VAR VAR_INPUT - L : DINT; + L: DINT; END_VAR VAR_IN_OUT - OUT : T; + OUT: T; END_VAR END_FUNCTION -FUNCTION LEFT__STRING : STRING[__STRING_LENGTH] +FUNCTION LEFT__STRING: STRING[__STRING_LENGTH] VAR_INPUT {ref} - IN : STRING[__STRING_LENGTH]; + IN: STRING[__STRING_LENGTH]; END_VAR VAR_INPUT - L : DINT; + L: DINT; END_VAR LEFT_EXT(IN, L, LEFT__STRING); END_FUNCTION -FUNCTION LEFT__WSTRING : WSTRING[__STRING_LENGTH] +FUNCTION LEFT__WSTRING: WSTRING[__STRING_LENGTH] VAR_INPUT {ref} - IN : WSTRING[__STRING_LENGTH]; + IN: WSTRING[__STRING_LENGTH]; END_VAR VAR_INPUT - L : DINT; + L: DINT; END_VAR LEFT_EXT(IN, L, LEFT__WSTRING); END_FUNCTION {external} -FUNCTION LEFT_EXT__STRING : DINT +FUNCTION LEFT_EXT__STRING: DINT VAR_INPUT {ref} - IN : STRING[__STRING_LENGTH]; + IN: STRING[__STRING_LENGTH]; END_VAR VAR_INPUT - L : DINT; + L: DINT; END_VAR VAR_IN_OUT - OUT : STRING[__STRING_LENGTH]; + OUT: STRING[__STRING_LENGTH]; END_VAR END_FUNCTION {external} -FUNCTION LEFT_EXT__WSTRING : DINT +FUNCTION LEFT_EXT__WSTRING: DINT VAR_INPUT {ref} - IN : WSTRING[__STRING_LENGTH]; + IN: WSTRING[__STRING_LENGTH]; END_VAR VAR_INPUT - L : DINT; + L: DINT; END_VAR VAR_IN_OUT - OUT : WSTRING[__STRING_LENGTH]; + OUT: WSTRING[__STRING_LENGTH]; END_VAR END_FUNCTION -(****************************************************************************** +(* ***************************************************************************** Description: Right Input: - - IN: A character string - - L: The length of the substring + - IN: A character string + - L: The length of the substring Return: A substring consisting of the rightmost L characters of IN -******************************************************************************) -FUNCTION RIGHT : T +***************************************************************************** *) +FUNCTION RIGHT < T: ANY_STRING >: T VAR_INPUT {ref} - IN : T; + IN: T; END_VAR VAR_INPUT - L : DINT; + L: DINT; END_VAR END_FUNCTION {external} -FUNCTION RIGHT_EXT : DINT +FUNCTION RIGHT_EXT < T: ANY_STRING >: DINT VAR_INPUT {ref} - IN : T; + IN: T; END_VAR VAR_INPUT - L : DINT; + L: DINT; END_VAR VAR_IN_OUT - OUT : T; + OUT: T; END_VAR END_FUNCTION -FUNCTION RIGHT__STRING : STRING[__STRING_LENGTH] +FUNCTION RIGHT__STRING: STRING[__STRING_LENGTH] VAR_INPUT {ref} - IN : STRING[__STRING_LENGTH]; + IN: STRING[__STRING_LENGTH]; END_VAR VAR_INPUT - L : DINT; + L: DINT; END_VAR RIGHT_EXT(IN, L, RIGHT__STRING); END_FUNCTION -FUNCTION RIGHT__WSTRING : WSTRING[__STRING_LENGTH] +FUNCTION RIGHT__WSTRING: WSTRING[__STRING_LENGTH] VAR_INPUT {ref} - IN : WSTRING[__STRING_LENGTH]; + IN: WSTRING[__STRING_LENGTH]; END_VAR VAR_INPUT - L : DINT; + L: DINT; END_VAR RIGHT_EXT(IN, L, RIGHT__WSTRING); END_FUNCTION {external} -FUNCTION RIGHT_EXT__STRING : DINT +FUNCTION RIGHT_EXT__STRING: DINT VAR_INPUT {ref} - IN : STRING[__STRING_LENGTH]; + IN: STRING[__STRING_LENGTH]; END_VAR VAR_INPUT - L : DINT; + L: DINT; END_VAR VAR_IN_OUT - OUT : STRING[__STRING_LENGTH]; + OUT: STRING[__STRING_LENGTH]; END_VAR END_FUNCTION {external} -FUNCTION RIGHT_EXT__WSTRING : DINT +FUNCTION RIGHT_EXT__WSTRING: DINT VAR_INPUT {ref} - IN : WSTRING[__STRING_LENGTH]; + IN: WSTRING[__STRING_LENGTH]; END_VAR VAR_INPUT - L : DINT; + L: DINT; END_VAR VAR_IN_OUT - OUT : WSTRING[__STRING_LENGTH]; + OUT: WSTRING[__STRING_LENGTH]; END_VAR END_FUNCTION -(****************************************************************************** +(* ***************************************************************************** Description: Middle Input: - - IN: A character string - - L: The length of the substring - - P: The starting index position + - IN: A character string + - L: The length of the substring + - P: The starting index position Return: A substring that contains L characters starting from position P in a string. -******************************************************************************) -FUNCTION MID : T +***************************************************************************** *) +FUNCTION MID < T: ANY_STRING >: T VAR_INPUT {ref} - IN : T; + IN: T; END_VAR VAR_INPUT - L : DINT; - P : DINT; + L: DINT; + P: DINT; END_VAR END_FUNCTION {external} -FUNCTION MID_EXT : DINT +FUNCTION MID_EXT < T: ANY_STRING >: DINT VAR_INPUT {ref} - IN : T; + IN: T; END_VAR VAR_INPUT - L : DINT; - P : DINT; + L: DINT; + P: DINT; END_VAR VAR_IN_OUT - OUT : T; + OUT: T; END_VAR END_FUNCTION -FUNCTION MID__STRING : STRING[__STRING_LENGTH] +FUNCTION MID__STRING: STRING[__STRING_LENGTH] VAR_INPUT {ref} - IN : STRING[__STRING_LENGTH]; + IN: STRING[__STRING_LENGTH]; END_VAR VAR_INPUT - L : DINT; - P : DINT; + L: DINT; + P: DINT; END_VAR MID_EXT(IN, L, P, MID__STRING); END_FUNCTION -FUNCTION MID__WSTRING : WSTRING[__STRING_LENGTH] +FUNCTION MID__WSTRING: WSTRING[__STRING_LENGTH] VAR_INPUT {ref} - IN : WSTRING[__STRING_LENGTH]; + IN: WSTRING[__STRING_LENGTH]; END_VAR VAR_INPUT - L : DINT; - P : DINT; + L: DINT; + P: DINT; END_VAR MID_EXT(IN, L, P, MID__WSTRING); END_FUNCTION {external} -FUNCTION MID_EXT__STRING : DINT +FUNCTION MID_EXT__STRING: DINT VAR_INPUT {ref} - IN : STRING[__STRING_LENGTH]; + IN: STRING[__STRING_LENGTH]; END_VAR VAR_INPUT - L : DINT; - P : DINT; + L: DINT; + P: DINT; END_VAR VAR_IN_OUT - OUT : STRING[__STRING_LENGTH]; + OUT: STRING[__STRING_LENGTH]; END_VAR END_FUNCTION {external} -FUNCTION MID_EXT__WSTRING : DINT +FUNCTION MID_EXT__WSTRING: DINT VAR_INPUT {ref} - IN : WSTRING[__STRING_LENGTH]; + IN: WSTRING[__STRING_LENGTH]; END_VAR VAR_INPUT - L : DINT; - P : DINT; + L: DINT; + P: DINT; END_VAR VAR_IN_OUT - OUT : WSTRING[__STRING_LENGTH]; + OUT: WSTRING[__STRING_LENGTH]; END_VAR END_FUNCTION -(****************************************************************************** +(* ***************************************************************************** Description: Extensible concatenation Input: - - IN: Two or more comma-separated strings + - IN: Two or more comma-separated strings Return: A string combining all given input strings in the same order as the given string parameters. -******************************************************************************) +***************************************************************************** *) {external} -FUNCTION CONCAT__STRING : STRING[2048] +FUNCTION CONCAT__STRING: STRING[2048] VAR_INPUT {ref} - args : {sized} STRING...; + args: {sized} STRING...; END_VAR END_FUNCTION {external} -FUNCTION CONCAT__WSTRING : WSTRING[2048] +FUNCTION CONCAT__WSTRING: WSTRING[2048] VAR_INPUT {ref} - args : {sized} WSTRING...; + args: {sized} WSTRING...; END_VAR END_FUNCTION -FUNCTION CONCAT : T +FUNCTION CONCAT < T: ANY_STRING >: T VAR_INPUT {ref} - args : {sized} T...; + args: {sized} T...; END_VAR END_FUNCTION {external} -FUNCTION CONCAT_EXT : DINT +FUNCTION CONCAT_EXT < T: ANY_STRING >: DINT VAR_IN_OUT - OUT : T; + OUT: T; END_VAR VAR_INPUT {ref} - args : {sized} T...; + args: {sized} T...; END_VAR END_FUNCTION -(****************************************************************************** +(* ***************************************************************************** Description: Insert Input: - IN1: The string to insert into - IN2: The string to insert - P: The position at which to insert + IN1: The string to insert into + IN2: The string to insert + P: The position at which to insert Return: A string consisting of IN2 inserted at position P into string IN1 -******************************************************************************) -FUNCTION INSERT : T +***************************************************************************** *) +FUNCTION INSERT < T: ANY_STRING >: T VAR_INPUT {ref} - IN1 : T; - IN2 : T; + IN1: T; + IN2: T; END_VAR VAR_INPUT - P : DINT; + P: DINT; END_VAR END_FUNCTION {external} -FUNCTION INSERT_EXT : DINT +FUNCTION INSERT_EXT < T: ANY_STRING >: DINT VAR_INPUT {ref} - IN1 : T; - IN2 : T; + IN1: T; + IN2: T; END_VAR VAR_INPUT - P : DINT; + P: DINT; END_VAR VAR_IN_OUT - OUT : T; + OUT: T; END_VAR END_FUNCTION -FUNCTION INSERT__STRING : STRING[__STRING_LENGTH] +FUNCTION INSERT__STRING: STRING[__STRING_LENGTH] VAR_INPUT {ref} - IN1 : STRING[__STRING_LENGTH]; - IN2 : STRING[__STRING_LENGTH]; + IN1: STRING[__STRING_LENGTH]; + IN2: STRING[__STRING_LENGTH]; END_VAR VAR_INPUT - P : DINT; + P: DINT; END_VAR INSERT_EXT(IN1, IN2, P, INSERT__STRING); END_FUNCTION -FUNCTION INSERT__WSTRING : WSTRING[__STRING_LENGTH] +FUNCTION INSERT__WSTRING: WSTRING[__STRING_LENGTH] VAR_INPUT {ref} - IN1 : WSTRING[__STRING_LENGTH]; - IN2 : WSTRING[__STRING_LENGTH]; + IN1: WSTRING[__STRING_LENGTH]; + IN2: WSTRING[__STRING_LENGTH]; END_VAR VAR_INPUT - P : DINT; + P: DINT; END_VAR INSERT_EXT(IN1, IN2, P, INSERT__WSTRING); END_FUNCTION {external} -FUNCTION INSERT_EXT__STRING : DINT +FUNCTION INSERT_EXT__STRING: DINT VAR_INPUT {ref} - IN1 : STRING[__STRING_LENGTH]; - IN2 : STRING[__STRING_LENGTH]; + IN1: STRING[__STRING_LENGTH]; + IN2: STRING[__STRING_LENGTH]; END_VAR VAR_INPUT - P : DINT; + P: DINT; END_VAR VAR_IN_OUT - OUT : STRING[__STRING_LENGTH]; + OUT: STRING[__STRING_LENGTH]; END_VAR END_FUNCTION {external} -FUNCTION INSERT_EXT__WSTRING : DINT +FUNCTION INSERT_EXT__WSTRING: DINT VAR_INPUT {ref} - IN1 : WSTRING[__STRING_LENGTH]; - IN2 : WSTRING[__STRING_LENGTH]; + IN1: WSTRING[__STRING_LENGTH]; + IN2: WSTRING[__STRING_LENGTH]; END_VAR VAR_INPUT - P : DINT; + P: DINT; END_VAR VAR_IN_OUT - OUT : WSTRING[__STRING_LENGTH]; + OUT: WSTRING[__STRING_LENGTH]; END_VAR END_FUNCTION -(****************************************************************************** +(* ***************************************************************************** Description: Delete Input: IN: The string to delete characters from - L: The amount of characters to delete - P: The position at which to start deleting + L: The amount of characters to delete + P: The position at which to start deleting Return: A new string with L characters deleted from P onwards -******************************************************************************) -FUNCTION DELETE : T +***************************************************************************** *) +FUNCTION DELETE < T: ANY_STRING >: T VAR_INPUT {ref} - IN : T; + IN: T; END_VAR VAR_INPUT - L : DINT; - P : DINT; + L: DINT; + P: DINT; END_VAR END_FUNCTION {external} -FUNCTION DELETE_EXT : DINT +FUNCTION DELETE_EXT < T: ANY_STRING >: DINT VAR_INPUT {ref} - IN : T; + IN: T; END_VAR VAR_INPUT - L : DINT; - P : DINT; + L: DINT; + P: DINT; END_VAR VAR_IN_OUT - OUT : T; + OUT: T; END_VAR END_FUNCTION -FUNCTION DELETE__STRING : STRING[__STRING_LENGTH] +FUNCTION DELETE__STRING: STRING[__STRING_LENGTH] VAR_INPUT {ref} - IN : STRING[__STRING_LENGTH]; + IN: STRING[__STRING_LENGTH]; END_VAR VAR_INPUT - L : DINT; - P : DINT; + L: DINT; + P: DINT; END_VAR DELETE_EXT(IN, L, P, DELETE__STRING); END_FUNCTION -FUNCTION DELETE__WSTRING : WSTRING[__STRING_LENGTH] +FUNCTION DELETE__WSTRING: WSTRING[__STRING_LENGTH] VAR_INPUT {ref} - IN : WSTRING[__STRING_LENGTH]; + IN: WSTRING[__STRING_LENGTH]; END_VAR VAR_INPUT - L : DINT; - P : DINT; + L: DINT; + P: DINT; END_VAR DELETE_EXT(IN, L, P, DELETE__WSTRING); END_FUNCTION {external} -FUNCTION DELETE_EXT__STRING : DINT +FUNCTION DELETE_EXT__STRING: DINT VAR_INPUT {ref} - IN : STRING[__STRING_LENGTH]; + IN: STRING[__STRING_LENGTH]; END_VAR VAR_INPUT - L : DINT; - P : DINT; + L: DINT; + P: DINT; END_VAR VAR_IN_OUT - OUT : STRING[__STRING_LENGTH]; + OUT: STRING[__STRING_LENGTH]; END_VAR END_FUNCTION {external} -FUNCTION DELETE_EXT__WSTRING : DINT +FUNCTION DELETE_EXT__WSTRING: DINT VAR_INPUT {ref} - IN : WSTRING[__STRING_LENGTH]; + IN: WSTRING[__STRING_LENGTH]; END_VAR VAR_INPUT - L : DINT; - P : DINT; + L: DINT; + P: DINT; END_VAR VAR_IN_OUT - OUT : WSTRING[__STRING_LENGTH]; + OUT: WSTRING[__STRING_LENGTH]; END_VAR END_FUNCTION -(****************************************************************************** +(* ***************************************************************************** Description: Replace Input: - IN1: The string to replace characters from - IN2: The replacement string to be inserted - L: The amount of characters to delete - P: The position at which to start deleting + IN1: The string to replace characters from + IN2: The replacement string to be inserted + L: The amount of characters to delete + P: The position at which to start deleting Return: A new string which has L characters replaced by IN2 from position P onwards -******************************************************************************) -FUNCTION REPLACE : T +***************************************************************************** *) +FUNCTION REPLACE < T: ANY_STRING >: T VAR_INPUT {ref} - IN1 : T; - IN2 : T; + IN1: T; + IN2: T; END_VAR VAR_INPUT - L : DINT; - P : DINT; + L: DINT; + P: DINT; END_VAR END_FUNCTION {external} -FUNCTION REPLACE_EXT : DINT +FUNCTION REPLACE_EXT < T: ANY_STRING >: DINT VAR_INPUT {ref} - IN1 : T; - IN2 : T; + IN1: T; + IN2: T; END_VAR VAR_INPUT - L : DINT; - P : DINT; + L: DINT; + P: DINT; END_VAR VAR_IN_OUT - OUT : T; + OUT: T; END_VAR END_FUNCTION -FUNCTION REPLACE__STRING : STRING[__STRING_LENGTH] +FUNCTION REPLACE__STRING: STRING[__STRING_LENGTH] VAR_INPUT {ref} - IN1 : STRING[__STRING_LENGTH]; - IN2 : STRING[__STRING_LENGTH]; + IN1: STRING[__STRING_LENGTH]; + IN2: STRING[__STRING_LENGTH]; END_VAR VAR_INPUT - L : DINT; - P : DINT; + L: DINT; + P: DINT; END_VAR REPLACE_EXT(IN1, IN2, L, P, REPLACE__STRING); END_FUNCTION -FUNCTION REPLACE__WSTRING : WSTRING[__STRING_LENGTH] +FUNCTION REPLACE__WSTRING: WSTRING[__STRING_LENGTH] VAR_INPUT {ref} - IN1 : WSTRING[__STRING_LENGTH]; - IN2 : WSTRING[__STRING_LENGTH]; + IN1: WSTRING[__STRING_LENGTH]; + IN2: WSTRING[__STRING_LENGTH]; END_VAR VAR_INPUT - L : DINT; - P : DINT; + L: DINT; + P: DINT; END_VAR REPLACE_EXT(IN1, IN2, L, P, REPLACE__WSTRING); END_FUNCTION {external} -FUNCTION REPLACE_EXT__STRING : DINT +FUNCTION REPLACE_EXT__STRING: DINT VAR_INPUT {ref} - IN1 : STRING[__STRING_LENGTH]; - IN2 : STRING[__STRING_LENGTH]; + IN1: STRING[__STRING_LENGTH]; + IN2: STRING[__STRING_LENGTH]; END_VAR VAR_INPUT - L : DINT; - P : DINT; + L: DINT; + P: DINT; END_VAR VAR_IN_OUT - OUT : STRING[__STRING_LENGTH]; + OUT: STRING[__STRING_LENGTH]; END_VAR END_FUNCTION {external} -FUNCTION REPLACE_EXT__WSTRING : DINT +FUNCTION REPLACE_EXT__WSTRING: DINT VAR_INPUT {ref} - IN1 : WSTRING[__STRING_LENGTH]; - IN2 : WSTRING[__STRING_LENGTH]; + IN1: WSTRING[__STRING_LENGTH]; + IN2: WSTRING[__STRING_LENGTH]; END_VAR VAR_INPUT - L : DINT; - P : DINT; + L: DINT; + P: DINT; END_VAR VAR_IN_OUT - OUT : WSTRING[__STRING_LENGTH]; + OUT: WSTRING[__STRING_LENGTH]; END_VAR END_FUNCTION -(****************************************************************************** +(* ***************************************************************************** Description: Find Input: - IN1: The string in which to search in - IN2: The substring to search for + IN1: The string in which to search in + IN2: The substring to search for Return: The character index of the first match. 0 if there are no matches. -******************************************************************************) +***************************************************************************** *) {external} -FUNCTION FIND : DINT +FUNCTION FIND < T: ANY_STRING >: DINT VAR_INPUT {ref} - IN1 : T; - IN2 : T; + IN1: T; + IN2: T; END_VAR END_FUNCTION -(****************************************************************************** +(* ***************************************************************************** Description: Decreasing sequence -Input: The strings to compare, in order. ((IN1>IN2) & (IN2>IN3) & .. & (INn-1>INn)) +Input: The strings to compare, in order. ((IN1>IN2) & (IN2>IN3) & .. & (INn-1>INn)) Return: TRUE if codepoints are in decreasing order (alphabetical order: ZYX > YXW > XWV ..) FALSE otherwise -******************************************************************************) -{external} -FUNCTION GT : BOOL -VAR_INPUT {ref} - IN1 : {sized} T...; -END_VAR -END_FUNCTION - -{external} -FUNCTION GT__STRING : BOOL -VAR_INPUT {ref} - IN1 : {sized} STRING...; -END_VAR -END_FUNCTION - -{external} -FUNCTION GT__WSTRING : BOOL -VAR_INPUT {ref} - IN1 : {sized} WSTRING...; -END_VAR -END_FUNCTION - +***************************************************************************** *) // passing strings by ref causes an error/warning. code still compiles and works correctly -FUNCTION STRING_GREATER : BOOL +FUNCTION STRING_GREATER: BOOL VAR_INPUT - a, b : STRING; + a, b: STRING; END_VAR - STRING_GREATER := GT(a, b); + STRING_GREATER := __STRING_GREATER(a, b); END_FUNCTION -FUNCTION WSTRING_GREATER : BOOL +FUNCTION WSTRING_GREATER: BOOL VAR_INPUT - a, b : WSTRING; -END_VAR - WSTRING_GREATER := GT(a, b); -END_FUNCTION - -(****************************************************************************** -Description: Monotonic sequence -Input: The strings to compare, in order. ((IN1>=IN2) & (IN2>=IN3) & .. & (INn-1>=INn)) -Return: - TRUE if codepoints are in decreasing order or are equal to adjacent codepoints (alphabetical order: ZYX >= ZYX >= YXW ..) - FALSE otherwise -******************************************************************************) -{external} -FUNCTION GE : BOOL -VAR_INPUT {ref} - IN1 : {sized} T...; + a, b: WSTRING; END_VAR + WSTRING_GREATER := __WSTRING_GREATER(a, b); END_FUNCTION -{external} -FUNCTION GE__STRING : BOOL -VAR_INPUT {ref} - IN1 : {sized} STRING...; -END_VAR -END_FUNCTION - -{external} -FUNCTION GE__WSTRING : BOOL -VAR_INPUT {ref} - IN1 : {sized} WSTRING...; -END_VAR -END_FUNCTION - -(****************************************************************************** +(* ***************************************************************************** Description: Equality Input: The strings to compare, in order. ((IN1=IN2) & (IN2=IN3) & .. & (INn-1=INn)) Return: TRUE if codepoints are equal to each other FALSE otherwise. -******************************************************************************) -{external} -FUNCTION EQ : BOOL -VAR_INPUT {ref} - IN1 : {sized} T...; -END_VAR -END_FUNCTION - -{external} -FUNCTION EQ__STRING : BOOL -VAR_INPUT {ref} - IN1 : {sized} STRING...; -END_VAR -END_FUNCTION - -{external} -FUNCTION EQ__WSTRING : BOOL -VAR_INPUT {ref} - IN1 : {sized} WSTRING...; -END_VAR -END_FUNCTION - -FUNCTION STRING_EQUAL : BOOL +***************************************************************************** *) +FUNCTION STRING_EQUAL: BOOL VAR_INPUT - a, b : STRING; + a, b: STRING; END_VAR - STRING_EQUAL := EQ(a, b); + STRING_EQUAL := __STRING_EQUAL(a, b); END_FUNCTION -FUNCTION WSTRING_EQUAL : BOOL +FUNCTION WSTRING_EQUAL: BOOL VAR_INPUT - a, b : WSTRING; + a, b: WSTRING; END_VAR - WSTRING_EQUAL := EQ(a, b); + WSTRING_EQUAL := __WSTRING_EQUAL(a, b); END_FUNCTION -(****************************************************************************** -Description: Monotonic sequence -Input: The strings to compare, in order. ((IN1<=IN2) & (IN2<=IN3) & .. & (INn-1<=INn)) +(* ***************************************************************************** +Description: Increasing sequence +Input: The strings to compare, in order. ((IN1 : BOOL -VAR_INPUT {ref} - IN1 : {sized} T...; +***************************************************************************** *) +FUNCTION STRING_LESS: BOOL +VAR_INPUT + a, b: STRING; END_VAR + STRING_LESS := __STRING_LESS(a, b); END_FUNCTION -{external} -FUNCTION LE__STRING : BOOL -VAR_INPUT {ref} - IN1 : {sized} STRING...; +FUNCTION WSTRING_LESS: BOOL +VAR_INPUT + a, b: WSTRING; END_VAR + WSTRING_LESS := __WSTRING_LESS(a, b); END_FUNCTION +// internal functions {external} -FUNCTION LE__WSTRING : BOOL +FUNCTION __STRING_GREATER: BOOL VAR_INPUT {ref} - IN1 : {sized} WSTRING...; + IN: {sized} STRING...; END_VAR END_FUNCTION -(****************************************************************************** -Description: Increasing sequence -Input: The strings to compare, in order. ((IN1 : BOOL +FUNCTION __STRING_EQUAL: BOOL VAR_INPUT {ref} - IN1 : {sized} T...; + IN: {sized} STRING...; END_VAR END_FUNCTION {external} -FUNCTION LT__STRING : BOOL +FUNCTION __STRING_LESS: BOOL VAR_INPUT {ref} - IN1 : {sized} STRING...; + IN: {sized} STRING...; END_VAR END_FUNCTION {external} -FUNCTION LT__WSTRING : BOOL +FUNCTION __WSTRING_GREATER: BOOL VAR_INPUT {ref} - IN1 : {sized} WSTRING...; + IN: {sized} WSTRING...; END_VAR END_FUNCTION -FUNCTION STRING_LESS : BOOL -VAR_INPUT - a, b : STRING; -END_VAR - STRING_LESS := LT(a, b); -END_FUNCTION - -FUNCTION WSTRING_LESS : BOOL -VAR_INPUT - a, b : WSTRING; +{external} +FUNCTION __WSTRING_EQUAL: BOOL +VAR_INPUT {ref} + IN: {sized} WSTRING...; END_VAR - WSTRING_LESS := LT(a, b); END_FUNCTION -(****************************************************************************** -Description: Inequality -Input: The strings to compare. (IN1<>IN2) -Return: - TRUE if strings do not match - FALSE otherwise -******************************************************************************) {external} -FUNCTION NE : BOOL +FUNCTION __WSTRING_LESS: BOOL VAR_INPUT {ref} - IN1 : T; - IN2 : T; + IN: {sized} WSTRING...; END_VAR END_FUNCTION diff --git a/libs/stdlib/src/string_functions.rs b/libs/stdlib/src/string_functions.rs index a2cc27d001..d83eeb06f4 100644 --- a/libs/stdlib/src/string_functions.rs +++ b/libs/stdlib/src/string_functions.rs @@ -760,7 +760,7 @@ where /// Works on raw pointers, inherently unsafe. #[allow(non_snake_case)] #[no_mangle] -pub unsafe extern "C" fn GT__STRING(argc: i32, argv: *const *const u8) -> bool { +pub unsafe extern "C" fn __STRING_GREATER(argc: i32, argv: *const *const u8) -> bool { compare(argc, argv, Ordering::is_gt) } @@ -772,34 +772,10 @@ pub unsafe extern "C" fn GT__STRING(argc: i32, argv: *const *const u8) -> bool { /// Works on raw pointers, inherently unsafe. #[allow(non_snake_case)] #[no_mangle] -pub unsafe extern "C" fn GT__WSTRING(argc: i32, argv: *const *const u16) -> bool { +pub unsafe extern "C" fn __WSTRING_GREATER(argc: i32, argv: *const *const u16) -> bool { compare(argc, argv, Ordering::is_gt) } -/// Extensible "greater or equal" comparison function. -/// Encoding: UTF-8 -/// -/// # Safety -/// -/// Works on raw pointers, inherently unsafe. -#[allow(non_snake_case)] -#[no_mangle] -pub unsafe extern "C" fn GE__STRING(argc: i32, argv: *const *const u8) -> bool { - compare(argc, argv, Ordering::is_ge) -} - -/// Extensible "greater or equal" comparison function. -/// Encoding: UTF-16 -/// -/// # Safety -/// -/// Works on raw pointers, inherently unsafe. -#[allow(non_snake_case)] -#[no_mangle] -pub unsafe extern "C" fn GE__WSTRING(argc: i32, argv: *const *const u16) -> bool { - compare(argc, argv, Ordering::is_ge) -} - /// Extensible "equal" comparison function. /// Encoding: UTF-8 /// @@ -808,7 +784,7 @@ pub unsafe extern "C" fn GE__WSTRING(argc: i32, argv: *const *const u16) -> bool /// Works on raw pointers, inherently unsafe. #[allow(non_snake_case)] #[no_mangle] -pub unsafe extern "C" fn EQ__STRING(argc: i32, argv: *const *const u8) -> bool { +pub unsafe extern "C" fn __STRING_EQUAL(argc: i32, argv: *const *const u8) -> bool { compare(argc, argv, Ordering::is_eq) } @@ -820,34 +796,10 @@ pub unsafe extern "C" fn EQ__STRING(argc: i32, argv: *const *const u8) -> bool { /// Works on raw pointers, inherently unsafe. #[allow(non_snake_case)] #[no_mangle] -pub unsafe extern "C" fn EQ__WSTRING(argc: i32, argv: *const *const u16) -> bool { +pub unsafe extern "C" fn __WSTRING_EQUAL(argc: i32, argv: *const *const u16) -> bool { compare(argc, argv, Ordering::is_eq) } -/// Extensible "less or equal" comparison function. -/// Encoding: UTF-8 -/// -/// # Safety -/// -/// Works on raw pointers, inherently unsafe. -#[allow(non_snake_case)] -#[no_mangle] -pub unsafe extern "C" fn LE__STRING(argc: i32, argv: *const *const u8) -> bool { - compare(argc, argv, Ordering::is_le) -} - -/// Extensible "less or equal" comparison function. -/// Encoding: UTF-16 -/// -/// # Safety -/// -/// Works on raw pointers, inherently unsafe. -#[allow(non_snake_case)] -#[no_mangle] -pub unsafe extern "C" fn LE__WSTRING(argc: i32, argv: *const *const u16) -> bool { - compare(argc, argv, Ordering::is_le) -} - /// Extensible "less than" comparison function. /// Encoding: UTF-8 /// @@ -856,7 +808,7 @@ pub unsafe extern "C" fn LE__WSTRING(argc: i32, argv: *const *const u16) -> bool /// Works on raw pointers, inherently unsafe. #[allow(non_snake_case)] #[no_mangle] -pub unsafe extern "C" fn LT__STRING(argc: i32, argv: *const *const u8) -> bool { +pub unsafe extern "C" fn __STRING_LESS(argc: i32, argv: *const *const u8) -> bool { compare(argc, argv, Ordering::is_lt) } @@ -868,34 +820,10 @@ pub unsafe extern "C" fn LT__STRING(argc: i32, argv: *const *const u8) -> bool { /// Works on raw pointers, inherently unsafe. #[allow(non_snake_case)] #[no_mangle] -pub unsafe extern "C" fn LT__WSTRING(argc: i32, argv: *const *const u16) -> bool { +pub unsafe extern "C" fn __WSTRING_LESS(argc: i32, argv: *const *const u16) -> bool { compare(argc, argv, Ordering::is_lt) } -/// "Not equal" comparison function. -/// Encoding: UTF-8 -/// -/// # Safety -/// -/// Works on raw pointers, inherently unsafe. -#[allow(non_snake_case)] -#[no_mangle] -pub unsafe extern "C" fn NE__STRING(string1: *const u8, string2: *const u8) -> bool { - ptr_to_slice(string1).cmp(ptr_to_slice(string2)).is_ne() -} - -/// "Not equal" comparison function. -/// Encoding: UTF-16 -/// -/// # Safety -/// -/// Works on raw pointers, inherently unsafe. -#[allow(non_snake_case)] -#[no_mangle] -pub unsafe extern "C" fn NE__WSTRING(string1: *const u16, string2: *const u16) -> bool { - ptr_to_slice(string1).cmp(ptr_to_slice(string2)).is_ne() -} - // -------------------------------------------------unit tests----------------------------------------- #[cfg(test)] mod test { @@ -1329,49 +1257,35 @@ mod test { fn test_greater_than_string_is_false_for_equal_strings() { let argv = ["hællø wørlÞ\0".as_ptr(), "hællø wørlÞ\0".as_ptr()]; let argc = argv.len() as i32; - unsafe { assert!(!GT__STRING(argc, argv.as_ptr())) } + unsafe { assert!(!__STRING_GREATER(argc, argv.as_ptr())) } } #[test] fn test_greater_than_string_is_true_for_decreasing_sequence() { let argv = ["zyxZabcdefghijklmn\0".as_ptr(), "zyxA\0".as_ptr(), "zyx\0".as_ptr()]; let argc = argv.len() as i32; - unsafe { assert!(GT__STRING(argc, argv.as_ptr())) } + unsafe { assert!(__STRING_GREATER(argc, argv.as_ptr())) } } #[test] fn test_greater_than_string_is_false_for_increasing_sequence() { let argv = ["abc\0".as_ptr(), "bce\0".as_ptr(), "xyz\0".as_ptr()]; let argc = argv.len() as i32; - unsafe { assert!(!GT__STRING(argc, argv.as_ptr())) } + unsafe { assert!(!__STRING_GREATER(argc, argv.as_ptr())) } } #[test] fn test_greater_than_string_works_correctly_for_two_params() { let argv = ["zyxAabcdefghijklmn\0".as_ptr(), "zyxZ".as_ptr()]; let argc = argv.len() as i32; - unsafe { assert!(!GT__STRING(argc, argv.as_ptr())) } - } - - #[test] - fn test_greater_or_equal_string() { - let argv = ["xyz\0".as_ptr(), "bcefghijkl\0".as_ptr(), "abc\0".as_ptr()]; - let argc = argv.len() as i32; - unsafe { assert!(GE__STRING(argc, argv.as_ptr())) } - } - - #[test] - fn test_greater_or_equal_string_is_true_for_equal_strings() { - let argv = ["hællø wørlÞ\0".as_ptr(), "hællø wørlÞ\0".as_ptr()]; - let argc = argv.len() as i32; - unsafe { assert!(GE__STRING(argc, argv.as_ptr())) } + unsafe { assert!(!__STRING_GREATER(argc, argv.as_ptr())) } } #[test] fn test_equal_string() { let argv = ["hællø wørlÞ\0".as_ptr(), "hællø wørlÞ\0".as_ptr()]; let argc = argv.len() as i32; - unsafe { assert!(EQ__STRING(argc, argv.as_ptr())) } + unsafe { assert!(__STRING_EQUAL(argc, argv.as_ptr())) } } #[test] @@ -1383,69 +1297,21 @@ mod test { "hællø wørlÞZZc\0".as_ptr(), ]; let argc = argv.len() as i32; - unsafe { assert!(!EQ__STRING(argc, argv.as_ptr())) } + unsafe { assert!(!__STRING_EQUAL(argc, argv.as_ptr())) } } #[test] fn test_lesser_than_string() { let argv = ["hællø wørlÞabc\0".as_ptr(), "hællø wørlÞz\0".as_ptr()]; let argc = argv.len() as i32; - unsafe { assert!(LT__STRING(argc, argv.as_ptr())) } + unsafe { assert!(__STRING_LESS(argc, argv.as_ptr())) } } #[test] fn test_lesser_than_string_is_false() { let argv = ["z\0".as_ptr(), "hællø wørlÞzbc\0".as_ptr()]; let argc = argv.len() as i32; - unsafe { assert!(!LT__STRING(argc, argv.as_ptr())) } - } - - #[test] - fn test_lesser_or_equal_string_is_true_for_increasing_sequence() { - let argv = [ - "a\0".as_ptr(), - "a\0".as_ptr(), - "b\0".as_ptr(), - "b\0".as_ptr(), - "b\0".as_ptr(), - "hællø wørlÞzbc\0".as_ptr(), - "hællø wørlÞzbc\0".as_ptr(), - "hællø wørlÞzbc\0".as_ptr(), - "q".as_ptr(), - ]; - let argc = argv.len() as i32; - unsafe { assert!(LE__STRING(argc, argv.as_ptr())) } - } - - #[test] - fn test_lesser_or_equal_string_is_false_if_last_string_doesnt_match() { - let argv = [ - "a\0".as_ptr(), - "a\0".as_ptr(), - "b\0".as_ptr(), - "b\0".as_ptr(), - "b\0".as_ptr(), - "hællø wørlÞzbc\0".as_ptr(), - "hællø wørlÞzbc\0".as_ptr(), - "hællø wørlÞzbc\0".as_ptr(), - "a".as_ptr(), - ]; - let argc = argv.len() as i32; - unsafe { assert!(!LE__STRING(argc, argv.as_ptr())) } - } - - #[test] - fn test_not_equal_string_is_true_for_unequal_strings() { - let string1 = "these strings".as_ptr(); - let string2 = "are not equal".as_ptr(); - unsafe { assert!(NE__STRING(string1, string2)) } - } - - #[test] - fn test_not_equal_string_is_false_for_equal_strings() { - let string1 = "these strings are equal".as_ptr(); - let string2 = "these strings are equal".as_ptr(); - unsafe { assert!(!NE__STRING(string1, string2)) } + unsafe { assert!(!__STRING_LESS(argc, argv.as_ptr())) } } // -----------------------------------UTF16 @@ -1855,22 +1721,7 @@ mod test { argv[i] = arg.as_ptr(); } let argc = argv.len() as i32; - unsafe { assert!(GT__WSTRING(argc, argv.as_ptr())) } - } - - #[test] - fn test_ge_wstring() { - let argvec: [Vec; 3] = [ - "hællø wørlÞ\0".encode_utf16().collect(), - "hello world\0".encode_utf16().collect(), - "hello world\0".encode_utf16().collect(), - ]; - let mut argv: [*const u16; 3] = [std::ptr::null(); 3]; - for (i, arg) in argvec.iter().enumerate() { - argv[i] = arg.as_ptr(); - } - let argc = argv.len() as i32; - unsafe { assert!(GE__WSTRING(argc, argv.as_ptr())) } + unsafe { assert!(__WSTRING_GREATER(argc, argv.as_ptr())) } } #[test] @@ -1885,7 +1736,7 @@ mod test { argv[i] = arg.as_ptr(); } let argc = argv.len() as i32; - unsafe { assert!(EQ__WSTRING(argc, argv.as_ptr())) } + unsafe { assert!(__WSTRING_EQUAL(argc, argv.as_ptr())) } } #[test] @@ -1900,35 +1751,6 @@ mod test { argv[i] = arg.as_ptr(); } let argc = argv.len() as i32; - unsafe { assert!(LT__WSTRING(argc, argv.as_ptr())) } - } - - #[test] - fn test_le_wstring() { - let argvec: [Vec; 6] = [ - "hello\0".encode_utf16().collect(), - "hello worlb\0".encode_utf16().collect(), - "hello worlc\0".encode_utf16().collect(), - "hello world\0".encode_utf16().collect(), - "hællø wørlÞ\0".encode_utf16().collect(), - "hællø wørlÞ\0".encode_utf16().collect(), - ]; - let mut argv: [*const u16; 6] = [std::ptr::null(); 6]; - for (i, arg) in argvec.iter().enumerate() { - argv[i] = arg.as_ptr(); - } - let argc = argv.len() as i32; - unsafe { assert!(LE__WSTRING(argc, argv.as_ptr())) } - } - - #[test] - fn test_ne_wstring() { - let argvec: [Vec; 2] = - ["hællø wørlÞ\0".encode_utf16().collect(), "hello world\0".encode_utf16().collect()]; - let mut argv: [*const u16; 2] = [std::ptr::null(); 2]; - for (i, arg) in argvec.iter().enumerate() { - argv[i] = arg.as_ptr(); - } - unsafe { assert!(NE__WSTRING(argv[0], argv[1])) } + unsafe { assert!(__WSTRING_LESS(argc, argv.as_ptr())) } } } diff --git a/libs/stdlib/tests/common/mod.rs b/libs/stdlib/tests/common/mod.rs index 548ee6c86a..93eba4e5ba 100644 --- a/libs/stdlib/tests/common/mod.rs +++ b/libs/stdlib/tests/common/mod.rs @@ -331,18 +331,12 @@ pub fn compile_with_native(context: &CodegenContext, source: T) - ("CONCAT_EXT__STRING", iec61131std::string_functions::CONCAT_EXT__STRING as usize), ("CONCAT__WSTRING", iec61131std::string_functions::CONCAT__WSTRING as usize), ("CONCAT_EXT__WSTRING", iec61131std::string_functions::CONCAT_EXT__WSTRING as usize), - ("GT__STRING", iec61131std::string_functions::GT__STRING as usize), - ("GT__WSTRING", iec61131std::string_functions::GT__WSTRING as usize), - ("GE__STRING", iec61131std::string_functions::GE__STRING as usize), - ("GE__WSTRING", iec61131std::string_functions::GE__WSTRING as usize), - ("EQ__STRING", iec61131std::string_functions::EQ__STRING as usize), - ("EQ__WSTRING", iec61131std::string_functions::EQ__WSTRING as usize), - ("LE__STRING", iec61131std::string_functions::LE__STRING as usize), - ("LE__WSTRING", iec61131std::string_functions::LE__WSTRING as usize), - ("LT__STRING", iec61131std::string_functions::LT__STRING as usize), - ("LT__WSTRING", iec61131std::string_functions::LT__WSTRING as usize), - ("NE__STRING", iec61131std::string_functions::NE__STRING as usize), - ("NE__WSTRING", iec61131std::string_functions::NE__WSTRING as usize), + ("__STRING_GREATER", iec61131std::string_functions::__STRING_GREATER as usize), + ("__WSTRING_GREATER", iec61131std::string_functions::__WSTRING_GREATER as usize), + ("__STRING_EQUAL", iec61131std::string_functions::__STRING_EQUAL as usize), + ("__WSTRING_EQUAL", iec61131std::string_functions::__WSTRING_EQUAL as usize), + ("__STRING_LESS", iec61131std::string_functions::__STRING_LESS as usize), + ("__WSTRING_LESS", iec61131std::string_functions::__WSTRING_LESS as usize), ("EXPT__REAL__DINT", iec61131std::arithmetic_functions::EXPT__REAL__DINT as usize), ("EXPT__REAL__REAL", iec61131std::arithmetic_functions::EXPT__REAL__REAL as usize), ("EXPT__REAL__LREAL", iec61131std::arithmetic_functions::EXPT__REAL__LREAL as usize), diff --git a/libs/stdlib/tests/date_time_numeric_functions_tests.rs b/libs/stdlib/tests/date_time_numeric_functions_tests.rs index 2c40fdff06..0d3dc5b6ba 100644 --- a/libs/stdlib/tests/date_time_numeric_functions_tests.rs +++ b/libs/stdlib/tests/date_time_numeric_functions_tests.rs @@ -933,3 +933,55 @@ fn div_ltime() { chrono::Utc.timestamp_millis_opt(2_700).unwrap() // 2_700ms => 2s 700ms ); } + +#[test] +#[should_panic] +fn date_time_overloaded_add_function_called_with_too_many_params() { + let src = " + FUNCTION main : LINT + VAR + x1 : ARRAY[0..3] OF DATE; + x2 : DATE; + END_VAR + main := ADD(x1[0], x1[1], x1[2], x1[3], x2); + END_FUNCTION + "; + + let sources = add_std!(src, "date_time_numeric_functions.st"); + let mut maintype = MainType::default(); + let _: i64 = compile_and_run(sources, &mut maintype); +} + +#[test] +fn date_time_overloaded_add_and_numerical_add_compile_correctly() { + let src = " + PROGRAM main + VAR + a: LINT; + b: REAL; + END_VAR + VAR_TEMP + var_tod : TOD := TOD#23:00:01; + var_time : TIME := TIME#55m59s; + var_real : REAL := 1.0; + var_dint : DINT := 10; + END_VAR + a := ADD(var_tod, var_time); + b := ADD(var_real, var_dint, 3, 4); + END_PROGRAM + "; + + #[derive(Default)] + struct MainType { + a: i64, + b: f32, + } + + let sources = add_std!(src, "date_time_numeric_functions.st"); + let mut maintype = MainType::default(); + let _: i64 = compile_and_run(sources, &mut maintype); + let tod_23h_56m = get_time_from_hms(23, 56, 0).timestamp_nanos(); + + assert_eq!(tod_23h_56m, maintype.a); + assert_eq!(18.0, maintype.b); +} diff --git a/src/builtins.rs b/src/builtins.rs index 8703113e21..5ea50f91dc 100644 --- a/src/builtins.rs +++ b/src/builtins.rs @@ -8,8 +8,8 @@ use inkwell::{ use lazy_static::lazy_static; use plc_ast::{ ast::{ - self, flatten_expression_list, pre_process, AstNode, AstStatement, CompilationUnit, GenericBinding, - LinkageType, TypeNature, + self, flatten_expression_list, pre_process, AstFactory, AstNode, AstStatement, CompilationUnit, + GenericBinding, LinkageType, Operator, TypeNature, }, literals::AstLiteral, provider::IdProvider, @@ -23,10 +23,10 @@ use crate::{ lexer, parser, resolver::{ self, - generics::{no_generic_name_resolver, GenericType}, + generics::{generic_name_resolver, no_generic_name_resolver, GenericType}, AnnotationMap, StatementAnnotation, TypeAnnotator, VisitorContext, }, - typesystem::{self, get_literal_actual_signed_type_name}, + typesystem::{self, get_bigger_type, get_literal_actual_signed_type_name}, validation::{Validator, Validators}, }; @@ -68,7 +68,7 @@ lazy_static! { END_VAR END_FUNCTION ", - annotation: Some(|annotator, operator, parameters, _| { + annotation: Some(|annotator, _, operator, parameters, _| { // invalid amount of parameters is checked during validation let Some(params) = parameters else { return; }; // Get the input and annotate it with a pointer type @@ -288,8 +288,8 @@ lazy_static! { dim : T; END_VAR END_FUNCTION", - annotation: Some(|annotator, _, parameters, _| { - annotate_variable_length_array_bound_function(annotator, parameters) + annotation: Some(|annotator, _, _, parameters, _| { + annotate_variable_length_array_bound_function(annotator, parameters); }), validation: Some(|validator, operator, parameters, annotations, index| { validate_variable_length_array_bound_function(validator, operator, parameters, annotations, index) @@ -311,8 +311,8 @@ lazy_static! { dim : T; END_VAR END_FUNCTION", - annotation: Some(|annotator, _, parameters, _| { - annotate_variable_length_array_bound_function(annotator, parameters) + annotation: Some(|annotator, _, _, parameters, _| { + annotate_variable_length_array_bound_function(annotator, parameters); }), validation: Some(|validator, operator, parameters, annotations, index| { validate_variable_length_array_bound_function(validator, operator, parameters, annotations, index) @@ -323,9 +323,396 @@ lazy_static! { } } ), + // Arithmetic functions + ( + "ADD", + BuiltIn { + decl: "FUNCTION ADD : T + VAR_INPUT + args: {sized} T...; + END_VAR + END_FUNCTION + ", + annotation: Some(|annotator, statement, operator, parameters, ctx| { + let Some(params) = parameters else { + return; + }; + + annotate_arithmetic_function(annotator, statement, operator, params, ctx, Operator::Plus) + }), + validation:Some(|validator, operator, parameters, _, _| { + validate_builtin_symbol_parameter_count(validator, operator, parameters, Operator::Plus) + }), + generic_name_resolver, + code: |_, _, _| { + unreachable!("ADD is not generated as a function call"); + } + } + ), + ( + "MUL", + BuiltIn { + decl: "FUNCTION MUL : T + VAR_INPUT + args: {sized} T...; + END_VAR + END_FUNCTION + ", + annotation: Some(|annotator, statement, operator, parameters, ctx| { + let Some(params) = parameters else { + return; + }; + + annotate_arithmetic_function(annotator, statement, operator, params, ctx, Operator::Multiplication) + }), + validation: Some(|validator, operator, parameters, _, _| { + validate_builtin_symbol_parameter_count(validator, operator, parameters, Operator::Multiplication) + }), + generic_name_resolver, + code: |_, _, _| { + unreachable!("MUL is not generated as a function call"); + } + } + ), + ( + "SUB", + BuiltIn { + decl: "FUNCTION SUB : T1 + VAR_INPUT + IN1 : T1; + IN2 : T2; + END_VAR + END_FUNCTION + ", + annotation: Some(|annotator, statement, operator, parameters, ctx| { + let Some(params) = parameters else { + return; + }; + annotate_arithmetic_function(annotator, statement, operator, params, ctx, Operator::Minus) + }), + validation:Some(|validator, operator, parameters, _, _| { + validate_builtin_symbol_parameter_count(validator, operator, parameters, Operator::Minus) + }), + generic_name_resolver, + code: |_, _, _| { + unreachable!("SUB is not generated as a function call"); + } + } + ), + ( + "DIV", + BuiltIn { + decl: "FUNCTION DIV : T1 + VAR_INPUT + IN1 : T1; + IN2 : T2; + END_VAR + END_FUNCTION + ", + annotation: Some(|annotator, statement, operator, parameters, ctx| { + let Some(params) = parameters else { + return; + }; + annotate_arithmetic_function(annotator, statement, operator, params, ctx, Operator::Division) + }), + validation:Some(|validator, operator, parameters, _, _| { + validate_builtin_symbol_parameter_count(validator, operator, parameters, Operator::Division) + }), + generic_name_resolver, + code: |_, _, _| { + unreachable!("DIV is not generated as a function call"); + } + } + ), + // TODO: MOD and AND/OR/XOR/NOT ANY_BIT ( NOT also supports boolean ) - FIXME: these are all keywords and therefore conflicting + ( + "GT", + BuiltIn { + decl: "FUNCTION GT : BOOL + VAR_INPUT + IN : {sized} T...; + END_VAR + END_FUNCTION + ", + annotation: Some(|annotator, statement, operator, parameters, ctx| { + let Some(params) = parameters else { + return; + }; + annotate_comparison_function(annotator, statement, operator, params, ctx, Operator::Greater); + }), + validation:Some(|validator, operator, parameters, _, _| { + validate_builtin_symbol_parameter_count(validator, operator, parameters, Operator::Greater) + }), + generic_name_resolver: no_generic_name_resolver, + code : |_, _, _| { + unreachable!("GT is not generated as a function call"); + } + } + ), + ( + "GE", + BuiltIn { + decl: "FUNCTION GE : BOOL + VAR_INPUT + IN : {sized} T...; + END_VAR + END_FUNCTION + ", + annotation: Some(|annotator, statement, operator, parameters, ctx| { + let Some(params) = parameters else { + return; + }; + annotate_comparison_function(annotator, statement, operator, params, ctx, Operator::GreaterOrEqual); + }), + validation:Some(|validator, operator, parameters, _, _| { + validate_builtin_symbol_parameter_count(validator, operator, parameters, Operator::GreaterOrEqual) + }), + generic_name_resolver: no_generic_name_resolver, + code : |_, _, _| { + unreachable!("GE is not generated as a function call"); + } + } + ), + ( + "EQ", + BuiltIn { + decl: "FUNCTION EQ : BOOL + VAR_INPUT + IN : {sized} T...; + END_VAR + END_FUNCTION + ", + annotation: Some(|annotator, statement, operator, parameters, ctx| { + let Some(params) = parameters else { + return; + }; + annotate_comparison_function(annotator, statement, operator, params, ctx, Operator::Equal); + }), + validation:Some(|validator, operator, parameters, _, _| { + validate_builtin_symbol_parameter_count(validator, operator, parameters, Operator::Equal) + }), + generic_name_resolver: no_generic_name_resolver, + code : |_, _, _| { + unreachable!("EQ is not generated as a function call"); + } + } + ), + ( + "LE", + BuiltIn { + decl: "FUNCTION LE : BOOL + VAR_INPUT + IN : {sized} T...; + END_VAR + END_FUNCTION + ", + annotation: Some(|annotator, statement, operator, parameters, ctx| { + let Some(params) = parameters else { + return; + }; + annotate_comparison_function(annotator, statement, operator, params, ctx, Operator::LessOrEqual); + }), + validation:Some(|validator, operator, parameters, _, _| { + validate_builtin_symbol_parameter_count(validator, operator, parameters, Operator::LessOrEqual) + }), + generic_name_resolver: no_generic_name_resolver, + code : |_, _, _| { + unreachable!("LE is not generated as a function call"); + } + } + ), + ( + "LT", + BuiltIn { + decl: "FUNCTION LT : BOOL + VAR_INPUT + IN : {sized} T...; + END_VAR + END_FUNCTION + ", + annotation: Some(|annotator, statement, operator, parameters, ctx| { + let Some(params) = parameters else { + return; + }; + annotate_comparison_function(annotator, statement, operator, params, ctx, Operator::Less); + }), + validation:Some(|validator, operator, parameters, _, _| { + validate_builtin_symbol_parameter_count(validator, operator, parameters, Operator::Less) + }), + generic_name_resolver: no_generic_name_resolver, + code : |_, _, _| { + unreachable!("LT is not generated as a function call"); + } + } + ), + ( + "NE", + BuiltIn { + decl: "FUNCTION NE : BOOL + VAR_INPUT + IN1 : T; + IN2 : T; + END_VAR + END_FUNCTION + ", + annotation: Some(|annotator, statement, operator, parameters, ctx| { + let Some(params) = parameters else { + return; + }; + annotate_comparison_function(annotator, statement, operator, params, ctx, Operator::NotEqual); + }), + validation: Some(|validator, operator, parameters, _, _| { + validate_builtin_symbol_parameter_count(validator, operator, parameters, Operator::NotEqual) + }), + generic_name_resolver: no_generic_name_resolver, + code : |_, _, _| { + unreachable!("NE is not generated as a function call"); + } + } + ), ]); } +fn validate_builtin_symbol_parameter_count( + validator: &mut Validator, + operator: &AstNode, + parameters: Option<&AstNode>, + operation: Operator, +) { + let Some(params) = parameters else { + validator.push_diagnostic(Diagnostic::invalid_parameter_count(2, 0, operator.get_location())); + return; + }; + + let count = flatten_expression_list(params).len(); + match operation { + // non-extensible operators + Operator::Minus | Operator::Division | Operator::NotEqual => { + if count != 2 { + validator.push_diagnostic(Diagnostic::invalid_parameter_count( + 2, + count, + operator.get_location(), + )); + } + } + _ => { + if count < 2 { + validator.push_diagnostic(Diagnostic::invalid_parameter_count( + 2, + count, + operator.get_location(), + )); + } + } + } +} + +// creates nested BinaryExpressions for each parameter, such that +// GT(a, b, c, d) ends up as (a > b) & (b > c) & (c > d) +fn annotate_comparison_function( + annotator: &mut TypeAnnotator, + statement: &AstNode, + operator: &AstNode, + parameters: &AstNode, + ctx: VisitorContext, + operation: Operator, +) { + let mut ctx = ctx; + let params_flattened = flatten_expression_list(parameters); + if params_flattened.iter().any(|it| { + !annotator + .annotation_map + .get_type_or_void(it, annotator.index) + .has_nature(TypeNature::Elementary, annotator.index) + }) { + // we are trying to call this function with a non-elementary type, so we redirect back to the resolver + annotator.annotate_call_statement(operator, Some(parameters), &ctx); + return; + } + + let comparisons = params_flattened + .windows(2) + .map(|window| { + AstFactory::create_binary_expression( + window[0].clone(), + operation, + window[1].clone(), + ctx.id_provider.next_id(), + ) + }) + .collect::>(); + let Some(new_statement) = comparisons.get(0) else { + // no windows => less than 2 parameters, caught during validation + return; + }; + let mut new_statement = new_statement.clone(); + comparisons.into_iter().skip(1).for_each(|right| { + new_statement = AstFactory::create_binary_expression( + new_statement.clone(), + Operator::And, + right, + ctx.id_provider.next_id(), + ) + }); + + annotator.visit_statement(&ctx, &new_statement); + annotator.update_expected_types(annotator.index.get_type_or_panic(typesystem::BOOL_TYPE), &new_statement); + annotator.annotate(statement, StatementAnnotation::ReplacementAst { statement: new_statement }); + annotator.update_expected_types(annotator.index.get_type_or_panic(typesystem::BOOL_TYPE), statement); +} + +fn annotate_arithmetic_function( + annotator: &mut TypeAnnotator, + statement: &AstNode, + operator: &AstNode, + parameters: &AstNode, + ctx: VisitorContext, + operation: Operator, +) { + let params_flattened = flatten_expression_list(parameters); + if params_flattened.iter().any(|it| { + !annotator + .annotation_map + .get_type_or_void(it, annotator.index) + .has_nature(TypeNature::Num, annotator.index) + }) { + // we are trying to call this function with a non-numerical type, so we redirect back to the resolver + annotator.annotate_call_statement(operator, Some(parameters), &ctx); + return; + } + + let mut ctx = ctx; + // find biggest type to later annotate it as type hint. this is done in a closure to avoid a borrow-checker tantrum later on due to + // mutable and immutable borrow of TypeAnnotator + let find_biggest_param_type_name = |annotator: &TypeAnnotator| { + let mut bigger = annotator + .annotation_map + .get_type_or_void(params_flattened.get(0).expect("must have this parameter"), annotator.index); + + for param in params_flattened.iter().skip(1) { + let right_type = annotator.annotation_map.get_type_or_void(param, annotator.index); + bigger = get_bigger_type(bigger, right_type, annotator.index); + } + + bigger.get_name().to_owned() + }; + + let bigger_type = find_biggest_param_type_name(annotator); + + // create nested AstStatement::BinaryExpression for each parameter, such that + // ADD(a, b, c, d) ends up as (((a + b) + c) + d) + let left = (*params_flattened.get(0).expect("Must exist")).clone(); + let new_statement = params_flattened.into_iter().skip(1).fold(left, |left, right| { + AstFactory::create_binary_expression(left, operation, right.clone(), ctx.id_provider.next_id()) + }); + + annotator.visit_statement(&ctx, &new_statement); + annotator.update_expected_types(annotator.index.get_type_or_panic(&bigger_type), &new_statement); + annotator.annotate(statement, StatementAnnotation::ReplacementAst { statement: new_statement }); + annotator.update_expected_types(annotator.index.get_type_or_panic(&bigger_type), statement); +} + fn annotate_variable_length_array_bound_function( annotator: &mut TypeAnnotator, parameters: Option<&AstNode>, @@ -497,7 +884,7 @@ fn generate_variable_length_array_bound_function<'ink>( Ok(ExpressionValue::RValue(bound)) } -type AnnotationFunction = fn(&mut TypeAnnotator, &AstNode, Option<&AstNode>, VisitorContext); +type AnnotationFunction = fn(&mut TypeAnnotator, &AstNode, &AstNode, Option<&AstNode>, VisitorContext); type GenericNameResolver = fn(&str, &[GenericBinding], &HashMap) -> String; type CodegenFunction = for<'ink, 'b> fn( &'b ExpressionCodeGenerator<'ink, 'b>, @@ -549,7 +936,7 @@ pub fn parse_built_ins(id_provider: IdProvider) -> CompilationUnit { unit } -/// Returns the requested functio from the builtin index or None +/// Returns the requested function from the builtin index or None pub fn get_builtin(name: &str) -> Option<&'static BuiltIn> { BUILTIN.get(name.to_uppercase().as_str()) } diff --git a/src/codegen/generators/expression_generator.rs b/src/codegen/generators/expression_generator.rs index cdde8a8afa..b0e279a18e 100644 --- a/src/codegen/generators/expression_generator.rs +++ b/src/codegen/generators/expression_generator.rs @@ -429,6 +429,14 @@ impl<'ink, 'b> ExpressionCodeGenerator<'ink, 'b> { // if the function is builtin, generate a basic value enum for it if let Some(builtin) = self.index.get_builtin_function(implementation_name) { // adr, ref, etc. + // let parameters_list = if let Some(StatementAnnotation::ReplacementAst { statement }) = + // self.annotations.get(operator) + // { + // statement.get_as_list() + // } else { + // parameters_list + // }; + return builtin.codegen(self, parameters_list.as_slice(), operator.get_location()); } diff --git a/src/codegen/tests/compare_instructions_tests.rs b/src/codegen/tests/compare_instructions_tests.rs index 1e9cdba24c..f13e44eca7 100644 --- a/src/codegen/tests/compare_instructions_tests.rs +++ b/src/codegen/tests/compare_instructions_tests.rs @@ -319,3 +319,82 @@ fn compare_instructions_with_different_types() { ); insta::assert_snapshot!(result); } + +#[test] +fn compare_instruction_functions_with_different_types() { + let result = codegen( + " + TYPE MySubRangeInt: INT(0..500); END_TYPE + TYPE MyDint: DINT; END_TYPE + + FUNCTION foo : REAL + END_FUNCTION + + PROGRAM main + VAR + ptr_float : REF_TO REAL; + + a : MySubRangeInt; + b : MyDint; + + var_real : REAL; + var_lreal : LREAL; + + var_sint : SINT; + var_int : INT; + var_dint : DINT; + var_lint : LINT; + + var_usint : USINT; + var_uint : UINT; + var_udint : UDINT; + var_ulint : ULINT; + END_VAR + ptr_float := &(var_real); + + EQ(var_sint, var_dint) + GT(var_int, 30); + GT(10.5, var_lreal); + + NE(var_usint, var_udint); + LE(var_uint, UDINT#40); + GE(UDINT#10, var_ulint); + + EQ(var_sint, var_usint); + LE(var_uint, var_lint); + GE(var_dint, var_ulint); + + LT(var_lint, a); + GT(a, var_sint); + LT(b, var_lint); + NE(SINT#5, b, 17); + + LE(ptr_float, var_usint); + EQ(a, ptr_float); + + NE(foo(), 40.5); + LE(var_udint, foo()); + EQ(foo(), var_lint); + END_PROGRAM + ", + ); + insta::assert_snapshot!(result); +} + +#[test] +fn compare_datetime_types() { + let result = codegen( + " + PROGRAM main + VAR + var_time: TIME; + var_time_of_day: TIME_OF_DAY; + var_date: DATE; + var_date_and_time: DATE_AND_TIME; + END_VAR + GT(var_time, var_time_of_day, var_date, var_date_and_time); + END_PROGRAM + ", + ); + insta::assert_snapshot!(result); +} diff --git a/src/codegen/tests/expression_tests.rs b/src/codegen/tests/expression_tests.rs index d02831c8ae..ee284e98fc 100644 --- a/src/codegen/tests/expression_tests.rs +++ b/src/codegen/tests/expression_tests.rs @@ -569,3 +569,209 @@ fn allowed_assignable_types() { insta::assert_snapshot!(result); } + +#[test] +fn builtin_add_ints() { + let src = r#" + FUNCTION main : DINT + VAR + x1, x2, x3 : DINT; + l1 : LINT; + s1 : SINT; + END_VAR + ADD(x1, x2, x3, l1, s1); + END_FUNCTION + "#; + + let res = codegen(src); + + insta::assert_snapshot!(res); +} + +#[test] +fn builtin_add_float() { + let src = r#" + FUNCTION main : DINT + VAR + x1, x2, x3 : REAL; + l1 : LREAL; + END_VAR + ADD(x1, x2, x3, l1); + END_FUNCTION + "#; + + let res = codegen(src); + + insta::assert_snapshot!(res); +} + +#[test] +fn builtin_add_mixed() { + let src = r#" + FUNCTION main : DINT + VAR + x1, x2, x3 : REAL; + l1 : LINT; + END_VAR + ADD(x1, x2, x3, l1); + END_FUNCTION + "#; + + let res = codegen(src); + + insta::assert_snapshot!(res); +} + +#[test] +fn builtin_mul_ints() { + let src = r#" + FUNCTION main : DINT + VAR + x1, x2, x3 : DINT; + l1 : LINT; + s1 : SINT; + END_VAR + MUL(x1, x2, x3, l1, s1); + END_FUNCTION + "#; + + let res = codegen(src); + + insta::assert_snapshot!(res); +} + +#[test] +fn builtin_mul_float() { + let src = r#" + FUNCTION main : DINT + VAR + x1, x2, x3 : REAL; + l1 : LREAL; + END_VAR + MUL(x1, x2, x3, l1); + END_FUNCTION + "#; + + let res = codegen(src); + + insta::assert_snapshot!(res); +} + +#[test] +fn builtin_mul_mixed() { + let src = r#" + FUNCTION main : DINT + VAR + x1, x2, x3 : REAL; + l1 : LINT; + END_VAR + MUL(x1, x2, x3, l1); + END_FUNCTION + "#; + + let res = codegen(src); + + insta::assert_snapshot!(res); +} + +#[test] +fn builtin_sub_ints() { + let src = r#" + FUNCTION main : DINT + VAR + x1 : DINT; + l1 : LINT; + END_VAR + SUB(x1, l1); + END_FUNCTION + "#; + + let res = codegen(src); + + insta::assert_snapshot!(res); +} + +#[test] +fn builtin_sub_float() { + let src = r#" + FUNCTION main : DINT + VAR + x1 : REAL; + l1 : LREAL; + END_VAR + SUB(x1, l1); + END_FUNCTION + "#; + + let res = codegen(src); + + insta::assert_snapshot!(res); +} + +#[test] +fn builtin_sub_mixed() { + let src = r#" + FUNCTION main : DINT + VAR + x1 : REAL; + l1 : LINT; + END_VAR + SUB(x1, l1); + END_FUNCTION + "#; + + let res = codegen(src); + + insta::assert_snapshot!(res); +} + +#[test] +fn builtin_div_ints() { + let src = r#" + FUNCTION main : DINT + VAR + x1 : DINT; + l1 : LINT; + END_VAR + DIV(x1, l1); + END_FUNCTION + "#; + + let res = codegen(src); + + insta::assert_snapshot!(res); +} + +#[test] +fn builtin_div_float() { + let src = r#" + FUNCTION main : DINT + VAR + x1 : REAL; + l1 : LREAL; + END_VAR + DIV(x1, l1); + END_FUNCTION + "#; + + let res = codegen(src); + + insta::assert_snapshot!(res); +} + +#[test] +fn builtin_div_mixed() { + let src = r#" + FUNCTION main : DINT + VAR + x1 : REAL; + l1 : LINT; + END_VAR + DIV(x1, l1); + END_FUNCTION + "#; + + let res = codegen(src); + + insta::assert_snapshot!(res); +} diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__compare_instructions_tests__compare_datetime_types.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__compare_instructions_tests__compare_datetime_types.snap new file mode 100644 index 0000000000..1a1db62774 --- /dev/null +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__compare_instructions_tests__compare_datetime_types.snap @@ -0,0 +1,44 @@ +--- +source: src/codegen/tests/compare_instructions_tests.rs +expression: result +--- +; ModuleID = 'main' +source_filename = "main" + +%main = type { i64, i64, i64, i64 } + +@main_instance = global %main zeroinitializer + +define void @main(%main* %0) { +entry: + %var_time = getelementptr inbounds %main, %main* %0, i32 0, i32 0 + %var_time_of_day = getelementptr inbounds %main, %main* %0, i32 0, i32 1 + %var_date = getelementptr inbounds %main, %main* %0, i32 0, i32 2 + %var_date_and_time = getelementptr inbounds %main, %main* %0, i32 0, i32 3 + %load_var_time = load i64, i64* %var_time, align 4 + %load_var_time_of_day = load i64, i64* %var_time_of_day, align 4 + %tmpVar = icmp sgt i64 %load_var_time, %load_var_time_of_day + br i1 %tmpVar, label %1, label %2 + +1: ; preds = %entry + %load_var_time_of_day1 = load i64, i64* %var_time_of_day, align 4 + %load_var_date = load i64, i64* %var_date, align 4 + %tmpVar2 = icmp sgt i64 %load_var_time_of_day1, %load_var_date + br label %2 + +2: ; preds = %1, %entry + %3 = phi i1 [ %tmpVar, %entry ], [ %tmpVar2, %1 ] + br i1 %3, label %4, label %5 + +4: ; preds = %2 + %load_var_date3 = load i64, i64* %var_date, align 4 + %load_var_date_and_time = load i64, i64* %var_date_and_time, align 4 + %tmpVar4 = icmp sgt i64 %load_var_date3, %load_var_date_and_time + br label %5 + +5: ; preds = %4, %2 + %6 = phi i1 [ %3, %2 ], [ %tmpVar4, %4 ] + %7 = zext i1 %6 to i8 + ret void +} + diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__compare_instructions_tests__compare_instruction_functions_with_different_types.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__compare_instructions_tests__compare_instruction_functions_with_different_types.snap new file mode 100644 index 0000000000..94ec08efae --- /dev/null +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__compare_instructions_tests__compare_instruction_functions_with_different_types.snap @@ -0,0 +1,128 @@ +--- +source: src/codegen/tests/compare_instructions_tests.rs +expression: result +--- +; ModuleID = 'main' +source_filename = "main" + +%main = type { float*, i16, i32, float, double, i8, i16, i32, i64, i8, i16, i32, i64 } + +@main_instance = global %main zeroinitializer + +define float @foo() { +entry: + %foo = alloca float, align 4 + store float 0.000000e+00, float* %foo, align 4 + %foo_ret = load float, float* %foo, align 4 + ret float %foo_ret +} + +define void @main(%main* %0) { +entry: + %ptr_float = getelementptr inbounds %main, %main* %0, i32 0, i32 0 + %a = getelementptr inbounds %main, %main* %0, i32 0, i32 1 + %b = getelementptr inbounds %main, %main* %0, i32 0, i32 2 + %var_real = getelementptr inbounds %main, %main* %0, i32 0, i32 3 + %var_lreal = getelementptr inbounds %main, %main* %0, i32 0, i32 4 + %var_sint = getelementptr inbounds %main, %main* %0, i32 0, i32 5 + %var_int = getelementptr inbounds %main, %main* %0, i32 0, i32 6 + %var_dint = getelementptr inbounds %main, %main* %0, i32 0, i32 7 + %var_lint = getelementptr inbounds %main, %main* %0, i32 0, i32 8 + %var_usint = getelementptr inbounds %main, %main* %0, i32 0, i32 9 + %var_uint = getelementptr inbounds %main, %main* %0, i32 0, i32 10 + %var_udint = getelementptr inbounds %main, %main* %0, i32 0, i32 11 + %var_ulint = getelementptr inbounds %main, %main* %0, i32 0, i32 12 + store float* %var_real, float** %ptr_float, align 8 + %load_var_sint = load i8, i8* %var_sint, align 1 + %1 = sext i8 %load_var_sint to i32 + %load_var_dint = load i32, i32* %var_dint, align 4 + %tmpVar = icmp eq i32 %1, %load_var_dint + %2 = zext i1 %tmpVar to i8 + %load_var_lreal = load double, double* %var_lreal, align 8 + %tmpVar1 = fcmp ogt double 1.050000e+01, %load_var_lreal + %3 = zext i1 %tmpVar1 to i8 + %load_var_usint = load i8, i8* %var_usint, align 1 + %4 = zext i8 %load_var_usint to i32 + %load_var_udint = load i32, i32* %var_udint, align 4 + %tmpVar2 = icmp ne i32 %4, %load_var_udint + %5 = zext i1 %tmpVar2 to i8 + %load_var_uint = load i16, i16* %var_uint, align 2 + %6 = zext i16 %load_var_uint to i32 + %tmpVar3 = icmp sle i32 %6, 40 + %7 = zext i1 %tmpVar3 to i8 + %load_var_ulint = load i64, i64* %var_ulint, align 4 + %tmpVar4 = icmp sge i64 10, %load_var_ulint + %8 = zext i1 %tmpVar4 to i8 + %load_var_sint5 = load i8, i8* %var_sint, align 1 + %9 = sext i8 %load_var_sint5 to i32 + %load_var_usint6 = load i8, i8* %var_usint, align 1 + %10 = zext i8 %load_var_usint6 to i32 + %tmpVar7 = icmp eq i32 %9, %10 + %11 = zext i1 %tmpVar7 to i8 + %load_var_uint8 = load i16, i16* %var_uint, align 2 + %12 = zext i16 %load_var_uint8 to i64 + %load_var_lint = load i64, i64* %var_lint, align 4 + %tmpVar9 = icmp sle i64 %12, %load_var_lint + %13 = zext i1 %tmpVar9 to i8 + %load_var_dint10 = load i32, i32* %var_dint, align 4 + %14 = sext i32 %load_var_dint10 to i64 + %load_var_ulint11 = load i64, i64* %var_ulint, align 4 + %tmpVar12 = icmp sge i64 %14, %load_var_ulint11 + %15 = zext i1 %tmpVar12 to i8 + %load_var_lint13 = load i64, i64* %var_lint, align 4 + %load_a = load i16, i16* %a, align 2 + %16 = sext i16 %load_a to i64 + %tmpVar14 = icmp slt i64 %load_var_lint13, %16 + %17 = zext i1 %tmpVar14 to i8 + %load_a15 = load i16, i16* %a, align 2 + %18 = sext i16 %load_a15 to i32 + %load_var_sint16 = load i8, i8* %var_sint, align 1 + %19 = sext i8 %load_var_sint16 to i32 + %tmpVar17 = icmp sgt i32 %18, %19 + %20 = zext i1 %tmpVar17 to i8 + %load_b = load i32, i32* %b, align 4 + %21 = sext i32 %load_b to i64 + %load_var_lint18 = load i64, i64* %var_lint, align 4 + %tmpVar19 = icmp slt i64 %21, %load_var_lint18 + %22 = zext i1 %tmpVar19 to i8 + %load_b20 = load i32, i32* %b, align 4 + %tmpVar21 = icmp ne i32 5, %load_b20 + br i1 %tmpVar21, label %23, label %24 + +23: ; preds = %entry + %load_b22 = load i32, i32* %b, align 4 + %tmpVar23 = icmp ne i32 %load_b22, 17 + br label %24 + +24: ; preds = %23, %entry + %25 = phi i1 [ %tmpVar21, %entry ], [ %tmpVar23, %23 ] + %26 = zext i1 %25 to i8 + %load_ptr_float = load float*, float** %ptr_float, align 8 + %load_var_usint24 = load i8, i8* %var_usint, align 1 + %27 = zext i8 %load_var_usint24 to i64 + %28 = ptrtoint float* %load_ptr_float to i64 + %tmpVar25 = icmp sle i64 %28, %27 + %29 = zext i1 %tmpVar25 to i8 + %load_a26 = load i16, i16* %a, align 2 + %30 = sext i16 %load_a26 to i64 + %load_ptr_float27 = load float*, float** %ptr_float, align 8 + %31 = ptrtoint float* %load_ptr_float27 to i64 + %tmpVar28 = icmp eq i64 %30, %31 + %32 = zext i1 %tmpVar28 to i8 + %call = call float @foo() + %tmpVar29 = fcmp one float %call, 4.050000e+01 + %33 = zext i1 %tmpVar29 to i8 + %load_var_udint30 = load i32, i32* %var_udint, align 4 + %34 = uitofp i32 %load_var_udint30 to float + %call31 = call float @foo() + %tmpVar32 = fcmp ole float %34, %call31 + %35 = zext i1 %tmpVar32 to i8 + %call33 = call float @foo() + %36 = fpext float %call33 to double + %load_var_lint34 = load i64, i64* %var_lint, align 4 + %37 = sitofp i64 %load_var_lint34 to double + %tmpVar35 = fcmp oeq double %36, %37 + %38 = zext i1 %tmpVar35 to i8 + ret void +} + diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__expression_tests__builtin_add_float.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__expression_tests__builtin_add_float.snap new file mode 100644 index 0000000000..753ff39f42 --- /dev/null +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__expression_tests__builtin_add_float.snap @@ -0,0 +1,31 @@ +--- +source: src/codegen/tests/expression_tests.rs +expression: res +--- +; ModuleID = 'main' +source_filename = "main" + +define i32 @main() { +entry: + %main = alloca i32, align 4 + %x1 = alloca float, align 4 + %x2 = alloca float, align 4 + %x3 = alloca float, align 4 + %l1 = alloca double, align 8 + store float 0.000000e+00, float* %x1, align 4 + store float 0.000000e+00, float* %x2, align 4 + store float 0.000000e+00, float* %x3, align 4 + store double 0.000000e+00, double* %l1, align 8 + store i32 0, i32* %main, align 4 + %load_x1 = load float, float* %x1, align 4 + %load_x2 = load float, float* %x2, align 4 + %tmpVar = fadd float %load_x1, %load_x2 + %load_x3 = load float, float* %x3, align 4 + %tmpVar1 = fadd float %tmpVar, %load_x3 + %0 = fpext float %tmpVar1 to double + %load_l1 = load double, double* %l1, align 8 + %tmpVar2 = fadd double %0, %load_l1 + %main_ret = load i32, i32* %main, align 4 + ret i32 %main_ret +} + diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__expression_tests__builtin_add_ints.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__expression_tests__builtin_add_ints.snap new file mode 100644 index 0000000000..a34337745d --- /dev/null +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__expression_tests__builtin_add_ints.snap @@ -0,0 +1,36 @@ +--- +source: src/codegen/tests/expression_tests.rs +expression: res +--- +; ModuleID = 'main' +source_filename = "main" + +define i32 @main() { +entry: + %main = alloca i32, align 4 + %x1 = alloca i32, align 4 + %x2 = alloca i32, align 4 + %x3 = alloca i32, align 4 + %l1 = alloca i64, align 8 + %s1 = alloca i8, align 1 + store i32 0, i32* %x1, align 4 + store i32 0, i32* %x2, align 4 + store i32 0, i32* %x3, align 4 + store i64 0, i64* %l1, align 4 + store i8 0, i8* %s1, align 1 + store i32 0, i32* %main, align 4 + %load_x1 = load i32, i32* %x1, align 4 + %load_x2 = load i32, i32* %x2, align 4 + %tmpVar = add i32 %load_x1, %load_x2 + %load_x3 = load i32, i32* %x3, align 4 + %tmpVar1 = add i32 %tmpVar, %load_x3 + %0 = sext i32 %tmpVar1 to i64 + %load_l1 = load i64, i64* %l1, align 4 + %tmpVar2 = add i64 %0, %load_l1 + %load_s1 = load i8, i8* %s1, align 1 + %1 = sext i8 %load_s1 to i64 + %tmpVar3 = add i64 %tmpVar2, %1 + %main_ret = load i32, i32* %main, align 4 + ret i32 %main_ret +} + diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__expression_tests__builtin_add_mixed.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__expression_tests__builtin_add_mixed.snap new file mode 100644 index 0000000000..df13579370 --- /dev/null +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__expression_tests__builtin_add_mixed.snap @@ -0,0 +1,32 @@ +--- +source: src/codegen/tests/expression_tests.rs +expression: res +--- +; ModuleID = 'main' +source_filename = "main" + +define i32 @main() { +entry: + %main = alloca i32, align 4 + %x1 = alloca float, align 4 + %x2 = alloca float, align 4 + %x3 = alloca float, align 4 + %l1 = alloca i64, align 8 + store float 0.000000e+00, float* %x1, align 4 + store float 0.000000e+00, float* %x2, align 4 + store float 0.000000e+00, float* %x3, align 4 + store i64 0, i64* %l1, align 4 + store i32 0, i32* %main, align 4 + %load_x1 = load float, float* %x1, align 4 + %load_x2 = load float, float* %x2, align 4 + %tmpVar = fadd float %load_x1, %load_x2 + %load_x3 = load float, float* %x3, align 4 + %tmpVar1 = fadd float %tmpVar, %load_x3 + %0 = fpext float %tmpVar1 to double + %load_l1 = load i64, i64* %l1, align 4 + %1 = sitofp i64 %load_l1 to double + %tmpVar2 = fadd double %0, %1 + %main_ret = load i32, i32* %main, align 4 + ret i32 %main_ret +} + diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__expression_tests__builtin_div_float.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__expression_tests__builtin_div_float.snap new file mode 100644 index 0000000000..834715e7a4 --- /dev/null +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__expression_tests__builtin_div_float.snap @@ -0,0 +1,23 @@ +--- +source: src/codegen/tests/expression_tests.rs +expression: res +--- +; ModuleID = 'main' +source_filename = "main" + +define i32 @main() { +entry: + %main = alloca i32, align 4 + %x1 = alloca float, align 4 + %l1 = alloca double, align 8 + store float 0.000000e+00, float* %x1, align 4 + store double 0.000000e+00, double* %l1, align 8 + store i32 0, i32* %main, align 4 + %load_x1 = load float, float* %x1, align 4 + %0 = fpext float %load_x1 to double + %load_l1 = load double, double* %l1, align 8 + %tmpVar = fdiv double %0, %load_l1 + %main_ret = load i32, i32* %main, align 4 + ret i32 %main_ret +} + diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__expression_tests__builtin_div_ints.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__expression_tests__builtin_div_ints.snap new file mode 100644 index 0000000000..4261e8474d --- /dev/null +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__expression_tests__builtin_div_ints.snap @@ -0,0 +1,23 @@ +--- +source: src/codegen/tests/expression_tests.rs +expression: res +--- +; ModuleID = 'main' +source_filename = "main" + +define i32 @main() { +entry: + %main = alloca i32, align 4 + %x1 = alloca i32, align 4 + %l1 = alloca i64, align 8 + store i32 0, i32* %x1, align 4 + store i64 0, i64* %l1, align 4 + store i32 0, i32* %main, align 4 + %load_x1 = load i32, i32* %x1, align 4 + %0 = sext i32 %load_x1 to i64 + %load_l1 = load i64, i64* %l1, align 4 + %tmpVar = sdiv i64 %0, %load_l1 + %main_ret = load i32, i32* %main, align 4 + ret i32 %main_ret +} + diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__expression_tests__builtin_div_mixed.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__expression_tests__builtin_div_mixed.snap new file mode 100644 index 0000000000..4b763a2ff0 --- /dev/null +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__expression_tests__builtin_div_mixed.snap @@ -0,0 +1,24 @@ +--- +source: src/codegen/tests/expression_tests.rs +expression: res +--- +; ModuleID = 'main' +source_filename = "main" + +define i32 @main() { +entry: + %main = alloca i32, align 4 + %x1 = alloca float, align 4 + %l1 = alloca i64, align 8 + store float 0.000000e+00, float* %x1, align 4 + store i64 0, i64* %l1, align 4 + store i32 0, i32* %main, align 4 + %load_x1 = load float, float* %x1, align 4 + %0 = fpext float %load_x1 to double + %load_l1 = load i64, i64* %l1, align 4 + %1 = sitofp i64 %load_l1 to double + %tmpVar = fdiv double %0, %1 + %main_ret = load i32, i32* %main, align 4 + ret i32 %main_ret +} + diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__expression_tests__builtin_mul_float.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__expression_tests__builtin_mul_float.snap new file mode 100644 index 0000000000..8d0e2f5417 --- /dev/null +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__expression_tests__builtin_mul_float.snap @@ -0,0 +1,31 @@ +--- +source: src/codegen/tests/expression_tests.rs +expression: res +--- +; ModuleID = 'main' +source_filename = "main" + +define i32 @main() { +entry: + %main = alloca i32, align 4 + %x1 = alloca float, align 4 + %x2 = alloca float, align 4 + %x3 = alloca float, align 4 + %l1 = alloca double, align 8 + store float 0.000000e+00, float* %x1, align 4 + store float 0.000000e+00, float* %x2, align 4 + store float 0.000000e+00, float* %x3, align 4 + store double 0.000000e+00, double* %l1, align 8 + store i32 0, i32* %main, align 4 + %load_x1 = load float, float* %x1, align 4 + %load_x2 = load float, float* %x2, align 4 + %tmpVar = fmul float %load_x1, %load_x2 + %load_x3 = load float, float* %x3, align 4 + %tmpVar1 = fmul float %tmpVar, %load_x3 + %0 = fpext float %tmpVar1 to double + %load_l1 = load double, double* %l1, align 8 + %tmpVar2 = fmul double %0, %load_l1 + %main_ret = load i32, i32* %main, align 4 + ret i32 %main_ret +} + diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__expression_tests__builtin_mul_ints.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__expression_tests__builtin_mul_ints.snap new file mode 100644 index 0000000000..66a2f3ef86 --- /dev/null +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__expression_tests__builtin_mul_ints.snap @@ -0,0 +1,36 @@ +--- +source: src/codegen/tests/expression_tests.rs +expression: res +--- +; ModuleID = 'main' +source_filename = "main" + +define i32 @main() { +entry: + %main = alloca i32, align 4 + %x1 = alloca i32, align 4 + %x2 = alloca i32, align 4 + %x3 = alloca i32, align 4 + %l1 = alloca i64, align 8 + %s1 = alloca i8, align 1 + store i32 0, i32* %x1, align 4 + store i32 0, i32* %x2, align 4 + store i32 0, i32* %x3, align 4 + store i64 0, i64* %l1, align 4 + store i8 0, i8* %s1, align 1 + store i32 0, i32* %main, align 4 + %load_x1 = load i32, i32* %x1, align 4 + %load_x2 = load i32, i32* %x2, align 4 + %tmpVar = mul i32 %load_x1, %load_x2 + %load_x3 = load i32, i32* %x3, align 4 + %tmpVar1 = mul i32 %tmpVar, %load_x3 + %0 = sext i32 %tmpVar1 to i64 + %load_l1 = load i64, i64* %l1, align 4 + %tmpVar2 = mul i64 %0, %load_l1 + %load_s1 = load i8, i8* %s1, align 1 + %1 = sext i8 %load_s1 to i64 + %tmpVar3 = mul i64 %tmpVar2, %1 + %main_ret = load i32, i32* %main, align 4 + ret i32 %main_ret +} + diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__expression_tests__builtin_mul_mixed.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__expression_tests__builtin_mul_mixed.snap new file mode 100644 index 0000000000..e1b5769b95 --- /dev/null +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__expression_tests__builtin_mul_mixed.snap @@ -0,0 +1,32 @@ +--- +source: src/codegen/tests/expression_tests.rs +expression: res +--- +; ModuleID = 'main' +source_filename = "main" + +define i32 @main() { +entry: + %main = alloca i32, align 4 + %x1 = alloca float, align 4 + %x2 = alloca float, align 4 + %x3 = alloca float, align 4 + %l1 = alloca i64, align 8 + store float 0.000000e+00, float* %x1, align 4 + store float 0.000000e+00, float* %x2, align 4 + store float 0.000000e+00, float* %x3, align 4 + store i64 0, i64* %l1, align 4 + store i32 0, i32* %main, align 4 + %load_x1 = load float, float* %x1, align 4 + %load_x2 = load float, float* %x2, align 4 + %tmpVar = fmul float %load_x1, %load_x2 + %load_x3 = load float, float* %x3, align 4 + %tmpVar1 = fmul float %tmpVar, %load_x3 + %0 = fpext float %tmpVar1 to double + %load_l1 = load i64, i64* %l1, align 4 + %1 = sitofp i64 %load_l1 to double + %tmpVar2 = fmul double %0, %1 + %main_ret = load i32, i32* %main, align 4 + ret i32 %main_ret +} + diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__expression_tests__builtin_sub_float.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__expression_tests__builtin_sub_float.snap new file mode 100644 index 0000000000..5d25f72be2 --- /dev/null +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__expression_tests__builtin_sub_float.snap @@ -0,0 +1,23 @@ +--- +source: src/codegen/tests/expression_tests.rs +expression: res +--- +; ModuleID = 'main' +source_filename = "main" + +define i32 @main() { +entry: + %main = alloca i32, align 4 + %x1 = alloca float, align 4 + %l1 = alloca double, align 8 + store float 0.000000e+00, float* %x1, align 4 + store double 0.000000e+00, double* %l1, align 8 + store i32 0, i32* %main, align 4 + %load_x1 = load float, float* %x1, align 4 + %0 = fpext float %load_x1 to double + %load_l1 = load double, double* %l1, align 8 + %tmpVar = fsub double %0, %load_l1 + %main_ret = load i32, i32* %main, align 4 + ret i32 %main_ret +} + diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__expression_tests__builtin_sub_ints.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__expression_tests__builtin_sub_ints.snap new file mode 100644 index 0000000000..1fb0aa6c64 --- /dev/null +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__expression_tests__builtin_sub_ints.snap @@ -0,0 +1,23 @@ +--- +source: src/codegen/tests/expression_tests.rs +expression: res +--- +; ModuleID = 'main' +source_filename = "main" + +define i32 @main() { +entry: + %main = alloca i32, align 4 + %x1 = alloca i32, align 4 + %l1 = alloca i64, align 8 + store i32 0, i32* %x1, align 4 + store i64 0, i64* %l1, align 4 + store i32 0, i32* %main, align 4 + %load_x1 = load i32, i32* %x1, align 4 + %0 = sext i32 %load_x1 to i64 + %load_l1 = load i64, i64* %l1, align 4 + %tmpVar = sub i64 %0, %load_l1 + %main_ret = load i32, i32* %main, align 4 + ret i32 %main_ret +} + diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__expression_tests__builtin_sub_mixed.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__expression_tests__builtin_sub_mixed.snap new file mode 100644 index 0000000000..32df16613a --- /dev/null +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__expression_tests__builtin_sub_mixed.snap @@ -0,0 +1,24 @@ +--- +source: src/codegen/tests/expression_tests.rs +expression: res +--- +; ModuleID = 'main' +source_filename = "main" + +define i32 @main() { +entry: + %main = alloca i32, align 4 + %x1 = alloca float, align 4 + %l1 = alloca i64, align 8 + store float 0.000000e+00, float* %x1, align 4 + store i64 0, i64* %l1, align 4 + store i32 0, i32* %main, align 4 + %load_x1 = load float, float* %x1, align 4 + %0 = fpext float %load_x1 to double + %load_l1 = load i64, i64* %l1, align 4 + %1 = sitofp i64 %load_l1 to double + %tmpVar = fsub double %0, %1 + %main_ret = load i32, i32* %main, align 4 + ret i32 %main_ret +} + diff --git a/src/resolver.rs b/src/resolver.rs index f2f8bcd980..d20f2c5606 100644 --- a/src/resolver.rs +++ b/src/resolver.rs @@ -78,7 +78,7 @@ pub struct VisitorContext<'s> { /// true the visitor entered a body (so no declarations) in_body: bool, - id_provider: IdProvider, + pub id_provider: IdProvider, // what's the current strategy for resolving resolve_strategy: Vec, @@ -282,6 +282,120 @@ impl TypeAnnotator<'_> { ctx.id_provider.next_id(), )) } + + pub fn annotate_call_statement( + &mut self, + operator: &AstNode, + parameters_stmt: Option<&AstNode>, + ctx: &VisitorContext, + ) { + let parameters = if let Some(parameters) = parameters_stmt { + self.visit_statement(ctx, parameters); + flatten_expression_list(parameters) + } else { + vec![] + }; + let operator_qualifier = &self.get_call_name(operator); + + let mut generics_candidates: HashMap> = HashMap::new(); + let mut params = vec![]; + let mut parameters = parameters.into_iter(); + + // If we are dealing with an action call statement, we need to get the declared parameters from the parent POU in order + // to annotate them with the correct type hint. + let operator_qualifier = self + .index + .find_implementation_by_name(operator_qualifier) + .map(|it| it.get_type_name()) + .unwrap_or(operator_qualifier); + + for m in self.index.get_declared_parameters(operator_qualifier).into_iter() { + if let Some(p) = parameters.next() { + let type_name = m.get_type_name(); + if let Some((key, candidate)) = + TypeAnnotator::get_generic_candidate(self.index, &self.annotation_map, type_name, p) + { + generics_candidates.entry(key.to_string()).or_default().push(candidate.to_string()) + } else { + params.push((p, type_name.to_string())) + } + } + } + + //We possibly did not consume all parameters, see if the variadic arguments are derivable + match self.index.find_pou(operator_qualifier) { + Some(pou) if pou.is_variadic() => { + //get variadic argument type, if it is generic, update the generic candidates + if let Some(type_name) = + self.index.get_variadic_member(pou.get_name()).map(VariableIndexEntry::get_type_name) + { + for parameter in parameters { + if let Some((key, candidate)) = TypeAnnotator::get_generic_candidate( + self.index, + &self.annotation_map, + type_name, + parameter, + ) { + generics_candidates + .entry(key.to_string()) + .or_default() + .push(candidate.to_string()) + } else { + // intrinsic type promotion for variadics in order to be compatible with the C standard. + // see ISO/IEC 9899:1999, 6.5.2.2 Function calls (https://www.open-std.org/jtc1/sc22/wg14/www/docs/n1256.pdf) + // or https://en.cppreference.com/w/cpp/language/implicit_conversion#Integral_promotion + // for more about default argument promotion. + + // varargs without a type declaration will be annotated "VOID", so in order to check if a + // promotion is necessary, we need to first check the type of each parameter. in the case of numerical + // types, we promote if the type is smaller than double/i32 (except for booleans). + let type_name = if let Some(data_type) = + self.annotation_map.get_type(parameter, self.index) + { + match &data_type.information { + DataTypeInformation::Float { .. } => get_bigger_type( + data_type, + self.index.get_type_or_panic(LREAL_TYPE), + self.index, + ) + .get_name(), + DataTypeInformation::Integer { .. } + if !&data_type.information.is_bool() => + { + get_bigger_type( + data_type, + self.index.get_type_or_panic(DINT_TYPE), + self.index, + ) + .get_name() + } + _ => type_name, + } + } else { + // default to original type in case no type could be found + // and let the validator handle situations that might lead here + type_name + }; + + params.push((parameter, type_name.to_string())); + } + } + } + } + _ => {} + } + for (p, name) in params { + self.annotate_parameters(p, &name); + } + //Attempt to resolve the generic signature here + self.update_generic_call_statement( + generics_candidates, + operator_qualifier, + operator, + parameters_stmt, + ctx.to_owned(), + ); + } } #[derive(Debug, Clone, PartialEq)] @@ -791,7 +905,7 @@ impl<'i> TypeAnnotator<'i> { /// updates the expected types of statements on the right side of an assignment /// e.g. x : ARRAY [0..1] OF BYTE := [2,3]; - fn update_expected_types(&mut self, expected_type: &typesystem::DataType, statement: &AstNode) { + pub fn update_expected_types(&mut self, expected_type: &typesystem::DataType, statement: &AstNode) { //see if we need to dive into it match statement.get_stmt() { AstStatement::Literal(AstLiteral::Array(Array { elements: Some(elements) }), ..) => { @@ -1634,125 +1748,29 @@ impl<'i> TypeAnnotator<'i> { //Use the context without the is_call =true //TODO why do we start a lhs context here??? let ctx = ctx.with_lhs(operator_qualifier.as_str()); - let parameters = if let Some(parameters) = parameters_stmt { + if let Some(parameters) = parameters_stmt { self.visit_statement(&ctx, parameters); - flatten_expression_list(parameters) - } else { - vec![] }; + if let Some(annotation) = builtins::get_builtin(&operator_qualifier).and_then(BuiltIn::get_annotation) { - annotation(self, operator, parameters_stmt, ctx.to_owned()) + annotation(self, statement, operator, parameters_stmt, ctx.to_owned()); } else { - //If builtin, skip this - let mut generics_candidates: HashMap> = HashMap::new(); - let mut params = vec![]; - let mut parameters = parameters.into_iter(); - - // If we are dealing with an action call statement, we need to get the declared parameters from the parent POU in order - // to annotate them with the correct type hint. - let operator_qualifier = self - .index - .find_implementation_by_name(&operator_qualifier) - .map(|it| it.get_type_name()) - .unwrap_or(operator_qualifier.as_str()); - - for m in self.index.get_declared_parameters(operator_qualifier).into_iter() { - if let Some(p) = parameters.next() { - let type_name = m.get_type_name(); - if let Some((key, candidate)) = - TypeAnnotator::get_generic_candidate(self.index, &self.annotation_map, type_name, p) - { - generics_candidates - .entry(key.to_string()) - .or_insert_with(std::vec::Vec::new) - .push(candidate.to_string()) - } else { - params.push((p, type_name.to_string())) - } - } - } - //We possibly did not consume all parameters, see if the variadic arguments are derivable - - match self.index.find_pou(operator_qualifier) { - Some(pou) if pou.is_variadic() => { - //get variadic argument type, if it is generic, update the generic candidates - if let Some(type_name) = - self.index.get_variadic_member(pou.get_name()).map(VariableIndexEntry::get_type_name) - { - for parameter in parameters { - if let Some((key, candidate)) = TypeAnnotator::get_generic_candidate( - self.index, - &self.annotation_map, - type_name, - parameter, - ) { - generics_candidates - .entry(key.to_string()) - .or_insert_with(std::vec::Vec::new) - .push(candidate.to_string()) - } else { - // intrinsic type promotion for variadics in order to be compatible with the C standard. - // see ISO/IEC 9899:1999, 6.5.2.2 Function calls (https://www.open-std.org/jtc1/sc22/wg14/www/docs/n1256.pdf) - // or https://en.cppreference.com/w/cpp/language/implicit_conversion#Integral_promotion - // for more about default argument promotion. - - // varargs without a type declaration will be annotated "VOID", so in order to check if a - // promotion is necessary, we need to first check the type of each parameter. in the case of numerical - // types, we promote if the type is smaller than double/i32 (except for booleans). - let type_name = if let Some(data_type) = - self.annotation_map.get_type(parameter, self.index) - { - match &data_type.information { - DataTypeInformation::Float { .. } => get_bigger_type( - data_type, - self.index.get_type_or_panic(LREAL_TYPE), - self.index, - ) - .get_name(), - DataTypeInformation::Integer { .. } - if !&data_type.information.is_bool() => - { - get_bigger_type( - data_type, - self.index.get_type_or_panic(DINT_TYPE), - self.index, - ) - .get_name() - } - _ => type_name, - } - } else { - // default to original type in case no type could be found - // and let the validator handle situations that might lead here - type_name - }; + //This is skipped for builtins that provide their own annotation-logic + self.annotate_call_statement(operator, parameters_stmt, &ctx); + }; - params.push((parameter, type_name.to_string())); - } - } - } - } - _ => {} - } - for (p, name) in params { - self.annotate_parameters(p, &name); - } - //Attempt to resolve the generic signature here - self.update_generic_call_statement( - generics_candidates, - operator_qualifier, - operator, - parameters_stmt, - ctx.to_owned(), - ); - } if let Some(StatementAnnotation::Function { return_type, .. }) = self.annotation_map.get(operator) { if let Some(return_type) = self .index .find_effective_type_by_name(return_type) .or_else(|| self.annotation_map.new_index.find_effective_type_by_name(return_type)) { + if let Some(StatementAnnotation::ReplacementAst { .. }) = self.annotation_map.get(statement) { + // if we have a replacement ast, we do not need to annotate the function return type as it would + // overwrite the replacement ast + return; + } self.annotate(statement, StatementAnnotation::value(return_type.get_name())); } } @@ -1990,7 +2008,7 @@ fn get_int_type_name_for(value: i128) -> &'static str { fn get_real_type_name_for(value: &str) -> &'static str { let parsed = value.parse::().unwrap_or(f32::INFINITY); - if parsed == f32::INFINITY || parsed == f32::NEG_INFINITY { + if parsed.is_infinite() { return LREAL_TYPE; } diff --git a/src/resolver/tests/resolve_expressions_tests.rs b/src/resolver/tests/resolve_expressions_tests.rs index 9e40af983e..4997f48006 100644 --- a/src/resolver/tests/resolve_expressions_tests.rs +++ b/src/resolver/tests/resolve_expressions_tests.rs @@ -5313,3 +5313,155 @@ fn annotate_method_in_super() { ); } } + +// these test checks if builtin calls to GT, LT, GE, LE, EQ, NE are annotated correctly +#[test] +fn comparison_function_replacement_ast_is_identical_to_using_symbols() { + let id_provider = IdProvider::default(); + let (unit, index) = index_with_ids( + " + FUNCTION foo: DINT + VAR + a: DINT; + b: DINT; + c: REAL; + d: DATE; + END_VAR + a > b AND b > c AND c > d; + GT(a, b, c, d); + a <= b AND b <= c AND c <= d; + LE(a, b, c, d); + END_FUNCTION + ", + id_provider.clone(), + ); + + let (annotations, ..) = TypeAnnotator::visit_unit(&index, &unit, id_provider); + + // check if a > b AND b > c AND c < d produces the same AST to GT(a, b, c, d) + let stmt = &unit.implementations[0].statements[0]; + let AstNode { stmt: expected, .. } = stmt; + + let stmt = &unit.implementations[0].statements[1]; + let Some(StatementAnnotation::ReplacementAst { statement }) = annotations.get(stmt) else { + unreachable!() + }; + let AstNode { stmt: actual, .. } = statement; + + assert_eq!(format!("{:#?}", expected), format!("{:#?}", actual)); + + // check if a <= b AND b <= c AND c <= d produces the same AST to LE(a, b, c, d) + let stmt = &unit.implementations[0].statements[2]; + let AstNode { stmt: expected, .. } = stmt; + + let stmt = &unit.implementations[0].statements[3]; + let Some(StatementAnnotation::ReplacementAst { statement }) = annotations.get(stmt) else { + unreachable!() + }; + let AstNode { stmt: actual, .. } = statement; + + assert_eq!(format!("{:#?}", expected), format!("{:#?}", actual)) +} + +#[test] +fn builtin_gt_replacement_ast() { + insta::assert_debug_snapshot!(generate_comparison_test("GT")); +} +#[test] +fn builtin_ge_replacement_ast() { + insta::assert_debug_snapshot!(generate_comparison_test("GE")); +} + +#[test] +fn builtin_eq_replacement_ast() { + insta::assert_debug_snapshot!(generate_comparison_test("EQ")); +} + +#[test] +fn builtin_lt_replacement_ast() { + insta::assert_debug_snapshot!(generate_comparison_test("LT")); +} + +#[test] +fn builtin_le_replacement_ast() { + insta::assert_debug_snapshot!(generate_comparison_test("LE")); +} + +#[test] +fn builtin_ne_replacement_ast() { + insta::assert_debug_snapshot!(generate_comparison_test("NE")); +} + +// Helper function to generate the comparison test +fn generate_comparison_test(operator: &str) -> StatementAnnotation { + let id_provider = IdProvider::default(); + let (unit, index) = index_with_ids( + format!( + " + FUNCTION main : DINT + VAR + a : DINT; + b : INT; + c : LINT; + d : LWORD; + END_VAR + {}(a, b, c, d); + END_FUNCTION + ", + operator + ), + id_provider.clone(), + ); + let (annotations, ..) = TypeAnnotator::visit_unit(&index, &unit, id_provider); + + let stmt = &unit.implementations[0].statements[0]; + annotations.get(stmt).unwrap().clone() +} + +#[test] +fn builtin_add_replacement_ast() { + let id_provider = IdProvider::default(); + let (unit, index) = index_with_ids( + " + FUNCTION main : DINT + VAR + a : DINT; + b : INT; + c : LINT; + d : REAL; + END_VAR + ADD(a, b, c, d); + END_FUNCTION + ", + id_provider.clone(), + ); + let (annotations, ..) = TypeAnnotator::visit_unit(&index, &unit, id_provider); + + let stmt = &unit.implementations[0].statements[0]; + insta::assert_debug_snapshot!(annotations.get(stmt)); +} + +#[test] +fn builtin_add_doesnt_annotate_replacement_ast_when_called_with_incorrect_type_nature() { + let id_provider = IdProvider::default(); + let (unit, index) = index_with_ids( + " + FUNCTION main : DINT + VAR + a : DINT; + b : INT; + c : LWORD; + d : TIME; + END_VAR + ADD(a, b, c, d); + END_FUNCTION + ", + id_provider.clone(), + ); + let (annotations, ..) = TypeAnnotator::visit_unit(&index, &unit, id_provider); + + let stmt = &unit.implementations[0].statements[0]; + if let Some(StatementAnnotation::ReplacementAst { statement }) = annotations.get(stmt) { + panic!("Expected no replacement ast, got {:?}", statement) + } +} diff --git a/src/resolver/tests/resolve_generic_calls.rs b/src/resolver/tests/resolve_generic_calls.rs index cda9f0ac68..706f8e525c 100644 --- a/src/resolver/tests/resolve_generic_calls.rs +++ b/src/resolver/tests/resolve_generic_calls.rs @@ -1,3 +1,4 @@ +use insta::assert_debug_snapshot; use plc_ast::{ ast::{flatten_expression_list, Assignment, AstNode, AstStatement, CallStatement}, provider::IdProvider, @@ -1093,18 +1094,8 @@ fn generic_function_sharing_a_datatype_name_resolves() { let annotations = annotate_with_ids(&unit, &mut index, id_provider); let statement = &unit.implementations[1].statements[0]; - if let AstNode { stmt: AstStatement::CallStatement(CallStatement { operator, .. }, ..), .. } = statement { - assert_eq!( - annotations.get(operator).unwrap(), - &StatementAnnotation::Function { - return_type: "BOOL".to_string(), - qualified_name: "LT".to_string(), - call_name: Some("LT__STRING".to_string()), - } - ); - } else { - unreachable!("This should always be a call statement.") - } + // comparision function calls are resolved to replacement-AST expressions + assert_debug_snapshot!(annotations.get(statement)); } #[test] diff --git a/src/resolver/tests/snapshots/rusty__resolver__tests__resolve_expressions_tests__builtin_add_replacement_ast.snap b/src/resolver/tests/snapshots/rusty__resolver__tests__resolve_expressions_tests__builtin_add_replacement_ast.snap new file mode 100644 index 0000000000..40d414dba3 --- /dev/null +++ b/src/resolver/tests/snapshots/rusty__resolver__tests__resolve_expressions_tests__builtin_add_replacement_ast.snap @@ -0,0 +1,49 @@ +--- +source: src/resolver/tests/resolve_expressions_tests.rs +expression: annotations.get(operator) +--- +Some( + ReplacementAst { + statement: BinaryExpression { + operator: Plus, + left: BinaryExpression { + operator: Plus, + left: BinaryExpression { + operator: Plus, + left: ReferenceExpr { + kind: Member( + Identifier { + name: "a", + }, + ), + base: None, + }, + right: ReferenceExpr { + kind: Member( + Identifier { + name: "b", + }, + ), + base: None, + }, + }, + right: ReferenceExpr { + kind: Member( + Identifier { + name: "c", + }, + ), + base: None, + }, + }, + right: ReferenceExpr { + kind: Member( + Identifier { + name: "d", + }, + ), + base: None, + }, + }, + }, +) diff --git a/src/resolver/tests/snapshots/rusty__resolver__tests__resolve_expressions_tests__builtin_eq_replacement_ast.snap b/src/resolver/tests/snapshots/rusty__resolver__tests__resolve_expressions_tests__builtin_eq_replacement_ast.snap new file mode 100644 index 0000000000..15041598cf --- /dev/null +++ b/src/resolver/tests/snapshots/rusty__resolver__tests__resolve_expressions_tests__builtin_eq_replacement_ast.snap @@ -0,0 +1,69 @@ +--- +source: src/resolver/tests/resolve_expressions_tests.rs +expression: "generate_comparison_test(\"EQ\")" +--- +ReplacementAst { + statement: BinaryExpression { + operator: And, + left: BinaryExpression { + operator: And, + left: BinaryExpression { + operator: Equal, + left: ReferenceExpr { + kind: Member( + Identifier { + name: "a", + }, + ), + base: None, + }, + right: ReferenceExpr { + kind: Member( + Identifier { + name: "b", + }, + ), + base: None, + }, + }, + right: BinaryExpression { + operator: Equal, + left: ReferenceExpr { + kind: Member( + Identifier { + name: "b", + }, + ), + base: None, + }, + right: ReferenceExpr { + kind: Member( + Identifier { + name: "c", + }, + ), + base: None, + }, + }, + }, + right: BinaryExpression { + operator: Equal, + left: ReferenceExpr { + kind: Member( + Identifier { + name: "c", + }, + ), + base: None, + }, + right: ReferenceExpr { + kind: Member( + Identifier { + name: "d", + }, + ), + base: None, + }, + }, + }, +} diff --git a/src/resolver/tests/snapshots/rusty__resolver__tests__resolve_expressions_tests__builtin_ge_replacement_ast.snap b/src/resolver/tests/snapshots/rusty__resolver__tests__resolve_expressions_tests__builtin_ge_replacement_ast.snap new file mode 100644 index 0000000000..547721a657 --- /dev/null +++ b/src/resolver/tests/snapshots/rusty__resolver__tests__resolve_expressions_tests__builtin_ge_replacement_ast.snap @@ -0,0 +1,69 @@ +--- +source: src/resolver/tests/resolve_expressions_tests.rs +expression: "generate_comparison_test(\"GE\")" +--- +ReplacementAst { + statement: BinaryExpression { + operator: And, + left: BinaryExpression { + operator: And, + left: BinaryExpression { + operator: GreaterOrEqual, + left: ReferenceExpr { + kind: Member( + Identifier { + name: "a", + }, + ), + base: None, + }, + right: ReferenceExpr { + kind: Member( + Identifier { + name: "b", + }, + ), + base: None, + }, + }, + right: BinaryExpression { + operator: GreaterOrEqual, + left: ReferenceExpr { + kind: Member( + Identifier { + name: "b", + }, + ), + base: None, + }, + right: ReferenceExpr { + kind: Member( + Identifier { + name: "c", + }, + ), + base: None, + }, + }, + }, + right: BinaryExpression { + operator: GreaterOrEqual, + left: ReferenceExpr { + kind: Member( + Identifier { + name: "c", + }, + ), + base: None, + }, + right: ReferenceExpr { + kind: Member( + Identifier { + name: "d", + }, + ), + base: None, + }, + }, + }, +} diff --git a/src/resolver/tests/snapshots/rusty__resolver__tests__resolve_expressions_tests__builtin_gt_replacement_ast.snap b/src/resolver/tests/snapshots/rusty__resolver__tests__resolve_expressions_tests__builtin_gt_replacement_ast.snap new file mode 100644 index 0000000000..70d1cdabee --- /dev/null +++ b/src/resolver/tests/snapshots/rusty__resolver__tests__resolve_expressions_tests__builtin_gt_replacement_ast.snap @@ -0,0 +1,69 @@ +--- +source: src/resolver/tests/resolve_expressions_tests.rs +expression: "generate_comparison_test(\"GT\")" +--- +ReplacementAst { + statement: BinaryExpression { + operator: And, + left: BinaryExpression { + operator: And, + left: BinaryExpression { + operator: Greater, + left: ReferenceExpr { + kind: Member( + Identifier { + name: "a", + }, + ), + base: None, + }, + right: ReferenceExpr { + kind: Member( + Identifier { + name: "b", + }, + ), + base: None, + }, + }, + right: BinaryExpression { + operator: Greater, + left: ReferenceExpr { + kind: Member( + Identifier { + name: "b", + }, + ), + base: None, + }, + right: ReferenceExpr { + kind: Member( + Identifier { + name: "c", + }, + ), + base: None, + }, + }, + }, + right: BinaryExpression { + operator: Greater, + left: ReferenceExpr { + kind: Member( + Identifier { + name: "c", + }, + ), + base: None, + }, + right: ReferenceExpr { + kind: Member( + Identifier { + name: "d", + }, + ), + base: None, + }, + }, + }, +} diff --git a/src/resolver/tests/snapshots/rusty__resolver__tests__resolve_expressions_tests__builtin_le_replacement_ast.snap b/src/resolver/tests/snapshots/rusty__resolver__tests__resolve_expressions_tests__builtin_le_replacement_ast.snap new file mode 100644 index 0000000000..716bcf500c --- /dev/null +++ b/src/resolver/tests/snapshots/rusty__resolver__tests__resolve_expressions_tests__builtin_le_replacement_ast.snap @@ -0,0 +1,69 @@ +--- +source: src/resolver/tests/resolve_expressions_tests.rs +expression: "generate_comparison_test(\"LE\")" +--- +ReplacementAst { + statement: BinaryExpression { + operator: And, + left: BinaryExpression { + operator: And, + left: BinaryExpression { + operator: LessOrEqual, + left: ReferenceExpr { + kind: Member( + Identifier { + name: "a", + }, + ), + base: None, + }, + right: ReferenceExpr { + kind: Member( + Identifier { + name: "b", + }, + ), + base: None, + }, + }, + right: BinaryExpression { + operator: LessOrEqual, + left: ReferenceExpr { + kind: Member( + Identifier { + name: "b", + }, + ), + base: None, + }, + right: ReferenceExpr { + kind: Member( + Identifier { + name: "c", + }, + ), + base: None, + }, + }, + }, + right: BinaryExpression { + operator: LessOrEqual, + left: ReferenceExpr { + kind: Member( + Identifier { + name: "c", + }, + ), + base: None, + }, + right: ReferenceExpr { + kind: Member( + Identifier { + name: "d", + }, + ), + base: None, + }, + }, + }, +} diff --git a/src/resolver/tests/snapshots/rusty__resolver__tests__resolve_expressions_tests__builtin_lt_replacement_ast.snap b/src/resolver/tests/snapshots/rusty__resolver__tests__resolve_expressions_tests__builtin_lt_replacement_ast.snap new file mode 100644 index 0000000000..46c4292cc0 --- /dev/null +++ b/src/resolver/tests/snapshots/rusty__resolver__tests__resolve_expressions_tests__builtin_lt_replacement_ast.snap @@ -0,0 +1,69 @@ +--- +source: src/resolver/tests/resolve_expressions_tests.rs +expression: "generate_comparison_test(\"LT\")" +--- +ReplacementAst { + statement: BinaryExpression { + operator: And, + left: BinaryExpression { + operator: And, + left: BinaryExpression { + operator: Less, + left: ReferenceExpr { + kind: Member( + Identifier { + name: "a", + }, + ), + base: None, + }, + right: ReferenceExpr { + kind: Member( + Identifier { + name: "b", + }, + ), + base: None, + }, + }, + right: BinaryExpression { + operator: Less, + left: ReferenceExpr { + kind: Member( + Identifier { + name: "b", + }, + ), + base: None, + }, + right: ReferenceExpr { + kind: Member( + Identifier { + name: "c", + }, + ), + base: None, + }, + }, + }, + right: BinaryExpression { + operator: Less, + left: ReferenceExpr { + kind: Member( + Identifier { + name: "c", + }, + ), + base: None, + }, + right: ReferenceExpr { + kind: Member( + Identifier { + name: "d", + }, + ), + base: None, + }, + }, + }, +} diff --git a/src/resolver/tests/snapshots/rusty__resolver__tests__resolve_expressions_tests__builtin_ne_replacement_ast.snap b/src/resolver/tests/snapshots/rusty__resolver__tests__resolve_expressions_tests__builtin_ne_replacement_ast.snap new file mode 100644 index 0000000000..439e709eff --- /dev/null +++ b/src/resolver/tests/snapshots/rusty__resolver__tests__resolve_expressions_tests__builtin_ne_replacement_ast.snap @@ -0,0 +1,69 @@ +--- +source: src/resolver/tests/resolve_expressions_tests.rs +expression: "generate_comparison_test(\"NE\")" +--- +ReplacementAst { + statement: BinaryExpression { + operator: And, + left: BinaryExpression { + operator: And, + left: BinaryExpression { + operator: NotEqual, + left: ReferenceExpr { + kind: Member( + Identifier { + name: "a", + }, + ), + base: None, + }, + right: ReferenceExpr { + kind: Member( + Identifier { + name: "b", + }, + ), + base: None, + }, + }, + right: BinaryExpression { + operator: NotEqual, + left: ReferenceExpr { + kind: Member( + Identifier { + name: "b", + }, + ), + base: None, + }, + right: ReferenceExpr { + kind: Member( + Identifier { + name: "c", + }, + ), + base: None, + }, + }, + }, + right: BinaryExpression { + operator: NotEqual, + left: ReferenceExpr { + kind: Member( + Identifier { + name: "c", + }, + ), + base: None, + }, + right: ReferenceExpr { + kind: Member( + Identifier { + name: "d", + }, + ), + base: None, + }, + }, + }, +} diff --git a/src/resolver/tests/snapshots/rusty__resolver__tests__resolve_generic_calls__generic_function_sharing_a_datatype_name_resolves.snap b/src/resolver/tests/snapshots/rusty__resolver__tests__resolve_generic_calls__generic_function_sharing_a_datatype_name_resolves.snap new file mode 100644 index 0000000000..60ce64f830 --- /dev/null +++ b/src/resolver/tests/snapshots/rusty__resolver__tests__resolve_generic_calls__generic_function_sharing_a_datatype_name_resolves.snap @@ -0,0 +1,19 @@ +--- +source: src/resolver/tests/resolve_generic_calls.rs +expression: annotations.get(operator) +--- +Some( + ReplacementAst { + statement: BinaryExpression { + operator: Less, + left: LiteralString { + value: "hello", + is_wide: false, + }, + right: LiteralString { + value: "world", + is_wide: false, + }, + }, + }, +) diff --git a/src/validation/array.rs b/src/validation/array.rs index d96bf767c2..ab6f9ef523 100644 --- a/src/validation/array.rs +++ b/src/validation/array.rs @@ -31,8 +31,12 @@ pub(super) fn validate_array_assignment( context: &ValidationContext, wrapper: Wrapper, ) { - let Some(lhs_type) = wrapper.datatype_info_lhs(context) else { return; }; - let Some(rhs_stmt) = wrapper.get_rhs() else { return; }; + let Some(lhs_type) = wrapper.datatype_info_lhs(context) else { + return; + }; + let Some(rhs_stmt) = wrapper.get_rhs() else { + return; + }; if !lhs_type.is_array() { return; @@ -75,15 +79,23 @@ fn validate_array_of_structs( lhs_type: &DataTypeInformation, rhs_stmt: &AstNode, ) { - let Some(array_type_name) = lhs_type.get_inner_array_type_name() else { return; }; - let Some(dti) = context.index.find_effective_type_by_name(array_type_name) else { return; }; + let Some(array_type_name) = lhs_type.get_inner_array_type_name() else { + return; + }; + let Some(dti) = context.index.find_effective_type_by_name(array_type_name) else { + return; + }; if !dti.is_struct() { return; } - let AstStatement::Literal(AstLiteral::Array(array)) = rhs_stmt.get_stmt() else { return; }; - let Some(elements) = array.elements().map(AstNode::get_stmt) else { return; }; + let AstStatement::Literal(AstLiteral::Array(array)) = rhs_stmt.get_stmt() else { + return; + }; + let Some(elements) = array.elements().map(AstNode::get_stmt) else { + return; + }; match elements { AstStatement::ExpressionList(expressions) => { @@ -143,7 +155,9 @@ impl<'a> Wrapper<'a> { { match self { Wrapper::Statement(statement) => { - let AstNode { stmt: AstStatement::Assignment(data), .. } = statement else { return None; }; + let AstNode { stmt: AstStatement::Assignment(data), .. } = statement else { + return None; + }; context.annotations.get_type(&data.left, context.index).map(|it| it.get_type_information()) } diff --git a/src/validation/statement.rs b/src/validation/statement.rs index d45b93f307..a1b1d83b17 100644 --- a/src/validation/statement.rs +++ b/src/validation/statement.rs @@ -907,13 +907,13 @@ fn validate_call( let mut variable_location_in_parent = vec![]; // validate parameters - for (i, p) in passed_parameters.iter().enumerate() { + for (i, param) in passed_parameters.iter().enumerate() { if let Ok((parameter_location_in_parent, right, is_implicit)) = - get_implicit_call_parameter(p, &declared_parameters, i) + get_implicit_call_parameter(param, &declared_parameters, i) { let left = declared_parameters.get(parameter_location_in_parent); if let Some(left) = left { - validate_call_by_ref(validator, left, p); + validate_call_by_ref(validator, left, param); // 'parameter location in parent' and 'variable location in parent' are not the same (e.g VAR blocks are not counted as param). // save actual location in parent for InOut validation variable_location_in_parent.push(left.get_location_in_parent()); @@ -922,7 +922,7 @@ fn validate_call( // explicit call parameter assignments will be handled by // `visit_statement()` via `Assignment` and `OutputAssignment` if is_implicit { - validate_assignment(validator, right, None, &p.get_location(), context); + validate_assignment(validator, right, None, ¶m.get_location(), context); } // mixing implicit and explicit parameters is not allowed @@ -930,11 +930,11 @@ fn validate_call( if i == 0 { are_implicit_parameters = is_implicit; } else if are_implicit_parameters != is_implicit { - validator.push_diagnostic(Diagnostic::invalid_parameter_type(p.get_location())); + validator.push_diagnostic(Diagnostic::invalid_parameter_type(param.get_location())); } } - visit_statement(validator, p, context); + visit_statement(validator, param, context); } // for PROGRAM/FB we need special inout validation diff --git a/src/validation/tests.rs b/src/validation/tests.rs index 58a1b90635..2b27ea2eb0 100644 --- a/src/validation/tests.rs +++ b/src/validation/tests.rs @@ -2,6 +2,7 @@ mod array_validation_test; mod assignment_validation_tests; mod bitaccess_validation_test; +mod builtin_validation_tests; mod duplicates_validation_test; mod generic_validation_tests; mod literals_validation_tests; diff --git a/src/validation/tests/builtin_validation_tests.rs b/src/validation/tests/builtin_validation_tests.rs new file mode 100644 index 0000000000..4f61b1a0e3 --- /dev/null +++ b/src/validation/tests/builtin_validation_tests.rs @@ -0,0 +1,105 @@ +use crate::{assert_validation_snapshot, test_utils::tests::parse_and_validate}; + +#[test] +fn arithmetic_builtins_allow_mixing_of_fp_and_int_params() { + let diagnostics = parse_and_validate( + " + FUNCTION main : LINT + VAR + i1, i2 : DINT; + f1, f2 : LREAL; + res_i : DINT; + res_fp: LREAL; + END_VAR + res_i := ADD(i1, i2, f1, f2); + res_fp := MUL(i1, i2, f1, f2); + res_i := SUB(i1, f2); + res_fp := DIV(i1, f2); + END_FUNCTION + ", + ); + + assert!(diagnostics.is_empty()); +} + +#[test] +#[ignore = "FIXME: no validation for incompatible types for arithmetic operations"] +fn arithmetic_builtins_called_with_incompatible_types() { + let diagnostics = parse_and_validate( + " + FUNCTION main : DINT + VAR + x1 : ARRAY[0..2] OF TOD; + x2 : STRING; + END_VAR + x1 + x2; // will currently also validate without errors + ADD(x1, x1); + DIV(x1, x2); + SUB(x2, x2); + END_FUNCTION + ", + ); + + assert_validation_snapshot!(&diagnostics); +} + +#[test] +fn arithmetic_builtins_called_with_invalid_param_count() { + let diagnostics = parse_and_validate( + " + FUNCTION main : DINT + VAR + x1 : DINT; + x2 : REAL; + END_VAR + ADD(); + MUL(x1); + DIV(x2, x2, x1, x2); // DIV and SUB are not extensible + SUB(x2, x2, x1, x2); + END_FUNCTION + ", + ); + + assert_validation_snapshot!(&diagnostics); +} + +#[test] +#[ignore = "FIXME: no validation for incompatible type comparisons"] +fn comparison_builtins_called_with_incompatible_types() { + let diagnostics = parse_and_validate( + " + FUNCTION main : DINT + VAR + x1 : ARRAY[0..2] OF TOD; + x2 : STRING; + END_VAR + x1 > x2; + EQ(x1, x1); + GT(x1, x2); + NE(x2, x2); + END_FUNCTION + ", + ); + + assert_validation_snapshot!(&diagnostics); +} + +#[test] +fn comparison_builtins_called_with_invalid_param_count() { + let diagnostics = parse_and_validate( + " + FUNCTION main : DINT + VAR + x1 : DINT; + x2 : REAL; + END_VAR + EQ(); + GT(x1); + LE(x2, x2, x1, x2); // OK + NE(x2, x2, x1, x2); // NE is not extensible + END_FUNCTION + ", + ); + + assert_validation_snapshot!(&diagnostics); +} diff --git a/src/validation/tests/snapshots/rusty__validation__tests__builtin_validation_tests__arithmetic_builtins_called_with_invalid_param_count.snap b/src/validation/tests/snapshots/rusty__validation__tests__builtin_validation_tests__arithmetic_builtins_called_with_invalid_param_count.snap new file mode 100644 index 0000000000..4e5c52b823 --- /dev/null +++ b/src/validation/tests/snapshots/rusty__validation__tests__builtin_validation_tests__arithmetic_builtins_called_with_invalid_param_count.snap @@ -0,0 +1,10 @@ +--- +source: src/validation/tests/builtin_validation_tests.rs +expression: res +--- +SyntaxError { message: "Invalid parameter count. Received 0 parameters while 2 parameters were expected.", range: [SourceLocation { span: Range(TextLocation { line: 6, column: 12, offset: 116 }..TextLocation { line: 6, column: 15, offset: 119 }) }], err_no: call__invalid_parameter_count } +SyntaxError { message: "Could not resolve generic type T with nature Num", range: [SourceLocation { span: Range(TextLocation { line: 6, column: 12, offset: 116 }..TextLocation { line: 6, column: 18, offset: 122 }) }], err_no: type__unresolved_generic } +SyntaxError { message: "Invalid parameter count. Received 1 parameters while 2 parameters were expected.", range: [SourceLocation { span: Range(TextLocation { line: 7, column: 12, offset: 135 }..TextLocation { line: 7, column: 15, offset: 138 }) }], err_no: call__invalid_parameter_count } +SyntaxError { message: "Invalid parameter count. Received 4 parameters while 2 parameters were expected.", range: [SourceLocation { span: Range(TextLocation { line: 8, column: 12, offset: 156 }..TextLocation { line: 8, column: 15, offset: 159 }) }], err_no: call__invalid_parameter_count } +SyntaxError { message: "Invalid parameter count. Received 4 parameters while 2 parameters were expected.", range: [SourceLocation { span: Range(TextLocation { line: 9, column: 12, offset: 223 }..TextLocation { line: 9, column: 15, offset: 226 }) }], err_no: call__invalid_parameter_count } + diff --git a/src/validation/tests/snapshots/rusty__validation__tests__builtin_validation_tests__comparison_builtins_called_with_invalid_param_count.snap b/src/validation/tests/snapshots/rusty__validation__tests__builtin_validation_tests__comparison_builtins_called_with_invalid_param_count.snap new file mode 100644 index 0000000000..db7017f941 --- /dev/null +++ b/src/validation/tests/snapshots/rusty__validation__tests__builtin_validation_tests__comparison_builtins_called_with_invalid_param_count.snap @@ -0,0 +1,8 @@ +--- +source: src/validation/tests/builtin_validation_tests.rs +expression: res +--- +SyntaxError { message: "Invalid parameter count. Received 0 parameters while 2 parameters were expected.", range: [SourceLocation { span: Range(TextLocation { line: 6, column: 12, offset: 116 }..TextLocation { line: 6, column: 14, offset: 118 }) }], err_no: call__invalid_parameter_count } +SyntaxError { message: "Invalid parameter count. Received 1 parameters while 2 parameters were expected.", range: [SourceLocation { span: Range(TextLocation { line: 7, column: 12, offset: 134 }..TextLocation { line: 7, column: 14, offset: 136 }) }], err_no: call__invalid_parameter_count } +SyntaxError { message: "Invalid parameter count. Received 4 parameters while 2 parameters were expected.", range: [SourceLocation { span: Range(TextLocation { line: 9, column: 12, offset: 192 }..TextLocation { line: 9, column: 14, offset: 194 }) }], err_no: call__invalid_parameter_count } + diff --git a/tests/correctness/arithmetic_functions/addition.rs b/tests/correctness/arithmetic_functions/addition.rs new file mode 100644 index 0000000000..490c4b2df5 --- /dev/null +++ b/tests/correctness/arithmetic_functions/addition.rs @@ -0,0 +1,51 @@ +use crate::correctness::math_operators::addition::approx_equal; +use driver::runner::compile_and_run_no_params; + +#[test] +fn builtin_add_with_ints() { + let prog = r#" + FUNCTION main : LINT + VAR_TEMP + x1 : ARRAY[0..3] OF DINT := (1, 2, 3, 4); + l1 : LINT := 1000; + s1 : SINT := 1; + END_VAR + main := ADD(x1[0], x1[1], x1[2], x1[3], l1, s1); + END_FUNCTION + "#; + + let res: i64 = compile_and_run_no_params(prog.to_string()); + assert_eq!(res, 1011); +} + +#[test] +fn builtin_add_with_floats() { + let prog = r#" + FUNCTION main : LREAL + VAR_TEMP + x1 : ARRAY[0..3] OF REAL := (1.0, 2.2, 3.4, 4.1); + x2 : LREAL := 1000.9; + END_VAR + main := ADD(x1[0], x1[1], x1[2], x1[3], x2); + END_FUNCTION + "#; + + let res: f64 = compile_and_run_no_params(prog.to_string()); + assert!(approx_equal(1011.6, res, 1)); +} + +#[test] +fn builtin_add_with_ints_and_floats() { + let prog = r#" + FUNCTION main : LREAL + VAR_TEMP + x1 : ARRAY[0..3] OF DINT := (1, 2, 3, 4); + x2 : LREAL := 1000.9; + END_VAR + main := ADD(x1[0], x1[1], x1[2], x1[3], x2); + END_FUNCTION + "#; + + let res: f64 = compile_and_run_no_params(prog.to_string()); + assert!(approx_equal(1010.9, res, 1)); +} diff --git a/tests/correctness/arithmetic_functions/division.rs b/tests/correctness/arithmetic_functions/division.rs new file mode 100644 index 0000000000..dea9dfab55 --- /dev/null +++ b/tests/correctness/arithmetic_functions/division.rs @@ -0,0 +1,58 @@ +use crate::correctness::math_operators::addition::approx_equal; +use driver::runner::compile_and_run; + +struct MainType; + +#[test] +fn builtin_div_with_ints() { + let prog = r#" + FUNCTION main : LINT + VAR + x1 : DINT := 1000; + l1 : LINT := 333; + END_VAR + main := DIV(x1, l1); + END_FUNCTION + "#; + + let mut main = MainType {}; + + let res: i64 = compile_and_run(prog.to_string(), &mut main); + assert_eq!(res, 3); +} + +#[test] +fn builtin_div_with_floats() { + let prog = r#" + FUNCTION main : LREAL + VAR + x1 : REAL := 10.0; + x2 : LREAL := 1000.0; + END_VAR + main := DIV(x1, x2); + END_FUNCTION + "#; + + let mut main = MainType {}; + + let res: f64 = compile_and_run(prog.to_string(), &mut main); + assert!(approx_equal(0.01, res, 2)); +} + +#[test] +fn builtin_div_with_ints_and_floats() { + let prog = r#" + FUNCTION main : LREAL + VAR + x1 : DINT := 20; + x2 : LREAL := 1000.0; + END_VAR + main := DIV(x1, x2); + END_FUNCTION + "#; + + let mut main = MainType {}; + + let res: f64 = compile_and_run(prog.to_string(), &mut main); + assert!(approx_equal(0.02, res, 2)); +} diff --git a/tests/correctness/arithmetic_functions/multiplication.rs b/tests/correctness/arithmetic_functions/multiplication.rs new file mode 100644 index 0000000000..9e22ce2db6 --- /dev/null +++ b/tests/correctness/arithmetic_functions/multiplication.rs @@ -0,0 +1,53 @@ +use crate::correctness::math_operators::addition::approx_equal; +use driver::runner::compile_and_run_no_params; + +#[test] +fn mul_with_ints() { + let prog = r#" + FUNCTION main : LINT + VAR + x1 : ARRAY[0..3] OF DINT := (1, 2, 3, 4); + l1 : LINT := 1000; + s1 : SINT := 5; + END_VAR + main := MUL(x1[0], x1[1], x1[2], x1[3], l1, s1); + END_FUNCTION + "#; + + let expected = 1 * 2 * 3 * 4 * 1000 * 5; + let res: i64 = compile_and_run_no_params(prog.to_string()); + assert_eq!(expected, res); +} + +#[test] +fn mul_with_floats() { + let prog = r#" + FUNCTION main : LREAL + VAR + x1 : ARRAY[0..3] OF REAL := (1.0, 2.2, 3.4, 4.1); + x2 : LREAL := 1000.9; + END_VAR + main := MUL(x1[0], x1[1], x1[2], x1[3], x2); + END_FUNCTION + "#; + + let expected = 1.0 * 2.2 * 3.4 * 4.1 * 1000.9; + let res: f64 = compile_and_run_no_params(prog.to_string()); + assert!(approx_equal(expected, res, 1)); +} + +#[test] +fn builtin_mul_with_ints_and_floats() { + let prog = r#" + FUNCTION main : LREAL + VAR + x1 : ARRAY[0..3] OF DINT := (1, 2, 3, 4); + x2 : LREAL := 0.5; + END_VAR + main := MUL(x1[0], x1[1], x1[2], x1[3], x2); + END_FUNCTION + "#; + + let res: f64 = compile_and_run_no_params(prog.to_string()); + assert!(approx_equal(12.0, res, 1)); +} diff --git a/tests/correctness/arithmetic_functions/substraction.rs b/tests/correctness/arithmetic_functions/substraction.rs new file mode 100644 index 0000000000..4bf6472699 --- /dev/null +++ b/tests/correctness/arithmetic_functions/substraction.rs @@ -0,0 +1,50 @@ +use crate::correctness::math_operators::addition::approx_equal; +use driver::runner::compile_and_run_no_params; + +#[test] +fn builtin_sub_with_ints() { + let prog = r#" + FUNCTION main : LINT + VAR + x1 : DINT := 1000; + l1 : LINT := 333; + END_VAR + main := SUB(x1, l1); + END_FUNCTION + "#; + + let res: i64 = compile_and_run_no_params(prog.to_string()); + assert_eq!(res, 667); +} + +#[test] +fn builtin_sub_with_floats() { + let prog = r#" + FUNCTION main : LREAL + VAR + x1 : REAL := 10.0; + x2 : LREAL := 1000.0; + END_VAR + main := SUB(x1, x2); + END_FUNCTION + "#; + + let res: f64 = compile_and_run_no_params(prog.to_string()); + assert!(approx_equal(-990.0, res, 2)); +} + +#[test] +fn builtin_sub_with_ints_and_floats() { + let prog = r#" + FUNCTION main : LREAL + VAR + x1 : DINT := 20; + x2 : LREAL := 19.9; + END_VAR + main := SUB(x1, x2); + END_FUNCTION + "#; + + let res: f64 = compile_and_run_no_params(prog.to_string()); + assert!(approx_equal(0.1, res, 1)); +} diff --git a/tests/correctness/comparison_functions/equal.rs b/tests/correctness/comparison_functions/equal.rs new file mode 100644 index 0000000000..f255fcdab7 --- /dev/null +++ b/tests/correctness/comparison_functions/equal.rs @@ -0,0 +1,102 @@ +use driver::runner::{compile_and_run, MainType}; + +#[test] +fn builtin_eq_with_ints_monotonic() { + let prog = r#" + FUNCTION main : BOOL + VAR + i1, i2, i3 : DINT; + END_VAR + i1 := 1; + i2 := 1; + i3 := 1; + main := EQ(i1, i2, i3); + END_FUNCTION + "#; + + let mut main = MainType::default(); + + let res: bool = compile_and_run(prog.to_string(), &mut main); + assert_eq!(res, true); +} + +#[test] +fn builtin_eq_with_ints() { + let prog = r#" + FUNCTION main : BOOL + VAR + i1, i2, i3 : DINT; + END_VAR + i1 := 3; + i2 := 2; // not equal to i3, should return false + i3 := 3; + main := EQ(i1, i2, i3); + END_FUNCTION + "#; + + let mut main = MainType::default(); + + let res: bool = compile_and_run(prog.to_string(), &mut main); + assert_eq!(res, false); +} + +#[test] +fn builtin_eq_with_floats_monotonic() { + let prog = r#" + FUNCTION main : BOOL + VAR + r1, r2, r3 : REAL; + END_VAR + r1 := 2.9; + r2 := 2.9; + r3 := 2.9; + main := EQ(r1, r2, r3); + END_FUNCTION + "#; + + let mut main = MainType::default(); + + let res: bool = compile_and_run(prog.to_string(), &mut main); + assert_eq!(res, true); +} + +#[test] +fn builtin_eq_with_floats() { + let prog = r#" + FUNCTION main : BOOL + VAR + r1, r2, r3 : REAL; + END_VAR + r1 := 3.0; + r2 := 2.9; // not equal to r3, should return false + r3 := 3.2; + main := EQ(r1, r2, r3); + END_FUNCTION + "#; + + let mut main = MainType::default(); + + let res: bool = compile_and_run(prog.to_string(), &mut main); + assert_eq!(res, false); +} + +#[test] +fn builtin_eq_with_mixed_ints_and_floats() { + let prog = r#" + FUNCTION main : BOOL + VAR + i1 : DINT; + r1, r2 : REAL; + END_VAR + i1 := 5; + r1 := 4.5; + r2 := 3.2; + main := EQ(i1, r1, r2); + END_FUNCTION + "#; + + let mut main = MainType::default(); + + let res: bool = compile_and_run(prog.to_string(), &mut main); + assert_eq!(res, false); +} diff --git a/tests/correctness/comparison_functions/greater_than.rs b/tests/correctness/comparison_functions/greater_than.rs new file mode 100644 index 0000000000..040a6cb71c --- /dev/null +++ b/tests/correctness/comparison_functions/greater_than.rs @@ -0,0 +1,102 @@ +use driver::runner::{compile_and_run, MainType}; + +#[test] +fn builtin_gt_with_ints_descending() { + let prog = r#" + FUNCTION main : BOOL + VAR + i1, i2, i3 : DINT; + END_VAR + i1 := 3; + i2 := 2; + i3 := 1; + main := GT(i1, i2, i3); + END_FUNCTION + "#; + + let mut main = MainType::default(); + + let res: bool = compile_and_run(prog.to_string(), &mut main); + assert_eq!(res, true); +} + +#[test] +fn builtin_gt_with_ints() { + let prog = r#" + FUNCTION main : BOOL + VAR + i1, i2, i3 : DINT; + END_VAR + i1 := 3; + i2 := 2; // not greater than i3, should return false + i3 := 3; + main := GT(i1, i2, i3); + END_FUNCTION + "#; + + let mut main = MainType::default(); + + let res: bool = compile_and_run(prog.to_string(), &mut main); + assert_eq!(res, false); +} + +#[test] +fn builtin_gt_with_floats_descending() { + let prog = r#" + FUNCTION main : BOOL + VAR + r1, r2, r3 : REAL; + END_VAR + r1 := 3.0; + r2 := 2.9; + r3 := 2.8; + main := GT(r1, r2, r3); + END_FUNCTION + "#; + + let mut main = MainType::default(); + + let res: bool = compile_and_run(prog.to_string(), &mut main); + assert_eq!(res, true); +} + +#[test] +fn builtin_gt_with_floats() { + let prog = r#" + FUNCTION main : BOOL + VAR + r1, r2, r3 : REAL; + END_VAR + r1 := 3.0; + r2 := 2.9; // not greater than r3, should return false + r3 := 3.2; + main := GT(r1, r2, r3); + END_FUNCTION + "#; + + let mut main = MainType::default(); + + let res: bool = compile_and_run(prog.to_string(), &mut main); + assert_eq!(res, false); +} + +#[test] +fn builtin_gt_with_mixed_ints_and_floats() { + let prog = r#" + FUNCTION main : BOOL + VAR + i1 : DINT; + r1, r2 : REAL; + END_VAR + i1 := 5; + r1 := 4.5; + r2 := 3.2; + main := GT(i1, r1, r2); + END_FUNCTION + "#; + + let mut main = MainType::default(); + + let res: bool = compile_and_run(prog.to_string(), &mut main); + assert_eq!(res, true); +} diff --git a/tests/correctness/comparison_functions/greater_than_or_equal.rs b/tests/correctness/comparison_functions/greater_than_or_equal.rs new file mode 100644 index 0000000000..6033a9bd57 --- /dev/null +++ b/tests/correctness/comparison_functions/greater_than_or_equal.rs @@ -0,0 +1,102 @@ +use driver::runner::{compile_and_run, MainType}; + +#[test] +fn builtin_ge_with_ints_monotonic() { + let prog = r#" + FUNCTION main : BOOL + VAR + i1, i2, i3 : DINT; + END_VAR + i1 := 1; + i2 := 1; + i3 := 1; + main := GE(i1, i2, i3); + END_FUNCTION + "#; + + let mut main = MainType::default(); + + let res: bool = compile_and_run(prog.to_string(), &mut main); + assert_eq!(res, true); +} + +#[test] +fn builtin_ge_with_ints() { + let prog = r#" + FUNCTION main : BOOL + VAR + i1, i2, i3 : DINT; + END_VAR + i1 := 3; + i2 := 2; // not greater or equal to i3, should return false + i3 := 3; + main := GE(i1, i2, i3); + END_FUNCTION + "#; + + let mut main = MainType::default(); + + let res: bool = compile_and_run(prog.to_string(), &mut main); + assert_eq!(res, false); +} + +#[test] +fn builtin_ge_with_floats_monotonic() { + let prog = r#" + FUNCTION main : BOOL + VAR + r1, r2, r3 : REAL; + END_VAR + r1 := 2.9; + r2 := 2.9; + r3 := 2.9; + main := GE(r1, r2, r3); + END_FUNCTION + "#; + + let mut main = MainType::default(); + + let res: bool = compile_and_run(prog.to_string(), &mut main); + assert_eq!(res, true); +} + +#[test] +fn builtin_ge_with_floats() { + let prog = r#" + FUNCTION main : BOOL + VAR + r1, r2, r3 : REAL; + END_VAR + r1 := 3.0; + r2 := 2.9; // not greater or equal to r3, should return false + r3 := 3.2; + main := GE(r1, r2, r3); + END_FUNCTION + "#; + + let mut main = MainType::default(); + + let res: bool = compile_and_run(prog.to_string(), &mut main); + assert_eq!(res, false); +} + +#[test] +fn builtin_ge_with_mixed_ints_and_floats() { + let prog = r#" + FUNCTION main : BOOL + VAR + i1 : DINT; + r1, r2 : REAL; + END_VAR + i1 := 5; + r1 := 4.5; + r2 := 3.2; + main := GE(i1, r1, r2); + END_FUNCTION + "#; + + let mut main = MainType::default(); + + let res: bool = compile_and_run(prog.to_string(), &mut main); + assert_eq!(res, true); +} diff --git a/tests/correctness/comparison_functions/less_than.rs b/tests/correctness/comparison_functions/less_than.rs new file mode 100644 index 0000000000..f09b86baec --- /dev/null +++ b/tests/correctness/comparison_functions/less_than.rs @@ -0,0 +1,102 @@ +use driver::runner::{compile_and_run, MainType}; + +#[test] +fn builtin_lt_with_ints_monotonic() { + let prog = r#" + FUNCTION main : BOOL + VAR + i1, i2, i3 : DINT; + END_VAR + i1 := 1; + i2 := 1; + i3 := 1; + main := LT(i1, i2, i3); + END_FUNCTION + "#; + + let mut main = MainType::default(); + + let res: bool = compile_and_run(prog.to_string(), &mut main); + assert_eq!(res, false); +} + +#[test] +fn builtin_lt_with_ints() { + let prog = r#" + FUNCTION main : BOOL + VAR + i1, i2, i3 : DINT; + END_VAR + i1 := 3; + i2 := 2; + i3 := 2; // not less than i3, should return false + main := LT(i1, i2, i3); + END_FUNCTION + "#; + + let mut main = MainType::default(); + + let res: bool = compile_and_run(prog.to_string(), &mut main); + assert_eq!(res, false); +} + +#[test] +fn builtin_lt_with_floats_monotonic() { + let prog = r#" + FUNCTION main : BOOL + VAR + r1, r2, r3 : REAL; + END_VAR + r1 := 2.9; + r2 := 2.9; + r3 := 2.9; + main := LT(r1, r2, r3); + END_FUNCTION + "#; + + let mut main = MainType::default(); + + let res: bool = compile_and_run(prog.to_string(), &mut main); + assert_eq!(res, false); +} + +#[test] +fn builtin_lt_with_floats() { + let prog = r#" + FUNCTION main : BOOL + VAR + r1, r2, r3 : REAL; + END_VAR + r1 := 3.0; + r2 := 2.9; + r3 := 3.2; // not less than r3, should return false + main := LT(r1, r2, r3); + END_FUNCTION + "#; + + let mut main = MainType::default(); + + let res: bool = compile_and_run(prog.to_string(), &mut main); + assert_eq!(res, false); +} + +#[test] +fn builtin_lt_with_mixed_ints_and_floats() { + let prog = r#" + FUNCTION main : BOOL + VAR + i1 : DINT; + r1, r2 : REAL; + END_VAR + i1 := 5; + r1 := 4.5; + r2 := 3.2; + main := LT(i1, r1, r2); + END_FUNCTION + "#; + + let mut main = MainType::default(); + + let res: bool = compile_and_run(prog.to_string(), &mut main); + assert_eq!(res, false); +} diff --git a/tests/correctness/comparison_functions/less_than_or_equal.rs b/tests/correctness/comparison_functions/less_than_or_equal.rs new file mode 100644 index 0000000000..c9b2af6e4a --- /dev/null +++ b/tests/correctness/comparison_functions/less_than_or_equal.rs @@ -0,0 +1,102 @@ +use driver::runner::{compile_and_run, MainType}; + +#[test] +fn builtin_le_with_ints_monotonic() { + let prog = r#" + FUNCTION main : BOOL + VAR + i1, i2, i3 : DINT; + END_VAR + i1 := 1; + i2 := 1; + i3 := 1; + main := LE(i1, i2, i3); + END_FUNCTION + "#; + + let mut main = MainType::default(); + + let res: bool = compile_and_run(prog.to_string(), &mut main); + assert_eq!(res, true); +} + +#[test] +fn builtin_le_with_ints() { + let prog = r#" + FUNCTION main : BOOL + VAR + i1, i2, i3 : DINT; + END_VAR + i1 := 3; + i2 := 2; + i3 := 3; // not less or equal to i2, should return false + main := LE(i1, i2, i3); + END_FUNCTION + "#; + + let mut main = MainType::default(); + + let res: bool = compile_and_run(prog.to_string(), &mut main); + assert_eq!(res, false); +} + +#[test] +fn builtin_le_with_floats_monotonic() { + let prog = r#" + FUNCTION main : BOOL + VAR + r1, r2, r3 : REAL; + END_VAR + r1 := 2.9; + r2 := 2.9; + r3 := 2.9; + main := LE(r1, r2, r3); + END_FUNCTION + "#; + + let mut main = MainType::default(); + + let res: bool = compile_and_run(prog.to_string(), &mut main); + assert_eq!(res, true); +} + +#[test] +fn builtin_le_with_floats() { + let prog = r#" + FUNCTION main : BOOL + VAR + r1, r2, r3 : REAL; + END_VAR + r1 := 3.0; + r2 := 2.9; + r3 := 3.2; // not less or equal to r3, should return false + main := LE(r1, r2, r3); + END_FUNCTION + "#; + + let mut main = MainType::default(); + + let res: bool = compile_and_run(prog.to_string(), &mut main); + assert_eq!(res, false); +} + +#[test] +fn builtin_le_with_mixed_ints_and_floats() { + let prog = r#" + FUNCTION main : BOOL + VAR + i1 : DINT; + r1, r2 : REAL; + END_VAR + i1 := 5; + r1 := 4.5; + r2 := 3.2; + main := LE(i1, r1, r2); + END_FUNCTION + "#; + + let mut main = MainType::default(); + + let res: bool = compile_and_run(prog.to_string(), &mut main); + assert_eq!(res, false); +} diff --git a/tests/correctness/comparison_functions/not_equal.rs b/tests/correctness/comparison_functions/not_equal.rs new file mode 100644 index 0000000000..bf9b243f1a --- /dev/null +++ b/tests/correctness/comparison_functions/not_equal.rs @@ -0,0 +1,102 @@ +use driver::runner::{compile_and_run, MainType}; + +#[test] +fn builtin_ne_with_ints_monotonic() { + let prog = r#" + FUNCTION main : BOOL + VAR + i1, i2, i3 : DINT; + END_VAR + i1 := 1; + i2 := 1; + i3 := 1; + main := NE(i1, i2); + END_FUNCTION + "#; + + let mut main = MainType::default(); + + let res: bool = compile_and_run(prog.to_string(), &mut main); + assert_eq!(res, false); +} + +#[test] +fn builtin_ne_with_ints() { + let prog = r#" + FUNCTION main : BOOL + VAR + i1, i2, i3 : DINT; + END_VAR + i1 := 3; + i2 := 2; + i3 := 3; + main := NE(i1, i2); + END_FUNCTION + "#; + + let mut main = MainType::default(); + + let res: bool = compile_and_run(prog.to_string(), &mut main); + assert_eq!(res, true); +} + +#[test] +fn builtin_ne_with_floats_monotonic() { + let prog = r#" + FUNCTION main : BOOL + VAR + r1, r2, r3 : REAL; + END_VAR + r1 := 2.9; + r2 := 2.9; + r3 := 2.9; + main := NE(r1, r2); + END_FUNCTION + "#; + + let mut main = MainType::default(); + + let res: bool = compile_and_run(prog.to_string(), &mut main); + assert_eq!(res, false); +} + +#[test] +fn builtin_ne_with_floats() { + let prog = r#" + FUNCTION main : BOOL + VAR + r1, r2, r3 : REAL; + END_VAR + r1 := 3.0; + r2 := 2.9; + r3 := 3.2; + main := NE(r1, r2); + END_FUNCTION + "#; + + let mut main = MainType::default(); + + let res: bool = compile_and_run(prog.to_string(), &mut main); + assert_eq!(res, true); +} + +#[test] +fn builtin_ne_with_mixed_ints_and_floats() { + let prog = r#" + FUNCTION main : BOOL + VAR + i1 : DINT; + r1, r2 : REAL; + END_VAR + i1 := 5; + r1 := 4.5; + r2 := 3.2; + main := NE(i1, r1); + END_FUNCTION + "#; + + let mut main = MainType::default(); + + let res: bool = compile_and_run(prog.to_string(), &mut main); + assert_eq!(res, true); +} diff --git a/tests/correctness/expressions.rs b/tests/correctness/expressions.rs index ebd02c985d..e7a5a19e8a 100644 --- a/tests/correctness/expressions.rs +++ b/tests/correctness/expressions.rs @@ -345,3 +345,39 @@ fn casting_of_floating_point_types_lreal() { let _: i32 = compile_and_run(src, &mut main); assert_eq!([main.a, main.b, main.c, main.d], [3.0, 3.5, 3.5, 3.5]) } + +#[test] +fn aliased_ranged_numbers_can_be_compared_with_builtins() { + #[derive(Default)] + #[repr(C)] + struct Main { + a: bool, + b: bool, + c: bool, + d: bool, + e: bool, + f: bool, + } + + let mut main = Main::default(); + + let src = r#" + TYPE MyInt: INT(0..500); END_TYPE + PROGRAM main + VAR + a, b, c, d, e, f : BOOL; + END_VAR + VAR_TEMP + x,y : MyInt; + END_VAR + a := LT(x, y); + b := LE(y, 0); + c := EQ(x, 3); + d := EQ(y, 500); + e := GE(x, 0) AND LE(x, 500); + f := LT(x, 0) OR GT(x, 500); + END_PROGRAM + "#; + let _: i32 = compile_and_run(src, &mut main); + assert_eq!([main.a, main.b, main.c, main.d, main.e, main.f], [false, true, false, false, true, false]); +} diff --git a/tests/correctness/external_functions.rs b/tests/correctness/external_functions.rs index 7e151fd58b..82f9f6c6e3 100644 --- a/tests/correctness/external_functions.rs +++ b/tests/correctness/external_functions.rs @@ -36,7 +36,7 @@ fn test_external_function_called() { //Test the function's result is executed } -extern "C" fn add(size: i32, ptr: *const i32) -> i32 { +extern "C" fn add_local(size: i32, ptr: *const i32) -> i32 { let mut result = 0; let mut ptr = ptr; for _ in 0..size { @@ -64,14 +64,14 @@ extern "C" fn add_ref(size: i32, ptr: *const *const i32) -> i32 { fn sized_variadic_call() { let src = " {external} - FUNCTION add : DINT + FUNCTION add_local : DINT VAR_INPUT args : {sized} DINT...; END_VAR END_FUNCTION FUNCTION main : DINT - main := add(1, 2, 3); + main := add_local(1, 2, 3); END_FUNCTION "; @@ -79,7 +79,7 @@ fn sized_variadic_call() { let source = SourceCode::new(src, "external_test.st"); let context = CodegenContext::create(); let module = compile(&context, source); - module.add_global_function_mapping("add", add as usize); + module.add_global_function_mapping("add_local", add_local as usize); let res: i32 = module.run_no_param("main"); assert_eq!(res, 6) diff --git a/tests/correctness/math_operators/addition.rs b/tests/correctness/math_operators/addition.rs index 79fb3f5d61..17d55b6cae 100644 --- a/tests/correctness/math_operators/addition.rs +++ b/tests/correctness/math_operators/addition.rs @@ -272,8 +272,7 @@ fn adds_array_basic() { } //-------------------------- - -fn approx_equal(a: T, b: T, decimal_places: u16) -> bool { +pub fn approx_equal(a: T, b: T, decimal_places: u16) -> bool { let factor: T = NumCast::from(10.0.powi(decimal_places as i32)).unwrap(); let a = (a * factor).round(); let b = (b * factor).round(); diff --git a/tests/tests.rs b/tests/tests.rs index 7a92b2b8e1..6351bf03f5 100644 --- a/tests/tests.rs +++ b/tests/tests.rs @@ -27,13 +27,27 @@ mod correctness { mod strings; mod sub_range_types; mod math_operators { - mod addition; + pub(super) mod addition; mod division; mod mixed; mod multiplication; mod substraction; } + mod arithmetic_functions { + mod addition; + mod division; + mod multiplication; + mod substraction; + } mod vla; + mod comparison_functions { + mod equal; + mod greater_than; + mod greater_than_or_equal; + mod less_than; + mod less_than_or_equal; + mod not_equal; + } } mod integration { mod build_description_tests; From 6a1b19a9352b1f5308d421f725c2dbbfba9476d4 Mon Sep 17 00:00:00 2001 From: Kari Argillander Date: Fri, 1 Dec 2023 13:00:17 +0200 Subject: [PATCH 13/33] chore: Update Cargo.lock for security and refactor deprecated chrono functions (#1045) * fix: update Cargo.lock for security updates Rustix needed an update, ran cargo update to address the issue * Use timestamp_nanos_opt() over timestamp_nanos() in tests timestamp_nanos() is deprecated and we can replace it very easily in unittests with timestamp_nanos_opt().unwrap(). These are unittests and we do not except timestamp_nanos_opt() to fail so unwrap is totally ok. * Use timestamp_nanos_opt() over timestamp_nanos() timestamp_nanos() is deprecated and we should replace it with timestamp_nanos_opt(). Before it would just panic if range was not in between 1677-09-21T00:12:44.0 and 2262-04-11T23:47:16.854775804. Now we can decide what to do in which situation. I tried to follow what ever error stategy function did before. * Replace deprecated from_utc() with from_utc_datetime() Function from_utc is deprecated. I choose to use TimeZone::from_utc_datetime which is pretty similar. --------- Co-authored-by: Ghaith Hachem Co-authored-by: Kari Argillander --- Cargo.lock | 910 +++++++++++------- compiler/plc_ast/src/literals.rs | 6 +- libs/stdlib/src/date_time_conversion.rs | 5 +- libs/stdlib/src/date_time_extra_functions.rs | 11 +- .../stdlib/src/date_time_numeric_functions.rs | 6 +- libs/stdlib/src/extra_functions.rs | 8 +- .../tests/date_time_conversion_tests.rs | 38 +- .../tests/date_time_extra_functions_tests.rs | 50 +- .../date_time_numeric_functions_tests.rs | 34 +- .../endianness_conversion_functions_tests.rs | 115 ++- libs/stdlib/tests/extra_function_tests.rs | 34 +- tests/correctness/math_operators/addition.rs | 6 +- tests/correctness/math_operators/division.rs | 6 +- tests/correctness/math_operators/mixed.rs | 18 +- .../math_operators/multiplication.rs | 6 +- .../math_operators/substraction.rs | 6 +- 16 files changed, 790 insertions(+), 469 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 9ac7b9a128..935cec6053 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -19,22 +19,23 @@ checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" [[package]] name = "ahash" -version = "0.8.3" +version = "0.8.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2c99f64d1e06488f620f932677e24bc6e2897582980441ae90a671415bd7ec2f" +checksum = "91429305e9f0a25f6205c5b8e0d2db09e0708a7a6df0f42212bb56c32c8ac97a" dependencies = [ "cfg-if", "getrandom", "once_cell", "serde", "version_check", + "zerocopy", ] [[package]] name = "aho-corasick" -version = "1.0.5" +version = "1.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c378d78423fdad8089616f827526ee33c19f2fddbd5de1629152c9593ba4783" +checksum = "b2969dcb958b36655471fc61f7e416fa76033bdd4bfed0678d8fee1e2d07a1f0" dependencies = [ "memchr", ] @@ -62,9 +63,9 @@ dependencies = [ [[package]] name = "anstream" -version = "0.5.0" +version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b1f58811cfac344940f1a400b6e6231ce35171f614f26439e80f8c1465c5cc0c" +checksum = "2ab91ebe16eb252986481c5b62f6098f3b698a45e34b5b98200cf20dd2484a44" dependencies = [ "anstyle", "anstyle-parse", @@ -76,15 +77,15 @@ dependencies = [ [[package]] name = "anstyle" -version = "1.0.3" +version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b84bf0a05bbb2a83e5eb6fa36bb6e87baa08193c35ff52bbf6b38d8af2890e46" +checksum = "7079075b41f533b8c61d2a4d073c4676e1f8b249ff94a393b0595db304e0dd87" [[package]] name = "anstyle-parse" -version = "0.2.1" +version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "938874ff5980b03a87c5524b3ae5b59cf99b1d6bc836848df7bc5ada9643c333" +checksum = "317b9a89c1868f5ea6ff1d9539a69f45dffc21ce321ac1fd1160dfa48c8e2140" dependencies = [ "utf8parse", ] @@ -100,9 +101,9 @@ dependencies = [ [[package]] name = "anstyle-wincon" -version = "2.1.0" +version = "3.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "58f54d10c6dfa51283a066ceab3ec1ab78d13fae00aa49243a45e4571fb79dfd" +checksum = "f0699d10d2f4d628a98ee7b57b289abbc98ff3bad977cb3152709d4bf2330628" dependencies = [ "anstyle", "windows-sys 0.48.0", @@ -121,36 +122,49 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "81953c529336010edd6d8e358f886d9581267795c61b19475b71314bffa46d35" dependencies = [ "concurrent-queue", - "event-listener", + "event-listener 2.5.3", "futures-core", ] +[[package]] +name = "async-channel" +version = "2.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1ca33f4bc4ed1babef42cad36cc1f51fa88be00420404e5b1e80ab1b18f7678c" +dependencies = [ + "concurrent-queue", + "event-listener 4.0.0", + "event-listener-strategy", + "futures-core", + "pin-project-lite", +] + [[package]] name = "async-executor" -version = "1.5.1" +version = "1.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6fa3dc5f2a8564f07759c008b9109dc0d39de92a88d5588b8a5036d286383afb" +checksum = "17ae5ebefcc48e7452b4987947920dac9450be1110cadf34d1b8c116bdbaf97c" dependencies = [ - "async-lock", + "async-lock 3.1.2", "async-task", "concurrent-queue", - "fastrand 1.9.0", - "futures-lite", + "fastrand 2.0.1", + "futures-lite 2.0.1", "slab", ] [[package]] name = "async-global-executor" -version = "2.3.1" +version = "2.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f1b6f5d7df27bd294849f8eec66ecfc63d11814df7a4f5d74168a2394467b776" +checksum = "9b4353121d5644cdf2beb5726ab752e79a8db1ebb52031770ec47db31d245526" dependencies = [ - "async-channel", + "async-channel 2.1.1", "async-executor", - "async-io", - "async-lock", + "async-io 2.2.1", + "async-lock 3.1.2", "blocking", - "futures-lite", + "futures-lite 2.0.1", "once_cell", ] @@ -160,27 +174,57 @@ version = "1.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0fc5b45d93ef0529756f812ca52e44c221b35341892d3dcc34132ac02f3dd2af" dependencies = [ - "async-lock", + "async-lock 2.8.0", "autocfg", "cfg-if", "concurrent-queue", - "futures-lite", + "futures-lite 1.13.0", "log", "parking", - "polling", - "rustix 0.37.25", + "polling 2.8.0", + "rustix 0.37.27", "slab", - "socket2 0.4.9", + "socket2 0.4.10", "waker-fn", ] +[[package]] +name = "async-io" +version = "2.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d6d3b15875ba253d1110c740755e246537483f152fa334f91abd7fe84c88b3ff" +dependencies = [ + "async-lock 3.1.2", + "cfg-if", + "concurrent-queue", + "futures-io", + "futures-lite 2.0.1", + "parking", + "polling 3.3.1", + "rustix 0.38.26", + "slab", + "tracing", + "windows-sys 0.52.0", +] + [[package]] name = "async-lock" version = "2.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "287272293e9d8c41773cec55e365490fe034813a2f172f502d6ddcf75b2f582b" dependencies = [ - "event-listener", + "event-listener 2.5.3", +] + +[[package]] +name = "async-lock" +version = "3.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dea8b3453dd7cc96711834b75400d671b73e3656975fa68d9f277163b7f7e316" +dependencies = [ + "event-listener 4.0.0", + "event-listener-strategy", + "pin-project-lite", ] [[package]] @@ -189,15 +233,15 @@ version = "1.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "62565bb4402e926b29953c785397c6dc0391b7b446e45008b0049eb43cec6f5d" dependencies = [ - "async-channel", + "async-channel 1.9.0", "async-global-executor", - "async-io", - "async-lock", + "async-io 1.13.0", + "async-lock 2.8.0", "crossbeam-utils", "futures-channel", "futures-core", "futures-io", - "futures-lite", + "futures-lite 1.13.0", "gloo-timers", "kv-log-macro", "log", @@ -211,9 +255,9 @@ dependencies = [ [[package]] name = "async-task" -version = "4.4.0" +version = "4.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ecc7ab41815b3c653ccd2978ec3255c81349336702dfdf62ee6f7069b12a3aae" +checksum = "b4eb2cdb97421e01129ccb49169d8279ed21e829929144f4a22a6e54ac549ca1" [[package]] name = "atoi" @@ -226,9 +270,19 @@ dependencies = [ [[package]] name = "atomic-waker" -version = "1.1.1" +version = "1.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1181e1e0d1fce796a03db1ae795d67167da795f9cf4a39c37589e85ef57f26d3" +checksum = "1505bd5d3d116872e7271a6d4e16d81d0c8570876c8de68093a09ac269d8aac0" + +[[package]] +name = "atomic-write-file" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "edcdbedc2236483ab103a53415653d6b4442ea6141baf1ffa85df29635e88436" +dependencies = [ + "nix", + "rand", +] [[package]] name = "atty" @@ -264,9 +318,9 @@ dependencies = [ [[package]] name = "base64" -version = "0.21.4" +version = "0.21.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ba43ea6f343b788c8764558649e08df62f86c6ef251fdaeb1ffd010a9ae50a2" +checksum = "35636a1494ede3b646cc98f74f8e62c773a38a659ebc777a2cf26b9b74171df9" [[package]] name = "base64ct" @@ -303,9 +357,9 @@ checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" [[package]] name = "bitflags" -version = "2.4.0" +version = "2.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b4682ae6287fcf752ecaabbfcc7b6f9b72aa33933dc23a554d853aea8eea8635" +checksum = "327762f6e5a765692301e5bb513e0d9fef63be86bbc14528052b1cd3e6f03e07" dependencies = [ "serde", ] @@ -321,24 +375,25 @@ dependencies = [ [[package]] name = "blocking" -version = "1.3.1" +version = "1.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77231a1c8f801696fc0123ec6150ce92cffb8e164a02afb9c8ddee0e9b65ad65" +checksum = "6a37913e8dc4ddcc604f0c6d3bf2887c995153af3611de9e23c352b44c1b9118" dependencies = [ - "async-channel", - "async-lock", + "async-channel 2.1.1", + "async-lock 3.1.2", "async-task", - "atomic-waker", - "fastrand 1.9.0", - "futures-lite", - "log", + "fastrand 2.0.1", + "futures-io", + "futures-lite 2.0.1", + "piper", + "tracing", ] [[package]] name = "bumpalo" -version = "3.13.0" +version = "3.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a3e2c3daef883ecc1b5d58c15adae93470a91d425f3532ba1695849656af3fc1" +checksum = "7f30e7476521f6f8af1a1c4c0b8cc94f0bee37d91763d0ca2665f299b6cd8aec" [[package]] name = "bytecount" @@ -348,9 +403,9 @@ checksum = "e1e5f035d16fc623ae5f74981db80a439803888314e3a555fd6f04acd51a3205" [[package]] name = "byteorder" -version = "1.4.3" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610" +checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" [[package]] name = "bytes" @@ -375,9 +430,9 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "chrono" -version = "0.4.30" +version = "0.4.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "defd4e7873dbddba6c7c91e199c7fcb946abc4a6a4ac3195400bcfb01b5de877" +checksum = "7f2c685bad3eb3d45a01354cedb7d5faa66194d1d58ba6e267a8de788f79db38" dependencies = [ "android-tzdata", "iana-time-zone", @@ -406,23 +461,23 @@ dependencies = [ [[package]] name = "clap" -version = "4.4.3" +version = "4.4.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "84ed82781cea27b43c9b106a979fe450a13a31aab0500595fb3fc06616de08e6" +checksum = "41fffed7514f420abec6d183b1d3acfd9099c79c3a10a06ade4f8203f1411272" dependencies = [ "clap_builder", - "clap_derive 4.4.2", + "clap_derive 4.4.7", ] [[package]] name = "clap_builder" -version = "4.4.2" +version = "4.4.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2bb9faaa7c2ef94b2743a21f5a29e6f0010dff4caa69ac8e9d6cf8b6fa74da08" +checksum = "63361bae7eef3771745f02d8d892bec2fee5f6e34af316ba556e7f97a7069ff1" dependencies = [ "anstream", "anstyle", - "clap_lex 0.5.1", + "clap_lex 0.6.0", "strsim", ] @@ -434,21 +489,21 @@ checksum = "ae6371b8bdc8b7d3959e9cf7b22d4435ef3e79e138688421ec654acf8c81b008" dependencies = [ "heck", "proc-macro-error", - "proc-macro2 1.0.67", + "proc-macro2 1.0.70", "quote 1.0.33", "syn 1.0.109", ] [[package]] name = "clap_derive" -version = "4.4.2" +version = "4.4.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0862016ff20d69b84ef8247369fabf5c008a7417002411897d40ee1f4532b873" +checksum = "cf9804afaaf59a91e75b022a30fb7229a7901f60c755489cc61c9b423b836442" dependencies = [ "heck", - "proc-macro2 1.0.67", + "proc-macro2 1.0.70", "quote 1.0.33", - "syn 2.0.33", + "syn 2.0.39", ] [[package]] @@ -462,9 +517,9 @@ dependencies = [ [[package]] name = "clap_lex" -version = "0.5.1" +version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cd7cc57abe963c6d3b9d8be5b06ba7c8957a930305ca90304f24ef040aa6f961" +checksum = "702fc72eb24e5a1e48ce58027a675bc24edd52096d5397d4aea7c6dd9eca0bd1" [[package]] name = "codespan-reporting" @@ -484,9 +539,9 @@ checksum = "acbf1af155f9b9ef647e42cdc158db4b64a1b61f743629225fde6f3e0be2a7c7" [[package]] name = "concurrent-queue" -version = "2.2.0" +version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "62ec6771ecfa0762d24683ee5a32ad78487a3d3afdc0fb8cae19d2c5deb50b7c" +checksum = "f057a694a54f12365049b0958a1685bb52d567f5593b355fbf685838e873d400" dependencies = [ "crossbeam-utils", ] @@ -511,9 +566,9 @@ checksum = "28c122c3980598d243d63d9a704629a2d748d101f278052ff068be5a4423ab6f" [[package]] name = "core-foundation" -version = "0.9.3" +version = "0.9.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "194a7a9e6de53fa55116934067c844d9d749312f75c6f6d0980e8c252f8c2146" +checksum = "91e195e091a93c46f7102ec7818a2aa394e1e1771c3ab4825963fa03e45afb8f" dependencies = [ "core-foundation-sys", "libc", @@ -521,15 +576,15 @@ dependencies = [ [[package]] name = "core-foundation-sys" -version = "0.8.4" +version = "0.8.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e496a50fda8aacccc86d7529e2c1e0892dbd0f898a6b5645b5561b89c3210efa" +checksum = "06ea2b9bc92be3c2baa9334a323ebca2d6f074ff852cd1d7b11064035cd3868f" [[package]] name = "cpufeatures" -version = "0.2.9" +version = "0.2.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a17b76ff3a4162b0b27f354a0c87015ddad39d35f9c0c36607a3bdd175dde1f1" +checksum = "ce420fe07aecd3e67c5f910618fe65e94158f6dcc0adf44e00d69ce2bdfe0fd0" dependencies = [ "libc", ] @@ -545,19 +600,9 @@ dependencies = [ [[package]] name = "crc-catalog" -version = "2.2.0" +version = "2.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9cace84e55f07e7301bae1c519df89cdad8cc3cd868413d3fdbdeca9ff3db484" - -[[package]] -name = "crossbeam-channel" -version = "0.5.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a33c2bf77f2df06183c3aa30d1e96c0695a313d4f9c453cc3762a6db39f99200" -dependencies = [ - "cfg-if", - "crossbeam-utils", -] +checksum = "19d374276b40fb8bbdee95aef7c7fa6b5316ec764510eb64b8dd0e2ed0d7e7f5" [[package]] name = "crossbeam-deque" @@ -619,7 +664,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "978747c1d849a7d2ee5e8adc0159961c48fb7e5db2f06af6723b80123bb53856" dependencies = [ "cfg-if", - "hashbrown 0.14.0", + "hashbrown 0.14.3", "lock_api", "once_cell", "parking_lot_core", @@ -704,9 +749,9 @@ dependencies = [ [[package]] name = "env_logger" -version = "0.10.0" +version = "0.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "85cdab6a89accf66733ad5a1693a4dcced6aeff64602b634530dd73c1f3ee9f0" +checksum = "95b3f3e67048839cb0d0781f445682a35113da7121f7c949db0e2be96a4fbece" dependencies = [ "humantime", "is-terminal", @@ -723,23 +768,12 @@ checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" [[package]] name = "errno" -version = "0.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "136526188508e25c6fef639d7927dfb3e0e3084488bf202267829cf7fc23dbdd" -dependencies = [ - "errno-dragonfly", - "libc", - "windows-sys 0.48.0", -] - -[[package]] -name = "errno-dragonfly" -version = "0.1.2" +version = "0.3.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aa68f1b12764fab894d2755d2518754e71b4fd80ecfb822714a1206c2aab39bf" +checksum = "a258e46cdc063eb8519c00b9fc845fc47bcfca4130e2f08e88665ceda8474245" dependencies = [ - "cc", "libc", + "windows-sys 0.52.0", ] [[package]] @@ -759,6 +793,27 @@ version = "2.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0206175f82b8d6bf6652ff7d71a1e27fd2e4efde587fd368662814d6ec1d9ce0" +[[package]] +name = "event-listener" +version = "4.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "770d968249b5d99410d61f5bf89057f3199a077a04d087092f58e7d10692baae" +dependencies = [ + "concurrent-queue", + "parking", + "pin-project-lite", +] + +[[package]] +name = "event-listener-strategy" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "958e4d70b6d5e81971bebec42271ec641e7ff4e170a6fa605f2b8a8b65cb97d3" +dependencies = [ + "event-listener 4.0.0", + "pin-project-lite", +] + [[package]] name = "fancy-regex" version = "0.11.0" @@ -780,9 +835,9 @@ dependencies = [ [[package]] name = "fastrand" -version = "2.0.0" +version = "2.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6999dc1837253364c2ebb0704ba97994bd874e8f195d665c50b7548f6ea92764" +checksum = "25cbce373ec4653f1a01a31e8a5e5ec0c622dc27ff9c4e6606eefef5cbbed4a5" [[package]] name = "finl_unicode" @@ -792,13 +847,12 @@ checksum = "8fcfdc7a0362c9f4444381a9e697c79d435fe65b52a37466fc2c1184cee9edc6" [[package]] name = "flume" -version = "0.10.14" +version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1657b4441c3403d9f7b3409e47575237dac27b1b5726df654a6ecbf92f0f7577" +checksum = "55ac459de2512911e4b674ce33cf20befaba382d05b62b008afc1c8b57cbf181" dependencies = [ "futures-core", "futures-sink", - "pin-project", "spin 0.9.8", ] @@ -825,9 +879,9 @@ checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b" [[package]] name = "form_urlencoded" -version = "1.2.0" +version = "1.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a62bc1cf6f830c2ec14a513a9fb124d0a213a629668a4186f329db21fe045652" +checksum = "e13624c2627564efccf4934284bdd98cbaa14e79b0b5a141218e507b3a823456" dependencies = [ "percent-encoding", ] @@ -844,9 +898,9 @@ dependencies = [ [[package]] name = "futures" -version = "0.3.28" +version = "0.3.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "23342abe12aba583913b2e62f22225ff9c950774065e4bfb61a19cd9770fec40" +checksum = "da0290714b38af9b4a7b094b8a37086d1b4e61f2df9122c3cad2577669145335" dependencies = [ "futures-channel", "futures-core", @@ -859,9 +913,9 @@ dependencies = [ [[package]] name = "futures-channel" -version = "0.3.28" +version = "0.3.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "955518d47e09b25bbebc7a18df10b81f0c766eaf4c4f1cccef2fca5f2a4fb5f2" +checksum = "ff4dd66668b557604244583e3e1e1eada8c5c2e96a6d0d6653ede395b78bbacb" dependencies = [ "futures-core", "futures-sink", @@ -869,15 +923,15 @@ dependencies = [ [[package]] name = "futures-core" -version = "0.3.28" +version = "0.3.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4bca583b7e26f571124fe5b7561d49cb2868d79116cfa0eefce955557c6fee8c" +checksum = "eb1d22c66e66d9d72e1758f0bd7d4fd0bee04cad842ee34587d68c07e45d088c" [[package]] name = "futures-executor" -version = "0.3.28" +version = "0.3.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ccecee823288125bd88b4d7f565c9e58e41858e47ab72e8ea2d64e93624386e0" +checksum = "0f4fb8693db0cf099eadcca0efe2a5a22e4550f98ed16aba6c48700da29597bc" dependencies = [ "futures-core", "futures-task", @@ -897,9 +951,9 @@ dependencies = [ [[package]] name = "futures-io" -version = "0.3.28" +version = "0.3.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4fff74096e71ed47f8e023204cfd0aa1289cd54ae5430a9523be060cdb849964" +checksum = "8bf34a163b5c4c52d0478a4d757da8fb65cabef42ba90515efee0f6f9fa45aaa" [[package]] name = "futures-lite" @@ -916,23 +970,37 @@ dependencies = [ "waker-fn", ] +[[package]] +name = "futures-lite" +version = "2.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3831c2651acb5177cbd83943f3d9c8912c5ad03c76afcc0e9511ba568ec5ebb" +dependencies = [ + "fastrand 2.0.1", + "futures-core", + "futures-io", + "memchr", + "parking", + "pin-project-lite", +] + [[package]] name = "futures-sink" -version = "0.3.28" +version = "0.3.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f43be4fe21a13b9781a69afa4985b0f6ee0e1afab2c6f454a8cf30e2b2237b6e" +checksum = "e36d3378ee38c2a36ad710c5d30c2911d752cb941c00c72dbabfb786a7970817" [[package]] name = "futures-task" -version = "0.3.28" +version = "0.3.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "76d3d132be6c0e6aa1534069c705a74a5997a356c0dc2f86a47765e5617c5b65" +checksum = "efd193069b0ddadc69c46389b740bbccdd97203899b48d09c5f7969591d6bae2" [[package]] name = "futures-util" -version = "0.3.28" +version = "0.3.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26b01e40b772d54cf6c6d721c1d1abd0647a0106a12ecaa1c186273392a69533" +checksum = "a19526d624e703a3179b3d322efec918b6246ea0fa51d41124525f00f1cc8104" dependencies = [ "futures-channel", "futures-core", @@ -966,9 +1034,9 @@ dependencies = [ [[package]] name = "getrandom" -version = "0.2.10" +version = "0.2.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be4136b2a15dd319360be1c07d9933517ccf0be8f16bf62a3bee4f0d618df427" +checksum = "fe9006bed769170c11f845cf00c7c1e9092aeb3f268e007c3e760ac68008070f" dependencies = [ "cfg-if", "js-sys", @@ -979,9 +1047,9 @@ dependencies = [ [[package]] name = "gimli" -version = "0.28.0" +version = "0.28.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6fb8d784f27acf97159b40fc4db5ecd8aa23b9ad5ef69cdd136d3bc80665f0c0" +checksum = "4271d37baee1b8c7e4b708028c57d816cf9d2434acb33a549475f78c181f6253" [[package]] name = "glob" @@ -1003,9 +1071,9 @@ dependencies = [ [[package]] name = "h2" -version = "0.3.21" +version = "0.3.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "91fc23aa11be92976ef4729127f1a74adf36d8436f7816b185d18df956790833" +checksum = "4d6250322ef6e60f93f9a2162799302cd6f68f79f6e5d85c8c16f14d1d958178" dependencies = [ "bytes", "fnv", @@ -1013,7 +1081,7 @@ dependencies = [ "futures-sink", "futures-util", "http", - "indexmap 1.9.3", + "indexmap 2.1.0", "slab", "tokio", "tokio-util", @@ -1028,9 +1096,9 @@ checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" [[package]] name = "hashbrown" -version = "0.14.0" +version = "0.14.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2c6201b9ff9fd90a5a3bac2e56a830d0caa509576f0e503818ee82c181b3437a" +checksum = "290f1a1d9242c78d09ce40a5e87e7554ee637af1351968159f4952f028f75604" dependencies = [ "ahash", "allocator-api2", @@ -1042,7 +1110,7 @@ version = "0.8.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e8094feaf31ff591f651a2664fb9cfd92bba7a60ce3197265e9482ebe753c8f7" dependencies = [ - "hashbrown 0.14.0", + "hashbrown 0.14.3", ] [[package]] @@ -1065,9 +1133,9 @@ dependencies = [ [[package]] name = "hermit-abi" -version = "0.3.2" +version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "443144c8cdadd93ebf52ddb4056d257f5b52c04d3c804e657d19eb73fc33668b" +checksum = "d77f7ec81a6d05a3abb01ab6eb7590f6083d08449fe5a1c8b1e620283546ccb7" [[package]] name = "hex" @@ -1113,9 +1181,9 @@ dependencies = [ [[package]] name = "http" -version = "0.2.9" +version = "0.2.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bd6effc99afb63425aff9b05836f029929e345a6148a14b7ecd5ab67af944482" +checksum = "8947b1a6fad4393052c7ba1f4cd97bed3e953a95c79c92ad9b051a04611d9fbb" dependencies = [ "bytes", "fnv", @@ -1168,7 +1236,7 @@ dependencies = [ "httpdate", "itoa", "pin-project-lite", - "socket2 0.4.9", + "socket2 0.4.10", "tokio", "tower-service", "tracing", @@ -1177,16 +1245,16 @@ dependencies = [ [[package]] name = "iana-time-zone" -version = "0.1.57" +version = "0.1.58" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2fad5b825842d2b38bd206f3e81d6957625fd7f0a361e345c30e01a0ae2dd613" +checksum = "8326b86b6cff230b97d0d312a6c40a60726df3332e721f72a1b035f451663b20" dependencies = [ "android_system_properties", "core-foundation-sys", "iana-time-zone-haiku", "js-sys", "wasm-bindgen", - "windows", + "windows-core", ] [[package]] @@ -1200,9 +1268,9 @@ dependencies = [ [[package]] name = "idna" -version = "0.4.0" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7d20d6b07bfbc108882d88ed8e37d39636dcc260e15e30c45e6ba089610b917c" +checksum = "634d9b1461af396cad843f47fdba5597a4f9e6ddd4bfb6ff5d85028c25cb12f6" dependencies = [ "unicode-bidi", "unicode-normalization", @@ -1235,12 +1303,12 @@ dependencies = [ [[package]] name = "indexmap" -version = "2.0.0" +version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d5477fe2230a79769d8dc68e0eabf5437907c0457a5614a9e8dddb67f65eb65d" +checksum = "d530e1a18b1cb4c484e6e34556a0d948706958449fca0cab753d649f2bce3d1f" dependencies = [ "equivalent", - "hashbrown 0.14.0", + "hashbrown 0.14.3", ] [[package]] @@ -1263,16 +1331,16 @@ version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b185e7d068d6820411502efa14d8fbf010750485399402156b72dd2a548ef8e9" dependencies = [ - "proc-macro2 1.0.67", + "proc-macro2 1.0.70", "quote 1.0.33", - "syn 2.0.33", + "syn 2.0.39", ] [[package]] name = "insta" -version = "1.31.0" +version = "1.34.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a0770b0a3d4c70567f0d58331f3088b0e4c4f56c9b8d764efe654b4a5d46de3a" +checksum = "5d64600be34b2fcfc267740a243fa7744441bb4947a619ac4e5bb6507f35fbfc" dependencies = [ "console", "lazy_static", @@ -1296,7 +1364,7 @@ version = "1.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "eae7b9aee968036d54dce06cebaefd919e4472e753296daccd6d344e3e2df0c2" dependencies = [ - "hermit-abi 0.3.2", + "hermit-abi 0.3.3", "libc", "windows-sys 0.48.0", ] @@ -1313,8 +1381,8 @@ version = "0.4.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cb0889898416213fab133e1d33a0e5858a48177452750691bde3666d0fdbaf8b" dependencies = [ - "hermit-abi 0.3.2", - "rustix 0.38.13", + "hermit-abi 0.3.3", + "rustix 0.38.26", "windows-sys 0.48.0", ] @@ -1344,9 +1412,9 @@ checksum = "af150ab688ff2122fcef229be89cb50dd66af9e01a4ff320cc137eecc9bacc38" [[package]] name = "js-sys" -version = "0.3.64" +version = "0.3.66" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c5f195fe497f702db0f318b07fdd68edb16955aed830df8363d837542f8f935a" +checksum = "cee9c64da59eae3b50095c18d3e74f8b73c0b86d2792824ff01bbce68ba229ca" dependencies = [ "wasm-bindgen", ] @@ -1361,7 +1429,7 @@ dependencies = [ "anyhow", "base64", "bytecount", - "clap 4.4.3", + "clap 4.4.10", "fancy-regex", "fraction", "getrandom", @@ -1401,21 +1469,21 @@ dependencies = [ [[package]] name = "libc" -version = "0.2.148" +version = "0.2.150" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9cdc71e17332e86d2e1d38c1f99edcb6288ee11b815fb1a4b049eaa2114d369b" +checksum = "89d92a4743f9a61002fae18374ed11e7973f530cb3a3255fb354818118b2203c" [[package]] name = "libm" -version = "0.2.7" +version = "0.2.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f7012b1bbb0719e1097c47611d3898568c546d597c2e74d66f6087edd5233ff4" +checksum = "4ec2a862134d2a7d32d7983ddcdd1c4923530833c9f2ea1a44fc5fa473989058" [[package]] name = "libsqlite3-sys" -version = "0.26.0" +version = "0.27.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "afc22eff61b133b115c6e8c74e818c628d6d5e7a502afea6f64dee076dd94326" +checksum = "cf4e226dcd58b4be396f7bd3c20da8fdee2911400705297ba7d2d7cc2c30f716" dependencies = [ "cc", "pkg-config", @@ -1436,9 +1504,9 @@ checksum = "ef53942eb7bf7ff43a617b3e2c1c4a5ecf5944a7c1bc12d7ee39bbb15e5c1519" [[package]] name = "linux-raw-sys" -version = "0.4.7" +version = "0.4.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1a9bad9f94746442c783ca431b22403b519cd7fbeed0533fdd6328b2f2212128" +checksum = "c4cd1a83af159aa67994778be9070f0ae1bd732942279cabb14f86f986a21456" [[package]] name = "lld_rs" @@ -1468,9 +1536,9 @@ dependencies = [ [[package]] name = "lock_api" -version = "0.4.10" +version = "0.4.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c1cc9717a20b1bb222f333e6a92fd32f7d8a18ddc5a3191a11af45dcbf4dcd16" +checksum = "3c168f8615b12bc01f9c17e2eb0cc07dcae1940121185446edc3744920e8ef45" dependencies = [ "autocfg", "scopeguard", @@ -1502,7 +1570,7 @@ checksum = "a1d849148dbaf9661a6151d1ca82b13bb4c4c128146a88d05253b38d4e2f496c" dependencies = [ "beef", "fnv", - "proc-macro2 1.0.67", + "proc-macro2 1.0.70", "quote 1.0.33", "regex-syntax 0.6.29", "syn 1.0.109", @@ -1510,18 +1578,19 @@ dependencies = [ [[package]] name = "md-5" -version = "0.10.5" +version = "0.10.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6365506850d44bff6e2fbcb5176cf63650e48bd45ef2fe2665ae1570e0f4b9ca" +checksum = "d89e7ee0cfbedfc4da3340218492196241d89eefb6dab27de5df917a6d2e78cf" dependencies = [ + "cfg-if", "digest", ] [[package]] name = "memchr" -version = "2.6.3" +version = "2.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f232d6ef707e1956a43342693d2a31e72989554d58299d7a88738cc95b0d35c" +checksum = "f665ee40bc4a3c5590afb1e9677db74a508659dfd71e126420da8274909a0167" [[package]] name = "memoffset" @@ -1555,9 +1624,9 @@ dependencies = [ [[package]] name = "mio" -version = "0.8.8" +version = "0.8.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "927a765cd3fc26206e66b296465fa9d3e5ab003e651c1b3c060e7956d96b19d2" +checksum = "3dce281c5e46beae905d4de1870d8b1509a9142b62eedf18b443b011ca8343d0" dependencies = [ "libc", "wasi", @@ -1582,6 +1651,17 @@ dependencies = [ "tempfile", ] +[[package]] +name = "nix" +version = "0.27.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2eb04e9c688eff1c89d72b407f168cf79bb9e867a9d3323ed6c01519eb9cc053" +dependencies = [ + "bitflags 2.4.1", + "cfg-if", + "libc", +] + [[package]] name = "nom" version = "7.1.3" @@ -1693,9 +1773,9 @@ dependencies = [ [[package]] name = "num-traits" -version = "0.2.16" +version = "0.2.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f30b0abd723be7e2ffca1272140fac1a2f084c77ec3e123c192b66af1ee9e6c2" +checksum = "39e3200413f237f41ab11ad6d161bc7239c84dcb631773ccd7de3dfe4b5c267c" dependencies = [ "autocfg", "libm", @@ -1707,7 +1787,7 @@ version = "1.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4161fcb6d602d4d2081af7c3a45852d875a03dd337a6bfdd6e06407b61342a43" dependencies = [ - "hermit-abi 0.3.2", + "hermit-abi 0.3.3", "libc", ] @@ -1732,7 +1812,7 @@ version = "0.10.60" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "79a4c6c3a2b158f7f8f2a2fc5a969fa3a068df6fc9dbb4a43845436e3af7c800" dependencies = [ - "bitflags 2.4.0", + "bitflags 2.4.1", "cfg-if", "foreign-types", "libc", @@ -1747,9 +1827,9 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" dependencies = [ - "proc-macro2 1.0.67", + "proc-macro2 1.0.70", "quote 1.0.33", - "syn 2.0.33", + "syn 2.0.39", ] [[package]] @@ -1772,15 +1852,15 @@ dependencies = [ [[package]] name = "os_str_bytes" -version = "6.5.1" +version = "6.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4d5d9eb14b174ee9aa2ef96dc2b94637a2d4b6e7cb873c7e171f0c20c6cf3eac" +checksum = "e2355d85b9a3786f481747ced0e0ff2ba35213a1f9bd406ed906554d7af805a1" [[package]] name = "parking" -version = "2.1.0" +version = "2.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "14f2252c834a40ed9bb5422029649578e63aa341ac401f74e719dd1afda8394e" +checksum = "bb813b8af86854136c6922af0598d719255ecb2179515e6e7730d468f05c9cae" [[package]] name = "parking_lot" @@ -1794,9 +1874,9 @@ dependencies = [ [[package]] name = "parking_lot_core" -version = "0.9.8" +version = "0.9.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "93f00c865fe7cabf650081affecd3871070f26767e7b2070a3ffae14c654b447" +checksum = "4c42a9226546d68acdd9c0a280d17ce19bfe27a46bf68784e4066115788d008e" dependencies = [ "cfg-if", "libc", @@ -1822,29 +1902,9 @@ dependencies = [ [[package]] name = "percent-encoding" -version = "2.3.0" +version = "2.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b2a4787296e9989611394c33f193f676704af1686e70b8f8033ab5ba9a35a94" - -[[package]] -name = "pin-project" -version = "1.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fda4ed1c6c173e3fc7a83629421152e01d7b1f9b7f65fb301e490e8cfc656422" -dependencies = [ - "pin-project-internal", -] - -[[package]] -name = "pin-project-internal" -version = "1.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4359fd9c9171ec6e8c62926d6faaf553a8dc3f64e1507e76da7911b4f6a04405" -dependencies = [ - "proc-macro2 1.0.67", - "quote 1.0.33", - "syn 2.0.33", -] +checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e" [[package]] name = "pin-project-lite" @@ -1858,6 +1918,17 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" +[[package]] +name = "piper" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "668d31b1c4eba19242f2088b2bf3316b82ca31082a8335764db4e083db7485d4" +dependencies = [ + "atomic-waker", + "fastrand 2.0.1", + "futures-io", +] + [[package]] name = "pkcs1" version = "0.7.5" @@ -1921,7 +1992,7 @@ dependencies = [ "encoding_rs", "encoding_rs_io", "env_logger", - "indexmap 2.0.0", + "indexmap 2.1.0", "insta", "log", "plc_ast", @@ -1972,7 +2043,7 @@ name = "plc_xml" version = "0.1.0" dependencies = [ "html-escape", - "indexmap 2.0.0", + "indexmap 2.1.0", "insta", "itertools", "logos", @@ -1999,6 +2070,20 @@ dependencies = [ "windows-sys 0.48.0", ] +[[package]] +name = "polling" +version = "3.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf63fa624ab313c11656b4cda960bfc46c410187ad493c41f6ba2d8c1e991c9e" +dependencies = [ + "cfg-if", + "concurrent-queue", + "pin-project-lite", + "rustix 0.38.26", + "tracing", + "windows-sys 0.52.0", +] + [[package]] name = "powerfmt" version = "0.2.0" @@ -2028,7 +2113,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "da25490ff9892aab3fcf7c36f08cfb902dd3e71ca0f9f9517bea02a73a5ce38c" dependencies = [ "proc-macro-error-attr", - "proc-macro2 1.0.67", + "proc-macro2 1.0.70", "quote 1.0.33", "syn 1.0.109", "version_check", @@ -2040,7 +2125,7 @@ version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a1be40180e52ecc98ad80b184934baf3d0d29f979574e439af5a55274b35f869" dependencies = [ - "proc-macro2 1.0.67", + "proc-macro2 1.0.70", "quote 1.0.33", "version_check", ] @@ -2056,9 +2141,9 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.67" +version = "1.0.70" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3d433d9f1a3e8c1263d9456598b16fec66f4acc9a74dacffd35c7bb09b3a1328" +checksum = "39278fbbf5fb4f646ce651690877f89d1c5811a3d4acb27700c1cb3cdb78fd3b" dependencies = [ "unicode-ident", ] @@ -2088,7 +2173,7 @@ version = "1.0.33" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5267fca4496028628a95160fc423a33e8b2e6af8a5302579e322e4b520293cae" dependencies = [ - "proc-macro2 1.0.67", + "proc-macro2 1.0.70", ] [[package]] @@ -2123,9 +2208,9 @@ dependencies = [ [[package]] name = "rayon" -version = "1.7.0" +version = "1.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d2df5196e37bcc87abebc0053e20787d73847bb33134a69841207dd0a47f03b" +checksum = "9c27db03db7734835b3f53954b534c91069375ce6ccaa2e065441e07d9b6cdb1" dependencies = [ "either", "rayon-core", @@ -2133,46 +2218,44 @@ dependencies = [ [[package]] name = "rayon-core" -version = "1.11.0" +version = "1.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4b8f95bd6966f5c87776639160a66bd8ab9895d9d4ab01ddba9fc60661aebe8d" +checksum = "5ce3fb6ad83f861aac485e76e1985cd109d9a3713802152be56c3b1f0e0658ed" dependencies = [ - "crossbeam-channel", "crossbeam-deque", "crossbeam-utils", - "num_cpus", ] [[package]] name = "redox_syscall" -version = "0.3.5" +version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "567664f262709473930a4bf9e51bf2ebf3348f2e748ccc50dea20646858f8f29" +checksum = "4722d768eff46b75989dd134e5c353f0d6296e5aaa3132e776cbdb56be7731aa" dependencies = [ "bitflags 1.3.2", ] [[package]] name = "regex" -version = "1.9.5" +version = "1.10.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "697061221ea1b4a94a624f67d0ae2bfe4e22b8a17b6a192afb11046542cc8c47" +checksum = "380b951a9c5e80ddfd6136919eef32310721aa4aacd4889a8d39124b026ab343" dependencies = [ "aho-corasick", "memchr", "regex-automata", - "regex-syntax 0.7.5", + "regex-syntax 0.8.2", ] [[package]] name = "regex-automata" -version = "0.3.8" +version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c2f401f4955220693b56f8ec66ee9c78abffd8d1c4f23dc41a23839eb88f0795" +checksum = "5f804c7828047e88b2d32e2d7fe5a105da8ee3264f01902f796c8e067dc2483f" dependencies = [ "aho-corasick", "memchr", - "regex-syntax 0.7.5", + "regex-syntax 0.8.2", ] [[package]] @@ -2183,9 +2266,9 @@ checksum = "f162c6dd7b008981e4d40210aca20b4bd0f9b60ca9271061b07f78537722f2e1" [[package]] name = "regex-syntax" -version = "0.7.5" +version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dbb5fb1acd8a1a18b3dd5be62d25485eb770e05afb408a9627d14d451bae12da" +checksum = "c08c74e62047bb2de4ff487b251e4a92e24f48745648451635cec7d591162d9f" [[package]] name = "reqwest" @@ -2224,16 +2307,14 @@ dependencies = [ [[package]] name = "rsa" -version = "0.9.2" +version = "0.9.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ab43bb47d23c1a631b4b680199a45255dce26fa9ab2fa902581f624ff13e6a8" +checksum = "af6c4b23d99685a1408194da11270ef8e9809aff951cc70ec9b17350b087e474" dependencies = [ - "byteorder", "const-oid", "digest", "num-bigint-dig", "num-integer", - "num-iter", "num-traits", "pkcs1", "pkcs8", @@ -2252,9 +2333,9 @@ checksum = "d626bb9dae77e28219937af045c257c28bfd3f69333c512553507f5f9798cb76" [[package]] name = "rustix" -version = "0.37.25" +version = "0.37.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d4eb579851244c2c03e7c24f501c3432bed80b8f720af1d6e5b0e0f01555a035" +checksum = "fea8ca367a3a01fe35e6943c400addf443c0f57670e6ec51196f71a4b8762dd2" dependencies = [ "bitflags 1.3.2", "errno", @@ -2266,15 +2347,15 @@ dependencies = [ [[package]] name = "rustix" -version = "0.38.13" +version = "0.38.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d7db8590df6dfcd144d22afd1b83b36c21a18d7cbc1dc4bb5295a8712e9eb662" +checksum = "9470c4bf8246c8daf25f9598dca807fb6510347b1e1cfa55749113850c79d88a" dependencies = [ - "bitflags 2.4.0", + "bitflags 2.4.1", "errno", "libc", - "linux-raw-sys 0.4.7", - "windows-sys 0.48.0", + "linux-raw-sys 0.4.12", + "windows-sys 0.52.0", ] [[package]] @@ -2286,7 +2367,7 @@ dependencies = [ "encoding_rs", "encoding_rs_io", "generational-arena", - "indexmap 2.0.0", + "indexmap 2.1.0", "inkwell", "insta", "itertools", @@ -2361,35 +2442,35 @@ dependencies = [ [[package]] name = "semver" -version = "1.0.18" +version = "1.0.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b0293b4b29daaf487284529cc2f5675b8e57c61f70167ba415a463651fd6a918" +checksum = "836fa6a3e1e547f9a2c4040802ec865b5d85f4014efe00555d7090a3dcaa1090" [[package]] name = "serde" -version = "1.0.188" +version = "1.0.193" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf9e0fcba69a370eed61bcf2b728575f726b50b55cba78064753d708ddc7549e" +checksum = "25dd9975e68d0cb5aa1120c288333fc98731bd1dd12f561e468ea4728c042b89" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.188" +version = "1.0.193" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4eca7ac642d82aa35b60049a6eccb4be6be75e599bd2e9adb5f875a737654af2" +checksum = "43576ca501357b9b071ac53cdc7da8ef0cbd9493d8df094cd821777ea6e894d3" dependencies = [ - "proc-macro2 1.0.67", + "proc-macro2 1.0.70", "quote 1.0.33", - "syn 2.0.33", + "syn 2.0.39", ] [[package]] name = "serde_json" -version = "1.0.107" +version = "1.0.108" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6b420ce6e3d8bd882e9b243c6eed35dbc9a6110c9769e74b584e0d68d1f20c65" +checksum = "3d1c7e3eac408d115102c4c24ad393e0821bb3a5df4d506a80f85f7a742a526b" dependencies = [ "itoa", "ryu", @@ -2428,16 +2509,16 @@ version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "91d129178576168c589c9ec973feedf7d3126c01ac2bf08795109aa35b69fb8f" dependencies = [ - "proc-macro2 1.0.67", + "proc-macro2 1.0.70", "quote 1.0.33", - "syn 2.0.33", + "syn 2.0.39", ] [[package]] name = "sha1" -version = "0.10.5" +version = "0.10.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f04293dc80c3993519f2d7f6f511707ee7094fe0c6d3406feb330cdb3540eba3" +checksum = "e3bf829a2d51ab4a5ddf1352d8470c140cadc8301b2ae1789db023f01cedd6ba" dependencies = [ "cfg-if", "cpufeatures", @@ -2446,9 +2527,9 @@ dependencies = [ [[package]] name = "sha2" -version = "0.10.7" +version = "0.10.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "479fb9d862239e610720565ca91403019f2f00410f1864c5aa7479b950a76ed8" +checksum = "793db75ad2bcafc3ffa7c68b215fee268f537982cd901d132f89c6343f3a3dc8" dependencies = [ "cfg-if", "cpufeatures", @@ -2463,9 +2544,9 @@ checksum = "24188a676b6ae68c3b2cb3a01be17fbf7240ce009799bb56d5b1409051e78fde" [[package]] name = "signature" -version = "2.1.0" +version = "2.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5e1788eed21689f9cf370582dfc467ef36ed9c707f073528ddafa8d83e3b8500" +checksum = "77549399552de45a898a580c1b41d445bf730df867cc44e6c0233bbc4b8329de" dependencies = [ "digest", "rand_core", @@ -2473,9 +2554,9 @@ dependencies = [ [[package]] name = "similar" -version = "2.2.1" +version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "420acb44afdae038210c99e69aae24109f32f15500aa708e81d46c9f29d55fcf" +checksum = "2aeaf503862c419d66959f5d7ca015337d864e9c49485d771b732e2a20453597" [[package]] name = "slab" @@ -2488,15 +2569,15 @@ dependencies = [ [[package]] name = "smallvec" -version = "1.11.0" +version = "1.11.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "62bb4feee49fdd9f707ef802e22365a35de4b7b299de4763d44bfea899442ff9" +checksum = "4dccd0940a2dcdf68d092b8cbab7dc0ad8fa938bf95787e1b916b0e3d0e8e970" [[package]] name = "socket2" -version = "0.4.9" +version = "0.4.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "64a4a911eed85daf18834cfaa86a79b7d266ff93ff5ba14005426219480ed662" +checksum = "9f7916fc008ca5542385b89a3d3ce689953c143e9304a9bf8beec1de48994c0d" dependencies = [ "libc", "winapi", @@ -2504,9 +2585,9 @@ dependencies = [ [[package]] name = "socket2" -version = "0.5.4" +version = "0.5.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4031e820eb552adee9295814c0ced9e5cf38ddf1e8b7d566d6de8e2538ea989e" +checksum = "7b5fac59a5cb5dd637972e5fca70daf0523c9067fcdc4842f053dae04a18f8e9" dependencies = [ "libc", "windows-sys 0.48.0", @@ -2529,9 +2610,9 @@ dependencies = [ [[package]] name = "spki" -version = "0.7.2" +version = "0.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9d1e996ef02c474957d681f1b05213dfb0abab947b446a62d37770b23500184a" +checksum = "d91ed6c858b01f942cd56b37a94b3e0a1798290327d1236e4d9cf4eaca44d29d" dependencies = [ "base64ct", "der", @@ -2550,9 +2631,9 @@ dependencies = [ [[package]] name = "sqlx" -version = "0.7.1" +version = "0.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e58421b6bc416714d5115a2ca953718f6c621a51b68e4f4922aea5a4391a721" +checksum = "dba03c279da73694ef99763320dea58b51095dfe87d001b1d4b5fe78ba8763cf" dependencies = [ "sqlx-core", "sqlx-macros", @@ -2563,12 +2644,12 @@ dependencies = [ [[package]] name = "sqlx-core" -version = "0.7.1" +version = "0.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dd4cef4251aabbae751a3710927945901ee1d97ee96d757f6880ebb9a79bfd53" +checksum = "d84b0a3c3739e220d94b3239fd69fb1f74bc36e16643423bd99de3b43c21bfbd" dependencies = [ "ahash", - "async-io", + "async-io 1.13.0", "async-std", "atoi", "byteorder", @@ -2577,7 +2658,7 @@ dependencies = [ "crossbeam-queue", "dotenvy", "either", - "event-listener", + "event-listener 2.5.3", "futures-channel", "futures-core", "futures-intrusive", @@ -2585,7 +2666,7 @@ dependencies = [ "futures-util", "hashlink", "hex", - "indexmap 2.0.0", + "indexmap 2.1.0", "log", "memchr", "native-tls", @@ -2604,11 +2685,11 @@ dependencies = [ [[package]] name = "sqlx-macros" -version = "0.7.1" +version = "0.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "208e3165167afd7f3881b16c1ef3f2af69fa75980897aac8874a0696516d12c2" +checksum = "89961c00dc4d7dffb7aee214964b065072bff69e36ddb9e2c107541f75e4f2a5" dependencies = [ - "proc-macro2 1.0.67", + "proc-macro2 1.0.70", "quote 1.0.33", "sqlx-core", "sqlx-macros-core", @@ -2617,17 +2698,18 @@ dependencies = [ [[package]] name = "sqlx-macros-core" -version = "0.7.1" +version = "0.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a4a8336d278c62231d87f24e8a7a74898156e34c1c18942857be2acb29c7dfc" +checksum = "d0bd4519486723648186a08785143599760f7cc81c52334a55d6a83ea1e20841" dependencies = [ "async-std", + "atomic-write-file", "dotenvy", "either", "heck", "hex", "once_cell", - "proc-macro2 1.0.67", + "proc-macro2 1.0.70", "quote 1.0.33", "serde", "serde_json", @@ -2642,13 +2724,13 @@ dependencies = [ [[package]] name = "sqlx-mysql" -version = "0.7.1" +version = "0.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ca69bf415b93b60b80dc8fda3cb4ef52b2336614d8da2de5456cc942a110482" +checksum = "e37195395df71fd068f6e2082247891bc11e3289624bbc776a0cdfa1ca7f1ea4" dependencies = [ "atoi", "base64", - "bitflags 2.4.0", + "bitflags 2.4.1", "byteorder", "bytes", "crc", @@ -2684,13 +2766,13 @@ dependencies = [ [[package]] name = "sqlx-postgres" -version = "0.7.1" +version = "0.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a0db2df1b8731c3651e204629dd55e52adbae0462fa1bdcbed56a2302c18181e" +checksum = "d6ac0ac3b7ccd10cc96c7ab29791a7dd236bd94021f31eec7ba3d46a74aa1c24" dependencies = [ "atoi", "base64", - "bitflags 2.4.0", + "bitflags 2.4.1", "byteorder", "crc", "dotenvy", @@ -2723,9 +2805,9 @@ dependencies = [ [[package]] name = "sqlx-sqlite" -version = "0.7.1" +version = "0.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be4c21bf34c7cae5b283efb3ac1bcc7670df7561124dc2f8bdc0b59be40f79a2" +checksum = "210976b7d948c7ba9fced8ca835b11cbb2d677c59c79de41ac0d397e14547490" dependencies = [ "atoi", "flume", @@ -2741,6 +2823,7 @@ dependencies = [ "sqlx-core", "tracing", "url", + "urlencoding", ] [[package]] @@ -2783,27 +2866,27 @@ version = "1.0.109" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" dependencies = [ - "proc-macro2 1.0.67", + "proc-macro2 1.0.70", "quote 1.0.33", "unicode-ident", ] [[package]] name = "syn" -version = "2.0.33" +version = "2.0.39" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9caece70c63bfba29ec2fed841a09851b14a235c60010fa4de58089b6c025668" +checksum = "23e78b90f2fcf45d3e842032ce32e3f2d1545ba6636271dcbf24fa306d87be7a" dependencies = [ - "proc-macro2 1.0.67", + "proc-macro2 1.0.70", "quote 1.0.33", "unicode-ident", ] [[package]] name = "sysinfo" -version = "0.29.10" +version = "0.29.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0a18d114d420ada3a891e6bc8e96a2023402203296a47cdd65083377dad18ba5" +checksum = "cd727fc423c2060f6c92d9534cef765c65a6ed3f428a03d7def74a8c4348e666" dependencies = [ "cfg-if", "core-foundation-sys", @@ -2837,22 +2920,22 @@ dependencies = [ [[package]] name = "tempfile" -version = "3.8.0" +version = "3.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cb94d2f3cc536af71caac6b6fcebf65860b347e7ce0cc9ebe8f70d3e521054ef" +checksum = "7ef1adac450ad7f4b3c28589471ade84f25f731a7a0fe30d71dfa9f60fd808e5" dependencies = [ "cfg-if", - "fastrand 2.0.0", + "fastrand 2.0.1", "redox_syscall", - "rustix 0.38.13", + "rustix 0.38.26", "windows-sys 0.48.0", ] [[package]] name = "termcolor" -version = "1.2.0" +version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be55cf8942feac5c765c2c993422806843c9a9a45d4d5c407ad6dd2ea95eb9b6" +checksum = "ff1bc3d3f05aff0403e8ac0d92ced918ec05b666a43f83297ccef5bea8a3d449" dependencies = [ "winapi-util", ] @@ -2865,22 +2948,22 @@ checksum = "222a222a5bfe1bba4a77b45ec488a741b3cb8872e5e499451fd7d0129c9c7c3d" [[package]] name = "thiserror" -version = "1.0.48" +version = "1.0.50" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9d6d7a740b8a666a7e828dd00da9c0dc290dff53154ea77ac109281de90589b7" +checksum = "f9a7210f5c9a7156bb50aa36aed4c95afb51df0df00713949448cf9e97d382d2" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.48" +version = "1.0.50" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49922ecae66cc8a249b77e68d1d0623c1b2c514f0060c27cdc68bd62a1219d35" +checksum = "266b2e40bc00e5a6c09c3584011e08b06f123c00362c92b975ba9843aaaa14b8" dependencies = [ - "proc-macro2 1.0.67", + "proc-macro2 1.0.70", "quote 1.0.33", - "syn 2.0.33", + "syn 2.0.39", ] [[package]] @@ -2928,9 +3011,9 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" [[package]] name = "tokio" -version = "1.33.0" +version = "1.34.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4f38200e3ef7995e5ef13baec2f432a6da0aa9ac495b2c0e8f3b7eec2c92d653" +checksum = "d0c014766411e834f7af5b8f4cf46257aab4036ca95e9d2c144a10f59ad6f5b9" dependencies = [ "backtrace", "bytes", @@ -2938,7 +3021,7 @@ dependencies = [ "mio", "num_cpus", "pin-project-lite", - "socket2 0.5.4", + "socket2 0.5.5", "windows-sys 0.48.0", ] @@ -2973,11 +3056,10 @@ checksum = "b6bc1c9ce2b5135ac7f93c72918fc37feb872bdc6a5533a8b85eb4b86bfdae52" [[package]] name = "tracing" -version = "0.1.37" +version = "0.1.40" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ce8c33a8d48bd45d624a6e523445fd21ec13d3653cd51f681abf67418f54eb8" +checksum = "c3523ab5a71916ccf420eebdf5521fcef02141234bbc0b8a49f2fdc4544364ef" dependencies = [ - "cfg-if", "log", "pin-project-lite", "tracing-attributes", @@ -2986,20 +3068,20 @@ dependencies = [ [[package]] name = "tracing-attributes" -version = "0.1.26" +version = "0.1.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f4f31f56159e98206da9efd823404b79b6ef3143b4a7ab76e67b1751b25a4ab" +checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" dependencies = [ - "proc-macro2 1.0.67", + "proc-macro2 1.0.70", "quote 1.0.33", - "syn 2.0.33", + "syn 2.0.39", ] [[package]] name = "tracing-core" -version = "0.1.31" +version = "0.1.32" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0955b8137a1df6f1a2e9a37d8a6656291ff0297c1a97c24e0d8425fe2312f79a" +checksum = "c06d3da6113f116aaee68e4d601191614c9053067f9ab7f6edbcb161237daa54" dependencies = [ "once_cell", ] @@ -3012,9 +3094,9 @@ checksum = "3528ecfd12c466c6f163363caf2d02a71161dd5e1cc6ae7b34207ea2d42d81ed" [[package]] name = "typenum" -version = "1.16.0" +version = "1.17.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "497961ef93d974e23eb6f433eb5fe1b7930b659f06d12dec6fc44a8f554c0bba" +checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825" [[package]] name = "unicode-bidi" @@ -3045,9 +3127,9 @@ checksum = "1dd624098567895118886609431a7c3b8f516e41d30e0643f03d94592a147e36" [[package]] name = "unicode-width" -version = "0.1.10" +version = "0.1.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c0edd1e5b14653f783770bce4a4dabb4a5108a5370a5f5d8cfe8710c361f6c8b" +checksum = "e51733f11c9c4f72aa0c160008246859e340b00807569a0da0e7a1079b27ba85" [[package]] name = "unicode-xid" @@ -3063,20 +3145,26 @@ checksum = "39ec24b3121d976906ece63c9daad25b85969647682eee313cb5779fdd69e14e" [[package]] name = "url" -version = "2.4.1" +version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "143b538f18257fac9cad154828a57c6bf5157e1aa604d4816b5995bf6de87ae5" +checksum = "31e6302e3bb753d46e83516cae55ae196fc0c309407cf11ab35cc51a4c2a4633" dependencies = [ "form_urlencoded", "idna", "percent-encoding", ] +[[package]] +name = "urlencoding" +version = "2.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "daf8dba3b7eb870caf1ddeed7bc9d2a049f3cfdfae7cb521b087cc33ae4c49da" + [[package]] name = "utf8-width" -version = "0.1.6" +version = "0.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5190c9442dcdaf0ddd50f37420417d219ae5261bbf5db120d0f9bab996c9cba1" +checksum = "86bd8d4e895da8537e5315b8254664e6b769c4ff3db18321b297a1e7004392e3" [[package]] name = "utf8parse" @@ -3086,15 +3174,15 @@ checksum = "711b9620af191e0cdc7468a8d14e709c3dcdb115b36f838e601583af800a370a" [[package]] name = "uuid" -version = "1.5.0" +version = "1.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "88ad59a7560b41a70d191093a945f0b87bc1deeda46fb237479708a1d6b6cdfc" +checksum = "5e395fcf16a7a3d8127ec99782007af141946b4795001f876d54fb0d55978560" [[package]] name = "value-bag" -version = "1.4.1" +version = "1.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d92ccd67fb88503048c01b59152a04effd0782d035a83a6d256ce6085f08f4a3" +checksum = "4a72e1902dde2bd6441347de2b70b7f5d59bf157c6c62f0c44572607a1d55bbe" [[package]] name = "vcpkg" @@ -3110,9 +3198,9 @@ checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" [[package]] name = "waker-fn" -version = "1.1.0" +version = "1.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9d5b2c62b4012a3e1eca5a7e077d13b3bf498c4073e33ccd58626607748ceeca" +checksum = "f3c4517f54858c779bbcbf228f4fca63d121bf85fbecb2dc578cdf4a39395690" [[package]] name = "want" @@ -3131,9 +3219,9 @@ checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" [[package]] name = "wasm-bindgen" -version = "0.2.87" +version = "0.2.89" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7706a72ab36d8cb1f80ffbf0e071533974a60d0a308d01a5d0375bf60499a342" +checksum = "0ed0d4f68a3015cc185aff4db9506a015f4b96f95303897bfa23f846db54064e" dependencies = [ "cfg-if", "wasm-bindgen-macro", @@ -3141,24 +3229,24 @@ dependencies = [ [[package]] name = "wasm-bindgen-backend" -version = "0.2.87" +version = "0.2.89" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5ef2b6d3c510e9625e5fe6f509ab07d66a760f0885d858736483c32ed7809abd" +checksum = "1b56f625e64f3a1084ded111c4d5f477df9f8c92df113852fa5a374dbda78826" dependencies = [ "bumpalo", "log", "once_cell", - "proc-macro2 1.0.67", + "proc-macro2 1.0.70", "quote 1.0.33", - "syn 2.0.33", + "syn 2.0.39", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-futures" -version = "0.4.37" +version = "0.4.39" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c02dbc21516f9f1f04f187958890d7e6026df8d16540b7ad9492bc34a67cea03" +checksum = "ac36a15a220124ac510204aec1c3e5db8a22ab06fd6706d881dc6149f8ed9a12" dependencies = [ "cfg-if", "js-sys", @@ -3168,9 +3256,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro" -version = "0.2.87" +version = "0.2.89" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dee495e55982a3bd48105a7b947fd2a9b4a8ae3010041b9e0faab3f9cd028f1d" +checksum = "0162dbf37223cd2afce98f3d0785506dcb8d266223983e4b5b525859e6e182b2" dependencies = [ "quote 1.0.33", "wasm-bindgen-macro-support", @@ -3178,28 +3266,28 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.87" +version = "0.2.89" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "54681b18a46765f095758388f2d0cf16eb8d4169b639ab575a8f5693af210c7b" +checksum = "f0eb82fcb7930ae6219a7ecfd55b217f5f0893484b7a13022ebb2b2bf20b5283" dependencies = [ - "proc-macro2 1.0.67", + "proc-macro2 1.0.70", "quote 1.0.33", - "syn 2.0.33", + "syn 2.0.39", "wasm-bindgen-backend", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-shared" -version = "0.2.87" +version = "0.2.89" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ca6ad05a4870b2bf5fe995117d3728437bd27d7cd5f06f13c17443ef369775a1" +checksum = "7ab9b36309365056cd639da3134bf87fa8f3d86008abf99e612384a6eecd459f" [[package]] name = "web-sys" -version = "0.3.64" +version = "0.3.66" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b85cbef8c220a6abc02aefd892dfc0fc23afb1c6a426316ec33253a3877249b" +checksum = "50c24a44ec86bb68fbecd1b3efed7e85ea5621b39b35ef2766b66cd984f8010f" dependencies = [ "js-sys", "wasm-bindgen", @@ -3214,7 +3302,7 @@ dependencies = [ "either", "home", "once_cell", - "rustix 0.38.13", + "rustix 0.38.26", ] [[package]] @@ -3241,9 +3329,9 @@ checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" [[package]] name = "winapi-util" -version = "0.1.5" +version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178" +checksum = "f29e6f9198ba0d26b4c9f07dbe6f9ed633e1f3d5b8b414090084349e46a52596" dependencies = [ "winapi", ] @@ -3255,10 +3343,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" [[package]] -name = "windows" -version = "0.48.0" +name = "windows-core" +version = "0.51.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e686886bc078bc1b0b600cac0147aadb815089b6e4da64016cbd754b6342700f" +checksum = "f1f8cf84f35d2db49a46868f947758c7a1138116f7fac3bc844f43ade1292e64" dependencies = [ "windows-targets 0.48.5", ] @@ -3281,6 +3369,15 @@ dependencies = [ "windows-targets 0.48.5", ] +[[package]] +name = "windows-sys" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" +dependencies = [ + "windows-targets 0.52.0", +] + [[package]] name = "windows-targets" version = "0.42.2" @@ -3311,6 +3408,21 @@ dependencies = [ "windows_x86_64_msvc 0.48.5", ] +[[package]] +name = "windows-targets" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a18201040b24831fbb9e4eb208f8892e1f50a37feb53cc7ff887feb8f50e7cd" +dependencies = [ + "windows_aarch64_gnullvm 0.52.0", + "windows_aarch64_msvc 0.52.0", + "windows_i686_gnu 0.52.0", + "windows_i686_msvc 0.52.0", + "windows_x86_64_gnu 0.52.0", + "windows_x86_64_gnullvm 0.52.0", + "windows_x86_64_msvc 0.52.0", +] + [[package]] name = "windows_aarch64_gnullvm" version = "0.42.2" @@ -3323,6 +3435,12 @@ version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cb7764e35d4db8a7921e09562a0304bf2f93e0a51bfccee0bd0bb0b666b015ea" + [[package]] name = "windows_aarch64_msvc" version = "0.42.2" @@ -3335,6 +3453,12 @@ version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" +[[package]] +name = "windows_aarch64_msvc" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bbaa0368d4f1d2aaefc55b6fcfee13f41544ddf36801e793edbbfd7d7df075ef" + [[package]] name = "windows_i686_gnu" version = "0.42.2" @@ -3347,6 +3471,12 @@ version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" +[[package]] +name = "windows_i686_gnu" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a28637cb1fa3560a16915793afb20081aba2c92ee8af57b4d5f28e4b3e7df313" + [[package]] name = "windows_i686_msvc" version = "0.42.2" @@ -3359,6 +3489,12 @@ version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" +[[package]] +name = "windows_i686_msvc" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ffe5e8e31046ce6230cc7215707b816e339ff4d4d67c65dffa206fd0f7aa7b9a" + [[package]] name = "windows_x86_64_gnu" version = "0.42.2" @@ -3371,6 +3507,12 @@ version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" +[[package]] +name = "windows_x86_64_gnu" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3d6fa32db2bc4a2f5abeacf2b69f7992cd09dca97498da74a151a3132c26befd" + [[package]] name = "windows_x86_64_gnullvm" version = "0.42.2" @@ -3383,6 +3525,12 @@ version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1a657e1e9d3f514745a572a6846d3c7aa7dbe1658c056ed9c3344c4109a6949e" + [[package]] name = "windows_x86_64_msvc" version = "0.42.2" @@ -3395,6 +3543,12 @@ version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" +[[package]] +name = "windows_x86_64_msvc" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dff9641d1cd4be8d1a070daf9e3773c5f67e78b4d9d42263020c057706765c04" + [[package]] name = "winreg" version = "0.50.0" @@ -3426,7 +3580,7 @@ version = "0.1.0" dependencies = [ "anyhow", "async-std", - "clap 4.4.3", + "clap 4.4.10", "plc_ast", "plc_source", "rusty", @@ -3453,8 +3607,28 @@ version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "09041cd90cf85f7f8b2df60c646f853b7f535ce68f85244eb6731cf89fa498ec" +[[package]] +name = "zerocopy" +version = "0.7.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7d6f15f7ade05d2a4935e34a457b936c23dc70a05cc1d97133dc99e7a3fe0f0e" +dependencies = [ + "zerocopy-derive", +] + +[[package]] +name = "zerocopy-derive" +version = "0.7.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dbbad221e3f78500350ecbd7dfa4e63ef945c05f4c61cb7f4d3f84cd0bba649b" +dependencies = [ + "proc-macro2 1.0.70", + "quote 1.0.33", + "syn 2.0.39", +] + [[package]] name = "zeroize" -version = "1.6.0" +version = "1.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2a0956f1ba7c7909bfb66c2e9e4124ab6f6482560f6628b5aaeba39207c9aad9" +checksum = "525b4ec142c6b68a2d10f01f7bbf6755599ca3f81ea53b8431b7dd348f5fdb2d" diff --git a/compiler/plc_ast/src/literals.rs b/compiler/plc_ast/src/literals.rs index d5b1eb3bde..ba4662aa4f 100644 --- a/compiler/plc_ast/src/literals.rs +++ b/compiler/plc_ast/src/literals.rs @@ -100,8 +100,12 @@ fn calculate_date_time( ) -> Result { NaiveDate::from_ymd_opt(year, month, day) .and_then(|date| date.and_hms_nano_opt(hour, min, sec, nano)) - .map(|date_time| date_time.timestamp_nanos()) .ok_or_else(|| format!("Invalid Date {year}-{month}-{day}-{hour}:{min}:{sec}.{nano}")) + .and_then(|date_time| { + date_time + .timestamp_nanos_opt() + .ok_or_else(|| format!("Out of range Date {year}-{month}-{day}-{hour}:{min}:{sec}.{nano}")) + }) } impl DateAndTime { diff --git a/libs/stdlib/src/date_time_conversion.rs b/libs/stdlib/src/date_time_conversion.rs index 5e6cf85fe3..32d9476061 100644 --- a/libs/stdlib/src/date_time_conversion.rs +++ b/libs/stdlib/src/date_time_conversion.rs @@ -10,7 +10,8 @@ pub extern "C" fn DATE_AND_TIME_TO_DATE(input: i64) -> i64 { let new_date_time = date_time.date_naive().and_hms_opt(0, 0, 0).expect("Cannot create date time from date"); - new_date_time.timestamp_nanos() + + new_date_time.timestamp_nanos_opt().expect("Out of range, cannot create DATE") } /// . @@ -29,5 +30,5 @@ pub extern "C" fn DATE_AND_TIME_TO_TIME_OF_DAY(input: i64) -> i64 { .and_then(|date| date.and_hms_nano_opt(hour, min, sec, nano)) .expect("Cannot create date time from given parameters"); - new_date_time.timestamp_nanos() + new_date_time.timestamp_nanos_opt().expect("Out of range, cannot create TOD") } diff --git a/libs/stdlib/src/date_time_extra_functions.rs b/libs/stdlib/src/date_time_extra_functions.rs index 7d4d601258..423152cefb 100644 --- a/libs/stdlib/src/date_time_extra_functions.rs +++ b/libs/stdlib/src/date_time_extra_functions.rs @@ -13,7 +13,10 @@ pub extern "C" fn CONCAT_DATE_TOD(in1: i64, in2: i64) -> i64 { let sec = tod.second(); let nano = tod.timestamp_subsec_nanos(); - date.and_hms_nano_opt(hour, min, sec, nano).expect("Invalid input").timestamp_nanos() + date.and_hms_nano_opt(hour, min, sec, nano) + .expect("Invalid input") + .timestamp_nanos_opt() + .expect("Out of range, cannot create Date") } /// . @@ -79,7 +82,8 @@ pub extern "C" fn concat_date(in1: i32, in2: u32, in3: u32) -> i64 { let dt = NaiveDate::from_ymd_opt(in1, in2, in3) .and_then(|date| date.and_hms_opt(0, 0, 0)) .expect("Invalid parameters, cannot create date"); - dt.timestamp_nanos() + + dt.timestamp_nanos_opt().expect("Out of range, cannot create date") } /// . @@ -163,7 +167,8 @@ pub extern "C" fn concat_tod(in1: u32, in2: u32, in3: u32, in4: u32) -> i64 { let dt = NaiveDate::from_ymd_opt(1970, 1, 1) .and_then(|date| date.and_hms_milli_opt(in1, in2, in3, in4)) .expect("Invalid parameters, cannot create TOD"); - dt.timestamp_nanos() + + dt.timestamp_nanos_opt().expect("Out of range, cannot create TOD") } /// . diff --git a/libs/stdlib/src/date_time_numeric_functions.rs b/libs/stdlib/src/date_time_numeric_functions.rs index 2d0e8c2299..6996892949 100644 --- a/libs/stdlib/src/date_time_numeric_functions.rs +++ b/libs/stdlib/src/date_time_numeric_functions.rs @@ -39,7 +39,8 @@ fn add_datetime_time(in1: i64, in2: i64) -> i64 { .timestamp_nanos(in1) .checked_add_signed(chrono::Duration::nanoseconds(in2)) .unwrap() - .timestamp_nanos() + .timestamp_nanos_opt() + .unwrap() } /// . @@ -109,7 +110,8 @@ fn sub_datetime_duration(in1: i64, in2: i64) -> i64 { .timestamp_nanos(in1) .checked_sub_signed(chrono::Duration::nanoseconds(in2)) .unwrap() - .timestamp_nanos() + .timestamp_nanos_opt() + .unwrap() } /// . diff --git a/libs/stdlib/src/extra_functions.rs b/libs/stdlib/src/extra_functions.rs index 4cdf436a02..cf60b6aa67 100644 --- a/libs/stdlib/src/extra_functions.rs +++ b/libs/stdlib/src/extra_functions.rs @@ -386,7 +386,7 @@ mod test { let datetime = chrono::NaiveDate::from_ymd_opt(1982, 12, 15) .and_then(|date| date.and_hms_nano_opt(0, 0, 0, 0)) .expect("Cannot create date time from given parameters"); - let timestamp = datetime.timestamp_nanos(); + let timestamp = datetime.timestamp_nanos_opt().unwrap(); let mut dest = [0_u8; 81]; let dest_ptr = dest.as_mut_ptr(); @@ -403,7 +403,7 @@ mod test { let datetime = chrono::NaiveDate::from_ymd_opt(1982, 12, 15) .and_then(|date| date.and_hms_nano_opt(10, 10, 2, 123456789)) .expect("Cannot create date time from given parameters"); - let timestamp = datetime.timestamp_nanos(); + let timestamp = datetime.timestamp_nanos_opt().unwrap(); let mut dest = [0_u8; 81]; let dest_ptr = dest.as_mut_ptr(); @@ -420,7 +420,7 @@ mod test { let datetime = chrono::NaiveDate::from_ymd_opt(1982, 12, 15) .and_then(|date| date.and_hms_nano_opt(10, 10, 2, 123456789)) .expect("Cannot create date time from given parameters"); - let timestamp = datetime.timestamp_nanos(); + let timestamp = datetime.timestamp_nanos_opt().unwrap(); let mut dest = [0_u8; 81]; let dest_ptr = dest.as_mut_ptr(); @@ -437,7 +437,7 @@ mod test { let datetime = chrono::NaiveDate::from_ymd_opt(2023, 1, 23) .and_then(|date| date.and_hms_nano_opt(10, 10, 0, 123456789)) .expect("Cannot create date time from given parameters"); - let timestamp = datetime.timestamp_nanos(); + let timestamp = datetime.timestamp_nanos_opt().unwrap(); let mut dest = [0_u8; 81]; let dest_ptr = dest.as_mut_ptr(); diff --git a/libs/stdlib/tests/date_time_conversion_tests.rs b/libs/stdlib/tests/date_time_conversion_tests.rs index 0749bd8d32..741cccab11 100644 --- a/libs/stdlib/tests/date_time_conversion_tests.rs +++ b/libs/stdlib/tests/date_time_conversion_tests.rs @@ -56,7 +56,8 @@ fn ldt_to_dt_conversion() { .unwrap() .and_hms_opt(22, 33, 14) .unwrap() - .timestamp_nanos() + .timestamp_nanos_opt() + .unwrap() ); } @@ -71,7 +72,12 @@ fn ldt_to_date_conversion() { let res: i64 = compile_and_run(sources, &mut maintype); assert_eq!( res, - chrono::NaiveDate::from_ymd_opt(2000, 1, 1).unwrap().and_hms_opt(0, 0, 0).unwrap().timestamp_nanos() + chrono::NaiveDate::from_ymd_opt(2000, 1, 1) + .unwrap() + .and_hms_opt(0, 0, 0) + .unwrap() + .timestamp_nanos_opt() + .unwrap() ); } @@ -90,7 +96,8 @@ fn ldt_to_ltod_conversion() { .unwrap() .and_hms_nano_opt(15, 36, 30, 123456000) .unwrap() - .timestamp_nanos() + .timestamp_nanos_opt() + .unwrap() ); } @@ -109,7 +116,8 @@ fn ldt_to_tod_conversion() { .unwrap() .and_hms_milli_opt(20, 15, 11, 543) .unwrap() - .timestamp_nanos() + .timestamp_nanos_opt() + .unwrap() ); } @@ -128,7 +136,8 @@ fn dt_to_ldt_conversion() { .unwrap() .and_hms_opt(22, 33, 14) .unwrap() - .timestamp_nanos() + .timestamp_nanos_opt() + .unwrap() ); } @@ -143,7 +152,12 @@ fn dt_to_date_conversion() { let res: i64 = compile_and_run(sources, &mut maintype); assert_eq!( res, - chrono::NaiveDate::from_ymd_opt(2000, 1, 1).unwrap().and_hms_opt(0, 0, 0).unwrap().timestamp_nanos() + chrono::NaiveDate::from_ymd_opt(2000, 1, 1) + .unwrap() + .and_hms_opt(0, 0, 0) + .unwrap() + .timestamp_nanos_opt() + .unwrap() ); } @@ -162,7 +176,8 @@ fn dt_to_ltod_conversion() { .unwrap() .and_hms_milli_opt(15, 36, 30, 123) .unwrap() - .timestamp_nanos() + .timestamp_nanos_opt() + .unwrap() ); } @@ -181,7 +196,8 @@ fn dt_to_tod_conversion() { .unwrap() .and_hms_milli_opt(20, 15, 11, 543) .unwrap() - .timestamp_nanos() + .timestamp_nanos_opt() + .unwrap() ); } @@ -200,7 +216,8 @@ fn ltod_to_tod_conversion() { .unwrap() .and_hms_opt(10, 20, 30) .unwrap() - .timestamp_nanos() + .timestamp_nanos_opt() + .unwrap() ); } @@ -219,6 +236,7 @@ fn tod_to_ltod_conversion() { .unwrap() .and_hms_opt(10, 20, 30) .unwrap() - .timestamp_nanos() + .timestamp_nanos_opt() + .unwrap() ); } diff --git a/libs/stdlib/tests/date_time_extra_functions_tests.rs b/libs/stdlib/tests/date_time_extra_functions_tests.rs index e21528c40e..57cdf36db0 100644 --- a/libs/stdlib/tests/date_time_extra_functions_tests.rs +++ b/libs/stdlib/tests/date_time_extra_functions_tests.rs @@ -34,7 +34,8 @@ fn concat_date_tod() { .unwrap() .and_hms_nano_opt(12, 30, 15, 121121121) .unwrap() - .timestamp_nanos(); + .timestamp_nanos_opt() + .unwrap(); assert_eq!(res, dt_2010y_3m_12d_12h_30m_15s_121121121ns); } @@ -51,7 +52,8 @@ fn concat_date_ltod() { .unwrap() .and_hms_nano_opt(12, 30, 15, 121121121) .unwrap() - .timestamp_nanos(); + .timestamp_nanos_opt() + .unwrap(); assert_eq!(res, dt_2010y_3m_12d_12h_30m_15s_121121121ns); } @@ -82,8 +84,12 @@ fn concat_date_signed_ints() { let sources = add_std!(src, "date_time_extra_functions.st"); let mut maintype = MainType::::default(); let _: i64 = compile_and_run(sources, &mut maintype); - let date_2000y_1m_1d = - chrono::NaiveDate::from_ymd_opt(2000, 1, 1).unwrap().and_hms_opt(0, 0, 0).unwrap().timestamp_nanos(); + let date_2000y_1m_1d = chrono::NaiveDate::from_ymd_opt(2000, 1, 1) + .unwrap() + .and_hms_opt(0, 0, 0) + .unwrap() + .timestamp_nanos_opt() + .unwrap(); assert_eq!(maintype.a, date_2000y_1m_1d); assert_eq!(maintype.b, date_2000y_1m_1d); assert_eq!(maintype.c, date_2000y_1m_1d); @@ -105,8 +111,12 @@ fn concat_date_unsigned_ints() { let sources = add_std!(src, "date_time_extra_functions.st"); let mut maintype = MainType::::default(); let _: i64 = compile_and_run(sources, &mut maintype); - let date_2000y_1m_1d = - chrono::NaiveDate::from_ymd_opt(2000, 1, 1).unwrap().and_hms_opt(0, 0, 0).unwrap().timestamp_nanos(); + let date_2000y_1m_1d = chrono::NaiveDate::from_ymd_opt(2000, 1, 1) + .unwrap() + .and_hms_opt(0, 0, 0) + .unwrap() + .timestamp_nanos_opt() + .unwrap(); assert_eq!(maintype.a, date_2000y_1m_1d); assert_eq!(maintype.b, date_2000y_1m_1d); assert_eq!(maintype.c, date_2000y_1m_1d); @@ -130,8 +140,8 @@ fn concat_tod_signed_ints() { let sources = add_std!(src, "date_time_extra_functions.st"); let mut maintype = MainType::::default(); let _: i64 = compile_and_run(sources, &mut maintype); - assert_eq!(maintype.a, get_time_from_hms_milli(20, 15, 12, 34).timestamp_nanos()); - let tod_20h_15m_12s_341ms = get_time_from_hms_milli(20, 15, 12, 341).timestamp_nanos(); + assert_eq!(maintype.a, get_time_from_hms_milli(20, 15, 12, 34).timestamp_nanos_opt().unwrap()); + let tod_20h_15m_12s_341ms = get_time_from_hms_milli(20, 15, 12, 341).timestamp_nanos_opt().unwrap(); assert_eq!(maintype.b, tod_20h_15m_12s_341ms); assert_eq!(maintype.c, tod_20h_15m_12s_341ms); assert_eq!(maintype.d, tod_20h_15m_12s_341ms); @@ -155,8 +165,8 @@ fn concat_tod_unsigned_ints() { let sources = add_std!(src, "date_time_extra_functions.st"); let mut maintype = MainType::::default(); let _: i64 = compile_and_run(sources, &mut maintype); - assert_eq!(maintype.a, get_time_from_hms_milli(20, 15, 12, 34).timestamp_nanos()); - let tod_20h_15m_12s_341ms = get_time_from_hms_milli(20, 15, 12, 341).timestamp_nanos(); + assert_eq!(maintype.a, get_time_from_hms_milli(20, 15, 12, 34).timestamp_nanos_opt().unwrap()); + let tod_20h_15m_12s_341ms = get_time_from_hms_milli(20, 15, 12, 341).timestamp_nanos_opt().unwrap(); assert_eq!(maintype.b, tod_20h_15m_12s_341ms); assert_eq!(maintype.c, tod_20h_15m_12s_341ms); assert_eq!(maintype.d, tod_20h_15m_12s_341ms); @@ -180,8 +190,8 @@ fn concat_ltod_signed_ints() { let sources = add_std!(src, "date_time_extra_functions.st"); let mut maintype = MainType::::default(); let _: i64 = compile_and_run(sources, &mut maintype); - assert_eq!(maintype.a, get_time_from_hms_milli(20, 15, 12, 34).timestamp_nanos()); - let tod_20h_15m_12s_341ms = get_time_from_hms_milli(20, 15, 12, 341).timestamp_nanos(); + assert_eq!(maintype.a, get_time_from_hms_milli(20, 15, 12, 34).timestamp_nanos_opt().unwrap()); + let tod_20h_15m_12s_341ms = get_time_from_hms_milli(20, 15, 12, 341).timestamp_nanos_opt().unwrap(); assert_eq!(maintype.b, tod_20h_15m_12s_341ms); assert_eq!(maintype.c, tod_20h_15m_12s_341ms); assert_eq!(maintype.d, tod_20h_15m_12s_341ms); @@ -205,8 +215,8 @@ fn concat_ltod_unsigned_ints() { let sources = add_std!(src, "date_time_extra_functions.st"); let mut maintype = MainType::::default(); let _: i64 = compile_and_run(sources, &mut maintype); - assert_eq!(maintype.a, get_time_from_hms_milli(20, 15, 12, 34).timestamp_nanos()); - let tod_20h_15m_12s_341ms = get_time_from_hms_milli(20, 15, 12, 341).timestamp_nanos(); + assert_eq!(maintype.a, get_time_from_hms_milli(20, 15, 12, 34).timestamp_nanos_opt().unwrap()); + let tod_20h_15m_12s_341ms = get_time_from_hms_milli(20, 15, 12, 341).timestamp_nanos_opt().unwrap(); assert_eq!(maintype.b, tod_20h_15m_12s_341ms); assert_eq!(maintype.c, tod_20h_15m_12s_341ms); assert_eq!(maintype.d, tod_20h_15m_12s_341ms); @@ -232,7 +242,8 @@ fn concat_dt_signed_ints() { .unwrap() .and_hms_milli_opt(20, 15, 12, 111) .unwrap() - .timestamp_nanos(); + .timestamp_nanos_opt() + .unwrap(); assert_eq!(maintype.a, dt_2000y_1m_2d_20h_15m_12s_111ms); assert_eq!(maintype.b, dt_2000y_1m_2d_20h_15m_12s_111ms); assert_eq!(maintype.c, dt_2000y_1m_2d_20h_15m_12s_111ms); @@ -258,7 +269,8 @@ fn concat_dt_unsigned_ints() { .unwrap() .and_hms_milli_opt(20, 15, 12, 111) .unwrap() - .timestamp_nanos(); + .timestamp_nanos_opt() + .unwrap(); assert_eq!(maintype.a, dt_2000y_1m_2d_20h_15m_12s_111ms); assert_eq!(maintype.b, dt_2000y_1m_2d_20h_15m_12s_111ms); assert_eq!(maintype.c, dt_2000y_1m_2d_20h_15m_12s_111ms); @@ -284,7 +296,8 @@ fn concat_ldt_signed_ints() { .unwrap() .and_hms_milli_opt(20, 15, 12, 111) .unwrap() - .timestamp_nanos(); + .timestamp_nanos_opt() + .unwrap(); assert_eq!(maintype.a, dt_2000y_1m_2d_20h_15m_12s_111ms); assert_eq!(maintype.b, dt_2000y_1m_2d_20h_15m_12s_111ms); assert_eq!(maintype.c, dt_2000y_1m_2d_20h_15m_12s_111ms); @@ -310,7 +323,8 @@ fn concat_ldt_unsigned_ints() { .unwrap() .and_hms_milli_opt(20, 15, 12, 111) .unwrap() - .timestamp_nanos(); + .timestamp_nanos_opt() + .unwrap(); assert_eq!(maintype.a, dt_2000y_1m_2d_20h_15m_12s_111ms); assert_eq!(maintype.b, dt_2000y_1m_2d_20h_15m_12s_111ms); assert_eq!(maintype.c, dt_2000y_1m_2d_20h_15m_12s_111ms); diff --git a/libs/stdlib/tests/date_time_numeric_functions_tests.rs b/libs/stdlib/tests/date_time_numeric_functions_tests.rs index 0d3dc5b6ba..99d773ecd2 100644 --- a/libs/stdlib/tests/date_time_numeric_functions_tests.rs +++ b/libs/stdlib/tests/date_time_numeric_functions_tests.rs @@ -44,9 +44,9 @@ fn add_time() { let sources = add_std!(src, "date_time_numeric_functions.st"); let mut maintype = MainType::default(); let _: i64 = compile_and_run(sources, &mut maintype); - assert_eq!(maintype.a, get_time_from_hms(5, 0, 30).timestamp_nanos()); - assert_eq!(maintype.b, get_time_from_hms(0, 0, 5).timestamp_nanos()); - let time_20s = get_time_from_hms(0, 0, 20).timestamp_nanos(); + assert_eq!(maintype.a, get_time_from_hms(5, 0, 30).timestamp_nanos_opt().unwrap()); + assert_eq!(maintype.b, get_time_from_hms(0, 0, 5).timestamp_nanos_opt().unwrap()); + let time_20s = get_time_from_hms(0, 0, 20).timestamp_nanos_opt().unwrap(); assert_eq!(maintype.c, -time_20s); // -20 seconds assert_eq!(maintype.d, time_20s); } @@ -69,10 +69,10 @@ fn add_tod_time() { let sources = add_std!(src, "date_time_numeric_functions.st"); let mut maintype = MainType::default(); let _: i64 = compile_and_run(sources, &mut maintype); - let tod_20h_1s = get_time_from_hms(20, 0, 1).timestamp_nanos(); + let tod_20h_1s = get_time_from_hms(20, 0, 1).timestamp_nanos_opt().unwrap(); assert_eq!(maintype.a, tod_20h_1s); assert_eq!(maintype.b, tod_20h_1s); - let tod_12h12m12s = get_time_from_hms(12, 12, 12).timestamp_nanos(); + let tod_12h12m12s = get_time_from_hms(12, 12, 12).timestamp_nanos_opt().unwrap(); assert_eq!(maintype.c, tod_12h12m12s); assert_eq!(maintype.d, tod_12h12m12s); } @@ -99,7 +99,8 @@ fn add_dt_time() { .unwrap() .and_hms_milli_opt(12, 12, 12, 123) .unwrap() - .timestamp_nanos(); + .timestamp_nanos_opt() + .unwrap(); assert_eq!(maintype.a, dt_2000y_1m_2d_12h_12m_12s_123ms); assert_eq!(maintype.b, dt_2000y_1m_2d_12h_12m_12s_123ms); assert_eq!(maintype.c, dt_2000y_1m_2d_12h_12m_12s_123ms); @@ -141,8 +142,8 @@ fn sub_time() { let sources = add_std!(src, "date_time_numeric_functions.st"); let mut maintype = MainType::default(); let _: i64 = compile_and_run(sources, &mut maintype); - assert_eq!(maintype.a, get_time_from_hms(11, 0, 0).timestamp_nanos()); - let time_4h_30m = get_time_from_hms(4, 30, 0).timestamp_nanos(); + assert_eq!(maintype.a, get_time_from_hms(11, 0, 0).timestamp_nanos_opt().unwrap()); + let time_4h_30m = get_time_from_hms(4, 30, 0).timestamp_nanos_opt().unwrap(); assert_eq!(maintype.b, time_4h_30m); assert_eq!(maintype.c, time_4h_30m); assert_eq!(maintype.d, time_4h_30m); @@ -193,7 +194,7 @@ fn sub_tod_time() { let sources = add_std!(src, "date_time_numeric_functions.st"); let mut maintype = MainType::default(); let _: i64 = compile_and_run(sources, &mut maintype); - let tod_20h = get_time_from_hms(20, 0, 0).timestamp_nanos(); + let tod_20h = get_time_from_hms(20, 0, 0).timestamp_nanos_opt().unwrap(); assert_eq!(maintype.a, tod_20h); assert_eq!(maintype.b, tod_20h); assert_eq!(maintype.c, tod_20h); @@ -218,7 +219,7 @@ fn sub_tod() { let sources = add_std!(src, "date_time_numeric_functions.st"); let mut maintype = MainType::default(); let _: i64 = compile_and_run(sources, &mut maintype); - let time_20h = get_time_from_hms(20, 0, 0).timestamp_nanos(); + let time_20h = get_time_from_hms(20, 0, 0).timestamp_nanos_opt().unwrap(); assert_eq!(maintype.a, time_20h); assert_eq!(maintype.a, time_20h); assert_eq!(maintype.a, time_20h); @@ -243,8 +244,12 @@ fn sub_dt_time() { let sources = add_std!(src, "date_time_numeric_functions.st"); let mut maintype = MainType::default(); let _: i64 = compile_and_run(sources, &mut maintype); - let dt_2000y_1m_1d_20h = - chrono::NaiveDate::from_ymd_opt(2000, 1, 1).unwrap().and_hms_opt(20, 0, 0).unwrap().timestamp_nanos(); + let dt_2000y_1m_1d_20h = chrono::NaiveDate::from_ymd_opt(2000, 1, 1) + .unwrap() + .and_hms_opt(20, 0, 0) + .unwrap() + .timestamp_nanos_opt() + .unwrap(); assert_eq!(maintype.a, dt_2000y_1m_1d_20h); assert_eq!(maintype.b, dt_2000y_1m_1d_20h); assert_eq!(maintype.c, dt_2000y_1m_1d_20h); @@ -272,7 +277,8 @@ fn sub_dt() { let time_1d_11h_22m_33s_444ms = get_time_from_hms_milli(11, 22, 33, 444) .checked_add_signed(chrono::Duration::days(1)) .unwrap() - .timestamp_nanos(); + .timestamp_nanos_opt() + .unwrap(); assert_eq!(maintype.a, time_1d_11h_22m_33s_444ms); assert_eq!(maintype.b, time_1d_11h_22m_33s_444ms); assert_eq!(maintype.c, time_1d_11h_22m_33s_444ms); @@ -980,7 +986,7 @@ fn date_time_overloaded_add_and_numerical_add_compile_correctly() { let sources = add_std!(src, "date_time_numeric_functions.st"); let mut maintype = MainType::default(); let _: i64 = compile_and_run(sources, &mut maintype); - let tod_23h_56m = get_time_from_hms(23, 56, 0).timestamp_nanos(); + let tod_23h_56m = get_time_from_hms(23, 56, 0).timestamp_nanos_opt().unwrap(); assert_eq!(tod_23h_56m, maintype.a); assert_eq!(18.0, maintype.b); diff --git a/libs/stdlib/tests/endianness_conversion_functions_tests.rs b/libs/stdlib/tests/endianness_conversion_functions_tests.rs index 472c9959e3..60a3996fe1 100644 --- a/libs/stdlib/tests/endianness_conversion_functions_tests.rs +++ b/libs/stdlib/tests/endianness_conversion_functions_tests.rs @@ -606,7 +606,13 @@ fn test_to_big_endian_date() { let res: i64 = compile_and_run_no_params(src); assert_eq!( res, - NaiveDate::from_ymd_opt(1984, 6, 25).unwrap().and_hms_opt(0, 0, 0).unwrap().timestamp_nanos().to_be() + NaiveDate::from_ymd_opt(1984, 6, 25) + .unwrap() + .and_hms_opt(0, 0, 0) + .unwrap() + .timestamp_nanos_opt() + .unwrap() + .to_be() ) } @@ -620,7 +626,13 @@ fn test_to_little_endian_date() { let res: i64 = compile_and_run_no_params(src); assert_eq!( res, - NaiveDate::from_ymd_opt(1984, 6, 25).unwrap().and_hms_opt(0, 0, 0).unwrap().timestamp_nanos().to_le() + NaiveDate::from_ymd_opt(1984, 6, 25) + .unwrap() + .and_hms_opt(0, 0, 0) + .unwrap() + .timestamp_nanos_opt() + .unwrap() + .to_le() ) } @@ -635,7 +647,12 @@ fn test_from_big_endian_date() { assert_eq!( res, i64::from_be( - NaiveDate::from_ymd_opt(1984, 6, 25).unwrap().and_hms_opt(0, 0, 0).unwrap().timestamp_nanos() + NaiveDate::from_ymd_opt(1984, 6, 25) + .unwrap() + .and_hms_opt(0, 0, 0) + .unwrap() + .timestamp_nanos_opt() + .unwrap() ) ) } @@ -651,7 +668,12 @@ fn test_from_little_endian_date() { assert_eq!( res, i64::from_le( - NaiveDate::from_ymd_opt(1984, 6, 25).unwrap().and_hms_opt(0, 0, 0).unwrap().timestamp_nanos() + NaiveDate::from_ymd_opt(1984, 6, 25) + .unwrap() + .and_hms_opt(0, 0, 0) + .unwrap() + .timestamp_nanos_opt() + .unwrap() ) ) } @@ -717,7 +739,13 @@ fn test_to_big_endian_dt() { let res: i64 = compile_and_run_no_params(src); assert_eq!( res, - NaiveDate::from_ymd_opt(1984, 6, 25).unwrap().and_hms_opt(0, 0, 0).unwrap().timestamp_nanos().to_be() + NaiveDate::from_ymd_opt(1984, 6, 25) + .unwrap() + .and_hms_opt(0, 0, 0) + .unwrap() + .timestamp_nanos_opt() + .unwrap() + .to_be() ) } @@ -732,7 +760,13 @@ fn test_to_little_endian_dt() { let res: i64 = compile_and_run_no_params(src); assert_eq!( res, - NaiveDate::from_ymd_opt(1984, 6, 25).unwrap().and_hms_opt(0, 0, 0).unwrap().timestamp_nanos().to_le() + NaiveDate::from_ymd_opt(1984, 6, 25) + .unwrap() + .and_hms_opt(0, 0, 0) + .unwrap() + .timestamp_nanos_opt() + .unwrap() + .to_le() ) } @@ -748,7 +782,12 @@ fn test_from_big_endian_dt() { assert_eq!( res, i64::from_be( - NaiveDate::from_ymd_opt(1984, 6, 25).unwrap().and_hms_opt(0, 0, 0).unwrap().timestamp_nanos() + NaiveDate::from_ymd_opt(1984, 6, 25) + .unwrap() + .and_hms_opt(0, 0, 0) + .unwrap() + .timestamp_nanos_opt() + .unwrap() ) ) } @@ -765,7 +804,12 @@ fn test_from_little_endian_dt() { assert_eq!( res, i64::from_le( - NaiveDate::from_ymd_opt(1984, 6, 25).unwrap().and_hms_opt(0, 0, 0).unwrap().timestamp_nanos() + NaiveDate::from_ymd_opt(1984, 6, 25) + .unwrap() + .and_hms_opt(0, 0, 0) + .unwrap() + .timestamp_nanos_opt() + .unwrap() ) ) } @@ -783,7 +827,13 @@ fn test_to_big_endian_ldate_nanos() { let res: i64 = compile_and_run_no_params(src); assert_eq!( res, - NaiveDate::from_ymd_opt(1984, 6, 25).unwrap().and_hms_opt(0, 0, 0).unwrap().timestamp_nanos().to_be() + NaiveDate::from_ymd_opt(1984, 6, 25) + .unwrap() + .and_hms_opt(0, 0, 0) + .unwrap() + .timestamp_nanos_opt() + .unwrap() + .to_be() ) } @@ -798,7 +848,13 @@ fn test_to_little_endian_ldate_nanos() { let res: i64 = compile_and_run_no_params(src); assert_eq!( res, - NaiveDate::from_ymd_opt(1984, 6, 25).unwrap().and_hms_opt(0, 0, 0).unwrap().timestamp_nanos().to_le() + NaiveDate::from_ymd_opt(1984, 6, 25) + .unwrap() + .and_hms_opt(0, 0, 0) + .unwrap() + .timestamp_nanos_opt() + .unwrap() + .to_le() ) } @@ -814,7 +870,12 @@ fn test_from_big_endian_ldate_nanos() { assert_eq!( res, i64::from_be( - NaiveDate::from_ymd_opt(1984, 6, 25).unwrap().and_hms_opt(0, 0, 0).unwrap().timestamp_nanos() + NaiveDate::from_ymd_opt(1984, 6, 25) + .unwrap() + .and_hms_opt(0, 0, 0) + .unwrap() + .timestamp_nanos_opt() + .unwrap() ) ) } @@ -831,7 +892,12 @@ fn test_from_little_endian_ldate_nanos() { assert_eq!( res, i64::from_le( - NaiveDate::from_ymd_opt(1984, 6, 25).unwrap().and_hms_opt(0, 0, 0).unwrap().timestamp_nanos() + NaiveDate::from_ymd_opt(1984, 6, 25) + .unwrap() + .and_hms_opt(0, 0, 0) + .unwrap() + .timestamp_nanos_opt() + .unwrap() ) ) } @@ -853,7 +919,8 @@ fn test_to_big_endian_ldt_nanos() { .unwrap() .and_hms_nano_opt(0, 0, 0, 0) .unwrap() - .timestamp_nanos() + .timestamp_nanos_opt() + .unwrap() .to_be() ) } @@ -869,7 +936,13 @@ fn test_to_little_endian_ldt_nanos() { let res: i64 = compile_and_run_no_params(src); assert_eq!( res, - NaiveDate::from_ymd_opt(1984, 6, 25).unwrap().and_hms_opt(0, 0, 0).unwrap().timestamp_nanos().to_le() + NaiveDate::from_ymd_opt(1984, 6, 25) + .unwrap() + .and_hms_opt(0, 0, 0) + .unwrap() + .timestamp_nanos_opt() + .unwrap() + .to_le() ) } @@ -885,7 +958,12 @@ fn test_from_big_endian_nanos() { assert_eq!( res, i64::from_be( - NaiveDate::from_ymd_opt(1984, 6, 25).unwrap().and_hms_opt(0, 0, 0).unwrap().timestamp_nanos() + NaiveDate::from_ymd_opt(1984, 6, 25) + .unwrap() + .and_hms_opt(0, 0, 0) + .unwrap() + .timestamp_nanos_opt() + .unwrap() ) ) } @@ -902,7 +980,12 @@ fn test_from_little_endian_nanos() { assert_eq!( res, i64::from_le( - NaiveDate::from_ymd_opt(1984, 6, 25).unwrap().and_hms_opt(0, 0, 0).unwrap().timestamp_nanos() + NaiveDate::from_ymd_opt(1984, 6, 25) + .unwrap() + .and_hms_opt(0, 0, 0) + .unwrap() + .timestamp_nanos_opt() + .unwrap() ) ) } diff --git a/libs/stdlib/tests/extra_function_tests.rs b/libs/stdlib/tests/extra_function_tests.rs index fcf93c56bc..4eab445e7f 100644 --- a/libs/stdlib/tests/extra_function_tests.rs +++ b/libs/stdlib/tests/extra_function_tests.rs @@ -1,4 +1,4 @@ -use chrono::{DateTime, NaiveDate, NaiveDateTime, NaiveTime, Timelike, Utc}; +use chrono::{NaiveDate, NaiveDateTime, NaiveTime, TimeZone, Timelike, Utc}; mod common; use common::add_std; use common::{compile_and_run, compile_and_run_no_params, compile_with_native}; @@ -558,7 +558,7 @@ fn dt_to_lword_conversion() { let date = NaiveDate::from_ymd_opt(1999, 12, 31).unwrap(); let time = NaiveTime::from_hms_micro_opt(1, 59, 59, 256700).unwrap(); - let expected = NaiveDateTime::new(date, time).timestamp_nanos() as u64; + let expected = NaiveDateTime::new(date, time).timestamp_nanos_opt().unwrap() as u64; assert_eq!(expected, res) } @@ -584,7 +584,7 @@ fn ldt_to_lword_conversion() { let date = NaiveDate::from_ymd_opt(1999, 12, 31).unwrap(); let time = NaiveTime::from_hms_micro_opt(1, 59, 59, 256700).unwrap(); - let expected = NaiveDateTime::new(date, time).timestamp_nanos() as u64; + let expected = NaiveDateTime::new(date, time).timestamp_nanos_opt().unwrap() as u64; assert_eq!(expected, res) } @@ -610,7 +610,7 @@ fn date_to_lword_conversion() { let date = NaiveDate::from_ymd_opt(1999, 12, 31).unwrap(); let time = NaiveTime::from_hms_opt(0, 0, 0).unwrap(); - let expected = NaiveDateTime::new(date, time).timestamp_nanos() as u64; + let expected = NaiveDateTime::new(date, time).timestamp_nanos_opt().unwrap() as u64; assert_eq!(expected, res) } @@ -636,7 +636,7 @@ fn ldate_to_lword_conversion() { let date = NaiveDate::from_ymd_opt(1999, 12, 31).unwrap(); let time = NaiveTime::from_hms_opt(0, 0, 0).unwrap(); - let expected = NaiveDateTime::new(date, time).timestamp_nanos() as u64; + let expected = NaiveDateTime::new(date, time).timestamp_nanos_opt().unwrap() as u64; assert_eq!(expected, res) } @@ -990,7 +990,7 @@ fn date_to_lint_conversion() { let date = NaiveDate::from_ymd_opt(1999, 12, 31).unwrap(); let time = NaiveTime::from_hms_opt(0, 0, 0).unwrap(); - let expected = NaiveDateTime::new(date, time).timestamp_nanos() as u64; + let expected = NaiveDateTime::new(date, time).timestamp_nanos_opt().unwrap() as u64; assert_eq!(expected, res) } @@ -1016,7 +1016,7 @@ fn ldate_to_lint_conversion() { let date = NaiveDate::from_ymd_opt(1999, 12, 31).unwrap(); let time = NaiveTime::from_hms_opt(0, 0, 0).unwrap(); - let expected = NaiveDateTime::new(date, time).timestamp_nanos() as u64; + let expected = NaiveDateTime::new(date, time).timestamp_nanos_opt().unwrap() as u64; assert_eq!(expected, res) } @@ -1041,8 +1041,8 @@ fn dt_to_lint_conversion() { let res: i64 = compile_and_run_no_params(sources); let naivedatetime_utc = NaiveDate::from_ymd_opt(2000, 1, 12).unwrap().and_hms_opt(23, 23, 0).unwrap(); - let datetime_utc = DateTime::::from_utc(naivedatetime_utc, Utc); - let expected = datetime_utc.timestamp_nanos(); + let datetime_utc = TimeZone::from_utc_datetime(&Utc, &naivedatetime_utc); + let expected = datetime_utc.timestamp_nanos_opt().unwrap(); assert_eq!(expected, res) } @@ -1067,8 +1067,8 @@ fn ldt_to_lint_conversion() { let res: i64 = compile_and_run_no_params(sources); let naivedatetime_utc = NaiveDate::from_ymd_opt(2000, 1, 12).unwrap().and_hms_opt(23, 23, 0).unwrap(); - let datetime_utc = DateTime::::from_utc(naivedatetime_utc, Utc); - let expected = datetime_utc.timestamp_nanos(); + let datetime_utc = TimeZone::from_utc_datetime(&Utc, &naivedatetime_utc); + let expected = datetime_utc.timestamp_nanos_opt().unwrap(); assert_eq!(expected, res) } @@ -1197,7 +1197,7 @@ fn date_to_ulint_conversion() { let date = NaiveDate::from_ymd_opt(1999, 12, 31).unwrap(); let time = NaiveTime::from_hms_opt(0, 0, 0).unwrap(); - let expected = NaiveDateTime::new(date, time).timestamp_nanos() as u64; + let expected = NaiveDateTime::new(date, time).timestamp_nanos_opt().unwrap() as u64; assert_eq!(expected, res) } @@ -1223,7 +1223,7 @@ fn ldate_to_ulint_conversion() { let date = NaiveDate::from_ymd_opt(1999, 12, 31).unwrap(); let time = NaiveTime::from_hms_opt(0, 0, 0).unwrap(); - let expected = NaiveDateTime::new(date, time).timestamp_nanos() as u64; + let expected = NaiveDateTime::new(date, time).timestamp_nanos_opt().unwrap() as u64; assert_eq!(expected, res) } @@ -1248,8 +1248,8 @@ fn dt_to_ulint_conversion() { let res: u64 = compile_and_run_no_params(sources); let naivedatetime_utc = NaiveDate::from_ymd_opt(2000, 1, 12).unwrap().and_hms_opt(23, 23, 0).unwrap(); - let datetime_utc = DateTime::::from_utc(naivedatetime_utc, Utc); - let expected = datetime_utc.timestamp_nanos() as u64; + let datetime_utc = TimeZone::from_utc_datetime(&Utc, &naivedatetime_utc); + let expected = datetime_utc.timestamp_nanos_opt().unwrap() as u64; assert_eq!(expected, res) } @@ -1274,8 +1274,8 @@ fn ldt_to_ulint_conversion() { let res: u64 = compile_and_run_no_params(sources); let naivedatetime_utc = NaiveDate::from_ymd_opt(2000, 1, 12).unwrap().and_hms_opt(23, 23, 0).unwrap(); - let datetime_utc = DateTime::::from_utc(naivedatetime_utc, Utc); - let expected = datetime_utc.timestamp_nanos() as u64; + let datetime_utc = TimeZone::from_utc_datetime(&Utc, &naivedatetime_utc); + let expected = datetime_utc.timestamp_nanos_opt().unwrap() as u64; assert_eq!(expected, res) } diff --git a/tests/correctness/math_operators/addition.rs b/tests/correctness/math_operators/addition.rs index 17d55b6cae..651fcfbddc 100644 --- a/tests/correctness/math_operators/addition.rs +++ b/tests/correctness/math_operators/addition.rs @@ -246,8 +246,10 @@ fn add_date_basic() { let mut main = MainType::default(); let res: u64 = compile_and_run(prog.to_string(), &mut main); - let date_var = chrono::Utc.with_ymd_and_hms(2021, 1, 1, 0, 0, 0).unwrap().timestamp_nanos() as u64; - let date_10_days = chrono::Utc.with_ymd_and_hms(1970, 1, 10, 0, 0, 0).unwrap().timestamp_nanos() as u64; + let date_var = + chrono::Utc.with_ymd_and_hms(2021, 1, 1, 0, 0, 0).unwrap().timestamp_nanos_opt().unwrap() as u64; + let date_10_days = + chrono::Utc.with_ymd_and_hms(1970, 1, 10, 0, 0, 0).unwrap().timestamp_nanos_opt().unwrap() as u64; assert_eq!(res, date_10_days + date_var); } diff --git a/tests/correctness/math_operators/division.rs b/tests/correctness/math_operators/division.rs index c876f67736..2b6c95cb8b 100644 --- a/tests/correctness/math_operators/division.rs +++ b/tests/correctness/math_operators/division.rs @@ -209,8 +209,10 @@ fn division_date_basic() { let mut main = MainType::default(); let res: u64 = compile_and_run(prog.to_string(), &mut main); - let date_var = chrono::Utc.with_ymd_and_hms(2021, 1, 1, 0, 0, 0).unwrap().timestamp_nanos() as u64; - let date_10_days = chrono::Utc.with_ymd_and_hms(1970, 1, 10, 0, 0, 0).unwrap().timestamp_nanos() as u64; + let date_var = + chrono::Utc.with_ymd_and_hms(2021, 1, 1, 0, 0, 0).unwrap().timestamp_nanos_opt().unwrap() as u64; + let date_10_days = + chrono::Utc.with_ymd_and_hms(1970, 1, 10, 0, 0, 0).unwrap().timestamp_nanos_opt().unwrap() as u64; assert_eq!(res, date_var + date_10_days / 2); } diff --git a/tests/correctness/math_operators/mixed.rs b/tests/correctness/math_operators/mixed.rs index c91fe413b1..cf7089f076 100644 --- a/tests/correctness/math_operators/mixed.rs +++ b/tests/correctness/math_operators/mixed.rs @@ -179,9 +179,12 @@ fn mixed_math_date_basic() { let mut main = MainType::default(); let res: u64 = compile_and_run(prog.to_string(), &mut main); - let date_var = chrono::Utc.with_ymd_and_hms(2021, 1, 1, 0, 0, 0).unwrap().timestamp_nanos() as u64; - let date_10_days = chrono::Utc.with_ymd_and_hms(1970, 1, 10, 0, 0, 0).unwrap().timestamp_nanos() as u64; - let date_1_day = chrono::Utc.with_ymd_and_hms(1970, 1, 2, 0, 0, 0).unwrap().timestamp_nanos() as u64; + let date_var = + chrono::Utc.with_ymd_and_hms(2021, 1, 1, 0, 0, 0).unwrap().timestamp_nanos_opt().unwrap() as u64; + let date_10_days = + chrono::Utc.with_ymd_and_hms(1970, 1, 10, 0, 0, 0).unwrap().timestamp_nanos_opt().unwrap() as u64; + let date_1_day = + chrono::Utc.with_ymd_and_hms(1970, 1, 2, 0, 0, 0).unwrap().timestamp_nanos_opt().unwrap() as u64; assert_eq!(res, date_var + date_10_days * 2 - date_1_day / 2); } @@ -203,9 +206,12 @@ fn mixed_math_dt_basic() { let mut main = MainType::default(); let res: u64 = compile_and_run(prog.to_string(), &mut main); - let date_var = chrono::Utc.with_ymd_and_hms(2021, 1, 1, 0, 0, 0).unwrap().timestamp_nanos() as u64; - let date_10_days = chrono::Utc.with_ymd_and_hms(1970, 1, 10, 0, 0, 0).unwrap().timestamp_nanos() as u64; - let date_1_day = chrono::Utc.with_ymd_and_hms(1970, 1, 2, 0, 0, 0).unwrap().timestamp_nanos() as u64; + let date_var = + chrono::Utc.with_ymd_and_hms(2021, 1, 1, 0, 0, 0).unwrap().timestamp_nanos_opt().unwrap() as u64; + let date_10_days = + chrono::Utc.with_ymd_and_hms(1970, 1, 10, 0, 0, 0).unwrap().timestamp_nanos_opt().unwrap() as u64; + let date_1_day = + chrono::Utc.with_ymd_and_hms(1970, 1, 2, 0, 0, 0).unwrap().timestamp_nanos_opt().unwrap() as u64; assert_eq!(res, date_var + date_10_days * 2 - date_1_day / 2); } diff --git a/tests/correctness/math_operators/multiplication.rs b/tests/correctness/math_operators/multiplication.rs index 3187ac17db..525d2c432c 100644 --- a/tests/correctness/math_operators/multiplication.rs +++ b/tests/correctness/math_operators/multiplication.rs @@ -172,8 +172,10 @@ fn multiplication_date_basic() { let mut main = MainType::default(); let res: u64 = compile_and_run(prog.to_string(), &mut main); - let date_var = chrono::Utc.with_ymd_and_hms(2021, 1, 1, 0, 0, 0).unwrap().timestamp_nanos() as u64; - let date_10_days = chrono::Utc.with_ymd_and_hms(1970, 1, 10, 0, 0, 0).unwrap().timestamp_nanos() as u64; + let date_var = + chrono::Utc.with_ymd_and_hms(2021, 1, 1, 0, 0, 0).unwrap().timestamp_nanos_opt().unwrap() as u64; + let date_10_days = + chrono::Utc.with_ymd_and_hms(1970, 1, 10, 0, 0, 0).unwrap().timestamp_nanos_opt().unwrap() as u64; assert_eq!(res, date_var + date_10_days * 2); } diff --git a/tests/correctness/math_operators/substraction.rs b/tests/correctness/math_operators/substraction.rs index 89826d5761..a5a968810a 100644 --- a/tests/correctness/math_operators/substraction.rs +++ b/tests/correctness/math_operators/substraction.rs @@ -232,8 +232,10 @@ fn substract_date_basic() { let mut main = MainType::default(); let res: u64 = compile_and_run(prog.to_string(), &mut main); - let date_var = chrono::Utc.with_ymd_and_hms(2021, 1, 1, 0, 0, 0).unwrap().timestamp_nanos() as u64; - let date_temp = chrono::Utc.with_ymd_and_hms(2021, 1, 10, 0, 0, 0).unwrap().timestamp_nanos() as u64; + let date_var = + chrono::Utc.with_ymd_and_hms(2021, 1, 1, 0, 0, 0).unwrap().timestamp_nanos_opt().unwrap() as u64; + let date_temp = + chrono::Utc.with_ymd_and_hms(2021, 1, 10, 0, 0, 0).unwrap().timestamp_nanos_opt().unwrap() as u64; assert_eq!(res, date_temp - date_var); } From 1e88fe5aa4d139c3357d41a4d720493e43b8b3b5 Mon Sep 17 00:00:00 2001 From: Volkan Date: Thu, 7 Dec 2023 10:17:01 +0100 Subject: [PATCH 14/33] fix(codegen): Convert pointer to actual type when passing by-value (#1039) We were missing an edge-case where an argument is passed into a function A by-ref (INOUT) which in turn is passed into a function B by-val (INPUT) which generated the following IR for a DINT array ``` %call = call i32 @function1(i32 %load_x)` // we want `@function1([5 x i32] %load_x)` however ``` This commit fixes it, in that the commented IR is generated - specifically before passing the argument into function B it is bit-cast into its actual type. --- .../generators/expression_generator.rs | 47 ++++++++++++++-- src/codegen/tests/function_tests.rs | 33 ++++++++++++ ...ests__argument_fed_by_ref_then_by_val.snap | 49 +++++++++++++++++ src/typesystem.rs | 4 ++ tests/correctness/functions.rs | 53 +++++++++++++++++++ 5 files changed, 181 insertions(+), 5 deletions(-) create mode 100644 src/codegen/tests/snapshots/rusty__codegen__tests__function_tests__argument_fed_by_ref_then_by_val.snap diff --git a/src/codegen/generators/expression_generator.rs b/src/codegen/generators/expression_generator.rs index b0e279a18e..cfaf1f9be9 100644 --- a/src/codegen/generators/expression_generator.rs +++ b/src/codegen/generators/expression_generator.rs @@ -168,6 +168,7 @@ impl<'ink, 'b> ExpressionCodeGenerator<'ink, 'b> { // we trust that the validator only passed us valid parameters (so left & right should be same type) return self.generate_expression(statement); } + let v = self .generate_expression_value(expression)? .as_r_value(self.llvm, self.get_load_name(expression)) @@ -763,12 +764,48 @@ impl<'ink, 'b> ExpressionCodeGenerator<'ink, 'b> { type_name: &str, param_statement: &AstNode, ) -> Result, Diagnostic> { - Ok(match self.index.find_effective_type_by_name(type_name) { - Some(type_info) if type_info.information.is_string() => { - self.generate_string_argument(type_info, param_statement)? + let Some(type_info) = self.index.find_effective_type_by_name(type_name) else { + return self.generate_expression(param_statement); + }; + + if type_info.is_string() { + return self.generate_string_argument(type_info, param_statement); + } + + // https://github.com/PLC-lang/rusty/issues/1037: + // This if-statement covers the case where we want to convert a pointer into its actual + // type, e.g. if an argument is passed into a function A by-ref (INOUT) which in turn is + // passed into another function B by-val (INPUT) then the pointer argument in function A has + // to be bit-cast into its actual type before passing it into function B. + if type_info.is_aggregate_type() && !type_info.is_vla() { + let deref = self.generate_expression_value(param_statement)?; + + if deref.get_basic_value_enum().is_pointer_value() { + let ty = self.llvm_index.get_associated_type(type_name)?; + let cast = self.llvm.builder.build_bitcast( + deref.get_basic_value_enum(), + ty.ptr_type(AddressSpace::from(ADDRESS_SPACE_GENERIC)), + "", + ); + + let load = self.llvm.builder.build_load( + cast.into_pointer_value(), + &self.get_load_name(param_statement).unwrap_or_default(), + ); + + if let Some(target_ty) = self.annotations.get_type_hint(param_statement, self.index) { + let actual_ty = self.annotations.get_type_or_void(param_statement, self.index); + let annotation = self.annotations.get(param_statement); + + return Ok(cast_if_needed!(self, target_ty, actual_ty, load, annotation)); + } + + return Ok(load); } - _ => self.generate_expression(param_statement)?, - }) + } + + // Fallback + self.generate_expression(param_statement) } /// Before passing a string to a function, it is copied to a new string with the diff --git a/src/codegen/tests/function_tests.rs b/src/codegen/tests/function_tests.rs index a01d117879..d12f525b5e 100644 --- a/src/codegen/tests/function_tests.rs +++ b/src/codegen/tests/function_tests.rs @@ -370,3 +370,36 @@ fn return_variable_in_nested_call() { // we want a call passing the return-variable as apointer (actually the adress as a LWORD) insta::assert_snapshot!(codegen(src)); } + +#[test] +fn argument_fed_by_ref_then_by_val() { + let result = codegen( + " + TYPE MyType : ARRAY[1..5] OF DWORD; END_TYPE + + FUNCTION main : DINT + VAR + arr : MyType; + END_VAR + + fn_by_ref(arr); + END_FUNCTION + + FUNCTION fn_by_ref : DINT + VAR_IN_OUT + arg_by_ref : MyType; + END_VAR + + fn_by_val(arg_by_ref); + END_FUNCTION + + FUNCTION fn_by_val : DINT + VAR_INPUT + arg_by_val : MyType; + END_VAR + END_FUNCTION + ", + ); + + insta::assert_snapshot!(result) +} diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__function_tests__argument_fed_by_ref_then_by_val.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__function_tests__argument_fed_by_ref_then_by_val.snap new file mode 100644 index 0000000000..d382b75e49 --- /dev/null +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__function_tests__argument_fed_by_ref_then_by_val.snap @@ -0,0 +1,49 @@ +--- +source: src/codegen/tests/function_tests.rs +expression: result +--- +; ModuleID = 'main' +source_filename = "main" + +define i32 @main() { +entry: + %main = alloca i32, align 4 + %arr = alloca [5 x i32], align 4 + %0 = bitcast [5 x i32]* %arr to i8* + call void @llvm.memset.p0i8.i64(i8* align 1 %0, i8 0, i64 ptrtoint ([5 x i32]* getelementptr ([5 x i32], [5 x i32]* null, i32 1) to i64), i1 false) + store i32 0, i32* %main, align 4 + %1 = bitcast [5 x i32]* %arr to i32* + %call = call i32 @fn_by_ref(i32* %1) + %main_ret = load i32, i32* %main, align 4 + ret i32 %main_ret +} + +define i32 @fn_by_ref(i32* %0) { +entry: + %fn_by_ref = alloca i32, align 4 + %arg_by_ref = alloca i32*, align 8 + store i32* %0, i32** %arg_by_ref, align 8 + store i32 0, i32* %fn_by_ref, align 4 + %deref = load i32*, i32** %arg_by_ref, align 8 + %1 = bitcast i32* %deref to [5 x i32]* + %load_arg_by_ref = load [5 x i32], [5 x i32]* %1, align 4 + %call = call i32 @fn_by_val([5 x i32] %load_arg_by_ref) + %fn_by_ref_ret = load i32, i32* %fn_by_ref, align 4 + ret i32 %fn_by_ref_ret +} + +define i32 @fn_by_val([5 x i32] %0) { +entry: + %fn_by_val = alloca i32, align 4 + %arg_by_val = alloca [5 x i32], align 4 + store [5 x i32] %0, [5 x i32]* %arg_by_val, align 4 + store i32 0, i32* %fn_by_val, align 4 + %fn_by_val_ret = load i32, i32* %fn_by_val, align 4 + ret i32 %fn_by_val_ret +} + +; Function Attrs: argmemonly nofree nounwind willreturn writeonly +declare void @llvm.memset.p0i8.i64(i8* nocapture writeonly, i8, i64, i1 immarg) #0 + +attributes #0 = { argmemonly nofree nounwind willreturn writeonly } + diff --git a/src/typesystem.rs b/src/typesystem.rs index 2a9bd3f4e4..e97cdd34d7 100644 --- a/src/typesystem.rs +++ b/src/typesystem.rs @@ -176,6 +176,10 @@ impl DataType { self.get_type_information().is_aggregate() } + pub fn is_string(&self) -> bool { + self.get_type_information().is_string() + } + pub fn get_nature(&self) -> TypeNature { self.nature } diff --git a/tests/correctness/functions.rs b/tests/correctness/functions.rs index 9fb9cc106d..3ab64d6154 100644 --- a/tests/correctness/functions.rs +++ b/tests/correctness/functions.rs @@ -1243,3 +1243,56 @@ fn sizeof_len() { assert_eq!(13, res); } + +#[test] +fn argument_passed_by_ref_then_by_val() { + #[repr(C)] + struct MainType { + arr: [i32; 5], + } + + let source = r" + TYPE MyType : ARRAY[1..5] OF DINT; END_TYPE + + PROGRAM main + VAR + arr : MyType; + END_VAR + + fn_by_ref(arr); + END_PROGRAM + + FUNCTION fn_by_ref : DINT + VAR_IN_OUT + arg_by_ref : MyType; + END_VAR + + // These SHOULD modify the underlying array passed from main + arg_by_ref[1] := 1; + arg_by_ref[2] := 2; + arg_by_ref[3] := 3; + arg_by_ref[4] := 4; + arg_by_ref[5] := 5; + + fn_by_val(arg_by_ref); + END_FUNCTION + + FUNCTION fn_by_val : DINT + VAR_INPUT + arg_by_val : MyType; + END_VAR + + // These should NOT modify the underlying array passed from main + arg_by_val[1] := 10; + arg_by_val[2] := 20; + arg_by_val[3] := 30; + arg_by_val[4] := 40; + arg_by_val[5] := 50; + END_FUNCTION + "; + + let mut maintype = MainType { arr: [0; 5] }; + let _: i32 = compile_and_run(source, &mut maintype); + + assert_eq!(maintype.arr, [1, 2, 3, 4, 5]); +} From a3c005556113ed1e5c78bfa42bb3fb13a40b23a3 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 15 Dec 2023 06:29:08 +0100 Subject: [PATCH 15/33] chore: Bump zerocopy from 0.7.28 to 0.7.31 (#1056) Bumps [zerocopy](https://github.com/google/zerocopy) from 0.7.28 to 0.7.31. - [Release notes](https://github.com/google/zerocopy/releases) - [Changelog](https://github.com/google/zerocopy/blob/main/CHANGELOG.md) - [Commits](https://github.com/google/zerocopy/compare/v0.7.28...v0.7.31) --- updated-dependencies: - dependency-name: zerocopy dependency-type: indirect ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- Cargo.lock | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 935cec6053..79a6f24017 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3609,18 +3609,18 @@ checksum = "09041cd90cf85f7f8b2df60c646f853b7f535ce68f85244eb6731cf89fa498ec" [[package]] name = "zerocopy" -version = "0.7.28" +version = "0.7.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7d6f15f7ade05d2a4935e34a457b936c23dc70a05cc1d97133dc99e7a3fe0f0e" +checksum = "1c4061bedbb353041c12f413700357bec76df2c7e2ca8e4df8bac24c6bf68e3d" dependencies = [ "zerocopy-derive", ] [[package]] name = "zerocopy-derive" -version = "0.7.28" +version = "0.7.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dbbad221e3f78500350ecbd7dfa4e63ef945c05f4c61cb7f4d3f84cd0bba649b" +checksum = "b3c129550b3e6de3fd0ba67ba5c81818f9805e58b8d7fee80a3a59d2c9fc601a" dependencies = [ "proc-macro2 1.0.70", "quote 1.0.33", From aa577c2be8844db554b2332f1655d1696988162d Mon Sep 17 00:00:00 2001 From: Volkan Date: Tue, 19 Dec 2023 13:50:30 +0100 Subject: [PATCH 16/33] feat(validation): Assignment suggestions for `=` operator (#1049) This commit adds a validation to identify binary expressions using the `=` (equal) operator with no effects. For example the following statement `foo = bar;` does nothing and the user probably meant to use a `:=` here, i.e. `foo := bar;`. Resolves https://github.com/PLC-lang/rusty/issues/939 --- compiler/plc_diagnostics/src/diagnostics.rs | 7 + ...ng__repeat_conditions_location_marked.snap | 8 +- ...ing__while_conditions_location_marked.snap | 4 +- ...ts__if_with_expression_generator_test.snap | 24 ++- ...en_tests__returning_early_in_function.snap | 4 +- ...ts__returning_early_in_function_block.snap | 4 +- ...de_gen_tests__while_loop_with_if_exit.snap | 8 +- ...ests__while_with_expression_statement.snap | 4 +- src/resolver.rs | 190 ++++++++---------- .../tests/resolve_expressions_tests.rs | 4 +- src/validation/statement.rs | 7 + ...on_for_equal_operation_with_no_effect.snap | 41 ++++ .../tests/variable_validation_tests.rs | 39 ++++ 13 files changed, 223 insertions(+), 121 deletions(-) create mode 100644 src/validation/tests/snapshots/rusty__validation__tests__variable_validation_tests__assignment_suggestion_for_equal_operation_with_no_effect.snap diff --git a/compiler/plc_diagnostics/src/diagnostics.rs b/compiler/plc_diagnostics/src/diagnostics.rs index 7f0593819a..db9b57cbd8 100644 --- a/compiler/plc_diagnostics/src/diagnostics.rs +++ b/compiler/plc_diagnostics/src/diagnostics.rs @@ -744,6 +744,13 @@ impl Diagnostic { err_no: ErrNo::var__invalid_enum_variant, } } + + pub fn assignment_instead_of_equal(range: SourceLocation) -> Diagnostic { + Diagnostic::ImprovementSuggestion { + message: "This statement has no effect, did you mean to use `:=`?".to_string(), + range: vec![range], + } + } } // CFC related diagnostics diff --git a/src/codegen/tests/debug_tests/snapshots/rusty__codegen__tests__debug_tests__expression_debugging__repeat_conditions_location_marked.snap b/src/codegen/tests/debug_tests/snapshots/rusty__codegen__tests__debug_tests__expression_debugging__repeat_conditions_location_marked.snap index f8b406a4e5..9f92bd5c61 100644 --- a/src/codegen/tests/debug_tests/snapshots/rusty__codegen__tests__debug_tests__expression_debugging__repeat_conditions_location_marked.snap +++ b/src/codegen/tests/debug_tests/snapshots/rusty__codegen__tests__debug_tests__expression_debugging__repeat_conditions_location_marked.snap @@ -15,8 +15,12 @@ entry: condition_check: ; preds = %while_body %load_myFunc = load i32, i32* %myFunc, align 4, !dbg !12 %tmpVar = icmp sgt i32 %load_myFunc, 10, !dbg !12 - %tmpVar1 = xor i1 %tmpVar, true, !dbg !12 - br i1 %tmpVar1, label %while_body, label %continue, !dbg !12 + %0 = zext i1 %tmpVar to i8, !dbg !12 + %1 = icmp ne i8 %0, 0, !dbg !12 + %tmpVar1 = xor i1 %1, true, !dbg !12 + %2 = zext i1 %tmpVar1 to i8, !dbg !12 + %3 = icmp ne i8 %2, 0, !dbg !12 + br i1 %3, label %while_body, label %continue, !dbg !12 while_body: ; preds = %entry, %condition_check store i32 1, i32* %myFunc, align 4, !dbg !11 diff --git a/src/codegen/tests/debug_tests/snapshots/rusty__codegen__tests__debug_tests__expression_debugging__while_conditions_location_marked.snap b/src/codegen/tests/debug_tests/snapshots/rusty__codegen__tests__debug_tests__expression_debugging__while_conditions_location_marked.snap index 088019ca7f..210e5d113c 100644 --- a/src/codegen/tests/debug_tests/snapshots/rusty__codegen__tests__debug_tests__expression_debugging__while_conditions_location_marked.snap +++ b/src/codegen/tests/debug_tests/snapshots/rusty__codegen__tests__debug_tests__expression_debugging__while_conditions_location_marked.snap @@ -15,7 +15,9 @@ entry: condition_check: ; preds = %entry, %while_body %load_myFunc = load i32, i32* %myFunc, align 4, !dbg !12 %tmpVar = icmp sgt i32 %load_myFunc, 1, !dbg !12 - br i1 %tmpVar, label %while_body, label %continue, !dbg !12 + %0 = zext i1 %tmpVar to i8, !dbg !12 + %1 = icmp ne i8 %0, 0, !dbg !12 + br i1 %1, label %while_body, label %continue, !dbg !12 while_body: ; preds = %condition_check store i32 1, i32* %myFunc, align 4, !dbg !11 diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__if_with_expression_generator_test.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__if_with_expression_generator_test.snap index d91b86c7c0..485cce3a48 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__if_with_expression_generator_test.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__if_with_expression_generator_test.snap @@ -15,22 +15,26 @@ entry: %b1 = getelementptr inbounds %prg, %prg* %0, i32 0, i32 1 %load_x = load i32, i32* %x, align 4 %tmpVar = icmp sgt i32 %load_x, 1 - br i1 %tmpVar, label %3, label %1 + %1 = zext i1 %tmpVar to i8 + %2 = icmp ne i8 %1, 0 + br i1 %2, label %5, label %3 -condition_body: ; preds = %3 +condition_body: ; preds = %5 %load_x1 = load i32, i32* %x, align 4 br label %continue -continue: ; preds = %condition_body, %3 +continue: ; preds = %condition_body, %5 ret void -1: ; preds = %entry +3: ; preds = %entry %load_b1 = load i8, i8* %b1, align 1 - %2 = icmp ne i8 %load_b1, 0 - br label %3 - -3: ; preds = %1, %entry - %4 = phi i1 [ %tmpVar, %entry ], [ %2, %1 ] - br i1 %4, label %condition_body, label %continue + %4 = icmp ne i8 %load_b1, 0 + br label %5 + +5: ; preds = %3, %entry + %6 = phi i1 [ %2, %entry ], [ %4, %3 ] + %7 = zext i1 %6 to i8 + %8 = icmp ne i8 %7, 0 + br i1 %8, label %condition_body, label %continue } diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__returning_early_in_function.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__returning_early_in_function.snap index 3681b4b66b..d6be89e902 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__returning_early_in_function.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__returning_early_in_function.snap @@ -14,7 +14,9 @@ entry: %load_n = load i8, i8* %n, align 1 %1 = sext i8 %load_n to i32 %tmpVar = icmp slt i32 %1, 10 - br i1 %tmpVar, label %condition_body, label %continue + %2 = zext i1 %tmpVar to i8 + %3 = icmp ne i8 %2, 0 + br i1 %3, label %condition_body, label %continue condition_body: ; preds = %entry %smaller_than_ten_ret = load i16, i16* %smaller_than_ten, align 2 diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__returning_early_in_function_block.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__returning_early_in_function_block.snap index e26fa8c863..10f321a84d 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__returning_early_in_function_block.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__returning_early_in_function_block.snap @@ -15,7 +15,9 @@ entry: %load_n = load i8, i8* %n, align 1 %1 = sext i8 %load_n to i32 %tmpVar = icmp slt i32 %1, 10 - br i1 %tmpVar, label %condition_body, label %continue + %2 = zext i1 %tmpVar to i8 + %3 = icmp ne i8 %2, 0 + br i1 %3, label %condition_body, label %continue condition_body: ; preds = %entry ret void diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__while_loop_with_if_exit.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__while_loop_with_if_exit.snap index 169623959a..b4c246c497 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__while_loop_with_if_exit.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__while_loop_with_if_exit.snap @@ -17,7 +17,9 @@ entry: condition_check: ; preds = %entry, %continue3 %load_x = load i32, i32* %x, align 4 %tmpVar = icmp slt i32 %load_x, 20 - br i1 %tmpVar, label %while_body, label %continue + %1 = zext i1 %tmpVar to i8 + %2 = icmp ne i8 %1, 0 + br i1 %2, label %while_body, label %continue while_body: ; preds = %condition_check %load_x1 = load i32, i32* %x, align 4 @@ -25,7 +27,9 @@ while_body: ; preds = %condition_check store i32 %tmpVar2, i32* %x, align 4 %load_x4 = load i32, i32* %x, align 4 %tmpVar5 = icmp sge i32 %load_x4, 10 - br i1 %tmpVar5, label %condition_body, label %continue3 + %3 = zext i1 %tmpVar5 to i8 + %4 = icmp ne i8 %3, 0 + br i1 %4, label %condition_body, label %continue3 continue: ; preds = %condition_body, %condition_check ret void diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__while_with_expression_statement.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__while_with_expression_statement.snap index 7301464b95..93829a14df 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__while_with_expression_statement.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__while_with_expression_statement.snap @@ -18,7 +18,9 @@ condition_check: ; preds = %entry, %while_body %load_x = load i8, i8* %x, align 1 %1 = zext i8 %load_x to i32 %tmpVar = icmp eq i32 %1, 0 - br i1 %tmpVar, label %while_body, label %continue + %2 = zext i1 %tmpVar to i8 + %3 = icmp ne i8 %2, 0 + br i1 %3, label %while_body, label %continue while_body: ; preds = %condition_check %load_x1 = load i8, i8* %x, align 1 diff --git a/src/resolver.rs b/src/resolver.rs index d20f2c5606..82fe52b63e 100644 --- a/src/resolver.rs +++ b/src/resolver.rs @@ -75,9 +75,12 @@ pub struct VisitorContext<'s> { /// e.g. true for `a.b.c` if either a,b or c is declared in a constant block constant: bool, - /// true the visitor entered a body (so no declarations) + /// true if the visitor entered a body (so no declarations) in_body: bool, + /// true if the visitor entered a control statement + in_control: bool, + pub id_provider: IdProvider, // what's the current strategy for resolving @@ -87,80 +90,54 @@ pub struct VisitorContext<'s> { impl<'s> VisitorContext<'s> { /// returns a copy of the current context and changes the `current_qualifier` to the given qualifier fn with_qualifier(&self, qualifier: String) -> VisitorContext<'s> { - VisitorContext { - pou: self.pou, - qualifier: Some(qualifier), - lhs: self.lhs, - constant: false, - in_body: self.in_body, - id_provider: self.id_provider.clone(), - resolve_strategy: self.resolve_strategy.clone(), - } + let mut ctx = self.clone(); + ctx.qualifier = Some(qualifier); + ctx.constant = false; + ctx } /// returns a copy of the current context and changes the `current_pou` to the given pou fn with_pou(&self, pou: &'s str) -> VisitorContext<'s> { - VisitorContext { - pou: Some(pou), - qualifier: self.qualifier.clone(), - lhs: self.lhs, - constant: false, - in_body: self.in_body, - id_provider: self.id_provider.clone(), - resolve_strategy: self.resolve_strategy.clone(), - } + let mut ctx = self.clone(); + ctx.pou = Some(pou); + ctx.constant = false; + ctx } /// returns a copy of the current context and changes the `lhs_pou` to the given pou fn with_lhs(&self, lhs_pou: &'s str) -> VisitorContext<'s> { - VisitorContext { - pou: self.pou, - qualifier: self.qualifier.clone(), - lhs: Some(lhs_pou), - constant: false, - in_body: self.in_body, - id_provider: self.id_provider.clone(), - resolve_strategy: self.resolve_strategy.clone(), - } + let mut ctx = self.clone(); + ctx.lhs = Some(lhs_pou); + ctx.constant = false; + ctx } /// returns a copy of the current context and changes the `is_call` to true fn with_const(&self, const_state: bool) -> VisitorContext<'s> { - VisitorContext { - pou: self.pou, - qualifier: self.qualifier.clone(), - lhs: self.lhs, - constant: const_state, - in_body: self.in_body, - id_provider: self.id_provider.clone(), - resolve_strategy: self.resolve_strategy.clone(), - } + let mut ctx = self.clone(); + ctx.constant = const_state; + ctx } // returns a copy of the current context and sets the in_body field to true fn enter_body(&self) -> Self { - VisitorContext { - pou: self.pou, - qualifier: self.qualifier.clone(), - lhs: self.lhs, - constant: self.constant, - in_body: true, - id_provider: self.id_provider.clone(), - resolve_strategy: self.resolve_strategy.clone(), - } + let mut ctx = self.clone(); + ctx.in_body = true; + ctx + } + + fn enter_control(&self) -> Self { + let mut ctx = self.clone(); + ctx.in_control = true; + ctx } // returns a copy of the current context and sets the resolve_strategy field to the given strategies fn with_resolving_strategy(&self, resolve_strategy: Vec) -> Self { - VisitorContext { - pou: self.pou, - qualifier: self.qualifier.clone(), - lhs: self.lhs, - constant: self.constant, - in_body: true, - id_provider: self.id_provider.clone(), - resolve_strategy, - } + let mut ctx = self.clone(); + ctx.in_body = true; + ctx.resolve_strategy = resolve_strategy; + ctx } fn is_in_a_body(&self) -> bool { @@ -762,6 +739,7 @@ impl<'i> TypeAnnotator<'i> { in_body: false, id_provider, resolve_strategy: ResolvingScope::default_scopes(), + in_control: false, }; for global_variable in unit.global_vars.iter().flat_map(|it| it.variables.iter()) { @@ -1244,54 +1222,56 @@ impl<'i> TypeAnnotator<'i> { self.visit_statement(ctx, expr); self.inherit_annotations(statement, expr); } - AstStatement::ControlStatement(AstControlStatement::If(stmt), ..) => { - stmt.blocks.iter().for_each(|b| { - self.visit_statement(ctx, b.condition.as_ref()); - b.body.iter().for_each(|s| self.visit_statement(ctx, s)); - }); - stmt.else_block.iter().for_each(|e| self.visit_statement(ctx, e)); - } - AstStatement::ControlStatement(AstControlStatement::ForLoop(stmt), ..) => { - visit_all_statements!(self, ctx, &stmt.counter, &stmt.start, &stmt.end); - if let Some(by_step) = &stmt.by_step { - self.visit_statement(ctx, by_step); - } - //Hint annotate start, end and step with the counter's real type - if let Some(type_name) = self - .annotation_map - .get_type(&stmt.counter, self.index) - .map(typesystem::DataType::get_name) - { - let annotation = StatementAnnotation::value(type_name); - self.annotation_map.annotate_type_hint(&stmt.start, annotation.clone()); - self.annotation_map.annotate_type_hint(&stmt.end, annotation.clone()); - if let Some(by_step) = &stmt.by_step { - self.annotation_map.annotate_type_hint(by_step, annotation); + AstStatement::ControlStatement(control) => { + match control { + AstControlStatement::If(stmt) => { + stmt.blocks.iter().for_each(|b| { + self.visit_statement(&ctx.enter_control(), b.condition.as_ref()); + b.body.iter().for_each(|s| self.visit_statement(ctx, s)); + }); + stmt.else_block.iter().for_each(|e| self.visit_statement(ctx, e)); } - } - stmt.body.iter().for_each(|s| self.visit_statement(ctx, s)); - } - AstStatement::ControlStatement(AstControlStatement::WhileLoop(stmt), ..) - | AstStatement::ControlStatement(AstControlStatement::RepeatLoop(stmt), ..) => { - self.visit_statement(ctx, &stmt.condition); - stmt.body.iter().for_each(|s| self.visit_statement(ctx, s)); - } - AstStatement::ControlStatement(AstControlStatement::Case(stmt), ..) => { - self.visit_statement(ctx, &stmt.selector); - let selector_type = self.annotation_map.get_type(&stmt.selector, self.index).cloned(); - stmt.case_blocks.iter().for_each(|b| { - self.visit_statement(ctx, b.condition.as_ref()); - if let Some(selector_type) = &selector_type { - self.update_expected_types(selector_type, b.condition.as_ref()); + AstControlStatement::ForLoop(stmt) => { + visit_all_statements!(self, ctx, &stmt.counter, &stmt.start, &stmt.end); + if let Some(by_step) = &stmt.by_step { + self.visit_statement(ctx, by_step); + } + //Hint annotate start, end and step with the counter's real type + if let Some(type_name) = self + .annotation_map + .get_type(&stmt.counter, self.index) + .map(typesystem::DataType::get_name) + { + let annotation = StatementAnnotation::value(type_name); + self.annotation_map.annotate_type_hint(&stmt.start, annotation.clone()); + self.annotation_map.annotate_type_hint(&stmt.end, annotation.clone()); + if let Some(by_step) = &stmt.by_step { + self.annotation_map.annotate_type_hint(by_step, annotation); + } + } + stmt.body.iter().for_each(|s| self.visit_statement(ctx, s)); + } + AstControlStatement::WhileLoop(stmt) | AstControlStatement::RepeatLoop(stmt) => { + self.visit_statement(&ctx.enter_control(), &stmt.condition); + stmt.body.iter().for_each(|s| self.visit_statement(ctx, s)); + } + AstControlStatement::Case(stmt) => { + self.visit_statement(ctx, &stmt.selector); + let selector_type = self.annotation_map.get_type(&stmt.selector, self.index).cloned(); + stmt.case_blocks.iter().for_each(|b| { + self.visit_statement(ctx, b.condition.as_ref()); + if let Some(selector_type) = &selector_type { + self.update_expected_types(selector_type, b.condition.as_ref()); + } + b.body.iter().for_each(|s| self.visit_statement(ctx, s)); + }); + stmt.else_block.iter().for_each(|s| self.visit_statement(ctx, s)); } - b.body.iter().for_each(|s| self.visit_statement(ctx, s)); - }); - stmt.else_block.iter().for_each(|s| self.visit_statement(ctx, s)); + } } + AstStatement::CaseCondition(condition, ..) => self.visit_statement(ctx, condition), - _ => { - self.visit_statement_expression(ctx, statement); - } + _ => self.visit_statement_expression(ctx, statement), } } @@ -1399,7 +1379,15 @@ impl<'i> TypeAnnotator<'i> { }; if let Some(statement_type) = statement_type { - self.annotate(statement, StatementAnnotation::value(statement_type)); + self.annotate(statement, StatementAnnotation::value(statement_type.clone())); + + // https://github.com/PLC-lang/rusty/issues/939: We rely on type-hints in order + // to identify `=` operations that have no effect (e.g. `foo = bar;`) hence + // type-hint the conditions of control statements to eliminate false-positives. + if ctx.in_control { + self.annotation_map + .annotate_type_hint(statement, StatementAnnotation::value(statement_type)) + } } } AstStatement::UnaryExpression(data, ..) => { @@ -1435,7 +1423,7 @@ impl<'i> TypeAnnotator<'i> { visit_all_statements!(self, ctx, &data.start, &data.end); } AstStatement::Assignment(data, ..) => { - self.visit_statement(ctx, &data.right); + self.visit_statement(&ctx.enter_control(), &data.right); if let Some(lhs) = ctx.lhs { //special context for left hand side self.visit_statement(&ctx.with_pou(lhs).with_lhs(lhs), &data.left); diff --git a/src/resolver/tests/resolve_expressions_tests.rs b/src/resolver/tests/resolve_expressions_tests.rs index 4997f48006..c9b39f9fd0 100644 --- a/src/resolver/tests/resolve_expressions_tests.rs +++ b/src/resolver/tests/resolve_expressions_tests.rs @@ -400,7 +400,7 @@ fn addition_subtraction_expression_with_pointers_resolves_to_pointer_type() { if let AstNode { stmt: AstStatement::BinaryExpression(BinaryExpression { left, .. }), .. } = &**addition { - assert_type_and_hint!(&annotations, &index, left, "__PRG_a", None); + assert_type_and_hint!(&annotations, &index, left, "__PRG_a", Some("__PRG_a")); } } if let AstNode { stmt: AstStatement::Assignment(Assignment { right: addition, .. }), .. } = &statements[2] @@ -462,7 +462,7 @@ fn complex_expressions_resolves_types_for_literals_directly() { // c assert_type_and_hint!(&annotations, &index, c, INT_TYPE, Some(DINT_TYPE)); // (b + USINT#7) - assert_type_and_hint!(&annotations, &index, left, DINT_TYPE, None); + assert_type_and_hint!(&annotations, &index, left, DINT_TYPE, Some(DINT_TYPE)); let AstStatement::ParenExpression(left) = left.get_stmt() else { panic!() }; if let AstNode { diff --git a/src/validation/statement.rs b/src/validation/statement.rs index a1b1d83b17..5ee8202ed4 100644 --- a/src/validation/statement.rs +++ b/src/validation/statement.rs @@ -524,6 +524,13 @@ fn visit_binary_expression( context: &ValidationContext, ) { match operator { + Operator::Equal => { + if context.annotations.get_type_hint(statement, context.index).is_none() { + validator.push_diagnostic(Diagnostic::assignment_instead_of_equal(statement.get_location())); + } + + validate_binary_expression(validator, statement, operator, left, right, context) + } Operator::NotEqual => { validate_binary_expression(validator, statement, &Operator::Equal, left, right, context) } diff --git a/src/validation/tests/snapshots/rusty__validation__tests__variable_validation_tests__assignment_suggestion_for_equal_operation_with_no_effect.snap b/src/validation/tests/snapshots/rusty__validation__tests__variable_validation_tests__assignment_suggestion_for_equal_operation_with_no_effect.snap new file mode 100644 index 0000000000..b3b3e13c1b --- /dev/null +++ b/src/validation/tests/snapshots/rusty__validation__tests__variable_validation_tests__assignment_suggestion_for_equal_operation_with_no_effect.snap @@ -0,0 +1,41 @@ +--- +source: src/validation/tests/variable_validation_tests.rs +expression: diagnostics +--- +warning: This statement has no effect, did you mean to use `:=`? + ┌─ :24:13 + │ +24 │ value = 1; + │ ^^^^^^^^^ This statement has no effect, did you mean to use `:=`? + +warning: This statement has no effect, did you mean to use `:=`? + ┌─ :25:13 + │ +25 │ value = condition AND condition; + │ ^^^^^^^^^^^^^^^^^ This statement has no effect, did you mean to use `:=`? + +warning: This statement has no effect, did you mean to use `:=`? + ┌─ :26:13 + │ +26 │ value = condition AND (condition = TRUE); + │ ^^^^^^^^^^^^^^^^^ This statement has no effect, did you mean to use `:=`? + +warning: This statement has no effect, did you mean to use `:=`? + ┌─ :26:36 + │ +26 │ value = condition AND (condition = TRUE); + │ ^^^^^^^^^^^^^^^^ This statement has no effect, did you mean to use `:=`? + +warning: This statement has no effect, did you mean to use `:=`? + ┌─ :28:26 + │ +28 │ IF TRUE THEN value = 1; END_IF + │ ^^^^^^^^^ This statement has no effect, did you mean to use `:=`? + +warning: This statement has no effect, did you mean to use `:=`? + ┌─ :29:27 + │ +29 │ WHILE TRUE DO value = 1; END_WHILE + │ ^^^^^^^^^ This statement has no effect, did you mean to use `:=`? + + diff --git a/src/validation/tests/variable_validation_tests.rs b/src/validation/tests/variable_validation_tests.rs index a054c7d922..1ac87a2004 100644 --- a/src/validation/tests/variable_validation_tests.rs +++ b/src/validation/tests/variable_validation_tests.rs @@ -380,3 +380,42 @@ fn type_initializers_in_structs_are_validated() { assert_snapshot!(diagnostics); } + +#[test] +fn assignment_suggestion_for_equal_operation_with_no_effect() { + let diagnostics = parse_and_validate_buffered( + " + PROGRAM main + VAR + value : DINT; + condition : BOOL; + + // These Should work + arr_dint : ARRAY[0..5] OF DINT := [1 = 1, 2, 3, 4, 5 = 5]; + arr_bool : ARRAY[1..5] OF BOOL := [1 = 1, 2 = 2, 3 = 3, 4 = 4, 5 = 10]; + END_VAR + + // These should work + value := (condition = TRUE); + + IF condition = TRUE THEN (* ... *) END_IF + IF (condition = TRUE) THEN (* ... *) END_IF + IF ((condition = TRUE)) THEN (* ... *) END_IF + + IF condition = TRUE AND condition = TRUE THEN (* ... *) END_IF + IF (condition = TRUE) AND (condition = TRUE) THEN (* ... *) END_IF + IF ((condition = TRUE) AND (condition = TRUE)) THEN (* ... *) END_IF + + // These should NOT work + value = 1; + value = condition AND condition; + value = condition AND (condition = TRUE); + + IF TRUE THEN value = 1; END_IF + WHILE TRUE DO value = 1; END_WHILE + END_PROGRAM + ", + ); + + assert_snapshot!(diagnostics); +} From a140882b9faa7f814f5f63bd043efd37caa64746 Mon Sep 17 00:00:00 2001 From: Michael <78988079+mhasel@users.noreply.github.com> Date: Tue, 26 Dec 2023 13:15:22 +0100 Subject: [PATCH 17/33] fix: dont report generic implementations for duplicates (#1054) *fix: no longer validate generic dupes --- .../generators/expression_generator.rs | 9 ------ src/validation/global.rs | 18 ++++++++--- .../tests/duplicates_validation_test.rs | 32 +++++++++++++++++++ ...ation_test__duplicate_pous_validation.snap | 2 +- 4 files changed, 47 insertions(+), 14 deletions(-) diff --git a/src/codegen/generators/expression_generator.rs b/src/codegen/generators/expression_generator.rs index cfaf1f9be9..3b7f34588a 100644 --- a/src/codegen/generators/expression_generator.rs +++ b/src/codegen/generators/expression_generator.rs @@ -334,7 +334,6 @@ impl<'ink, 'b> ExpressionCodeGenerator<'ink, 'b> { let reference = cast_if_needed!(self, target_type, self.get_type_hint_for(index)?, reference, None) .into_int_value(); - // let reference = reference.into_int_value(); //Multiply by the bitwitdh if access.get_bit_width() > 1 { let bitwidth = @@ -430,14 +429,6 @@ impl<'ink, 'b> ExpressionCodeGenerator<'ink, 'b> { // if the function is builtin, generate a basic value enum for it if let Some(builtin) = self.index.get_builtin_function(implementation_name) { // adr, ref, etc. - // let parameters_list = if let Some(StatementAnnotation::ReplacementAst { statement }) = - // self.annotations.get(operator) - // { - // statement.get_as_list() - // } else { - // parameters_list - // }; - return builtin.codegen(self, parameters_list.as_slice(), operator.get_location()); } diff --git a/src/validation/global.rs b/src/validation/global.rs index aef55d6c56..6672334fde 100644 --- a/src/validation/global.rs +++ b/src/validation/global.rs @@ -153,22 +153,27 @@ impl GlobalValidator { .unwrap_or(false) }) .map(|it| (it.get_name(), &it.source_location)); - let all_prgs_and_funcs = index + let all_prgs = index .get_pous() .values() .filter(|p| { matches!( p, PouIndexEntry::Program { .. } - | PouIndexEntry::Function { .. } | PouIndexEntry::Method { .. } | PouIndexEntry::Action { .. } ) }) .map(|it| (it.get_name(), it.get_location())); + let all_funcs = index + .get_pous() + .values() + .filter(|p| p.is_function() && !p.is_generic()) + .map(|it| (it.get_name(), it.get_location())); + self.check_uniqueness_of_cluster( - all_fb_instances.chain(all_prgs_and_funcs), + all_fb_instances.chain(all_prgs).chain(all_funcs), Some("Ambiguous callable symbol."), ); } @@ -186,7 +191,12 @@ impl GlobalValidator { .entries() .filter(|(_, entries_per_name)| entries_per_name.iter().filter(only_toplevel_pous).count() > 1) .map(|(name, pous)| { - (name.as_str(), pous.iter().filter(only_toplevel_pous).map(|p| p.get_location())) + ( + name.as_str(), + pous.iter() + .filter(|p| only_toplevel_pous(p) && !p.is_generic()) + .map(|p| p.get_location()), + ) }); for (name, cluster) in pou_clusters { diff --git a/src/validation/tests/duplicates_validation_test.rs b/src/validation/tests/duplicates_validation_test.rs index a4305485b6..2c20be45da 100644 --- a/src/validation/tests/duplicates_validation_test.rs +++ b/src/validation/tests/duplicates_validation_test.rs @@ -484,6 +484,38 @@ fn duplicate_with_generic() { assert_eq!(diagnostics, vec![]); } +#[test] +fn generics_with_duplicate_symbol_dont_err() { + // GIVEN a builtin function with the signature + // FUNCTION ADD : T + // VAR_INPUT + // args: {sized} T...; + // END_VAR + // END_FUNCTION + + // WHEN it is indexed and validated with other generic functions with the same name + let diagnostics = parse_and_validate( + r#" + FUNCTION ADD < T1: ANY, T2: ANY >: T1 + VAR_INPUT + IN1: T1; + IN2: T2; + END_VAR + END_FUNCTION + + FUNCTION ADD < K: ANY, V: ANY > : K + VAR_INPUT + IN1: K; + IN2: V; + END_VAR + END_FUNCTION + "#, + ); + + // THEN there should be no duplication diagnostics + assert_eq!(diagnostics, vec![]); +} + // #[test] // fn duplicate_with_generic_ir() { // // GIVEN several files with calls to a generic function diff --git a/src/validation/tests/snapshots/rusty__validation__tests__duplicates_validation_test__duplicate_pous_validation.snap b/src/validation/tests/snapshots/rusty__validation__tests__duplicates_validation_test__duplicate_pous_validation.snap index 32f0d03973..31edd25c4d 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__duplicates_validation_test__duplicate_pous_validation.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__duplicates_validation_test__duplicate_pous_validation.snap @@ -2,8 +2,8 @@ source: src/validation/tests/duplicates_validation_test.rs expression: res --- -SyntaxError { message: "foo: Ambiguous callable symbol.", range: [SourceLocation { span: Range(TextLocation { line: 1, column: 24, offset: 25 }..TextLocation { line: 1, column: 27, offset: 28 }) }, SourceLocation { span: Range(TextLocation { line: 3, column: 24, offset: 74 }..TextLocation { line: 3, column: 27, offset: 77 }) }], err_no: duplicate_symbol } SyntaxError { message: "foo: Ambiguous callable symbol.", range: [SourceLocation { span: Range(TextLocation { line: 3, column: 24, offset: 74 }..TextLocation { line: 3, column: 27, offset: 77 }) }, SourceLocation { span: Range(TextLocation { line: 1, column: 24, offset: 25 }..TextLocation { line: 1, column: 27, offset: 28 }) }], err_no: duplicate_symbol } +SyntaxError { message: "foo: Ambiguous callable symbol.", range: [SourceLocation { span: Range(TextLocation { line: 1, column: 24, offset: 25 }..TextLocation { line: 1, column: 27, offset: 28 }) }, SourceLocation { span: Range(TextLocation { line: 3, column: 24, offset: 74 }..TextLocation { line: 3, column: 27, offset: 77 }) }], err_no: duplicate_symbol } SyntaxError { message: "foo: Duplicate symbol.", range: [SourceLocation { span: Range(TextLocation { line: 1, column: 24, offset: 25 }..TextLocation { line: 1, column: 27, offset: 28 }) }, SourceLocation { span: Range(TextLocation { line: 3, column: 24, offset: 74 }..TextLocation { line: 3, column: 27, offset: 77 }) }, SourceLocation { span: Range(TextLocation { line: 5, column: 24, offset: 116 }..TextLocation { line: 5, column: 27, offset: 119 }) }], err_no: duplicate_symbol } SyntaxError { message: "foo: Duplicate symbol.", range: [SourceLocation { span: Range(TextLocation { line: 3, column: 24, offset: 74 }..TextLocation { line: 3, column: 27, offset: 77 }) }, SourceLocation { span: Range(TextLocation { line: 1, column: 24, offset: 25 }..TextLocation { line: 1, column: 27, offset: 28 }) }, SourceLocation { span: Range(TextLocation { line: 5, column: 24, offset: 116 }..TextLocation { line: 5, column: 27, offset: 119 }) }], err_no: duplicate_symbol } SyntaxError { message: "foo: Duplicate symbol.", range: [SourceLocation { span: Range(TextLocation { line: 5, column: 24, offset: 116 }..TextLocation { line: 5, column: 27, offset: 119 }) }, SourceLocation { span: Range(TextLocation { line: 1, column: 24, offset: 25 }..TextLocation { line: 1, column: 27, offset: 28 }) }, SourceLocation { span: Range(TextLocation { line: 3, column: 24, offset: 74 }..TextLocation { line: 3, column: 27, offset: 77 }) }], err_no: duplicate_symbol } From cfd43d7475dbcd4c3d30a0dbe9ecb638b9e7f22c Mon Sep 17 00:00:00 2001 From: Volkan Date: Wed, 27 Dec 2023 08:34:03 +0100 Subject: [PATCH 18/33] chore: Add "profiling" build profile (#1060) Building with the given profile can be accomplished via `cargo build --profile profiling` --- .cargo/config.toml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.cargo/config.toml b/.cargo/config.toml index 61e413fce5..8d072bbda0 100644 --- a/.cargo/config.toml +++ b/.cargo/config.toml @@ -15,3 +15,7 @@ rustflags = [ "link-arg=--target=aarch64-linux-gnu", ] linker = "clang" + +[profile.profiling] +inherits = "release" +debug = true From dd30d8d96a22f35473c281b3c1fe4194d74eba57 Mon Sep 17 00:00:00 2001 From: Volkan Date: Wed, 27 Dec 2023 09:11:28 +0100 Subject: [PATCH 19/33] fix(validation): Don't suggest brackets for call statements when dealing with arrays (#1059) Previously code like `my_arr := function_returning_array();` would trigger a validation message telling the user to wrap the call in bracket, i.e. `my_arr := [function_returning_array()];` which is incorrect. This commit changes this behavior. --- compiler/plc_ast/src/ast.rs | 4 + src/validation/array.rs | 101 ++++++++++-------- src/validation/statement.rs | 7 +- src/validation/tests/array_validation_test.rs | 26 +++++ ..._test__array_assignment_function_call.snap | 17 +++ src/validation/variable.rs | 4 +- 6 files changed, 106 insertions(+), 53 deletions(-) create mode 100644 src/validation/tests/snapshots/rusty__validation__tests__array_validation_test__array_assignment_function_call.snap diff --git a/compiler/plc_ast/src/ast.rs b/compiler/plc_ast/src/ast.rs index bd498cf64a..a1dfaae1fe 100644 --- a/compiler/plc_ast/src/ast.rs +++ b/compiler/plc_ast/src/ast.rs @@ -846,6 +846,10 @@ impl AstNode { matches!(self.stmt, AstStatement::ReferenceExpr(..)) } + pub fn is_call(&self) -> bool { + matches!(self.stmt, AstStatement::CallStatement(..)) + } + pub fn is_hardware_access(&self) -> bool { matches!(self.stmt, AstStatement::HardwareAccess(..)) } diff --git a/src/validation/array.rs b/src/validation/array.rs index ab6f9ef523..2f0efdafe6 100644 --- a/src/validation/array.rs +++ b/src/validation/array.rs @@ -19,31 +19,42 @@ use crate::{resolver::AnnotationMap, typesystem::DataTypeInformation}; use super::{ValidationContext, Validator, Validators}; -/// Indicates whether an array was defined in a VAR block or a POU body -#[derive(Debug)] -pub(super) enum Wrapper<'a> { +/// Indicates whether an array was assigned in a VAR block or a POU body +#[derive(Debug, Clone, Copy)] +pub(super) enum StatementWrapper<'a> { Statement(&'a AstNode), Variable(&'a Variable), } -pub(super) fn validate_array_assignment( +impl<'a> From<&'a AstNode> for StatementWrapper<'a> { + fn from(value: &'a AstNode) -> Self { + Self::Statement(value) + } +} + +impl<'a> From<&'a Variable> for StatementWrapper<'a> { + fn from(value: &'a Variable) -> Self { + Self::Variable(value) + } +} + +pub(super) fn validate_array_assignment<'a, T, S>( validator: &mut Validator, context: &ValidationContext, - wrapper: Wrapper, -) { - let Some(lhs_type) = wrapper.datatype_info_lhs(context) else { - return; - }; - let Some(rhs_stmt) = wrapper.get_rhs() else { - return; - }; - - if !lhs_type.is_array() { + statement: S, +) where + T: AnnotationMap, + S: Into> + Copy, +{ + let Some(rhs_stmt) = statement.into().rhs_statement() else { return }; + let Some(lhs_info) = statement.into().lhs_info(context) else { return }; + + if !lhs_info.is_array() { return; } - validate_array(validator, context, lhs_type, rhs_stmt); - validate_array_of_structs(validator, context, lhs_type, rhs_stmt); + validate_array(validator, context, lhs_info, rhs_stmt); + validate_array_of_structs(validator, context, lhs_info, rhs_stmt); } fn validate_array( @@ -53,14 +64,13 @@ fn validate_array( rhs_stmt: &AstNode, ) { let stmt_rhs = peel(rhs_stmt); - let stmt_rhs = peel(stmt_rhs); - if !(stmt_rhs.is_literal_array() || stmt_rhs.is_reference()) { + if !(stmt_rhs.is_literal_array() || stmt_rhs.is_reference() || stmt_rhs.is_call()) { validator.push_diagnostic(Diagnostic::array_assignment(stmt_rhs.get_location())); return; // Return here, because array size validation is error-prone with incorrect assignments } let len_lhs = lhs_type.get_array_length(context.index).unwrap_or(0); - let len_rhs = statement_to_array_length(stmt_rhs); + let len_rhs = statement_to_array_length(context, stmt_rhs); if len_lhs == 0 { return; @@ -79,23 +89,14 @@ fn validate_array_of_structs( lhs_type: &DataTypeInformation, rhs_stmt: &AstNode, ) { - let Some(array_type_name) = lhs_type.get_inner_array_type_name() else { - return; - }; - let Some(dti) = context.index.find_effective_type_by_name(array_type_name) else { - return; - }; - + let Some(array_type_name) = lhs_type.get_inner_array_type_name() else { return }; + let Some(dti) = context.index.find_effective_type_by_name(array_type_name) else { return }; if !dti.is_struct() { return; } - let AstStatement::Literal(AstLiteral::Array(array)) = rhs_stmt.get_stmt() else { - return; - }; - let Some(elements) = array.elements().map(AstNode::get_stmt) else { - return; - }; + let AstStatement::Literal(AstLiteral::Array(array)) = rhs_stmt.get_stmt() else { return }; + let Some(elements) = array.elements().map(AstNode::get_stmt) else { return }; match elements { AstStatement::ExpressionList(expressions) => { @@ -115,53 +116,61 @@ fn validate_array_of_structs( /// Takes an [`AstStatementKind`] and returns its length as if it was an array. For example calling this function /// on an expression-list such as `[(...), (...)]` would return 2. -fn statement_to_array_length(statement: &AstNode) -> usize { +fn statement_to_array_length(context: &ValidationContext, statement: &AstNode) -> usize { match statement.get_stmt() { - AstStatement::ExpressionList { .. } => 1, - AstStatement::ParenExpression(_) => 1, - AstStatement::MultipliedStatement(data) => data.multiplier as usize, AstStatement::Literal(AstLiteral::Array(arr)) => match arr.elements() { Some(AstNode { stmt: AstStatement::ExpressionList(expressions), .. }) => { - expressions.iter().map(statement_to_array_length).sum::() + expressions.iter().map(|it| statement_to_array_length(context, it)).sum::() } - Some(any) => statement_to_array_length(any), + Some(any) => statement_to_array_length(context, any), None => 0, }, + AstStatement::CallStatement(_) => context + .annotations + .get_type(statement, context.index) + .and_then(|it| it.information.get_array_length(context.index)) + .unwrap_or(0), + + AstStatement::MultipliedStatement(data) => data.multiplier as usize, + AstStatement::ExpressionList { .. } | AstStatement::ParenExpression(_) => 1, + // Any literal other than an array can be counted as 1 AstStatement::Literal { .. } => 1, _any => { // XXX: Not sure what else could be in here - log::warn!("Array size-counting for {statement:?} not covered; validation _might_ be wrong"); + log::debug!("Array size-counting for {statement:?} not covered; validation _might_ be wrong"); 0 } } } -impl<'a> Wrapper<'a> { - fn get_rhs(&self) -> Option<&'a AstNode> { +impl<'a> StatementWrapper<'a> { + fn rhs_statement(&self) -> Option<&'a AstNode> { match self { - Wrapper::Statement(AstNode { stmt: AstStatement::Assignment(data), .. }) => Some(&data.right), - Wrapper::Variable(variable) => variable.initializer.as_ref(), + StatementWrapper::Statement(AstNode { stmt: AstStatement::Assignment(data), .. }) => { + Some(&data.right) + } + StatementWrapper::Variable(variable) => variable.initializer.as_ref(), _ => None, } } - fn datatype_info_lhs(&self, context: &'a ValidationContext) -> Option<&'a DataTypeInformation> + fn lhs_info(&self, context: &'a ValidationContext) -> Option<&'a DataTypeInformation> where T: AnnotationMap, { match self { - Wrapper::Statement(statement) => { + StatementWrapper::Statement(statement) => { let AstNode { stmt: AstStatement::Assignment(data), .. } = statement else { return None; }; context.annotations.get_type(&data.left, context.index).map(|it| it.get_type_information()) } - Wrapper::Variable(variable) => variable + StatementWrapper::Variable(variable) => variable .data_type_declaration .get_referenced_type() .and_then(|it| context.index.find_effective_type_info(&it)), diff --git a/src/validation/statement.rs b/src/validation/statement.rs index 5ee8202ed4..2b57b1865c 100644 --- a/src/validation/statement.rs +++ b/src/validation/statement.rs @@ -11,10 +11,7 @@ use plc_ast::{ use plc_diagnostics::diagnostics::Diagnostic; use plc_source::source_location::SourceLocation; -use super::{ - array::{validate_array_assignment, Wrapper}, - ValidationContext, Validator, Validators, -}; +use super::{array::validate_array_assignment, ValidationContext, Validator, Validators}; use crate::{ builtins::{self, BuiltIn}, codegen::generators::expression_generator::get_implicit_call_parameter, @@ -96,7 +93,7 @@ pub fn visit_statement( visit_statement(validator, &data.right, context); validate_assignment(validator, &data.right, Some(&data.left), &statement.get_location(), context); - validate_array_assignment(validator, context, Wrapper::Statement(statement)); + validate_array_assignment(validator, context, statement); } AstStatement::OutputAssignment(data) => { visit_statement(validator, &data.left, context); diff --git a/src/validation/tests/array_validation_test.rs b/src/validation/tests/array_validation_test.rs index a56080c7b8..efcd210cba 100644 --- a/src/validation/tests/array_validation_test.rs +++ b/src/validation/tests/array_validation_test.rs @@ -320,3 +320,29 @@ fn parenthesized_struct_initializers() { assert_snapshot!(diagnostics); } + +#[test] +fn array_assignment_function_call() { + let diagnostics = parse_and_validate_buffered( + " + FUNCTION foo : ARRAY [0..3] OF USINT + foo[0] := 0; + foo[1] := 1; + foo[2] := 2; + foo[3] := 3; + END_FUNCTION + + FUNCTION main : DINT + VAR + arr : ARRAY[0..3] OF USINT; + arr_incorrect_size : ARRAY[0..1] OF USINT; + END_VAR + + arr := foo(); // We don't want a `... must be wrapped by []` error here + arr_incorrect_size := foo(); // We want a invalid size array error here + END_FUNCTION + ", + ); + + assert_snapshot!(diagnostics); +} diff --git a/src/validation/tests/snapshots/rusty__validation__tests__array_validation_test__array_assignment_function_call.snap b/src/validation/tests/snapshots/rusty__validation__tests__array_validation_test__array_assignment_function_call.snap new file mode 100644 index 0000000000..0d025501e3 --- /dev/null +++ b/src/validation/tests/snapshots/rusty__validation__tests__array_validation_test__array_assignment_function_call.snap @@ -0,0 +1,17 @@ +--- +source: src/validation/tests/array_validation_test.rs +expression: diagnostics +--- +error: Invalid assignment: cannot assign '__foo_return' to '__main_arr_incorrect_size' + ┌─ :16:13 + │ +16 │ arr_incorrect_size := foo(); // We want a invalid size array error here + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Invalid assignment: cannot assign '__foo_return' to '__main_arr_incorrect_size' + +error: Array __main_arr_incorrect_size has a size of 2, but 4 elements were provided + ┌─ :16:36 + │ +16 │ arr_incorrect_size := foo(); // We want a invalid size array error here + │ ^^^^^^ Array __main_arr_incorrect_size has a size of 2, but 4 elements were provided + + diff --git a/src/validation/variable.rs b/src/validation/variable.rs index 63e498ecbe..85f499906d 100644 --- a/src/validation/variable.rs +++ b/src/validation/variable.rs @@ -4,7 +4,7 @@ use plc_diagnostics::diagnostics::Diagnostic; use crate::{index::const_expressions::ConstExpression, resolver::AnnotationMap}; use super::{ - array::{validate_array_assignment, Wrapper}, + array::validate_array_assignment, statement::{validate_enum_variant_assignment, visit_statement}, types::{data_type_is_fb_or_class_instance, visit_data_type_declaration}, ValidationContext, Validator, Validators, @@ -104,7 +104,7 @@ fn validate_variable( // Assume `foo : ARRAY[1..5] OF DINT := [...]`, here the first function call validates the // assignment as a whole whereas the second function call (`visit_statement`) validates the // initializer in case it has further sub-assignments. - validate_array_assignment(validator, context, Wrapper::Variable(variable)); + validate_array_assignment(validator, context, variable); visit_statement(validator, initializer, context); } From faa8050d535a97b8ec262f3de71daf781f2c40da Mon Sep 17 00:00:00 2001 From: Michael <78988079+mhasel@users.noreply.github.com> Date: Wed, 27 Dec 2023 11:59:19 +0100 Subject: [PATCH 20/33] fix: only validate Action-VAR_IN_OUT parameters when necessary (#1057) * remove 'ignore' attr from test for already fixed issue * fix: only validate action-VAR_IN_OUT parameters when the context necessitates it * review change requests --- compiler/plc_ast/src/ast.rs | 8 +-- src/validation/statement.rs | 30 +++++++++++ .../tests/assignment_validation_tests.rs | 50 +++++++++++++++++-- ...idated_outside_of_parent_pou_contexts.snap | 11 ++++ ...action_call_assignments_are_validated.snap | 29 +++++++++++ 5 files changed, 116 insertions(+), 12 deletions(-) create mode 100644 src/validation/tests/snapshots/rusty__validation__tests__assignment_validation_tests__action_call_parameters_are_only_validated_outside_of_parent_pou_contexts.snap create mode 100644 src/validation/tests/snapshots/rusty__validation__tests__assignment_validation_tests__invalid_action_call_assignments_are_validated.snap diff --git a/compiler/plc_ast/src/ast.rs b/compiler/plc_ast/src/ast.rs index a1dfaae1fe..2e2e2cd1fb 100644 --- a/compiler/plc_ast/src/ast.rs +++ b/compiler/plc_ast/src/ast.rs @@ -819,13 +819,7 @@ impl AstNode { AstStatement::ReferenceExpr( ReferenceExpr { access: ReferenceAccess::Member(reference), .. }, .., - ) => { - if let AstStatement::Identifier(name, ..) = &reference.as_ref().stmt { - Some(name) - } else { - None - } - } + ) => reference.as_ref().get_flat_reference_name(), AstStatement::Identifier(name, ..) => Some(name), _ => None, } diff --git a/src/validation/statement.rs b/src/validation/statement.rs index 2b57b1865c..417f29bcb1 100644 --- a/src/validation/statement.rs +++ b/src/validation/statement.rs @@ -943,6 +943,12 @@ fn validate_call( // for PROGRAM/FB we need special inout validation if let PouIndexEntry::FunctionBlock { .. } | PouIndexEntry::Program { .. } = pou { + // pou might actually be an action call: in that case, + // we need to check if it is called within the context of the parent POU + // (either the body of the parent or another associated action) => we don't need to validate the params + if is_action_call_in_qualified_context(context, operator) { + return; + } let declared_in_out_params: Vec<&&VariableIndexEntry> = declared_parameters.iter().filter(|p| VariableType::InOut == p.get_variable_type()).collect(); @@ -967,6 +973,30 @@ fn validate_call( } } +fn is_action_call_in_qualified_context( + context: &ValidationContext, + operator: &AstNode, +) -> bool { + let Some(implementation) = context + .annotations + .get_call_name(operator) + .and_then(|it| context.index.find_implementation_by_name(it)) + else { + return false; + }; + + if !(implementation.get_implementation_type() == &crate::index::ImplementationType::Action) { + return false; + }; + + context.qualifier.is_some_and(|qualifier| { + let pou = context.index.find_pou(qualifier); + // we are in a qualified context for this action call, i.e. in the parent pou or another associated action + // => dont validate params + pou.is_some_and(|it| it.get_container() == implementation.get_type_name()) + }) +} + // selector, case_blocks, else_block fn validate_case_statement( validator: &mut Validator, diff --git a/src/validation/tests/assignment_validation_tests.rs b/src/validation/tests/assignment_validation_tests.rs index 634a7eb857..5c942f3c68 100644 --- a/src/validation/tests/assignment_validation_tests.rs +++ b/src/validation/tests/assignment_validation_tests.rs @@ -1,5 +1,5 @@ use crate::assert_validation_snapshot; -use crate::test_utils::tests::parse_and_validate; +use crate::test_utils::tests::{parse_and_validate, parse_and_validate_buffered}; #[test] fn constant_assignment_validation() { @@ -692,9 +692,8 @@ fn assigning_literal_with_incompatible_encoding_to_char_is_validated() { } #[test] -#[ignore = "var_in_out blocks cause false positive validation errors. see https://github.com/PLC-lang/rusty/issues/803"] fn invalid_action_call_assignments_are_validated() { - let diagnostics = parse_and_validate( + let diagnostics = parse_and_validate_buffered( r#" FUNCTION_BLOCK fb_t VAR @@ -729,8 +728,49 @@ fn invalid_action_call_assignments_are_validated() { END_FUNCTION "#, ); - assert_eq!(diagnostics.len(), 4); - assert_validation_snapshot!(&diagnostics) + insta::assert_snapshot!(&diagnostics) +} + +#[test] +fn action_call_parameters_are_only_validated_outside_of_parent_pou_contexts() { + let diagnostics = parse_and_validate_buffered( + "FUNCTION_BLOCK FOO_T + VAR_IN_OUT + arr: ARRAY[0..1] OF DINT; + END_VAR + VAR_TEMP + i: DINT; + END_VAR + BAR(); // associated action call here does not require parameters to be passed. + END_FUNCTION_BLOCK + + ACTIONS + ACTION BAR + FOR i := 0 TO 2 DO + arr[i] := i; + END_FOR; + + BAZ(); // we are still in the parent-pou context, no validation required + END_ACTION + + ACTION BAZ + FOR i := 0 TO 2 DO + arr[i] := 0; + END_FOR; + END_ACTION + END_ACTIONS + + FUNCTION main: DINT + VAR + fb: FOO_T; + arr: ARRAY[0..1] OF DINT; + END_VAR + fb(arr); + fb.bar(); // INVALID - we are not in the parent context and while we use a qualified call, we don't know if the variable has been initialized + END_FUNCTION", + ); + + insta::assert_snapshot!(diagnostics); } #[test] diff --git a/src/validation/tests/snapshots/rusty__validation__tests__assignment_validation_tests__action_call_parameters_are_only_validated_outside_of_parent_pou_contexts.snap b/src/validation/tests/snapshots/rusty__validation__tests__assignment_validation_tests__action_call_parameters_are_only_validated_outside_of_parent_pou_contexts.snap new file mode 100644 index 0000000000..b163daad4a --- /dev/null +++ b/src/validation/tests/snapshots/rusty__validation__tests__assignment_validation_tests__action_call_parameters_are_only_validated_outside_of_parent_pou_contexts.snap @@ -0,0 +1,11 @@ +--- +source: src/validation/tests/assignment_validation_tests.rs +expression: diagnostics +--- +error: Missing inout parameter: arr + ┌─ :33:13 + │ +33 │ fb.bar(); // INVALID - we are not in the parent context and while we use a qualified call, we don't know if the variable has been initialized + │ ^^^^^^ Missing inout parameter: arr + + diff --git a/src/validation/tests/snapshots/rusty__validation__tests__assignment_validation_tests__invalid_action_call_assignments_are_validated.snap b/src/validation/tests/snapshots/rusty__validation__tests__assignment_validation_tests__invalid_action_call_assignments_are_validated.snap new file mode 100644 index 0000000000..cce31cbd17 --- /dev/null +++ b/src/validation/tests/snapshots/rusty__validation__tests__assignment_validation_tests__invalid_action_call_assignments_are_validated.snap @@ -0,0 +1,29 @@ +--- +source: src/validation/tests/assignment_validation_tests.rs +expression: "&diagnostics" +--- +error: Invalid assignment: cannot assign '__main_arr' to 'WSTRING' + ┌─ :31:20 + │ +31 │ fb.foo(auto := arr, in1 := arr, in2 := arr, out => wstr); // invalid + │ ^^^^^^^^^^^ Invalid assignment: cannot assign '__main_arr' to 'WSTRING' + +error: Invalid assignment: cannot assign '__main_arr' to 'DINT' + ┌─ :31:33 + │ +31 │ fb.foo(auto := arr, in1 := arr, in2 := arr, out => wstr); // invalid + │ ^^^^^^^^^^ Invalid assignment: cannot assign '__main_arr' to 'DINT' + +error: Invalid assignment: cannot assign '__main_arr' to 'STRING' + ┌─ :31:45 + │ +31 │ fb.foo(auto := arr, in1 := arr, in2 := arr, out => wstr); // invalid + │ ^^^^^^^^^^ Invalid assignment: cannot assign '__main_arr' to 'STRING' + +error: Invalid assignment: cannot assign 'WSTRING' to '__fb_t_out' + ┌─ :31:57 + │ +31 │ fb.foo(auto := arr, in1 := arr, in2 := arr, out => wstr); // invalid + │ ^^^^^^^^^^^ Invalid assignment: cannot assign 'WSTRING' to '__fb_t_out' + + From 9c5765b3d8bc870e7793b45b14f8a0867502e371 Mon Sep 17 00:00:00 2001 From: Volkan Date: Wed, 27 Dec 2023 19:14:17 +0100 Subject: [PATCH 21/33] refactor: Introduce `GlobalContext` (#1058) * Make index and annotate steps infallible * Improve error message for assignment suggestion * Remove unwraps * Add "profiling" build profile * Make insert method fallible --- Cargo.lock | 12 +++ Cargo.toml | 2 + compiler/plc_ast/src/provider.rs | 2 +- compiler/plc_diagnostics/src/diagnostics.rs | 6 +- compiler/plc_driver/Cargo.toml | 1 + compiler/plc_driver/src/lib.rs | 59 +++++++------ compiler/plc_driver/src/pipelines.rs | 58 +++++-------- compiler/plc_driver/src/runner.rs | 11 ++- compiler/plc_driver/src/tests.rs | 12 +-- compiler/plc_index/Cargo.toml | 14 +++ compiler/plc_index/src/lib.rs | 85 +++++++++++++++++++ compiler/plc_source/src/lib.rs | 5 ++ compiler/plc_xml/src/xml_parser.rs | 6 +- src/parser.rs | 6 +- src/test_utils.rs | 13 ++- src/validation.rs | 20 +++-- src/validation/statement.rs | 7 +- .../tests/duplicates_validation_test.rs | 78 ++++++++++------- ...on_for_equal_operation_with_no_effect.snap | 24 +++--- tests/integration/cfc/resolver_tests.rs | 10 +-- tests/integration/cfc/validation_tests.rs | 12 +-- 21 files changed, 294 insertions(+), 149 deletions(-) create mode 100644 compiler/plc_index/Cargo.toml create mode 100644 compiler/plc_index/src/lib.rs diff --git a/Cargo.lock b/Cargo.lock index 79a6f24017..181d4a7f7f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1997,6 +1997,7 @@ dependencies = [ "log", "plc_ast", "plc_diagnostics", + "plc_index", "plc_project", "plc_source", "plc_xml", @@ -2008,6 +2009,16 @@ dependencies = [ "tempfile", ] +[[package]] +name = "plc_index" +version = "0.1.0" +dependencies = [ + "encoding_rs", + "plc_ast", + "plc_diagnostics", + "plc_source", +] + [[package]] name = "plc_project" version = "0.1.0" @@ -2380,6 +2391,7 @@ dependencies = [ "plc_derive", "plc_diagnostics", "plc_driver", + "plc_index", "plc_project", "plc_source", "plc_util", diff --git a/Cargo.toml b/Cargo.toml index 825edd9492..7348c2536f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -21,6 +21,7 @@ plc_source = { path = "./compiler/plc_source" } plc_ast = { path = "./compiler/plc_ast" } plc_util = { path = "./compiler/plc_util" } plc_diagnostics = { path = "./compiler/plc_diagnostics" } +plc_index = { path = "./compiler/plc_index" } logos = "0.12.0" thiserror = "1.0" clap = { version = "3.0", features = ["derive"] } @@ -69,6 +70,7 @@ members = [ "compiler/plc_util", "compiler/plc_xml", "compiler/plc_derive", + "compiler/plc_index", ] default-members = [".", "compiler/plc_driver", "compiler/plc_xml"] diff --git a/compiler/plc_ast/src/provider.rs b/compiler/plc_ast/src/provider.rs index f5dbf632ec..773661c7cf 100644 --- a/compiler/plc_ast/src/provider.rs +++ b/compiler/plc_ast/src/provider.rs @@ -5,7 +5,7 @@ use std::sync::{ use crate::ast::AstId; -#[derive(Clone)] +#[derive(Debug, Clone)] pub struct IdProvider { current_id: Arc, } diff --git a/compiler/plc_diagnostics/src/diagnostics.rs b/compiler/plc_diagnostics/src/diagnostics.rs index db9b57cbd8..a4bc5b0e73 100644 --- a/compiler/plc_diagnostics/src/diagnostics.rs +++ b/compiler/plc_diagnostics/src/diagnostics.rs @@ -745,10 +745,10 @@ impl Diagnostic { } } - pub fn assignment_instead_of_equal(range: SourceLocation) -> Diagnostic { + pub fn assignment_instead_of_equal(lhs: &str, rhs: &str, statement: &AstNode) -> Diagnostic { Diagnostic::ImprovementSuggestion { - message: "This statement has no effect, did you mean to use `:=`?".to_string(), - range: vec![range], + message: format!("This equal statement has no effect, did you mean `{lhs} := {rhs}`?"), + range: vec![statement.get_location()], } } } diff --git a/compiler/plc_driver/Cargo.toml b/compiler/plc_driver/Cargo.toml index 23e48ed61c..c1ece9a6ee 100644 --- a/compiler/plc_driver/Cargo.toml +++ b/compiler/plc_driver/Cargo.toml @@ -12,6 +12,7 @@ project = { path = "../plc_project/", package = "plc_project" } source_code = { path = "../plc_source/", package = "plc_source" } cfc = { path = "../plc_xml/", package = "plc_xml" } plc_diagnostics = { path = "../plc_diagnostics/" } +plc_index = { path = "../plc_index" } serde = { version = "1.0", features = ["derive"] } serde_json = "1" diff --git a/compiler/plc_driver/src/lib.rs b/compiler/plc_driver/src/lib.rs index 201de68db0..8968f52b65 100644 --- a/compiler/plc_driver/src/lib.rs +++ b/compiler/plc_driver/src/lib.rs @@ -15,7 +15,6 @@ use std::{ path::{Path, PathBuf}, }; -use ast::provider::IdProvider; use cli::{CompileParameters, ParameterError}; use pipelines::AnnotatedProject; use plc::{ @@ -23,6 +22,7 @@ use plc::{ }; use plc_diagnostics::{diagnostician::Diagnostician, diagnostics::Diagnostic}; +use plc_index::GlobalContext; use project::project::{LibraryInformation, Project}; use rayon::prelude::{IntoParallelIterator, ParallelIterator}; use source_code::SourceContainer; @@ -138,7 +138,6 @@ pub fn compile + AsRef + Debug>(args: &[T]) -> Result<(), C log::debug!("LIB_LOCATION={}", location.to_string_lossy()); env::set_var("LIB_LOCATION", location); } - let id_provider = IdProvider::default(); let mut diagnostician = match compile_parameters.error_format { ErrorFormat::Rich => Diagnostician::default(), ErrorFormat::Clang => Diagnostician::clang_format_diagnostician(), @@ -159,19 +158,29 @@ pub fn compile + AsRef + Debug>(args: &[T]) -> Result<(), C log::info!("{err}") } - // 1 : Parse - let annotated_project = pipelines::ParsedProject::parse( - &project, - compile_parameters.encoding, - id_provider.clone(), - &mut diagnostician, - )? - // 2 : Index - .index(id_provider.clone())? - // 3 : Resolve - .annotate(id_provider, &diagnostician)?; + // TODO: This can be improved quite a bit, e.g. `GlobalContext::new(project);`, to do that see the + // commented `project` method in the GlobalContext implementation block + let ctxt = GlobalContext::new() + .with_source(project.get_sources(), compile_parameters.encoding)? + .with_source(project.get_includes(), compile_parameters.encoding)? + .with_source( + project + .get_libraries() + .iter() + .flat_map(LibraryInformation::get_includes) + .collect::>() + .as_slice(), + None, + )?; + + // 1 : Parse, 2. Index and 3. Resolve / Annotate + let annotated_project = pipelines::ParsedProject::parse(&ctxt, &project, &mut diagnostician)? + .index(ctxt.provider()) + .annotate(ctxt.provider()); + // 4 : Validate - annotated_project.validate(&mut diagnostician)?; + annotated_project.validate(&ctxt, &mut diagnostician)?; + // 5 : Codegen if !compile_parameters.is_check() { let res = generate( @@ -201,20 +210,20 @@ pub fn compile + AsRef + Debug>(args: &[T]) -> Result<(), C pub fn parse_and_annotate( name: &str, src: Vec, -) -> Result { +) -> Result<(GlobalContext, AnnotatedProject), Diagnostic> { // Parse the source to ast let project = Project::new(name.to_string()).with_sources(src); - let id_provider = IdProvider::default(); + let ctxt = GlobalContext::new().with_source(project.get_sources(), None)?; let mut diagnostician = Diagnostician::default(); - pipelines::ParsedProject::parse(&project, None, id_provider.clone(), &mut diagnostician)? - // Create an index, add builtins - .index(id_provider.clone())? - // Resolve - .annotate(id_provider, &diagnostician) + let parsed = pipelines::ParsedProject::parse(&ctxt, &project, &mut diagnostician)?; + + // Create an index, add builtins then resolve + let provider = ctxt.provider(); + Ok((ctxt, parsed.index(provider.clone()).annotate(provider))) } /// Generates an IR string from a list of sources. Useful for tests or api calls -pub fn generate_to_string(name: &str, src: Vec) -> Result { +pub fn generate_to_string(name: &'static str, src: Vec) -> Result { generate_to_string_internal(name, src, false) } @@ -229,10 +238,10 @@ fn generate_to_string_internal( debug: bool, ) -> Result { let mut diagnostician = Diagnostician::default(); - let project = parse_and_annotate(name, src)?; + let (ctxt, project) = parse_and_annotate(name, src)?; // Validate - project.validate(&mut diagnostician)?; + project.validate(&ctxt, &mut diagnostician)?; // Generate let context = CodegenContext::create(); @@ -253,7 +262,7 @@ fn generate( compile_parameters: CompileParameters, project: Project, output_format: FormatOption, - annotated_project: pipelines::AnnotatedProject, + annotated_project: AnnotatedProject, build_location: Option, lib_location: Option, ) -> Result<(), Diagnostic> { diff --git a/compiler/plc_driver/src/pipelines.rs b/compiler/plc_driver/src/pipelines.rs index 05008c1930..1ef53cb4c0 100644 --- a/compiler/plc_driver/src/pipelines.rs +++ b/compiler/plc_driver/src/pipelines.rs @@ -10,7 +10,6 @@ use ast::{ ast::{pre_process, CompilationUnit, LinkageType}, provider::IdProvider, }; -use encoding_rs::Encoding; use indexmap::IndexSet; use plc::{ codegen::{CodegenContext, GeneratedModule}, @@ -26,6 +25,7 @@ use plc_diagnostics::{ diagnostics::Diagnostic, errno::ErrNo, }; +use plc_index::GlobalContext; use project::{ object::Object, project::{LibraryInformation, Project}, @@ -42,9 +42,8 @@ impl ParsedProject { /// Parses a giving project, transforming it to a `ParsedProject` /// Reports parsing diagnostics such as Syntax error on the fly pub fn parse( + ctxt: &GlobalContext, project: &Project, - encoding: Option<&'static Encoding>, - id_provider: IdProvider, diagnostician: &mut Diagnostician, ) -> Result { //TODO in parallel @@ -55,50 +54,37 @@ impl ParsedProject { .get_sources() .iter() .map(|it| { - let loaded_source = it.load_source(encoding).map_err(|err| { - Diagnostic::io_read_error( - &it.get_location().expect("Location should not be empty").to_string_lossy(), - &err, - ) - })?; - - let parse_func = match loaded_source.get_type() { + let source = ctxt.get(it.get_location_str()).expect("All sources should've been read"); + + let parse_func = match source.get_type() { source_code::SourceType::Text => parse_file, source_code::SourceType::Xml => cfc::xml_parser::parse_file, source_code::SourceType::Unknown => unreachable!(), }; - Ok(parse_func(loaded_source, LinkageType::Internal, id_provider.clone(), diagnostician)) + Ok(parse_func(source, LinkageType::Internal, ctxt.provider(), diagnostician)) }) .collect::, Diagnostic>>()?; units.extend(sources); + //Parse the includes let includes = project .get_includes() .iter() .map(|it| { - let loaded_source = it.load_source(encoding).map_err(|err| { - Diagnostic::io_read_error( - &it.get_location().expect("Location should not be empty").to_string_lossy(), - &err, - ) - })?; - Ok(parse_file(loaded_source, LinkageType::External, id_provider.clone(), diagnostician)) + let source = ctxt.get(it.get_location_str()).expect("All sources should've been read"); + Ok(parse_file(source, LinkageType::External, ctxt.provider(), diagnostician)) }) .collect::, Diagnostic>>()?; units.extend(includes); + //For each lib, parse the includes let lib_includes = project .get_libraries() .iter() .flat_map(LibraryInformation::get_includes) .map(|it| { - let loaded_source = it.load_source(encoding).map_err(|err| { - Diagnostic::io_read_error( - &it.get_location().expect("Location should not be empty").to_string_lossy(), - &err, - ) - })?; - Ok(parse_file(loaded_source, LinkageType::External, id_provider.clone(), diagnostician)) + let source = ctxt.get(it.get_location_str()).expect("All sources should've been read"); + Ok(parse_file(source, LinkageType::External, ctxt.provider(), diagnostician)) }) .collect::, Diagnostic>>()?; units.extend(lib_includes); @@ -107,7 +93,7 @@ impl ParsedProject { } /// Creates an index out of a pased project. The index could then be used to query datatypes - pub fn index(self, id_provider: IdProvider) -> Result { + pub fn index(self, id_provider: IdProvider) -> IndexedProject { let indexed_units = self .0 .into_par_iter() @@ -136,7 +122,7 @@ impl ParsedProject { let builtins = plc::builtins::parse_built_ins(id_provider); global_index.import(plc::index::visitor::visit(&builtins)); - Ok(IndexedProject { units, index: global_index }) + IndexedProject { units, index: global_index } } } @@ -149,11 +135,7 @@ pub struct IndexedProject { impl IndexedProject { /// Creates annotations on the project in order to facilitate codegen and validation - pub fn annotate( - self, - mut id_provider: IdProvider, - _diagnostician: &Diagnostician, - ) -> Result { + pub fn annotate(self, mut id_provider: IdProvider) -> AnnotatedProject { //Resolve constants //TODO: Not sure what we are currently doing with unresolvables let (mut full_index, _unresolvables) = plc::resolver::const_evaluator::evaluate_constants(self.index); @@ -180,7 +162,7 @@ impl IndexedProject { let annotations = AstAnnotations::new(all_annotations, id_provider.next_id()); - Ok(AnnotatedProject { units: annotated_units, index: full_index, annotations }) + AnnotatedProject { units: annotated_units, index: full_index, annotations } } } @@ -193,9 +175,13 @@ pub struct AnnotatedProject { impl AnnotatedProject { /// Validates the project, reports any new diagnostics on the fly - pub fn validate(&self, diagnostician: &mut Diagnostician) -> Result<(), Diagnostic> { + pub fn validate( + &self, + ctxt: &GlobalContext, + diagnostician: &mut Diagnostician, + ) -> Result<(), Diagnostic> { // perform global validation - let mut validator = Validator::new(); + let mut validator = Validator::new(ctxt); validator.perform_global_validation(&self.index); let diagnostics = validator.diagnostics(); let mut severity = diagnostician.handle(&diagnostics); diff --git a/compiler/plc_driver/src/runner.rs b/compiler/plc_driver/src/runner.rs index 4a20a18d4d..f0710c2c21 100644 --- a/compiler/plc_driver/src/runner.rs +++ b/compiler/plc_driver/src/runner.rs @@ -1,8 +1,8 @@ use crate::{pipelines::ParsedProject, CompileOptions}; -use ast::provider::IdProvider; use plc::codegen::{CodegenContext, GeneratedModule}; use plc_diagnostics::diagnostician::Diagnostician; +use plc_index::GlobalContext; use project::project::Project; use source_code::Compilable; @@ -26,12 +26,11 @@ impl Default for MainType { pub fn compile(context: &CodegenContext, source: T) -> GeneratedModule<'_> { let source = source.containers(); let project = Project::new("TestProject".to_string()).with_sources(source); + let ctxt = GlobalContext::new().with_source(project.get_sources(), None).unwrap(); let mut diagnostician = Diagnostician::null_diagnostician(); - let id_provider = IdProvider::default(); - let parsed_project = - ParsedProject::parse(&project, None, id_provider.clone(), &mut diagnostician).unwrap(); - let indexed_project = parsed_project.index(id_provider.clone()).unwrap(); - let annotated_project = indexed_project.annotate(id_provider, &diagnostician).unwrap(); + let parsed_project = ParsedProject::parse(&ctxt, &project, &mut diagnostician).unwrap(); + let indexed_project = parsed_project.index(ctxt.provider()); + let annotated_project = indexed_project.annotate(ctxt.provider()); let compile_options = CompileOptions { optimization: plc::OptimizationLevel::None, debug_level: plc::DebugLevel::None, diff --git a/compiler/plc_driver/src/tests.rs b/compiler/plc_driver/src/tests.rs index 8eb62ece84..58bc54949f 100644 --- a/compiler/plc_driver/src/tests.rs +++ b/compiler/plc_driver/src/tests.rs @@ -1,8 +1,8 @@ use std::{fmt::Debug, path::PathBuf}; -use ast::provider::IdProvider; use plc::DebugLevel; use plc_diagnostics::{diagnostician::Diagnostician, diagnostics::Diagnostic}; +use plc_index::GlobalContext; use project::project::Project; use source_code::SourceContainer; @@ -38,19 +38,21 @@ where let mut diagnostician = Diagnostician::null_diagnostician(); //Create a project let project = Project::new("TestProject".into()).with_sources(sources).with_source_includes(includes); + let ctxt = GlobalContext::new() + .with_source(project.get_sources(), None)? + .with_source(project.get_includes(), None)?; //Parse - let id_provider = IdProvider::default(); let compile_options = CompileOptions { root: path, debug_level, optimization: plc::OptimizationLevel::None, ..Default::default() }; - pipelines::ParsedProject::parse(&project, None, id_provider.clone(), &mut diagnostician)? + pipelines::ParsedProject::parse(&ctxt, &project, &mut diagnostician)? //Index - .index(id_provider.clone())? + .index(ctxt.provider()) //Resolve - .annotate(id_provider, &diagnostician)? + .annotate(ctxt.provider()) //Codegen .codegen_to_string(&compile_options) } diff --git a/compiler/plc_index/Cargo.toml b/compiler/plc_index/Cargo.toml new file mode 100644 index 0000000000..4d5b28e5ab --- /dev/null +++ b/compiler/plc_index/Cargo.toml @@ -0,0 +1,14 @@ +[package] +name = "plc_index" +version = "0.1.0" +edition = "2021" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] +plc_ast = { path = "../plc_ast" } +plc_source = { path = "../plc_source" } +plc_diagnostics = { path = "../plc_diagnostics" } +#plc_project = { path = "../plc_project" } # TODO: This will create a circular dependency + +encoding_rs = "0.8" diff --git a/compiler/plc_index/src/lib.rs b/compiler/plc_index/src/lib.rs new file mode 100644 index 0000000000..e005cf61f0 --- /dev/null +++ b/compiler/plc_index/src/lib.rs @@ -0,0 +1,85 @@ +use encoding_rs::Encoding; +use plc_ast::provider::IdProvider; +use plc_diagnostics::diagnostics::Diagnostic; +use plc_source::source_location::SourceLocation; +use plc_source::{SourceCode, SourceContainer}; +use std::collections::HashMap; + +#[derive(Debug, Default)] +pub struct GlobalContext { + sources: HashMap<&'static str, SourceCode>, + provider: IdProvider, + // TODO: The following would be also nice, to have a cleaner API i.e. instead of working with different structs such + // as the index or the diagnostics one could instead ONLY use the `GlobalContext` with methods like + // `ctxt.{add,get}_diagnostics(...)` making the code perhaps a bit cleaner / reducing the # of arguments for + // some functions / methods? + // RefCells may or may not make sense here, because maybe we dont want to pass the GlobalContext as a mutable reference? + // -> diagnostics: RefCell, (private visibility) + // -> index: RefCell, (private visibility; `get_index(&self) -> &mut Index`?) +} + +impl GlobalContext { + pub fn new() -> Self { + Self { sources: HashMap::new(), provider: IdProvider::default() } + } + + pub fn with_source(mut self, sources: &[S], enc: Option<&'static Encoding>) -> Result + where + S: SourceContainer, + { + for source in sources { + self.insert(source, enc)?; + } + + Ok(self) + } + + pub fn insert(&mut self, container: &S, encoding: Option<&'static Encoding>) -> Result<(), Diagnostic> + where + S: SourceContainer, + { + match container.load_source(encoding) { + Ok(value) => self.sources.insert(container.get_location_str(), value), + Err(why) => return Err(Diagnostic::io_read_error(container.get_location_str(), &why)), + }; + + Ok(()) + } + + pub fn get(&self, key: &str) -> Option<&SourceCode> { + self.sources.get(key) + } + + pub fn provider(&self) -> IdProvider { + self.provider.clone() + } + + // TODO: `impl Into` would be nice here, but adding `plc_ast` as a dep in `plc_source` yields a circular dep so not possible right now + pub fn slice(&self, location: &SourceLocation) -> &str { + let path = location.get_file_name().unwrap_or(""); + + let Some(code) = self.sources.get(path) else { return "" }; + let Some(span) = location.get_span().to_range() else { return "" }; + + &code.source[span] + } + + // // TODO: Importing `plc_project` would make life easier here and allow for the code below, but we get a circular dep + // pub fn project(project: &Project, encoding: Option<&'static Encoding>) -> Self { + // let mut ctxt = Self::new(); + // + // for source in project.get_sources() { + // ctxt.insert(source, encoding); + // } + // + // for source in project.get_includes() { + // ctxt.insert(source, encoding); + // } + // + // for source in project.get_libraries().iter().flat_map(LibraryInformation::get_includes) { + // ctxt.insert(source, encoding); + // } + // + // ctxt + // } +} diff --git a/compiler/plc_source/src/lib.rs b/compiler/plc_source/src/lib.rs index f2b07e159d..936c757111 100644 --- a/compiler/plc_source/src/lib.rs +++ b/compiler/plc_source/src/lib.rs @@ -132,6 +132,11 @@ impl SourceCode { pub fn new(source: impl Into, path: impl Into) -> Self { SourceCode { source: source.into(), path: Some(path.into()) } } + + pub fn with_path(mut self, name: impl Into) -> Self { + self.path = Some(name.into()); + self + } } pub trait Compilable { diff --git a/compiler/plc_xml/src/xml_parser.rs b/compiler/plc_xml/src/xml_parser.rs index 65d6c71700..ea9164999a 100644 --- a/compiler/plc_xml/src/xml_parser.rs +++ b/compiler/plc_xml/src/xml_parser.rs @@ -68,14 +68,14 @@ pub(crate) fn visit(content: &str) -> Result { } pub fn parse_file( - source: SourceCode, + source: &SourceCode, linkage: LinkageType, id_provider: IdProvider, diagnostician: &mut Diagnostician, ) -> CompilationUnit { - let (unit, errors) = parse(&source, linkage, id_provider); + let (unit, errors) = parse(source, linkage, id_provider); //Register the source file with the diagnostician - diagnostician.register_file(source.get_location_str().to_string(), source.source.to_string()); + diagnostician.register_file(source.get_location_str().to_string(), source.source.clone()); // TODO: Remove clone here, generally passing the GlobalContext instead of the actual source here or in the handle method should be sufficient diagnostician.handle(&errors); unit } diff --git a/src/parser.rs b/src/parser.rs index 874fbccf29..3e7a213d82 100644 --- a/src/parser.rs +++ b/src/parser.rs @@ -37,12 +37,12 @@ pub mod tests; pub type ParsedAst = (CompilationUnit, Vec); pub fn parse_file( - source: SourceCode, + source: &SourceCode, linkage: LinkageType, id_provider: IdProvider, diagnostician: &mut Diagnostician, ) -> CompilationUnit { - let location_factory = SourceLocationFactory::for_source(&source); + let location_factory = SourceLocationFactory::for_source(source); let (unit, errors) = parse( lexer::lex_with_ids(&source.source, id_provider, location_factory), linkage, @@ -50,7 +50,7 @@ pub fn parse_file( ); //Register the source file with the diagnostician //TODO: We should reduce the clone here - diagnostician.register_file(source.get_location_str().to_string(), source.source); + diagnostician.register_file(source.get_location_str().to_string(), source.source.clone()); // TODO: Remove clone here, generally passing the GlobalContext instead of the actual source here or in the handle method should be sufficient diagnostician.handle(&errors); unit } diff --git a/src/test_utils.rs b/src/test_utils.rs index 5a1659d172..a5464d8d37 100644 --- a/src/test_utils.rs +++ b/src/test_utils.rs @@ -10,6 +10,7 @@ pub mod tests { use plc_diagnostics::{ diagnostician::Diagnostician, diagnostics::Diagnostic, reporter::DiagnosticReporter, }; + use plc_index::GlobalContext; use plc_source::{source_location::SourceLocationFactory, Compilable, SourceCode, SourceContainer}; use crate::{ @@ -116,14 +117,18 @@ pub mod tests { } pub fn parse_and_validate(src: &str) -> Vec { - let id_provider = IdProvider::default(); - let (unit, index, mut diagnostics) = do_index(src, id_provider.clone()); + let src = SourceCode::from(src); + + let mut ctxt = GlobalContext::new(); + ctxt.insert(&src, None).unwrap(); + + let (unit, index, mut diagnostics) = do_index(src, ctxt.provider()); let (mut index, ..) = evaluate_constants(index); - let (mut annotations, ..) = TypeAnnotator::visit_unit(&index, &unit, id_provider); + let (mut annotations, ..) = TypeAnnotator::visit_unit(&index, &unit, ctxt.provider()); index.import(std::mem::take(&mut annotations.new_index)); - let mut validator = Validator::new(); + let mut validator = Validator::new(&ctxt); validator.perform_global_validation(&index); validator.visit_unit(&annotations, &index, &unit); diagnostics.extend(validator.diagnostics()); diff --git a/src/validation.rs b/src/validation.rs index ec948f745b..d1038b6ca6 100644 --- a/src/validation.rs +++ b/src/validation.rs @@ -1,6 +1,7 @@ use plc_ast::ast::{AstNode, CompilationUnit}; use plc_derive::Validators; use plc_diagnostics::diagnostics::Diagnostic; +use plc_index::GlobalContext; use crate::{ index::{ @@ -92,23 +93,26 @@ pub trait Validators { fn take_diagnostics(&mut self) -> Vec; } -#[derive(Validators)] -pub struct Validator { - //context: ValidationContext<'s>, +pub struct Validator<'a> { + context: &'a GlobalContext, diagnostics: Vec, global_validator: GlobalValidator, recursive_validator: RecursiveValidator, } -impl Default for Validator { - fn default() -> Self { - Self::new() +impl<'a> Validators for Validator<'a> { + fn push_diagnostic(&mut self, diagnostic: Diagnostic) { + self.diagnostics.push(diagnostic); + } + fn take_diagnostics(&mut self) -> Vec { + std::mem::take(&mut self.diagnostics) } } -impl Validator { - pub fn new() -> Validator { +impl<'a> Validator<'a> { + pub fn new(context: &'a GlobalContext) -> Validator { Validator { + context, diagnostics: Vec::new(), global_validator: GlobalValidator::new(), recursive_validator: RecursiveValidator::new(), diff --git a/src/validation/statement.rs b/src/validation/statement.rs index 417f29bcb1..e5288af7b6 100644 --- a/src/validation/statement.rs +++ b/src/validation/statement.rs @@ -523,7 +523,12 @@ fn visit_binary_expression( match operator { Operator::Equal => { if context.annotations.get_type_hint(statement, context.index).is_none() { - validator.push_diagnostic(Diagnostic::assignment_instead_of_equal(statement.get_location())); + let slice_lhs = validator.context.slice(&left.location); + let slice_rhs = validator.context.slice(&right.location); + + validator.push_diagnostic(Diagnostic::assignment_instead_of_equal( + slice_lhs, slice_rhs, statement, + )); } validate_binary_expression(validator, statement, operator, left, right, context) diff --git a/src/validation/tests/duplicates_validation_test.rs b/src/validation/tests/duplicates_validation_test.rs index 2c20be45da..aaeb5e9023 100644 --- a/src/validation/tests/duplicates_validation_test.rs +++ b/src/validation/tests/duplicates_validation_test.rs @@ -2,7 +2,9 @@ use plc_ast::{ ast::{pre_process, CompilationUnit, LinkageType}, provider::IdProvider, }; +use plc_index::GlobalContext; use plc_source::source_location::SourceLocationFactory; +use plc_source::SourceCode; use crate::{ assert_validation_snapshot, @@ -353,9 +355,10 @@ fn automatically_generated_output_types_in_different_files_dont_cause_duplicatio index } + let mut ctxt = GlobalContext::new(); + // GIVEN some code that automatically generates a ptr-types - let ids = IdProvider::default(); - let index1 = do_index( + let code1 = SourceCode::from( r#" FUNCTION foo : INT VAR_OUTPUT @@ -364,11 +367,10 @@ fn automatically_generated_output_types_in_different_files_dont_cause_duplicatio END_VAR END_FUNCTION "#, - ids.clone(), - ); + ) + .with_path("file1"); - //AND another file with also OUTPUT-INTS - let index2 = do_index( + let code2 = SourceCode::from( r#" FUNCTION foo2 : INT VAR_OUTPUT @@ -377,8 +379,13 @@ fn automatically_generated_output_types_in_different_files_dont_cause_duplicatio END_VAR END_FUNCTION "#, - ids, - ); + ) + .with_path("file2"); + + ctxt.insert(&code1, None).unwrap(); + ctxt.insert(&code2, None).unwrap(); + let index1 = do_index(&code1.source, ctxt.provider()); + let index2 = do_index(&code2.source, ctxt.provider()); // WHEN the index is combined let mut global_index = Index::default(); @@ -386,7 +393,7 @@ fn automatically_generated_output_types_in_different_files_dont_cause_duplicatio global_index.import(index2); //import file 2 // THEN there should be no duplication diagnostics - let mut validator = Validator::new(); + let mut validator = Validator::new(&ctxt); validator.perform_global_validation(&global_index); let diagnostics = validator.diagnostics(); assert_eq!(diagnostics, vec![]); @@ -408,9 +415,9 @@ fn duplicate_with_generic() { (index, unit) } - // GIVEN a generic function defined in its own file - let ids = IdProvider::default(); - let (index1, unit1) = do_index( + let mut ctxt = GlobalContext::new(); + + let code1 = SourceCode::from( r#" {external} FUNCTION foo : DATE @@ -421,13 +428,10 @@ fn duplicate_with_generic() { END_VAR END_FUNCTION "#, - ids.clone(), - "file1.st", - ); + ) + .with_path("file1"); - // AND another file that calls that generic function and implicitely - // create type-specific foo-implementations - let (index2, unit2) = do_index( + let code2 = SourceCode::from( r#" PROGRAM prg1 foo(INT#1, SINT#2, SINT#3); @@ -436,13 +440,10 @@ fn duplicate_with_generic() { foo(INT#1, SINT#2, SINT#3); END_PROGRAM "#, - ids.clone(), - "file2.st", - ); + ) + .with_path("file2"); - // AND another file that calls that generic function and implicitely - // create type-specific foo-implementations - let (index3, unit3) = do_index( + let code3 = SourceCode::from( r#" PROGRAM prg2 foo(INT#1, SINT#2, SINT#3); @@ -451,9 +452,24 @@ fn duplicate_with_generic() { foo(INT#1, SINT#2, SINT#3); END_PROGRAM "#, - ids.clone(), - "file3.st", - ); + ) + .with_path("file3"); + + ctxt.insert(&code1, None).unwrap(); + ctxt.insert(&code2, None).unwrap(); + ctxt.insert(&code3, None).unwrap(); + + // GIVEN a generic function defined in its own file + let (index1, unit1) = do_index(&code1.source, ctxt.provider(), "file1.st"); + + // AND another file that calls that generic function and implicitely + // create type-specific foo-implementations + let (index2, unit2) = do_index(&code2.source, ctxt.provider(), "file2.st"); + + // AND another file that calls that generic function and implicitely + // create type-specific foo-implementations + let (index3, unit3) = do_index(&code3.source, ctxt.provider(), "file3.st"); + // WHEN the index is combined let mut global_index = Index::default(); for data_type in typesystem::get_builtin_types() { @@ -464,9 +480,9 @@ fn duplicate_with_generic() { global_index.import(index3); //import file 3 // AND the resolvers does its job - let (mut annotations1, ..) = TypeAnnotator::visit_unit(&global_index, &unit1, ids.clone()); - let (mut annotations2, ..) = TypeAnnotator::visit_unit(&global_index, &unit2, ids.clone()); - let (mut annotations3, ..) = TypeAnnotator::visit_unit(&global_index, &unit3, ids); + let (mut annotations1, ..) = TypeAnnotator::visit_unit(&global_index, &unit1, ctxt.provider()); + let (mut annotations2, ..) = TypeAnnotator::visit_unit(&global_index, &unit2, ctxt.provider()); + let (mut annotations3, ..) = TypeAnnotator::visit_unit(&global_index, &unit3, ctxt.provider()); global_index.import(std::mem::take(&mut annotations1.new_index)); global_index.import(std::mem::take(&mut annotations2.new_index)); global_index.import(std::mem::take(&mut annotations3.new_index)); @@ -478,7 +494,7 @@ fn duplicate_with_generic() { ); // AND there should be no duplication diagnostics - let mut validator = Validator::new(); + let mut validator = Validator::new(&ctxt); validator.perform_global_validation(&global_index); let diagnostics = validator.diagnostics(); assert_eq!(diagnostics, vec![]); diff --git a/src/validation/tests/snapshots/rusty__validation__tests__variable_validation_tests__assignment_suggestion_for_equal_operation_with_no_effect.snap b/src/validation/tests/snapshots/rusty__validation__tests__variable_validation_tests__assignment_suggestion_for_equal_operation_with_no_effect.snap index b3b3e13c1b..dafe7cced8 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__variable_validation_tests__assignment_suggestion_for_equal_operation_with_no_effect.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__variable_validation_tests__assignment_suggestion_for_equal_operation_with_no_effect.snap @@ -2,40 +2,40 @@ source: src/validation/tests/variable_validation_tests.rs expression: diagnostics --- -warning: This statement has no effect, did you mean to use `:=`? +warning: This equal statement has no effect, did you mean `value := 1`? ┌─ :24:13 │ 24 │ value = 1; - │ ^^^^^^^^^ This statement has no effect, did you mean to use `:=`? + │ ^^^^^^^^^ This equal statement has no effect, did you mean `value := 1`? -warning: This statement has no effect, did you mean to use `:=`? +warning: This equal statement has no effect, did you mean `value := condition`? ┌─ :25:13 │ 25 │ value = condition AND condition; - │ ^^^^^^^^^^^^^^^^^ This statement has no effect, did you mean to use `:=`? + │ ^^^^^^^^^^^^^^^^^ This equal statement has no effect, did you mean `value := condition`? -warning: This statement has no effect, did you mean to use `:=`? +warning: This equal statement has no effect, did you mean `value := condition`? ┌─ :26:13 │ 26 │ value = condition AND (condition = TRUE); - │ ^^^^^^^^^^^^^^^^^ This statement has no effect, did you mean to use `:=`? + │ ^^^^^^^^^^^^^^^^^ This equal statement has no effect, did you mean `value := condition`? -warning: This statement has no effect, did you mean to use `:=`? +warning: This equal statement has no effect, did you mean `condition := TRUE`? ┌─ :26:36 │ 26 │ value = condition AND (condition = TRUE); - │ ^^^^^^^^^^^^^^^^ This statement has no effect, did you mean to use `:=`? + │ ^^^^^^^^^^^^^^^^ This equal statement has no effect, did you mean `condition := TRUE`? -warning: This statement has no effect, did you mean to use `:=`? +warning: This equal statement has no effect, did you mean `value := 1`? ┌─ :28:26 │ 28 │ IF TRUE THEN value = 1; END_IF - │ ^^^^^^^^^ This statement has no effect, did you mean to use `:=`? + │ ^^^^^^^^^ This equal statement has no effect, did you mean `value := 1`? -warning: This statement has no effect, did you mean to use `:=`? +warning: This equal statement has no effect, did you mean `value := 1`? ┌─ :29:27 │ 29 │ WHILE TRUE DO value = 1; END_WHILE - │ ^^^^^^^^^ This statement has no effect, did you mean to use `:=`? + │ ^^^^^^^^^ This equal statement has no effect, did you mean `value := 1`? diff --git a/tests/integration/cfc/resolver_tests.rs b/tests/integration/cfc/resolver_tests.rs index 30331bd765..f11c866739 100644 --- a/tests/integration/cfc/resolver_tests.rs +++ b/tests/integration/cfc/resolver_tests.rs @@ -13,7 +13,7 @@ fn label_added_to_index_as_annotation() { //Remove the path cfc_file.path.replace(".cfc".into()); - let index = parse_and_annotate("plc", vec![cfc_file]).unwrap().index; + let index = parse_and_annotate("plc", vec![cfc_file]).unwrap().1.index; assert_debug_snapshot!(index.get_label("main", "lbl").unwrap()); } @@ -24,7 +24,7 @@ fn jumps_annotated_with_label_annoations() { //Remove the path cfc_file.path.replace(".cfc".into()); - let annotated_project = parse_and_annotate("plc", vec![cfc_file]).unwrap(); + let annotated_project = parse_and_annotate("plc", vec![cfc_file]).unwrap().1; let annotations = &annotated_project.annotations; let (unit, ..) = &annotated_project.units[0]; // Get the jump @@ -39,7 +39,7 @@ fn unbound_jumps_not_annotated() { //Remove the path cfc_file.path.replace(".cfc".into()); - let annotated_project = parse_and_annotate("plc", vec![cfc_file]).unwrap(); + let annotated_project = parse_and_annotate("plc", vec![cfc_file]).unwrap().1; let annotations = &annotated_project.annotations; let (unit, ..) = &annotated_project.units[0]; // Get the jump @@ -54,7 +54,7 @@ fn action_variables_annotated() { //Remove the path cfc_file.path.replace(".cfc".into()); - let annotated_project = parse_and_annotate("plc", vec![cfc_file]).unwrap(); + let annotated_project = parse_and_annotate("plc", vec![cfc_file]).unwrap().1; let annotations = &annotated_project.annotations; let (unit, ..) = &annotated_project.units[0]; @@ -85,7 +85,7 @@ fn function_block_calls_are_annotated_correctly() { let main = main.load_source(None).unwrap(); let fb = fb.load_source(None).unwrap(); - let annotated_project = parse_and_annotate("plc", vec![main, fb]).unwrap(); + let annotated_project = parse_and_annotate("plc", vec![main, fb]).unwrap().1; let annotations = &annotated_project.annotations; let (unit, ..) = &annotated_project.units[0]; diff --git a/tests/integration/cfc/validation_tests.rs b/tests/integration/cfc/validation_tests.rs index 0ac7b84517..312d7ceabb 100644 --- a/tests/integration/cfc/validation_tests.rs +++ b/tests/integration/cfc/validation_tests.rs @@ -14,8 +14,8 @@ fn duplicate_label_validation() { let mut diagnostician = Diagnostician::buffered(); diagnostician.register_file(".cfc".to_string(), "".into()); - let project = parse_and_annotate("plc", vec![cfc_file]).unwrap(); - project.validate(&mut diagnostician).unwrap(); + let (ctxt, project) = parse_and_annotate("plc", vec![cfc_file]).unwrap(); + project.validate(&ctxt, &mut diagnostician).unwrap(); assert_snapshot!(diagnostician.buffer().unwrap()) } @@ -28,8 +28,8 @@ fn multiple_labels_in_file_are_no_error() { let mut diagnostician = Diagnostician::buffered(); diagnostician.register_file(".cfc".to_string(), "".into()); - let project = parse_and_annotate("plc", vec![cfc_file]).unwrap(); - project.validate(&mut diagnostician).unwrap(); + let (ctxt, project) = parse_and_annotate("plc", vec![cfc_file]).unwrap(); + project.validate(&ctxt, &mut diagnostician).unwrap(); assert!(diagnostician.buffer().unwrap().trim().is_empty()) } @@ -42,7 +42,7 @@ fn jump_with_missing_label_validation() { let mut diagnostician = Diagnostician::buffered(); diagnostician.register_file(".cfc".to_string(), "".into()); - let project = parse_and_annotate("plc", vec![cfc_file]).unwrap(); - project.validate(&mut diagnostician).unwrap_err(); + let (ctxt, project) = parse_and_annotate("plc", vec![cfc_file]).unwrap(); + project.validate(&ctxt, &mut diagnostician).unwrap_err(); assert_snapshot!(diagnostician.buffer().unwrap()) } From 601c3d0e7a9d3990445eec46d5167c7407764359 Mon Sep 17 00:00:00 2001 From: Volkan Date: Fri, 29 Dec 2023 09:34:36 +0100 Subject: [PATCH 22/33] feat: Improved error messages using slices (#1061) This PR improves error messages by using slices to reference the actual datatype instead of mangled names. For example an invalid assignment validation error message may now use ``ARRAY[1..5] OF DINT` instead of `__main_arr`. --- compiler/plc_diagnostics/src/diagnostics.rs | 2 +- compiler/plc_index/src/lib.rs | 64 +++++++++++++++---- src/validation/array.rs | 34 ++++++---- src/validation/statement.rs | 21 ++++-- .../tests/assignment_validation_tests.rs | 2 +- ..._test__array_assignment_function_call.snap | 8 +-- ..._array_validation_test__assignment_1d.snap | 8 +-- ..._array_validation_test__assignment_2d.snap | 16 ++--- ..._array_validation_test__assignment_3d.snap | 16 ++--- ...test__assignment_multiplied_statement.snap | 40 ++++++------ ...on_tests__array_assignment_validation.snap | 16 ++--- ...ion_tests__char_assignment_validation.snap | 2 +- ...action_call_assignments_are_validated.snap | 4 +- ...action_call_assignments_are_validated.snap | 16 ++--- ...tion_block_instantiation_is_validated.snap | 4 +- ...method_call_assignments_are_validated.snap | 4 +- ..._tests__pointer_assignment_validation.snap | 8 +-- ...ype_alias_assignment_can_be_validated.snap | 2 +- ...n_tests__struct_assignment_validation.snap | 12 ++-- ...ment_validation_tests__trimmed_slices.snap | 11 ++++ ...ation_tests__action_implicit_downcast.snap | 2 +- ..._to_too_small_type_result_in_an_error.snap | 2 +- ...ll_type_to_pointer_result_in_an_error.snap | 2 +- ...ent_of_incompatible_types_is_reported.snap | 8 +-- ...s__function_call_parameter_validation.snap | 4 +- ...ation_tests__method_implicit_downcast.snap | 2 +- ...ts__program_call_parameter_validation.snap | 4 +- ...nce_assignments_in_function_arguments.snap | 12 ++-- ...y_elements_passed_to_functions_by_ref.snap | 4 +- ...__validate_arrays_passed_to_functions.snap | 16 ++--- ..._access__variable_length_array_access.snap | 2 +- ...e_length_array_incompatible_datatypes.snap | 6 +- ...rray_test__assignment__function_calls.snap | 4 +- ...ns__builtins_called_with_invalid_type.snap | 4 +- 34 files changed, 218 insertions(+), 144 deletions(-) create mode 100644 src/validation/tests/snapshots/rusty__validation__tests__assignment_validation_tests__trimmed_slices.snap diff --git a/compiler/plc_diagnostics/src/diagnostics.rs b/compiler/plc_diagnostics/src/diagnostics.rs index a4bc5b0e73..29ac67b7e2 100644 --- a/compiler/plc_diagnostics/src/diagnostics.rs +++ b/compiler/plc_diagnostics/src/diagnostics.rs @@ -674,7 +674,7 @@ impl Diagnostic { pub fn array_size(name: &str, len_lhs: usize, len_rhs: usize, range: SourceLocation) -> Diagnostic { Diagnostic::SemanticError { - message: format!("Array {name} has a size of {len_lhs}, but {len_rhs} elements were provided"), + message: format!("Array `{name}` has a size of {len_lhs}, but {len_rhs} elements were provided"), range: vec![range], err_no: ErrNo::arr__invalid_array_assignment, } diff --git a/compiler/plc_index/src/lib.rs b/compiler/plc_index/src/lib.rs index e005cf61f0..6db52c4a48 100644 --- a/compiler/plc_index/src/lib.rs +++ b/compiler/plc_index/src/lib.rs @@ -7,7 +7,11 @@ use std::collections::HashMap; #[derive(Debug, Default)] pub struct GlobalContext { + /// HashMap containing all read, i.e. parsed, sources where the key represents + /// the relative file path and the value some [`SourceCode`] sources: HashMap<&'static str, SourceCode>, + + /// [`IdProvider`] used during the parsing session provider: IdProvider, // TODO: The following would be also nice, to have a cleaner API i.e. instead of working with different structs such // as the index or the diagnostics one could instead ONLY use the `GlobalContext` with methods like @@ -23,17 +27,7 @@ impl GlobalContext { Self { sources: HashMap::new(), provider: IdProvider::default() } } - pub fn with_source(mut self, sources: &[S], enc: Option<&'static Encoding>) -> Result - where - S: SourceContainer, - { - for source in sources { - self.insert(source, enc)?; - } - - Ok(self) - } - + /// Inserts a single [`SourceCode`] to the internal source map pub fn insert(&mut self, container: &S, encoding: Option<&'static Encoding>) -> Result<(), Diagnostic> where S: SourceContainer, @@ -46,16 +40,39 @@ impl GlobalContext { Ok(()) } + /// Inserts multiple [`SourceCode`]s to the internal source map + pub fn with_source(mut self, sources: &[S], enc: Option<&'static Encoding>) -> Result + where + S: SourceContainer, + { + for source in sources { + self.insert(source, enc)?; + } + + Ok(self) + } + + /// Returns some [`SourceCode`] based on the given key pub fn get(&self, key: &str) -> Option<&SourceCode> { self.sources.get(key) } + /// Returns a cloned [`IdProvider`] pub fn provider(&self) -> IdProvider { self.provider.clone() } // TODO: `impl Into` would be nice here, but adding `plc_ast` as a dep in `plc_source` yields a circular dep so not possible right now - pub fn slice(&self, location: &SourceLocation) -> &str { + /// Returns a (whitespace) trimmed slice representing the specified location of the source code. + /// For example if the location represents `ARRAY[1..5]\n\nOF\t DINT` the slice `ARRAY[1..5] OF DINT` will be returned instead. + pub fn slice(&self, location: &SourceLocation) -> String { + let slice = self.slice_original(location); + slice.split_whitespace().collect::>().join(" ") + } + + /// Returns a slice representing the specified location of the source code. + /// If the location, i.e. file path, does not exist an empty string will be returned. + pub fn slice_original(&self, location: &SourceLocation) -> &str { let path = location.get_file_name().unwrap_or(""); let Some(code) = self.sources.get(path) else { return "" }; @@ -83,3 +100,26 @@ impl GlobalContext { // ctxt // } } + +#[cfg(test)] +mod tests { + use crate::GlobalContext; + use plc_source::source_location::SourceLocationFactory; + use plc_source::SourceCode; + + #[test] + fn slice() { + let input = SourceCode::from("ARRAY[1..5] \n\n\n\nOF \n\n\n \t DINT"); + let mut ctxt = GlobalContext::new(); + ctxt.insert(&input, None).unwrap(); + + let factory = SourceLocationFactory::default(); + let location = factory.create_range(0..input.source.len()); + + assert_eq!(ctxt.slice(&location), "ARRAY[1..5] OF DINT"); + assert_eq!( + ctxt.slice_original(&location), + "ARRAY[1..5] \n\n\n\nOF \n\n\n \t DINT" + ); + } +} diff --git a/src/validation/array.rs b/src/validation/array.rs index 2f0efdafe6..baa2038ea0 100644 --- a/src/validation/array.rs +++ b/src/validation/array.rs @@ -14,6 +14,7 @@ use plc_ast::{ literals::AstLiteral, }; use plc_diagnostics::diagnostics::Diagnostic; +use plc_index::GlobalContext; use crate::{resolver::AnnotationMap, typesystem::DataTypeInformation}; @@ -46,20 +47,23 @@ pub(super) fn validate_array_assignment<'a, T, S>( T: AnnotationMap, S: Into> + Copy, { - let Some(rhs_stmt) = statement.into().rhs_statement() else { return }; - let Some(lhs_info) = statement.into().lhs_info(context) else { return }; + let statement = statement.into(); + + let Some(rhs_stmt) = statement.rhs_statement() else { return }; + let Some(lhs_info) = statement.lhs_info(context) else { return }; if !lhs_info.is_array() { return; } - validate_array(validator, context, lhs_info, rhs_stmt); + validate_array(validator, context, &statement, lhs_info, rhs_stmt); validate_array_of_structs(validator, context, lhs_info, rhs_stmt); } fn validate_array( validator: &mut Validator, context: &ValidationContext, + statement: &StatementWrapper, lhs_type: &DataTypeInformation, rhs_stmt: &AstNode, ) { @@ -77,9 +81,9 @@ fn validate_array( } if len_lhs < len_rhs { - let name = lhs_type.get_name(); + let name = statement.lhs_name(validator.context); let location = stmt_rhs.get_location(); - validator.push_diagnostic(Diagnostic::array_size(name, len_lhs, len_rhs, location)); + validator.push_diagnostic(Diagnostic::array_size(&name, len_lhs, len_rhs, location)); } } @@ -148,13 +152,23 @@ fn statement_to_array_length(context: &ValidationContext, s } impl<'a> StatementWrapper<'a> { + fn lhs_name(&self, context: &GlobalContext) -> String { + match self { + StatementWrapper::Variable(variable) => variable.name.clone(), + StatementWrapper::Statement(statement) => { + let AstStatement::Assignment(data) = &statement.stmt else { return "".to_string() }; + context.slice(&data.left.location) + } + } + } + fn rhs_statement(&self) -> Option<&'a AstNode> { match self { - StatementWrapper::Statement(AstNode { stmt: AstStatement::Assignment(data), .. }) => { + StatementWrapper::Variable(variable) => variable.initializer.as_ref(), + StatementWrapper::Statement(statement) => { + let AstStatement::Assignment(data) = &statement.stmt else { return None }; Some(&data.right) } - StatementWrapper::Variable(variable) => variable.initializer.as_ref(), - _ => None, } } @@ -164,9 +178,7 @@ impl<'a> StatementWrapper<'a> { { match self { StatementWrapper::Statement(statement) => { - let AstNode { stmt: AstStatement::Assignment(data), .. } = statement else { - return None; - }; + let AstNode { stmt: AstStatement::Assignment(data), .. } = statement else { return None }; context.annotations.get_type(&data.left, context.index).map(|it| it.get_type_information()) } diff --git a/src/validation/statement.rs b/src/validation/statement.rs index e5288af7b6..fc1228390b 100644 --- a/src/validation/statement.rs +++ b/src/validation/statement.rs @@ -12,6 +12,7 @@ use plc_diagnostics::diagnostics::Diagnostic; use plc_source::source_location::SourceLocation; use super::{array::validate_array_assignment, ValidationContext, Validator, Validators}; +use crate::validation::statement::helper::get_datatype_name_or_slice; use crate::{ builtins::{self, BuiltIn}, codegen::generators::expression_generator::get_implicit_call_parameter, @@ -527,7 +528,7 @@ fn visit_binary_expression( let slice_rhs = validator.context.slice(&right.location); validator.push_diagnostic(Diagnostic::assignment_instead_of_equal( - slice_lhs, slice_rhs, statement, + &slice_lhs, &slice_rhs, statement, )); } @@ -726,8 +727,8 @@ fn validate_assignment( && is_valid_assignment(left_type, right_type, right, context.index, location, validator)) { validator.push_diagnostic(Diagnostic::invalid_assignment( - right_type.get_type_information().get_name(), - left_type.get_type_information().get_name(), + &get_datatype_name_or_slice(validator.context, right_type), + &get_datatype_name_or_slice(validator.context, left_type), location.clone(), )); } else if right.is_literal() { @@ -767,8 +768,8 @@ fn validate_variable_length_array_assignment( if left_dt != right_dt || left_dims != right_dims { validator.push_diagnostic(Diagnostic::invalid_assignment( - right_type.get_type_information().get_name(), - left_type.get_type_information().get_name(), + &get_datatype_name_or_slice(validator.context, right_type), + &get_datatype_name_or_slice(validator.context, left_type), location.clone(), )); } @@ -1113,7 +1114,9 @@ mod helper { use std::ops::Range; use plc_ast::ast::DirectAccessType; + use plc_index::GlobalContext; + use crate::typesystem::DataType; use crate::{index::Index, typesystem::DataTypeInformation}; /// Returns true if the current index is in the range for the given type @@ -1139,4 +1142,12 @@ mod helper { pub fn is_compatible(access: &DirectAccessType, data_type: &DataTypeInformation, index: &Index) -> bool { data_type.get_semantic_size(index) as u64 > access.get_bit_width() } + + pub fn get_datatype_name_or_slice(context: &GlobalContext, dt: &DataType) -> String { + if dt.is_internal() { + return dt.get_type_information().get_name().to_string(); + } + + context.slice(&dt.location) + } } diff --git a/src/validation/tests/assignment_validation_tests.rs b/src/validation/tests/assignment_validation_tests.rs index 5c942f3c68..ee80bd54b4 100644 --- a/src/validation/tests/assignment_validation_tests.rs +++ b/src/validation/tests/assignment_validation_tests.rs @@ -982,5 +982,5 @@ fn string_type_alias_assignment_can_be_validated() { ", ); - assert_validation_snapshot!(diagnostics) + assert_validation_snapshot!(diagnostics); } diff --git a/src/validation/tests/snapshots/rusty__validation__tests__array_validation_test__array_assignment_function_call.snap b/src/validation/tests/snapshots/rusty__validation__tests__array_validation_test__array_assignment_function_call.snap index 0d025501e3..fb54e8bb7d 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__array_validation_test__array_assignment_function_call.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__array_validation_test__array_assignment_function_call.snap @@ -2,16 +2,16 @@ source: src/validation/tests/array_validation_test.rs expression: diagnostics --- -error: Invalid assignment: cannot assign '__foo_return' to '__main_arr_incorrect_size' +error: Invalid assignment: cannot assign 'ARRAY [0..3] OF USINT' to 'ARRAY[0..1] OF USINT' ┌─ :16:13 │ 16 │ arr_incorrect_size := foo(); // We want a invalid size array error here - │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Invalid assignment: cannot assign '__foo_return' to '__main_arr_incorrect_size' + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Invalid assignment: cannot assign 'ARRAY [0..3] OF USINT' to 'ARRAY[0..1] OF USINT' -error: Array __main_arr_incorrect_size has a size of 2, but 4 elements were provided +error: Array `arr_incorrect_size` has a size of 2, but 4 elements were provided ┌─ :16:36 │ 16 │ arr_incorrect_size := foo(); // We want a invalid size array error here - │ ^^^^^^ Array __main_arr_incorrect_size has a size of 2, but 4 elements were provided + │ ^^^^^^ Array `arr_incorrect_size` has a size of 2, but 4 elements were provided diff --git a/src/validation/tests/snapshots/rusty__validation__tests__array_validation_test__assignment_1d.snap b/src/validation/tests/snapshots/rusty__validation__tests__array_validation_test__assignment_1d.snap index f2a359ccfc..67411b1e13 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__array_validation_test__assignment_1d.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__array_validation_test__assignment_1d.snap @@ -32,11 +32,11 @@ error: Unexpected token: expected KeywordParensClose but found ';' 16 │ arr := (1, 2, 3, 4, 5]; │ ^ Unexpected token: expected KeywordParensClose but found ';' -error: Array __main_arr has a size of 5, but 6 elements were provided +error: Array `arr` has a size of 5, but 6 elements were provided ┌─ :4:54 │ 4 │ arr : ARRAY[1..5] OF DINT := [1, 2, 3, 4, 5, 6]; - │ ^^^^^^^^^^^^^^^^^^ Array __main_arr has a size of 5, but 6 elements were provided + │ ^^^^^^^^^^^^^^^^^^ Array `arr` has a size of 5, but 6 elements were provided error: Array assignments must be surrounded with `[]` ┌─ :5:55 @@ -62,11 +62,11 @@ error: Array assignments must be surrounded with `[]` 13 │ arr := (1, 2, 3, 4, 5, 6); │ ^^^^^^^^^^^^^^^^ Array assignments must be surrounded with `[]` -error: Array __main_arr has a size of 5, but 6 elements were provided +error: Array `arr` has a size of 5, but 6 elements were provided ┌─ :14:20 │ 14 │ arr := [1, 2, 3, 4, 5, 6]; - │ ^^^^^^^^^^^^^^^^^^ Array __main_arr has a size of 5, but 6 elements were provided + │ ^^^^^^^^^^^^^^^^^^ Array `arr` has a size of 5, but 6 elements were provided error: Array assignments must be surrounded with `[]` ┌─ :15:34 diff --git a/src/validation/tests/snapshots/rusty__validation__tests__array_validation_test__assignment_2d.snap b/src/validation/tests/snapshots/rusty__validation__tests__array_validation_test__assignment_2d.snap index 1088f43f87..eaad77bb0c 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__array_validation_test__assignment_2d.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__array_validation_test__assignment_2d.snap @@ -2,11 +2,11 @@ source: src/validation/tests/array_validation_test.rs expression: diagnostics --- -error: Array __main_arr has a size of 10, but 11 elements were provided +error: Array `arr` has a size of 10, but 11 elements were provided ┌─ :4:64 │ 4 │ arr : ARRAY[1..2, 1..5] OF DINT := [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]; - │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Array __main_arr has a size of 10, but 11 elements were provided + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Array `arr` has a size of 10, but 11 elements were provided error: Array assignments must be surrounded with `[]` ┌─ :5:65 @@ -14,11 +14,11 @@ error: Array assignments must be surrounded with `[]` 5 │ arr_alt : ARRAY[1..2, 1..5] OF DINT := (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11); │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Array assignments must be surrounded with `[]` -error: Array __main_arr_nested has a size of 10, but 15 elements were provided +error: Array `arr_nested` has a size of 10, but 15 elements were provided ┌─ :7:73 │ 7 │ arr_nested : ARRAY[1..2] OF ARRAY[1..5] OF DINT := [ [1, 2, 3, 4, 5], [6, 7, 8, 9, 10], [11, 12, 13, 14, 15] ]; - │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Array __main_arr_nested has a size of 10, but 15 elements were provided + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Array `arr_nested` has a size of 10, but 15 elements were provided error: Array assignments must be surrounded with `[]` ┌─ :8:75 @@ -44,17 +44,17 @@ error: Array assignments must be surrounded with `[]` 16 │ arr := (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11); │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Array assignments must be surrounded with `[]` -error: Array __main_arr has a size of 10, but 11 elements were provided +error: Array `arr` has a size of 10, but 11 elements were provided ┌─ :17:20 │ 17 │ arr := [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]; - │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Array __main_arr has a size of 10, but 11 elements were provided + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Array `arr` has a size of 10, but 11 elements were provided -error: Array __main_arr_nested has a size of 10, but 15 elements were provided +error: Array `arr_nested` has a size of 10, but 15 elements were provided ┌─ :20:32 │ 20 │ arr_nested := [ [1, 2, 3, 4, 5], [6, 7, 8, 9, 10], [11, 12, 13, 14, 15] ]; - │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Array __main_arr_nested has a size of 10, but 15 elements were provided + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Array `arr_nested` has a size of 10, but 15 elements were provided error: Array assignments must be surrounded with `[]` ┌─ :21:34 diff --git a/src/validation/tests/snapshots/rusty__validation__tests__array_validation_test__assignment_3d.snap b/src/validation/tests/snapshots/rusty__validation__tests__array_validation_test__assignment_3d.snap index 35218d5538..e536a3fb2c 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__array_validation_test__assignment_3d.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__array_validation_test__assignment_3d.snap @@ -2,11 +2,11 @@ source: src/validation/tests/array_validation_test.rs expression: diagnostics --- -error: Array __main_arr has a size of 8, but 9 elements were provided +error: Array `arr` has a size of 8, but 9 elements were provided ┌─ :4:66 │ 4 │ arr : ARRAY[1..2, 1..2, 1..2] OF DINT := [1, 2, 3, 4, 5, 6, 7, 8, 9]; - │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^ Array __main_arr has a size of 8, but 9 elements were provided + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^ Array `arr` has a size of 8, but 9 elements were provided error: Array assignments must be surrounded with `[]` ┌─ :5:67 @@ -14,11 +14,11 @@ error: Array assignments must be surrounded with `[]` 5 │ arr_alt : ARRAY[1..2, 1..2, 1..2] OF DINT := (1, 2, 3, 4, 5, 6, 7, 8, 9); │ ^^^^^^^^^^^^^^^^^^^^^^^^^ Array assignments must be surrounded with `[]` -error: Array __main_arr_nested has a size of 8, but 12 elements were provided +error: Array `arr_nested` has a size of 8, but 12 elements were provided ┌─ :7:88 │ 7 │ arr_nested : ARRAY[1..2] OF ARRAY[1..2] OF ARRAY[1..2] OF DINT := [ [[1, 2], [3, 4]], [[5, 6], [7, 8]], [[9, 10], [11, 12]] ]; - │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Array __main_arr_nested has a size of 8, but 12 elements were provided + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Array `arr_nested` has a size of 8, but 12 elements were provided error: Array assignments must be surrounded with `[]` ┌─ :8:90 @@ -38,17 +38,17 @@ error: Array assignments must be surrounded with `[]` 15 │ arr := (1, 2, 3, 4, 5, 6, 7, 8, 9); │ ^^^^^^^^^^^^^^^^^^^^^^^^^ Array assignments must be surrounded with `[]` -error: Array __main_arr has a size of 8, but 9 elements were provided +error: Array `arr` has a size of 8, but 9 elements were provided ┌─ :16:20 │ 16 │ arr := [1, 2, 3, 4, 5, 6, 7, 8, 9]; - │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^ Array __main_arr has a size of 8, but 9 elements were provided + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^ Array `arr` has a size of 8, but 9 elements were provided -error: Array __main_arr_nested has a size of 8, but 12 elements were provided +error: Array `arr_nested` has a size of 8, but 12 elements were provided ┌─ :19:27 │ 19 │ arr_nested := [ [[1, 2], [3, 4]], [[5, 6], [7, 8]], [[9, 10], [11, 12]] ]; - │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Array __main_arr_nested has a size of 8, but 12 elements were provided + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Array `arr_nested` has a size of 8, but 12 elements were provided error: Array assignments must be surrounded with `[]` ┌─ :20:29 diff --git a/src/validation/tests/snapshots/rusty__validation__tests__array_validation_test__assignment_multiplied_statement.snap b/src/validation/tests/snapshots/rusty__validation__tests__array_validation_test__assignment_multiplied_statement.snap index 3084c720a5..3fcc8be91f 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__array_validation_test__assignment_multiplied_statement.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__array_validation_test__assignment_multiplied_statement.snap @@ -2,64 +2,64 @@ source: src/validation/tests/array_validation_test.rs expression: diagnostics --- -error: Array __main_arr_1d has a size of 5, but 6 elements were provided +error: Array `arr_1d` has a size of 5, but 6 elements were provided ┌─ :4:49 │ 4 │ arr_1d : ARRAY[1..5] OF DINT := [6(0)]; - │ ^^^^^^ Array __main_arr_1d has a size of 5, but 6 elements were provided + │ ^^^^^^ Array `arr_1d` has a size of 5, but 6 elements were provided -error: Array __main_arr_2d has a size of 10, but 11 elements were provided +error: Array `arr_2d` has a size of 10, but 11 elements were provided ┌─ :6:55 │ 6 │ arr_2d : ARRAY[1..2, 1..5] OF DINT := [11(0)]; - │ ^^^^^^^ Array __main_arr_2d has a size of 10, but 11 elements were provided + │ ^^^^^^^ Array `arr_2d` has a size of 10, but 11 elements were provided -error: Array __main_arr_2d_nested has a size of 10, but 11 elements were provided +error: Array `arr_2d_nested` has a size of 10, but 11 elements were provided ┌─ :7:71 │ 7 │ arr_2d_nested : ARRAY[1..2] OF ARRAY[1..5] OF DINT := [11(0)]; - │ ^^^^^^^ Array __main_arr_2d_nested has a size of 10, but 11 elements were provided + │ ^^^^^^^ Array `arr_2d_nested` has a size of 10, but 11 elements were provided -error: Array __main_arr_3d has a size of 8, but 9 elements were provided +error: Array `arr_3d` has a size of 8, but 9 elements were provided ┌─ :9:61 │ 9 │ arr_3d : ARRAY[1..2, 1..2, 1..2] OF DINT := [9(0)]; - │ ^^^^^^ Array __main_arr_3d has a size of 8, but 9 elements were provided + │ ^^^^^^ Array `arr_3d` has a size of 8, but 9 elements were provided -error: Array __main_arr_3d_nested has a size of 8, but 9 elements were provided +error: Array `arr_3d_nested` has a size of 8, but 9 elements were provided ┌─ :10:86 │ 10 │ arr_3d_nested : ARRAY[1..2] OF ARRAY[1..2] OF ARRAY[1..2] OF DINT := [9(0)]; - │ ^^^^^^ Array __main_arr_3d_nested has a size of 8, but 9 elements were provided + │ ^^^^^^ Array `arr_3d_nested` has a size of 8, but 9 elements were provided -error: Array __main_arr_1d has a size of 5, but 6 elements were provided +error: Array `arr_1d` has a size of 5, but 6 elements were provided ┌─ :21:23 │ 21 │ arr_1d := [6(0)]; - │ ^^^^^^ Array __main_arr_1d has a size of 5, but 6 elements were provided + │ ^^^^^^ Array `arr_1d` has a size of 5, but 6 elements were provided -error: Array __main_arr_2d has a size of 10, but 11 elements were provided +error: Array `arr_2d` has a size of 10, but 11 elements were provided ┌─ :22:23 │ 22 │ arr_2d := [11(0)]; - │ ^^^^^^^ Array __main_arr_2d has a size of 10, but 11 elements were provided + │ ^^^^^^^ Array `arr_2d` has a size of 10, but 11 elements were provided -error: Array __main_arr_2d_nested has a size of 10, but 11 elements were provided +error: Array `arr_2d_nested` has a size of 10, but 11 elements were provided ┌─ :23:30 │ 23 │ arr_2d_nested := [11(0)]; - │ ^^^^^^^ Array __main_arr_2d_nested has a size of 10, but 11 elements were provided + │ ^^^^^^^ Array `arr_2d_nested` has a size of 10, but 11 elements were provided -error: Array __main_arr_3d has a size of 8, but 9 elements were provided +error: Array `arr_3d` has a size of 8, but 9 elements were provided ┌─ :24:23 │ 24 │ arr_3d := [9(0)]; - │ ^^^^^^ Array __main_arr_3d has a size of 8, but 9 elements were provided + │ ^^^^^^ Array `arr_3d` has a size of 8, but 9 elements were provided -error: Array __main_arr_3d_nested has a size of 8, but 9 elements were provided +error: Array `arr_3d_nested` has a size of 8, but 9 elements were provided ┌─ :25:30 │ 25 │ arr_3d_nested := [9(0)]; - │ ^^^^^^ Array __main_arr_3d_nested has a size of 8, but 9 elements were provided + │ ^^^^^^ Array `arr_3d_nested` has a size of 8, but 9 elements were provided diff --git a/src/validation/tests/snapshots/rusty__validation__tests__assignment_validation_tests__array_assignment_validation.snap b/src/validation/tests/snapshots/rusty__validation__tests__assignment_validation_tests__array_assignment_validation.snap index 58f77aa6b2..b40cb3862d 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__assignment_validation_tests__array_assignment_validation.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__assignment_validation_tests__array_assignment_validation.snap @@ -2,12 +2,12 @@ source: src/validation/tests/assignment_validation_tests.rs expression: res --- -SyntaxError { message: "Invalid assignment: cannot assign '__main_v_arr_sized_string2' to '__main_v_arr_sized_string'", range: [SourceLocation { span: Range(TextLocation { line: 29, column: 4, offset: 729 }..TextLocation { line: 29, column: 45, offset: 770 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid assignment: cannot assign '__main_v_arr_int_2' to '__main_v_arr_int_3'", range: [SourceLocation { span: Range(TextLocation { line: 30, column: 4, offset: 787 }..TextLocation { line: 30, column: 30, offset: 813 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid assignment: cannot assign '__main_v_arr_int_4' to '__main_v_arr_int_3'", range: [SourceLocation { span: Range(TextLocation { line: 32, column: 4, offset: 871 }..TextLocation { line: 32, column: 30, offset: 897 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid assignment: cannot assign '__main_v_arr_real_3' to '__main_v_arr_int_3'", range: [SourceLocation { span: Range(TextLocation { line: 33, column: 4, offset: 914 }..TextLocation { line: 33, column: 31, offset: 941 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid assignment: cannot assign '__main_v_arr_string_3' to '__main_v_arr_int_3'", range: [SourceLocation { span: Range(TextLocation { line: 34, column: 4, offset: 958 }..TextLocation { line: 34, column: 33, offset: 987 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid assignment: cannot assign '__main_v_arr_char_3' to '__main_v_arr_int_3'", range: [SourceLocation { span: Range(TextLocation { line: 35, column: 4, offset: 1004 }..TextLocation { line: 35, column: 31, offset: 1031 }) }], err_no: var__invalid_assignment } +SyntaxError { message: "Invalid assignment: cannot assign 'ARRAY[0..8] OF STRING[1256]' to 'ARRAY[0..3] OF STRING[256]'", range: [SourceLocation { span: Range(TextLocation { line: 29, column: 4, offset: 729 }..TextLocation { line: 29, column: 45, offset: 770 }) }], err_no: var__invalid_assignment } +SyntaxError { message: "Invalid assignment: cannot assign 'ARRAY[0..2] OF INT' to 'ARRAY[0..3] OF INT'", range: [SourceLocation { span: Range(TextLocation { line: 30, column: 4, offset: 787 }..TextLocation { line: 30, column: 30, offset: 813 }) }], err_no: var__invalid_assignment } +SyntaxError { message: "Invalid assignment: cannot assign 'ARRAY[0..4] OF INT' to 'ARRAY[0..3] OF INT'", range: [SourceLocation { span: Range(TextLocation { line: 32, column: 4, offset: 871 }..TextLocation { line: 32, column: 30, offset: 897 }) }], err_no: var__invalid_assignment } +SyntaxError { message: "Invalid assignment: cannot assign 'ARRAY[0..3] OF REAL' to 'ARRAY[0..3] OF INT'", range: [SourceLocation { span: Range(TextLocation { line: 33, column: 4, offset: 914 }..TextLocation { line: 33, column: 31, offset: 941 }) }], err_no: var__invalid_assignment } +SyntaxError { message: "Invalid assignment: cannot assign 'ARRAY[0..3] OF STRING' to 'ARRAY[0..3] OF INT'", range: [SourceLocation { span: Range(TextLocation { line: 34, column: 4, offset: 958 }..TextLocation { line: 34, column: 33, offset: 987 }) }], err_no: var__invalid_assignment } +SyntaxError { message: "Invalid assignment: cannot assign 'ARRAY[0..3] OF CHAR' to 'ARRAY[0..3] OF INT'", range: [SourceLocation { span: Range(TextLocation { line: 35, column: 4, offset: 1004 }..TextLocation { line: 35, column: 31, offset: 1031 }) }], err_no: var__invalid_assignment } SyntaxError { message: "Array assignments must be surrounded with `[]`", range: [SourceLocation { span: Range(TextLocation { line: 36, column: 19, offset: 1063 }..TextLocation { line: 36, column: 20, offset: 1064 }) }], err_no: arr__invalid_array_assignment } SyntaxError { message: "Array assignments must be surrounded with `[]`", range: [SourceLocation { span: Range(TextLocation { line: 37, column: 20, offset: 1106 }..TextLocation { line: 37, column: 30, offset: 1116 }) }], err_no: arr__invalid_array_assignment } SyntaxError { message: "Array assignments must be surrounded with `[]`", range: [SourceLocation { span: Range(TextLocation { line: 38, column: 20, offset: 1148 }..TextLocation { line: 38, column: 36, offset: 1164 }) }], err_no: arr__invalid_array_assignment } @@ -17,6 +17,6 @@ SyntaxError { message: "Invalid assignment: cannot assign 'STRING' to 'INT'", ra SyntaxError { message: "Invalid assignment: cannot assign 'CHAR' to 'INT'", range: [SourceLocation { span: Range(TextLocation { line: 46, column: 4, offset: 1488 }..TextLocation { line: 46, column: 28, offset: 1512 }) }], err_no: var__invalid_assignment } SyntaxError { message: "Invalid assignment: cannot assign 'CHAR' to 'INT'", range: [SourceLocation { span: Range(TextLocation { line: 47, column: 4, offset: 1529 }..TextLocation { line: 47, column: 30, offset: 1555 }) }], err_no: var__invalid_assignment } SyntaxError { message: "Invalid assignment: cannot assign 'STRING' to 'INT'", range: [SourceLocation { span: Range(TextLocation { line: 49, column: 4, offset: 1615 }..TextLocation { line: 49, column: 35, offset: 1646 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid assignment: cannot assign 'DINT' to '__main_v_arr_int_3'", range: [SourceLocation { span: Range(TextLocation { line: 50, column: 4, offset: 1663 }..TextLocation { line: 50, column: 25, offset: 1684 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid assignment: cannot assign '__main_v_arr_int_3' to 'DINT'", range: [SourceLocation { span: Range(TextLocation { line: 51, column: 4, offset: 1701 }..TextLocation { line: 51, column: 25, offset: 1722 }) }], err_no: var__invalid_assignment } +SyntaxError { message: "Invalid assignment: cannot assign 'DINT' to 'ARRAY[0..3] OF INT'", range: [SourceLocation { span: Range(TextLocation { line: 50, column: 4, offset: 1663 }..TextLocation { line: 50, column: 25, offset: 1684 }) }], err_no: var__invalid_assignment } +SyntaxError { message: "Invalid assignment: cannot assign 'ARRAY[0..3] OF INT' to 'DINT'", range: [SourceLocation { span: Range(TextLocation { line: 51, column: 4, offset: 1701 }..TextLocation { line: 51, column: 25, offset: 1722 }) }], err_no: var__invalid_assignment } diff --git a/src/validation/tests/snapshots/rusty__validation__tests__assignment_validation_tests__char_assignment_validation.snap b/src/validation/tests/snapshots/rusty__validation__tests__assignment_validation_tests__char_assignment_validation.snap index 1fbeda4d02..23e12c83d2 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__assignment_validation_tests__char_assignment_validation.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__assignment_validation_tests__char_assignment_validation.snap @@ -12,7 +12,7 @@ SyntaxError { message: "Invalid assignment: cannot assign 'TIME' to 'CHAR'", ran SyntaxError { message: "Invalid assignment: cannot assign 'TIME' to 'CHAR'", range: [SourceLocation { span: Range(TextLocation { line: 38, column: 4, offset: 769 }..TextLocation { line: 38, column: 28, offset: 793 }) }], err_no: var__invalid_assignment } SyntaxError { message: "Invalid assignment: cannot assign 'WORD' to 'CHAR'", range: [SourceLocation { span: Range(TextLocation { line: 39, column: 4, offset: 810 }..TextLocation { line: 39, column: 20, offset: 826 }) }], err_no: var__invalid_assignment } SyntaxError { message: "Invalid assignment: cannot assign 'WORD' to 'CHAR'", range: [SourceLocation { span: Range(TextLocation { line: 40, column: 4, offset: 843 }..TextLocation { line: 40, column: 26, offset: 865 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid assignment: cannot assign 'STRING' to 'CHAR'", range: [SourceLocation { span: Range(TextLocation { line: 41, column: 4, offset: 882 }..TextLocation { line: 41, column: 23, offset: 901 }) }], err_no: var__invalid_assignment } +SyntaxError { message: "Invalid assignment: cannot assign 'STRING[1]' to 'CHAR'", range: [SourceLocation { span: Range(TextLocation { line: 41, column: 4, offset: 882 }..TextLocation { line: 41, column: 23, offset: 901 }) }], err_no: var__invalid_assignment } SyntaxError { message: "Invalid assignment: cannot assign 'STRING' to 'CHAR'", range: [SourceLocation { span: Range(TextLocation { line: 42, column: 4, offset: 933 }..TextLocation { line: 42, column: 24, offset: 953 }) }], err_no: var__invalid_assignment } SyntaxError { message: "Invalid assignment: cannot assign 'WSTRING' to 'CHAR'", range: [SourceLocation { span: Range(TextLocation { line: 44, column: 4, offset: 1013 }..TextLocation { line: 44, column: 17, offset: 1026 }) }], err_no: var__invalid_assignment } SyntaxError { message: "Invalid assignment: cannot assign 'STRING' to 'CHAR'", range: [SourceLocation { span: Range(TextLocation { line: 45, column: 4, offset: 1043 }..TextLocation { line: 45, column: 22, offset: 1061 }) }], err_no: var__invalid_assignment } diff --git a/src/validation/tests/snapshots/rusty__validation__tests__assignment_validation_tests__implicit_invalid_action_call_assignments_are_validated.snap b/src/validation/tests/snapshots/rusty__validation__tests__assignment_validation_tests__implicit_invalid_action_call_assignments_are_validated.snap index ab08bc0074..fb6e7e6a54 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__assignment_validation_tests__implicit_invalid_action_call_assignments_are_validated.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__assignment_validation_tests__implicit_invalid_action_call_assignments_are_validated.snap @@ -2,6 +2,6 @@ source: src/validation/tests/assignment_validation_tests.rs expression: res --- -SyntaxError { message: "Invalid assignment: cannot assign '__main_arr' to 'DINT'", range: [SourceLocation { span: Range(TextLocation { line: 23, column: 19, offset: 516 }..TextLocation { line: 23, column: 22, offset: 519 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid assignment: cannot assign '__main_arr' to 'STRING'", range: [SourceLocation { span: Range(TextLocation { line: 23, column: 24, offset: 521 }..TextLocation { line: 23, column: 27, offset: 524 }) }], err_no: var__invalid_assignment } +SyntaxError { message: "Invalid assignment: cannot assign 'ARRAY[0..10] OF WSTRING' to 'DINT'", range: [SourceLocation { span: Range(TextLocation { line: 23, column: 19, offset: 516 }..TextLocation { line: 23, column: 22, offset: 519 }) }], err_no: var__invalid_assignment } +SyntaxError { message: "Invalid assignment: cannot assign 'ARRAY[0..10] OF WSTRING' to 'STRING'", range: [SourceLocation { span: Range(TextLocation { line: 23, column: 24, offset: 521 }..TextLocation { line: 23, column: 27, offset: 524 }) }], err_no: var__invalid_assignment } diff --git a/src/validation/tests/snapshots/rusty__validation__tests__assignment_validation_tests__invalid_action_call_assignments_are_validated.snap b/src/validation/tests/snapshots/rusty__validation__tests__assignment_validation_tests__invalid_action_call_assignments_are_validated.snap index cce31cbd17..7232aa527f 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__assignment_validation_tests__invalid_action_call_assignments_are_validated.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__assignment_validation_tests__invalid_action_call_assignments_are_validated.snap @@ -2,28 +2,28 @@ source: src/validation/tests/assignment_validation_tests.rs expression: "&diagnostics" --- -error: Invalid assignment: cannot assign '__main_arr' to 'WSTRING' +error: Invalid assignment: cannot assign 'ARRAY[0..10] OF WSTRING' to 'WSTRING' ┌─ :31:20 │ 31 │ fb.foo(auto := arr, in1 := arr, in2 := arr, out => wstr); // invalid - │ ^^^^^^^^^^^ Invalid assignment: cannot assign '__main_arr' to 'WSTRING' + │ ^^^^^^^^^^^ Invalid assignment: cannot assign 'ARRAY[0..10] OF WSTRING' to 'WSTRING' -error: Invalid assignment: cannot assign '__main_arr' to 'DINT' +error: Invalid assignment: cannot assign 'ARRAY[0..10] OF WSTRING' to 'DINT' ┌─ :31:33 │ 31 │ fb.foo(auto := arr, in1 := arr, in2 := arr, out => wstr); // invalid - │ ^^^^^^^^^^ Invalid assignment: cannot assign '__main_arr' to 'DINT' + │ ^^^^^^^^^^ Invalid assignment: cannot assign 'ARRAY[0..10] OF WSTRING' to 'DINT' -error: Invalid assignment: cannot assign '__main_arr' to 'STRING' +error: Invalid assignment: cannot assign 'ARRAY[0..10] OF WSTRING' to 'STRING' ┌─ :31:45 │ 31 │ fb.foo(auto := arr, in1 := arr, in2 := arr, out => wstr); // invalid - │ ^^^^^^^^^^ Invalid assignment: cannot assign '__main_arr' to 'STRING' + │ ^^^^^^^^^^ Invalid assignment: cannot assign 'ARRAY[0..10] OF WSTRING' to 'STRING' -error: Invalid assignment: cannot assign 'WSTRING' to '__fb_t_out' +error: Invalid assignment: cannot assign 'WSTRING' to 'ARRAY[0..10] OF WSTRING' ┌─ :31:57 │ 31 │ fb.foo(auto := arr, in1 := arr, in2 := arr, out => wstr); // invalid - │ ^^^^^^^^^^^ Invalid assignment: cannot assign 'WSTRING' to '__fb_t_out' + │ ^^^^^^^^^^^ Invalid assignment: cannot assign 'WSTRING' to 'ARRAY[0..10] OF WSTRING' diff --git a/src/validation/tests/snapshots/rusty__validation__tests__assignment_validation_tests__invalid_function_block_instantiation_is_validated.snap b/src/validation/tests/snapshots/rusty__validation__tests__assignment_validation_tests__invalid_function_block_instantiation_is_validated.snap index 13a20dfb10..002af10fc2 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__assignment_validation_tests__invalid_function_block_instantiation_is_validated.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__assignment_validation_tests__invalid_function_block_instantiation_is_validated.snap @@ -3,7 +3,7 @@ source: src/validation/tests/assignment_validation_tests.rs expression: res --- SyntaxError { message: "Invalid assignment: cannot assign 'STRING' to 'WSTRING'", range: [SourceLocation { span: Range(TextLocation { line: 14, column: 15, offset: 319 }..TextLocation { line: 14, column: 22, offset: 326 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid assignment: cannot assign '__prog_arr_64' to '__fb_t_arr_32'", range: [SourceLocation { span: Range(TextLocation { line: 14, column: 24, offset: 328 }..TextLocation { line: 14, column: 40, offset: 344 }) }], err_no: var__invalid_assignment } +SyntaxError { message: "Invalid assignment: cannot assign 'ARRAY[0..1] OF LINT' to 'ARRAY[0..1] OF DINT'", range: [SourceLocation { span: Range(TextLocation { line: 14, column: 24, offset: 328 }..TextLocation { line: 14, column: 40, offset: 344 }) }], err_no: var__invalid_assignment } SyntaxError { message: "Invalid assignment: cannot assign 'STRING' to 'WSTRING'", range: [SourceLocation { span: Range(TextLocation { line: 15, column: 15, offset: 382 }..TextLocation { line: 15, column: 16, offset: 383 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid assignment: cannot assign '__prog_arr_64' to '__fb_t_arr_32'", range: [SourceLocation { span: Range(TextLocation { line: 15, column: 18, offset: 385 }..TextLocation { line: 15, column: 24, offset: 391 }) }], err_no: var__invalid_assignment } +SyntaxError { message: "Invalid assignment: cannot assign 'ARRAY[0..1] OF LINT' to 'ARRAY[0..1] OF DINT'", range: [SourceLocation { span: Range(TextLocation { line: 15, column: 18, offset: 385 }..TextLocation { line: 15, column: 24, offset: 391 }) }], err_no: var__invalid_assignment } diff --git a/src/validation/tests/snapshots/rusty__validation__tests__assignment_validation_tests__invalid_method_call_assignments_are_validated.snap b/src/validation/tests/snapshots/rusty__validation__tests__assignment_validation_tests__invalid_method_call_assignments_are_validated.snap index bdc1434d4e..b1a87cc139 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__assignment_validation_tests__invalid_method_call_assignments_are_validated.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__assignment_validation_tests__invalid_method_call_assignments_are_validated.snap @@ -2,6 +2,6 @@ source: src/validation/tests/assignment_validation_tests.rs expression: res --- -SyntaxError { message: "Invalid assignment: cannot assign '__main_arr' to 'DINT'", range: [SourceLocation { span: Range(TextLocation { line: 21, column: 19, offset: 425 }..TextLocation { line: 21, column: 22, offset: 428 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid assignment: cannot assign '__main_arr' to 'STRING'", range: [SourceLocation { span: Range(TextLocation { line: 21, column: 24, offset: 430 }..TextLocation { line: 21, column: 27, offset: 433 }) }], err_no: var__invalid_assignment } +SyntaxError { message: "Invalid assignment: cannot assign 'ARRAY[0..10] OF WSTRING' to 'DINT'", range: [SourceLocation { span: Range(TextLocation { line: 21, column: 19, offset: 425 }..TextLocation { line: 21, column: 22, offset: 428 }) }], err_no: var__invalid_assignment } +SyntaxError { message: "Invalid assignment: cannot assign 'ARRAY[0..10] OF WSTRING' to 'STRING'", range: [SourceLocation { span: Range(TextLocation { line: 21, column: 24, offset: 430 }..TextLocation { line: 21, column: 27, offset: 433 }) }], err_no: var__invalid_assignment } diff --git a/src/validation/tests/snapshots/rusty__validation__tests__assignment_validation_tests__pointer_assignment_validation.snap b/src/validation/tests/snapshots/rusty__validation__tests__assignment_validation_tests__pointer_assignment_validation.snap index e4c8298392..569348292b 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__assignment_validation_tests__pointer_assignment_validation.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__assignment_validation_tests__pointer_assignment_validation.snap @@ -3,11 +3,11 @@ source: src/validation/tests/assignment_validation_tests.rs expression: res --- SyntaxError { message: "The type DINT 32 is too small to hold a Pointer", range: [SourceLocation { span: Range(TextLocation { line: 27, column: 4, offset: 412 }..TextLocation { line: 27, column: 23, offset: 431 }) }], err_no: type__incompatible_size } -SyntaxError { message: "Invalid assignment: cannot assign '__main_v_ptr_int' to 'DINT'", range: [SourceLocation { span: Range(TextLocation { line: 27, column: 4, offset: 412 }..TextLocation { line: 27, column: 23, offset: 431 }) }], err_no: var__invalid_assignment } +SyntaxError { message: "Invalid assignment: cannot assign 'REF_TO INT' to 'DINT'", range: [SourceLocation { span: Range(TextLocation { line: 27, column: 4, offset: 412 }..TextLocation { line: 27, column: 23, offset: 431 }) }], err_no: var__invalid_assignment } SyntaxError { message: "The type WORD 16 is too small to hold a Pointer", range: [SourceLocation { span: Range(TextLocation { line: 28, column: 4, offset: 448 }..TextLocation { line: 28, column: 23, offset: 467 }) }], err_no: type__incompatible_size } -SyntaxError { message: "Invalid assignment: cannot assign '__main_v_ptr_int' to 'WORD'", range: [SourceLocation { span: Range(TextLocation { line: 28, column: 4, offset: 448 }..TextLocation { line: 28, column: 23, offset: 467 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid assignment: cannot assign '__POINTER_TO_REAL' to '__main_v_ptr_int'", range: [SourceLocation { span: Range(TextLocation { line: 30, column: 4, offset: 519 }..TextLocation { line: 30, column: 24, offset: 539 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid assignment: cannot assign '__POINTER_TO_STRING' to '__main_v_ptr_int'", range: [SourceLocation { span: Range(TextLocation { line: 40, column: 4, offset: 898 }..TextLocation { line: 40, column: 26, offset: 920 }) }], err_no: var__invalid_assignment } +SyntaxError { message: "Invalid assignment: cannot assign 'REF_TO INT' to 'WORD'", range: [SourceLocation { span: Range(TextLocation { line: 28, column: 4, offset: 448 }..TextLocation { line: 28, column: 23, offset: 467 }) }], err_no: var__invalid_assignment } +SyntaxError { message: "Invalid assignment: cannot assign '__POINTER_TO_REAL' to 'REF_TO INT'", range: [SourceLocation { span: Range(TextLocation { line: 30, column: 4, offset: 519 }..TextLocation { line: 30, column: 24, offset: 539 }) }], err_no: var__invalid_assignment } +SyntaxError { message: "Invalid assignment: cannot assign '__POINTER_TO_STRING' to 'REF_TO INT'", range: [SourceLocation { span: Range(TextLocation { line: 40, column: 4, offset: 898 }..TextLocation { line: 40, column: 26, offset: 920 }) }], err_no: var__invalid_assignment } SyntaxError { message: "Invalid assignment: cannot assign 'STRING' to 'INT'", range: [SourceLocation { span: Range(TextLocation { line: 41, column: 4, offset: 937 }..TextLocation { line: 41, column: 26, offset: 959 }) }], err_no: var__invalid_assignment } SyntaxError { message: "Invalid assignment: cannot assign 'CHAR' to 'INT'", range: [SourceLocation { span: Range(TextLocation { line: 43, column: 4, offset: 1041 }..TextLocation { line: 43, column: 24, offset: 1061 }) }], err_no: var__invalid_assignment } SyntaxError { message: "Invalid assignment: cannot assign 'STRING' to 'INT'", range: [SourceLocation { span: Range(TextLocation { line: 47, column: 4, offset: 1191 }..TextLocation { line: 47, column: 35, offset: 1222 }) }], err_no: var__invalid_assignment } diff --git a/src/validation/tests/snapshots/rusty__validation__tests__assignment_validation_tests__string_type_alias_assignment_can_be_validated.snap b/src/validation/tests/snapshots/rusty__validation__tests__assignment_validation_tests__string_type_alias_assignment_can_be_validated.snap index 26ec13027e..d12727e38b 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__assignment_validation_tests__string_type_alias_assignment_can_be_validated.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__assignment_validation_tests__string_type_alias_assignment_can_be_validated.snap @@ -3,5 +3,5 @@ source: src/validation/tests/assignment_validation_tests.rs expression: res --- SyntaxError { message: "Invalid assignment: cannot assign 'INT' to 'STRING'", range: [SourceLocation { span: Range(TextLocation { line: 10, column: 12, offset: 241 }..TextLocation { line: 10, column: 23, offset: 252 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid assignment: cannot assign 'INT' to 'STRING'", range: [SourceLocation { span: Range(TextLocation { line: 11, column: 12, offset: 266 }..TextLocation { line: 11, column: 29, offset: 283 }) }], err_no: var__invalid_assignment } +SyntaxError { message: "Invalid assignment: cannot assign 'INT' to 'MY_OTHER_STR'", range: [SourceLocation { span: Range(TextLocation { line: 11, column: 12, offset: 266 }..TextLocation { line: 11, column: 29, offset: 283 }) }], err_no: var__invalid_assignment } diff --git a/src/validation/tests/snapshots/rusty__validation__tests__assignment_validation_tests__struct_assignment_validation.snap b/src/validation/tests/snapshots/rusty__validation__tests__assignment_validation_tests__struct_assignment_validation.snap index 22cb0ebbe1..c5d8573f58 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__assignment_validation_tests__struct_assignment_validation.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__assignment_validation_tests__struct_assignment_validation.snap @@ -7,10 +7,10 @@ SyntaxError { message: "Invalid assignment: cannot assign 'REAL' to 'STRUCT1'", SyntaxError { message: "Invalid assignment: cannot assign 'STRUCT2' to 'STRUCT1'", range: [SourceLocation { span: Range(TextLocation { line: 49, column: 4, offset: 866 }..TextLocation { line: 49, column: 26, offset: 888 }) }], err_no: var__invalid_assignment } SyntaxError { message: "Invalid assignment: cannot assign 'STRUCT2' to 'STRUCT1'", range: [SourceLocation { span: Range(TextLocation { line: 52, column: 18, offset: 974 }..TextLocation { line: 52, column: 42, offset: 998 }) }], err_no: var__invalid_assignment } SyntaxError { message: "Invalid assignment: cannot assign 'STRUCT2' to 'STRUCT1'", range: [SourceLocation { span: Range(TextLocation { line: 55, column: 9, offset: 1073 }..TextLocation { line: 55, column: 39, offset: 1103 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid assignment: cannot assign '__POINTER_TO_REAL' to '__main_v_ref_to_struct1'", range: [SourceLocation { span: Range(TextLocation { line: 66, column: 4, offset: 1410 }..TextLocation { line: 66, column: 35, offset: 1441 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid assignment: cannot assign '__POINTER_TO_STRING' to '__main_v_ref_to_struct1'", range: [SourceLocation { span: Range(TextLocation { line: 67, column: 4, offset: 1458 }..TextLocation { line: 67, column: 37, offset: 1491 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid assignment: cannot assign '__POINTER_TO_CHAR' to '__main_v_ref_to_struct1'", range: [SourceLocation { span: Range(TextLocation { line: 68, column: 4, offset: 1508 }..TextLocation { line: 68, column: 35, offset: 1539 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid assignment: cannot assign '__POINTER_TO_REAL' to '__main_v_ref_to_struct1'", range: [SourceLocation { span: Range(TextLocation { line: 70, column: 4, offset: 1557 }..TextLocation { line: 70, column: 33, offset: 1586 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid assignment: cannot assign '__POINTER_TO_STRING' to '__main_v_ref_to_struct1'", range: [SourceLocation { span: Range(TextLocation { line: 71, column: 4, offset: 1603 }..TextLocation { line: 71, column: 35, offset: 1634 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid assignment: cannot assign '__POINTER_TO_CHAR' to '__main_v_ref_to_struct1'", range: [SourceLocation { span: Range(TextLocation { line: 72, column: 4, offset: 1651 }..TextLocation { line: 72, column: 33, offset: 1680 }) }], err_no: var__invalid_assignment } +SyntaxError { message: "Invalid assignment: cannot assign '__POINTER_TO_REAL' to 'REF_TO STRUCT1'", range: [SourceLocation { span: Range(TextLocation { line: 66, column: 4, offset: 1410 }..TextLocation { line: 66, column: 35, offset: 1441 }) }], err_no: var__invalid_assignment } +SyntaxError { message: "Invalid assignment: cannot assign '__POINTER_TO_STRING' to 'REF_TO STRUCT1'", range: [SourceLocation { span: Range(TextLocation { line: 67, column: 4, offset: 1458 }..TextLocation { line: 67, column: 37, offset: 1491 }) }], err_no: var__invalid_assignment } +SyntaxError { message: "Invalid assignment: cannot assign '__POINTER_TO_CHAR' to 'REF_TO STRUCT1'", range: [SourceLocation { span: Range(TextLocation { line: 68, column: 4, offset: 1508 }..TextLocation { line: 68, column: 35, offset: 1539 }) }], err_no: var__invalid_assignment } +SyntaxError { message: "Invalid assignment: cannot assign '__POINTER_TO_REAL' to 'REF_TO STRUCT1'", range: [SourceLocation { span: Range(TextLocation { line: 70, column: 4, offset: 1557 }..TextLocation { line: 70, column: 33, offset: 1586 }) }], err_no: var__invalid_assignment } +SyntaxError { message: "Invalid assignment: cannot assign '__POINTER_TO_STRING' to 'REF_TO STRUCT1'", range: [SourceLocation { span: Range(TextLocation { line: 71, column: 4, offset: 1603 }..TextLocation { line: 71, column: 35, offset: 1634 }) }], err_no: var__invalid_assignment } +SyntaxError { message: "Invalid assignment: cannot assign '__POINTER_TO_CHAR' to 'REF_TO STRUCT1'", range: [SourceLocation { span: Range(TextLocation { line: 72, column: 4, offset: 1651 }..TextLocation { line: 72, column: 33, offset: 1680 }) }], err_no: var__invalid_assignment } diff --git a/src/validation/tests/snapshots/rusty__validation__tests__assignment_validation_tests__trimmed_slices.snap b/src/validation/tests/snapshots/rusty__validation__tests__assignment_validation_tests__trimmed_slices.snap new file mode 100644 index 0000000000..d37f05f286 --- /dev/null +++ b/src/validation/tests/snapshots/rusty__validation__tests__assignment_validation_tests__trimmed_slices.snap @@ -0,0 +1,11 @@ +--- +source: src/validation/tests/assignment_validation_tests.rs +expression: diagnostic +--- +error: Invalid assignment: cannot assign 'ARRAY[1..5] OF DINT' to 'ARRAY[1..1] OF DINT' + ┌─ :13:13 + │ +13 │ one := two; + │ ^^^^^^^^^^ Invalid assignment: cannot assign 'ARRAY[1..5] OF DINT' to 'ARRAY[1..1] OF DINT' + + diff --git a/src/validation/tests/snapshots/rusty__validation__tests__statement_validation_tests__action_implicit_downcast.snap b/src/validation/tests/snapshots/rusty__validation__tests__statement_validation_tests__action_implicit_downcast.snap index c4815796a5..172cbf754d 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__statement_validation_tests__action_implicit_downcast.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__statement_validation_tests__action_implicit_downcast.snap @@ -3,5 +3,5 @@ source: src/validation/tests/statement_validation_tests.rs expression: res --- SyntaxError { message: "Invalid assignment: cannot assign 'WSTRING' to 'STRING'", range: [SourceLocation { span: Range(TextLocation { line: 8, column: 29, offset: 213 }..TextLocation { line: 8, column: 37, offset: 221 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid assignment: cannot assign '__main_var_arr' to 'STRING'", range: [SourceLocation { span: Range(TextLocation { line: 9, column: 31, offset: 276 }..TextLocation { line: 9, column: 38, offset: 283 }) }], err_no: var__invalid_assignment } +SyntaxError { message: "Invalid assignment: cannot assign 'ARRAY[1..3] OF LINT' to 'STRING'", range: [SourceLocation { span: Range(TextLocation { line: 9, column: 31, offset: 276 }..TextLocation { line: 9, column: 38, offset: 283 }) }], err_no: var__invalid_assignment } diff --git a/src/validation/tests/snapshots/rusty__validation__tests__statement_validation_tests__assign_pointer_to_too_small_type_result_in_an_error.snap b/src/validation/tests/snapshots/rusty__validation__tests__statement_validation_tests__assign_pointer_to_too_small_type_result_in_an_error.snap index 907136b3db..a6c8a6c9a0 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__statement_validation_tests__assign_pointer_to_too_small_type_result_in_an_error.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__statement_validation_tests__assign_pointer_to_too_small_type_result_in_an_error.snap @@ -3,5 +3,5 @@ source: src/validation/tests/statement_validation_tests.rs expression: res --- SyntaxError { message: "The type DWORD 32 is too small to hold a Pointer", range: [SourceLocation { span: Range(TextLocation { line: 8, column: 12, offset: 174 }..TextLocation { line: 8, column: 26, offset: 188 }) }], err_no: type__incompatible_size } -SyntaxError { message: "Invalid assignment: cannot assign '__FOO_ptr' to 'DWORD'", range: [SourceLocation { span: Range(TextLocation { line: 8, column: 12, offset: 174 }..TextLocation { line: 8, column: 26, offset: 188 }) }], err_no: var__invalid_assignment } +SyntaxError { message: "Invalid assignment: cannot assign 'REF_TO INT' to 'DWORD'", range: [SourceLocation { span: Range(TextLocation { line: 8, column: 12, offset: 174 }..TextLocation { line: 8, column: 26, offset: 188 }) }], err_no: var__invalid_assignment } diff --git a/src/validation/tests/snapshots/rusty__validation__tests__statement_validation_tests__assign_too_small_type_to_pointer_result_in_an_error.snap b/src/validation/tests/snapshots/rusty__validation__tests__statement_validation_tests__assign_too_small_type_to_pointer_result_in_an_error.snap index b1a4cec19e..6028b9bbed 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__statement_validation_tests__assign_too_small_type_to_pointer_result_in_an_error.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__statement_validation_tests__assign_too_small_type_to_pointer_result_in_an_error.snap @@ -3,5 +3,5 @@ source: src/validation/tests/statement_validation_tests.rs expression: res --- SyntaxError { message: "The type DWORD 32 is too small to to be stored in a Pointer", range: [SourceLocation { span: Range(TextLocation { line: 8, column: 12, offset: 174 }..TextLocation { line: 8, column: 26, offset: 188 }) }], err_no: type__incompatible_size } -SyntaxError { message: "Invalid assignment: cannot assign 'DWORD' to '__FOO_ptr'", range: [SourceLocation { span: Range(TextLocation { line: 8, column: 12, offset: 174 }..TextLocation { line: 8, column: 26, offset: 188 }) }], err_no: var__invalid_assignment } +SyntaxError { message: "Invalid assignment: cannot assign 'DWORD' to 'REF_TO INT'", range: [SourceLocation { span: Range(TextLocation { line: 8, column: 12, offset: 174 }..TextLocation { line: 8, column: 26, offset: 188 }) }], err_no: var__invalid_assignment } diff --git a/src/validation/tests/snapshots/rusty__validation__tests__statement_validation_tests__assignment_of_incompatible_types_is_reported.snap b/src/validation/tests/snapshots/rusty__validation__tests__statement_validation_tests__assignment_of_incompatible_types_is_reported.snap index 7450ec5381..809d91ef38 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__statement_validation_tests__assignment_of_incompatible_types_is_reported.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__statement_validation_tests__assignment_of_incompatible_types_is_reported.snap @@ -8,11 +8,11 @@ error: Invalid assignment: cannot assign 'DINT' to 'STRING' 8 │ string_ := dint_; // invalid │ ^^^^^^^^^^^^^^^^ Invalid assignment: cannot assign 'DINT' to 'STRING' -error: Invalid assignment: cannot assign '__prog_array_' to 'STRING' +error: Invalid assignment: cannot assign 'ARRAY[0..3] OF LWORD' to 'STRING' ┌─ :9:9 │ 9 │ string_ := array_; // invalid - │ ^^^^^^^^^^^^^^^^^ Invalid assignment: cannot assign '__prog_array_' to 'STRING' + │ ^^^^^^^^^^^^^^^^^ Invalid assignment: cannot assign 'ARRAY[0..3] OF LWORD' to 'STRING' error: Invalid assignment: cannot assign 'STRING' to 'DINT' ┌─ :10:9 @@ -20,10 +20,10 @@ error: Invalid assignment: cannot assign 'STRING' to 'DINT' 10 │ dint_ := string_; // invalid │ ^^^^^^^^^^^^^^^^ Invalid assignment: cannot assign 'STRING' to 'DINT' -error: Invalid assignment: cannot assign 'STRING' to '__prog_array_' +error: Invalid assignment: cannot assign 'STRING' to 'ARRAY[0..3] OF LWORD' ┌─ :11:9 │ 11 │ array_ := string_; // invalid - │ ^^^^^^^^^^^^^^^^^ Invalid assignment: cannot assign 'STRING' to '__prog_array_' + │ ^^^^^^^^^^^^^^^^^ Invalid assignment: cannot assign 'STRING' to 'ARRAY[0..3] OF LWORD' diff --git a/src/validation/tests/snapshots/rusty__validation__tests__statement_validation_tests__function_call_parameter_validation.snap b/src/validation/tests/snapshots/rusty__validation__tests__statement_validation_tests__function_call_parameter_validation.snap index 2d8ed5723e..b7fc7df26c 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__statement_validation_tests__function_call_parameter_validation.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__statement_validation_tests__function_call_parameter_validation.snap @@ -6,8 +6,8 @@ SyntaxError { message: "Cannot mix implicit and explicit call parameters!", rang SyntaxError { message: "Cannot mix implicit and explicit call parameters!", range: [SourceLocation { span: Range(TextLocation { line: 22, column: 39, offset: 513 }..TextLocation { line: 22, column: 43, offset: 517 }) }], err_no: call__invalid_parameter_type } SyntaxError { message: "Invalid assignment: cannot assign 'STRING' to 'DINT'", range: [SourceLocation { span: Range(TextLocation { line: 24, column: 16, offset: 581 }..TextLocation { line: 24, column: 30, offset: 595 }) }], err_no: var__invalid_assignment } SyntaxError { message: "The type DINT 32 is too small to hold a Pointer", range: [SourceLocation { span: Range(TextLocation { line: 24, column: 32, offset: 597 }..TextLocation { line: 24, column: 46, offset: 611 }) }], err_no: type__incompatible_size } -SyntaxError { message: "Invalid assignment: cannot assign '__main_var3' to 'DINT'", range: [SourceLocation { span: Range(TextLocation { line: 24, column: 32, offset: 597 }..TextLocation { line: 24, column: 46, offset: 611 }) }], err_no: var__invalid_assignment } +SyntaxError { message: "Invalid assignment: cannot assign 'REF_TO WSTRING' to 'DINT'", range: [SourceLocation { span: Range(TextLocation { line: 24, column: 32, offset: 597 }..TextLocation { line: 24, column: 46, offset: 611 }) }], err_no: var__invalid_assignment } SyntaxError { message: "Invalid assignment: cannot assign 'STRING' to 'DINT'", range: [SourceLocation { span: Range(TextLocation { line: 26, column: 16, offset: 770 }..TextLocation { line: 26, column: 20, offset: 774 }) }], err_no: var__invalid_assignment } SyntaxError { message: "The type DINT 32 is too small to hold a Pointer", range: [SourceLocation { span: Range(TextLocation { line: 26, column: 22, offset: 776 }..TextLocation { line: 26, column: 26, offset: 780 }) }], err_no: type__incompatible_size } -SyntaxError { message: "Invalid assignment: cannot assign '__main_var3' to 'DINT'", range: [SourceLocation { span: Range(TextLocation { line: 26, column: 22, offset: 776 }..TextLocation { line: 26, column: 26, offset: 780 }) }], err_no: var__invalid_assignment } +SyntaxError { message: "Invalid assignment: cannot assign 'REF_TO WSTRING' to 'DINT'", range: [SourceLocation { span: Range(TextLocation { line: 26, column: 22, offset: 776 }..TextLocation { line: 26, column: 26, offset: 780 }) }], err_no: var__invalid_assignment } diff --git a/src/validation/tests/snapshots/rusty__validation__tests__statement_validation_tests__method_implicit_downcast.snap b/src/validation/tests/snapshots/rusty__validation__tests__statement_validation_tests__method_implicit_downcast.snap index c63ac493ad..738b575116 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__statement_validation_tests__method_implicit_downcast.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__statement_validation_tests__method_implicit_downcast.snap @@ -2,5 +2,5 @@ source: src/validation/tests/statement_validation_tests.rs expression: res --- -SyntaxError { message: "Invalid assignment: cannot assign '__main_var_arr' to '__MyClass.testMethod_arr'", range: [SourceLocation { span: Range(TextLocation { line: 7, column: 32, offset: 156 }..TextLocation { line: 7, column: 39, offset: 163 }) }], err_no: var__invalid_assignment } +SyntaxError { message: "Invalid assignment: cannot assign 'ARRAY[1..3] OF DINT' to 'ARRAY[1..3] OF SINT'", range: [SourceLocation { span: Range(TextLocation { line: 7, column: 32, offset: 156 }..TextLocation { line: 7, column: 39, offset: 163 }) }], err_no: var__invalid_assignment } diff --git a/src/validation/tests/snapshots/rusty__validation__tests__statement_validation_tests__program_call_parameter_validation.snap b/src/validation/tests/snapshots/rusty__validation__tests__statement_validation_tests__program_call_parameter_validation.snap index 10d97c65da..910492da3e 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__statement_validation_tests__program_call_parameter_validation.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__statement_validation_tests__program_call_parameter_validation.snap @@ -6,8 +6,8 @@ SyntaxError { message: "Cannot mix implicit and explicit call parameters!", rang SyntaxError { message: "Cannot mix implicit and explicit call parameters!", range: [SourceLocation { span: Range(TextLocation { line: 22, column: 40, offset: 507 }..TextLocation { line: 22, column: 44, offset: 511 }) }], err_no: call__invalid_parameter_type } SyntaxError { message: "Invalid assignment: cannot assign 'STRING' to 'DINT'", range: [SourceLocation { span: Range(TextLocation { line: 24, column: 17, offset: 576 }..TextLocation { line: 24, column: 31, offset: 590 }) }], err_no: var__invalid_assignment } SyntaxError { message: "The type DINT 32 is too small to hold a Pointer", range: [SourceLocation { span: Range(TextLocation { line: 24, column: 33, offset: 592 }..TextLocation { line: 24, column: 47, offset: 606 }) }], err_no: type__incompatible_size } -SyntaxError { message: "Invalid assignment: cannot assign '__main_var3' to 'DINT'", range: [SourceLocation { span: Range(TextLocation { line: 24, column: 33, offset: 592 }..TextLocation { line: 24, column: 47, offset: 606 }) }], err_no: var__invalid_assignment } +SyntaxError { message: "Invalid assignment: cannot assign 'REF_TO WSTRING' to 'DINT'", range: [SourceLocation { span: Range(TextLocation { line: 24, column: 33, offset: 592 }..TextLocation { line: 24, column: 47, offset: 606 }) }], err_no: var__invalid_assignment } SyntaxError { message: "Invalid assignment: cannot assign 'STRING' to 'DINT'", range: [SourceLocation { span: Range(TextLocation { line: 26, column: 17, offset: 767 }..TextLocation { line: 26, column: 21, offset: 771 }) }], err_no: var__invalid_assignment } SyntaxError { message: "The type DINT 32 is too small to hold a Pointer", range: [SourceLocation { span: Range(TextLocation { line: 26, column: 23, offset: 773 }..TextLocation { line: 26, column: 27, offset: 777 }) }], err_no: type__incompatible_size } -SyntaxError { message: "Invalid assignment: cannot assign '__main_var3' to 'DINT'", range: [SourceLocation { span: Range(TextLocation { line: 26, column: 23, offset: 773 }..TextLocation { line: 26, column: 27, offset: 777 }) }], err_no: var__invalid_assignment } +SyntaxError { message: "Invalid assignment: cannot assign 'REF_TO WSTRING' to 'DINT'", range: [SourceLocation { span: Range(TextLocation { line: 26, column: 23, offset: 773 }..TextLocation { line: 26, column: 27, offset: 777 }) }], err_no: var__invalid_assignment } diff --git a/src/validation/tests/snapshots/rusty__validation__tests__statement_validation_tests__reference_to_reference_assignments_in_function_arguments.snap b/src/validation/tests/snapshots/rusty__validation__tests__statement_validation_tests__reference_to_reference_assignments_in_function_arguments.snap index a9b6d99a12..45b1cc0b55 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__statement_validation_tests__reference_to_reference_assignments_in_function_arguments.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__statement_validation_tests__reference_to_reference_assignments_in_function_arguments.snap @@ -2,10 +2,10 @@ source: src/validation/tests/statement_validation_tests.rs expression: res --- -SyntaxError { message: "Invalid assignment: cannot assign '__POINTER_TO_INT' to '__prog_input1'", range: [SourceLocation { span: Range(TextLocation { line: 46, column: 12, offset: 1286 }..TextLocation { line: 46, column: 34, offset: 1308 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid assignment: cannot assign '__POINTER_TO_REAL' to '__prog_input2'", range: [SourceLocation { span: Range(TextLocation { line: 47, column: 12, offset: 1322 }..TextLocation { line: 47, column: 34, offset: 1344 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid assignment: cannot assign '__POINTER_TO_STRING' to '__prog_input3'", range: [SourceLocation { span: Range(TextLocation { line: 48, column: 12, offset: 1358 }..TextLocation { line: 48, column: 34, offset: 1380 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid assignment: cannot assign '__POINTER_TO_INT' to '__prog_input1'", range: [SourceLocation { span: Range(TextLocation { line: 54, column: 12, offset: 1588 }..TextLocation { line: 54, column: 32, offset: 1608 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid assignment: cannot assign '__POINTER_TO_REAL' to '__prog_input2'", range: [SourceLocation { span: Range(TextLocation { line: 55, column: 12, offset: 1622 }..TextLocation { line: 55, column: 32, offset: 1642 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid assignment: cannot assign '__POINTER_TO___global_global6' to '__prog_input3'", range: [SourceLocation { span: Range(TextLocation { line: 56, column: 12, offset: 1656 }..TextLocation { line: 56, column: 32, offset: 1676 }) }], err_no: var__invalid_assignment } +SyntaxError { message: "Invalid assignment: cannot assign '__POINTER_TO_INT' to 'REF_TO STRUCT_params'", range: [SourceLocation { span: Range(TextLocation { line: 46, column: 12, offset: 1286 }..TextLocation { line: 46, column: 34, offset: 1308 }) }], err_no: var__invalid_assignment } +SyntaxError { message: "Invalid assignment: cannot assign '__POINTER_TO_REAL' to 'REF_TO STRUCT_params'", range: [SourceLocation { span: Range(TextLocation { line: 47, column: 12, offset: 1322 }..TextLocation { line: 47, column: 34, offset: 1344 }) }], err_no: var__invalid_assignment } +SyntaxError { message: "Invalid assignment: cannot assign '__POINTER_TO_STRING' to 'REF_TO STRUCT_params'", range: [SourceLocation { span: Range(TextLocation { line: 48, column: 12, offset: 1358 }..TextLocation { line: 48, column: 34, offset: 1380 }) }], err_no: var__invalid_assignment } +SyntaxError { message: "Invalid assignment: cannot assign '__POINTER_TO_INT' to 'REF_TO STRUCT_params'", range: [SourceLocation { span: Range(TextLocation { line: 54, column: 12, offset: 1588 }..TextLocation { line: 54, column: 32, offset: 1608 }) }], err_no: var__invalid_assignment } +SyntaxError { message: "Invalid assignment: cannot assign '__POINTER_TO_REAL' to 'REF_TO STRUCT_params'", range: [SourceLocation { span: Range(TextLocation { line: 55, column: 12, offset: 1622 }..TextLocation { line: 55, column: 32, offset: 1642 }) }], err_no: var__invalid_assignment } +SyntaxError { message: "Invalid assignment: cannot assign '__POINTER_TO___global_global6' to 'REF_TO STRUCT_params'", range: [SourceLocation { span: Range(TextLocation { line: 56, column: 12, offset: 1656 }..TextLocation { line: 56, column: 32, offset: 1676 }) }], err_no: var__invalid_assignment } diff --git a/src/validation/tests/snapshots/rusty__validation__tests__statement_validation_tests__validate_array_elements_passed_to_functions_by_ref.snap b/src/validation/tests/snapshots/rusty__validation__tests__statement_validation_tests__validate_array_elements_passed_to_functions_by_ref.snap index 85f404dac5..0f4d381118 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__statement_validation_tests__validate_array_elements_passed_to_functions_by_ref.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__statement_validation_tests__validate_array_elements_passed_to_functions_by_ref.snap @@ -2,6 +2,6 @@ source: src/validation/tests/statement_validation_tests.rs expression: res --- -SyntaxError { message: "Invalid assignment: cannot assign '__main_x' to 'INT'", range: [SourceLocation { span: Range(TextLocation { line: 16, column: 17, offset: 323 }..TextLocation { line: 16, column: 18, offset: 324 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid assignment: cannot assign '__main_x' to 'INT'", range: [SourceLocation { span: Range(TextLocation { line: 16, column: 20, offset: 326 }..TextLocation { line: 16, column: 21, offset: 327 }) }], err_no: var__invalid_assignment } +SyntaxError { message: "Invalid assignment: cannot assign 'ARRAY[0..1] OF INT' to 'INT'", range: [SourceLocation { span: Range(TextLocation { line: 16, column: 17, offset: 323 }..TextLocation { line: 16, column: 18, offset: 324 }) }], err_no: var__invalid_assignment } +SyntaxError { message: "Invalid assignment: cannot assign 'ARRAY[0..1] OF INT' to 'INT'", range: [SourceLocation { span: Range(TextLocation { line: 16, column: 20, offset: 326 }..TextLocation { line: 16, column: 21, offset: 327 }) }], err_no: var__invalid_assignment } diff --git a/src/validation/tests/snapshots/rusty__validation__tests__statement_validation_tests__validate_arrays_passed_to_functions.snap b/src/validation/tests/snapshots/rusty__validation__tests__statement_validation_tests__validate_arrays_passed_to_functions.snap index 741d7bf9af..f05608379a 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__statement_validation_tests__validate_arrays_passed_to_functions.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__statement_validation_tests__validate_arrays_passed_to_functions.snap @@ -2,12 +2,12 @@ source: src/validation/tests/statement_validation_tests.rs expression: res --- -SyntaxError { message: "Invalid assignment: cannot assign '__main_arr_sint' to '__func_arr_dint'", range: [SourceLocation { span: Range(TextLocation { line: 25, column: 17, offset: 959 }..TextLocation { line: 25, column: 25, offset: 967 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid assignment: cannot assign '__main_arr_int' to '__func_arr_dint'", range: [SourceLocation { span: Range(TextLocation { line: 26, column: 17, offset: 987 }..TextLocation { line: 26, column: 24, offset: 994 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid assignment: cannot assign '__main_arr_lint' to '__func_arr_dint'", range: [SourceLocation { span: Range(TextLocation { line: 28, column: 17, offset: 1042 }..TextLocation { line: 28, column: 25, offset: 1050 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid assignment: cannot assign '__main_arr_real' to '__func_arr_dint'", range: [SourceLocation { span: Range(TextLocation { line: 29, column: 17, offset: 1070 }..TextLocation { line: 29, column: 25, offset: 1078 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid assignment: cannot assign '__main_arr_lreal' to '__func_arr_dint'", range: [SourceLocation { span: Range(TextLocation { line: 30, column: 17, offset: 1098 }..TextLocation { line: 30, column: 26, offset: 1107 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid assignment: cannot assign '__main_arr_dint_1_10' to '__func_arr_dint'", range: [SourceLocation { span: Range(TextLocation { line: 35, column: 17, offset: 1300 }..TextLocation { line: 35, column: 30, offset: 1313 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid assignment: cannot assign '__main_arr_dint_10_100' to '__func_arr_dint'", range: [SourceLocation { span: Range(TextLocation { line: 36, column: 17, offset: 1333 }..TextLocation { line: 36, column: 32, offset: 1348 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid assignment: cannot assign '__main_arr_dint_2d' to '__func_arr_dint'", range: [SourceLocation { span: Range(TextLocation { line: 39, column: 17, offset: 1425 }..TextLocation { line: 39, column: 28, offset: 1436 }) }], err_no: var__invalid_assignment } +SyntaxError { message: "Invalid assignment: cannot assign 'ARRAY[0..1] OF SINT' to 'ARRAY[0..1] OF DINT'", range: [SourceLocation { span: Range(TextLocation { line: 25, column: 17, offset: 959 }..TextLocation { line: 25, column: 25, offset: 967 }) }], err_no: var__invalid_assignment } +SyntaxError { message: "Invalid assignment: cannot assign 'ARRAY[0..1] OF INT' to 'ARRAY[0..1] OF DINT'", range: [SourceLocation { span: Range(TextLocation { line: 26, column: 17, offset: 987 }..TextLocation { line: 26, column: 24, offset: 994 }) }], err_no: var__invalid_assignment } +SyntaxError { message: "Invalid assignment: cannot assign 'ARRAY[0..1] OF LINT' to 'ARRAY[0..1] OF DINT'", range: [SourceLocation { span: Range(TextLocation { line: 28, column: 17, offset: 1042 }..TextLocation { line: 28, column: 25, offset: 1050 }) }], err_no: var__invalid_assignment } +SyntaxError { message: "Invalid assignment: cannot assign 'ARRAY[0..1] OF REAL' to 'ARRAY[0..1] OF DINT'", range: [SourceLocation { span: Range(TextLocation { line: 29, column: 17, offset: 1070 }..TextLocation { line: 29, column: 25, offset: 1078 }) }], err_no: var__invalid_assignment } +SyntaxError { message: "Invalid assignment: cannot assign 'ARRAY[0..1] OF LREAL' to 'ARRAY[0..1] OF DINT'", range: [SourceLocation { span: Range(TextLocation { line: 30, column: 17, offset: 1098 }..TextLocation { line: 30, column: 26, offset: 1107 }) }], err_no: var__invalid_assignment } +SyntaxError { message: "Invalid assignment: cannot assign 'ARRAY[1..10] OF DINT' to 'ARRAY[0..1] OF DINT'", range: [SourceLocation { span: Range(TextLocation { line: 35, column: 17, offset: 1300 }..TextLocation { line: 35, column: 30, offset: 1313 }) }], err_no: var__invalid_assignment } +SyntaxError { message: "Invalid assignment: cannot assign 'ARRAY[10..100] OF DINT' to 'ARRAY[0..1] OF DINT'", range: [SourceLocation { span: Range(TextLocation { line: 36, column: 17, offset: 1333 }..TextLocation { line: 36, column: 32, offset: 1348 }) }], err_no: var__invalid_assignment } +SyntaxError { message: "Invalid assignment: cannot assign 'ARRAY[0..1] OF ARRAY[0..1] OF DINT' to 'ARRAY[0..1] OF DINT'", range: [SourceLocation { span: Range(TextLocation { line: 39, column: 17, offset: 1425 }..TextLocation { line: 39, column: 28, offset: 1436 }) }], err_no: var__invalid_assignment } diff --git a/src/validation/tests/snapshots/rusty__validation__tests__variable_length_array_test__access__variable_length_array_access.snap b/src/validation/tests/snapshots/rusty__validation__tests__variable_length_array_test__access__variable_length_array_access.snap index a733a89e97..99ef91d8b6 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__variable_length_array_test__access__variable_length_array_access.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__variable_length_array_test__access__variable_length_array_access.snap @@ -3,5 +3,5 @@ source: src/validation/tests/variable_length_array_test.rs expression: res --- SemanticError { message: "Expected array access with 1 dimensions, found 2", range: [SourceLocation { span: Range(TextLocation { line: 7, column: 20, offset: 187 }..TextLocation { line: 7, column: 24, offset: 191 }) }], err_no: vla__invalid_array_access } -SyntaxError { message: "Invalid assignment: cannot assign '__main_local_b' to '__fn_arr'", range: [SourceLocation { span: Range(TextLocation { line: 17, column: 19, offset: 514 }..TextLocation { line: 17, column: 26, offset: 521 }) }], err_no: var__invalid_assignment } +SyntaxError { message: "Invalid assignment: cannot assign 'ARRAY[0..5, 5..10] OF DINT' to 'ARRAY[*] OF DINT'", range: [SourceLocation { span: Range(TextLocation { line: 17, column: 19, offset: 514 }..TextLocation { line: 17, column: 26, offset: 521 }) }], err_no: var__invalid_assignment } diff --git a/src/validation/tests/snapshots/rusty__validation__tests__variable_length_array_test__access__variable_length_array_incompatible_datatypes.snap b/src/validation/tests/snapshots/rusty__validation__tests__variable_length_array_test__access__variable_length_array_incompatible_datatypes.snap index 3add64c302..16d09d6de1 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__variable_length_array_test__access__variable_length_array_incompatible_datatypes.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__variable_length_array_test__access__variable_length_array_incompatible_datatypes.snap @@ -2,7 +2,7 @@ source: src/validation/tests/variable_length_array_test.rs expression: res --- -SyntaxError { message: "Invalid assignment: cannot assign '__main_local_int' to '__fn_arr'", range: [SourceLocation { span: Range(TextLocation { line: 14, column: 19, offset: 436 }..TextLocation { line: 14, column: 28, offset: 445 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid assignment: cannot assign '__main_local_float' to '__fn_arr'", range: [SourceLocation { span: Range(TextLocation { line: 15, column: 19, offset: 467 }..TextLocation { line: 15, column: 30, offset: 478 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid assignment: cannot assign '__main_local_string' to '__fn_arr'", range: [SourceLocation { span: Range(TextLocation { line: 16, column: 19, offset: 500 }..TextLocation { line: 16, column: 31, offset: 512 }) }], err_no: var__invalid_assignment } +SyntaxError { message: "Invalid assignment: cannot assign 'ARRAY[0..10] OF INT' to 'ARRAY[*] OF DINT'", range: [SourceLocation { span: Range(TextLocation { line: 14, column: 19, offset: 436 }..TextLocation { line: 14, column: 28, offset: 445 }) }], err_no: var__invalid_assignment } +SyntaxError { message: "Invalid assignment: cannot assign 'ARRAY[0..10] OF REAL' to 'ARRAY[*] OF DINT'", range: [SourceLocation { span: Range(TextLocation { line: 15, column: 19, offset: 467 }..TextLocation { line: 15, column: 30, offset: 478 }) }], err_no: var__invalid_assignment } +SyntaxError { message: "Invalid assignment: cannot assign 'ARRAY[0..10] OF STRING' to 'ARRAY[*] OF DINT'", range: [SourceLocation { span: Range(TextLocation { line: 16, column: 19, offset: 500 }..TextLocation { line: 16, column: 31, offset: 512 }) }], err_no: var__invalid_assignment } diff --git a/src/validation/tests/snapshots/rusty__validation__tests__variable_length_array_test__assignment__function_calls.snap b/src/validation/tests/snapshots/rusty__validation__tests__variable_length_array_test__assignment__function_calls.snap index be2ab8b14b..6635324a26 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__variable_length_array_test__assignment__function_calls.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__variable_length_array_test__assignment__function_calls.snap @@ -2,6 +2,6 @@ source: src/validation/tests/variable_length_array_test.rs expression: res --- -SyntaxError { message: "Invalid assignment: cannot assign '__fn_vla' to '__fn_a'", range: [SourceLocation { span: Range(TextLocation { line: 11, column: 16, offset: 267 }..TextLocation { line: 11, column: 26, offset: 277 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid assignment: cannot assign '__fn_a' to '__fn_vla'", range: [SourceLocation { span: Range(TextLocation { line: 12, column: 16, offset: 295 }..TextLocation { line: 12, column: 24, offset: 303 }) }], err_no: var__invalid_assignment } +SyntaxError { message: "Invalid assignment: cannot assign 'ARRAY[*] OF DINT' to 'ARRAY[0..10] OF DINT'", range: [SourceLocation { span: Range(TextLocation { line: 11, column: 16, offset: 267 }..TextLocation { line: 11, column: 26, offset: 277 }) }], err_no: var__invalid_assignment } +SyntaxError { message: "Invalid assignment: cannot assign 'ARRAY[0..10] OF DINT' to 'ARRAY[*] OF DINT'", range: [SourceLocation { span: Range(TextLocation { line: 12, column: 16, offset: 295 }..TextLocation { line: 12, column: 24, offset: 303 }) }], err_no: var__invalid_assignment } diff --git a/src/validation/tests/snapshots/rusty__validation__tests__variable_length_array_test__builtins__builtins_called_with_invalid_type.snap b/src/validation/tests/snapshots/rusty__validation__tests__variable_length_array_test__builtins__builtins_called_with_invalid_type.snap index f4f2841d12..b1cabf23fc 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__variable_length_array_test__builtins__builtins_called_with_invalid_type.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__variable_length_array_test__builtins__builtins_called_with_invalid_type.snap @@ -2,11 +2,11 @@ source: src/validation/tests/variable_length_array_test.rs expression: res --- -SyntaxError { message: "Invalid assignment: cannot assign '__main_arr' to 'VARIABLE LENGTH ARRAY'", range: [SourceLocation { span: Range(TextLocation { line: 9, column: 24, offset: 221 }..TextLocation { line: 9, column: 27, offset: 224 }) }], err_no: var__invalid_assignment } +SyntaxError { message: "Invalid assignment: cannot assign 'ARRAY[0..1] OF DINT' to 'VARIABLE LENGTH ARRAY'", range: [SourceLocation { span: Range(TextLocation { line: 9, column: 24, offset: 221 }..TextLocation { line: 9, column: 27, offset: 224 }) }], err_no: var__invalid_assignment } SyntaxError { message: "Invalid assignment: cannot assign 'TIME' to 'VARIABLE LENGTH ARRAY'", range: [SourceLocation { span: Range(TextLocation { line: 10, column: 24, offset: 265 }..TextLocation { line: 10, column: 32, offset: 273 }) }], err_no: var__invalid_assignment } SyntaxError { message: "Expected a reference for parameter arr because their type is InOut", range: [SourceLocation { span: Range(TextLocation { line: 11, column: 24, offset: 303 }..TextLocation { line: 11, column: 39, offset: 318 }) }], err_no: call__invalid_parameter_type } SyntaxError { message: "Invalid assignment: cannot assign 'STRING' to 'VARIABLE LENGTH ARRAY'", range: [SourceLocation { span: Range(TextLocation { line: 11, column: 24, offset: 303 }..TextLocation { line: 11, column: 39, offset: 318 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid assignment: cannot assign '__main_arr' to 'VARIABLE LENGTH ARRAY'", range: [SourceLocation { span: Range(TextLocation { line: 13, column: 24, offset: 349 }..TextLocation { line: 13, column: 27, offset: 352 }) }], err_no: var__invalid_assignment } +SyntaxError { message: "Invalid assignment: cannot assign 'ARRAY[0..1] OF DINT' to 'VARIABLE LENGTH ARRAY'", range: [SourceLocation { span: Range(TextLocation { line: 13, column: 24, offset: 349 }..TextLocation { line: 13, column: 27, offset: 352 }) }], err_no: var__invalid_assignment } SyntaxError { message: "Invalid assignment: cannot assign 'TIME' to 'VARIABLE LENGTH ARRAY'", range: [SourceLocation { span: Range(TextLocation { line: 14, column: 24, offset: 393 }..TextLocation { line: 14, column: 32, offset: 401 }) }], err_no: var__invalid_assignment } SyntaxError { message: "Expected a reference for parameter arr because their type is InOut", range: [SourceLocation { span: Range(TextLocation { line: 15, column: 24, offset: 431 }..TextLocation { line: 15, column: 39, offset: 446 }) }], err_no: call__invalid_parameter_type } SyntaxError { message: "Invalid assignment: cannot assign 'STRING' to 'VARIABLE LENGTH ARRAY'", range: [SourceLocation { span: Range(TextLocation { line: 15, column: 24, offset: 431 }..TextLocation { line: 15, column: 39, offset: 446 }) }], err_no: var__invalid_assignment } From 27e5b2b75dbcffeec439b6b5b4b35ad82d2d31d9 Mon Sep 17 00:00:00 2001 From: Michael <78988079+mhasel@users.noreply.github.com> Date: Tue, 16 Jan 2024 12:03:45 +0100 Subject: [PATCH 23/33] fix(timers): add internal flag to track state (#1068) --- libs/stdlib/iec61131-st/timers.st | 11 ++++++++++- libs/stdlib/src/timers.rs | 5 ++++- libs/stdlib/tests/timer_tests.rs | 27 +++++++++++++++++++++++++++ 3 files changed, 41 insertions(+), 2 deletions(-) diff --git a/libs/stdlib/iec61131-st/timers.st b/libs/stdlib/iec61131-st/timers.st index 7b3faea699..cf11504daf 100644 --- a/libs/stdlib/iec61131-st/timers.st +++ b/libs/stdlib/iec61131-st/timers.st @@ -20,6 +20,7 @@ FUNCTION_BLOCK TP END_VAR VAR __signal__ : BOOL; (* Value representing the internal signal *) + __is_running__: BOOL; (* Internal flag to track timer on/off state *) __BUFFER__ : ARRAY[1..24] OF BYTE; (* Buffer used for internal implementation *) END_VAR END_FUNCTION_BLOCK @@ -46,6 +47,7 @@ FUNCTION_BLOCK TP_TIME END_VAR VAR __signal__ : BOOL; (* Value representing the internal signal *) + __is_running__: BOOL; (* Internal flag to track timer on/off state *) __BUFFER__ : ARRAY[1..24] OF BYTE; (* Buffer used for internal implementation *) END_VAR END_FUNCTION_BLOCK @@ -72,6 +74,7 @@ FUNCTION_BLOCK TP_LTIME END_VAR VAR __signal__ : BOOL; (* Value representing the internal signal *) + __is_running__: BOOL; (* Internal flag to track timer on/off state *) __BUFFER__ : ARRAY[1..24] OF BYTE; (* Buffer used for internal implementation *) END_VAR END_FUNCTION_BLOCK @@ -98,6 +101,7 @@ VAR_OUTPUT END_VAR VAR __signal__ : BOOL; (* Value representing the internal signal *) + __is_running__: BOOL; (* Internal flag to track timer on/off state *) __BUFFER__ : ARRAY[1..24] OF BYTE; (* Buffer used for internal implementation *) END_VAR END_FUNCTION_BLOCK @@ -124,6 +128,7 @@ VAR_OUTPUT END_VAR VAR __signal__ : BOOL; (* Value representing the internal signal *) + __is_running__: BOOL; (* Internal flag to track timer on/off state *) __BUFFER__ : ARRAY[1..24] OF BYTE; (* Buffer used for internal implementation *) END_VAR END_FUNCTION_BLOCK @@ -149,7 +154,8 @@ VAR_OUTPUT ET: TIME; END_VAR VAR - __signal__ : BOOL; (* Value representing the internal signal *) + __signal__ : BOOL; (* Value representing the internal signal *) + __is_running__: BOOL; (* Internal flag to track timer on/off state *) __BUFFER__ : ARRAY[1..24] OF BYTE; (* Buffer used for internal implementation *) END_VAR END_FUNCTION_BLOCK @@ -176,6 +182,7 @@ VAR_OUTPUT END_VAR VAR __signal__ : BOOL; (* Value representing the internal signal *) + __is_running__: BOOL; (* Internal flag to track timer on/off state *) __BUFFER__ : ARRAY[1..24] OF BYTE; (* Buffer used for internal implementation *) END_VAR END_FUNCTION_BLOCK @@ -202,6 +209,7 @@ VAR_OUTPUT END_VAR VAR __signal__ : BOOL; (* Value representing the internal signal *) + __is_running__: BOOL; (* Internal flag to track timer on/off state *) __BUFFER__ : ARRAY[1..24] OF BYTE; (* Buffer used for internal implementation *) END_VAR END_FUNCTION_BLOCK @@ -228,6 +236,7 @@ VAR_OUTPUT END_VAR VAR __signal__ : BOOL; (* Value representing the internal signal *) + __is_running__: BOOL; (* Internal flag to track timer on/off state *) __BUFFER__ : ARRAY[1..24] OF BYTE; (* Buffer used for internal implementation *) END_VAR END_FUNCTION_BLOCK diff --git a/libs/stdlib/src/timers.rs b/libs/stdlib/src/timers.rs index 8d33820d13..a3c47d6c10 100644 --- a/libs/stdlib/src/timers.rs +++ b/libs/stdlib/src/timers.rs @@ -20,6 +20,7 @@ pub struct TimerParams { output: bool, elapsed_time: Time, input_edge: Signal, + is_running: bool, start_time: Option, } @@ -28,16 +29,18 @@ impl TimerParams { /// It does not take into consideration the preset/range for the timer /// Only if a start time has been set. fn is_running(&self) -> bool { - self.start_time.is_some() + self.is_running } fn start(&mut self) { self.start_time = Some(Instant::now()); + self.is_running = true; self.set_elapsed_time(0); } fn reset(&mut self) { self.start_time = None; + self.is_running = false; self.set_elapsed_time(0); } diff --git a/libs/stdlib/tests/timer_tests.rs b/libs/stdlib/tests/timer_tests.rs index b7d16260fe..3c80c156ff 100644 --- a/libs/stdlib/tests/timer_tests.rs +++ b/libs/stdlib/tests/timer_tests.rs @@ -237,6 +237,33 @@ fn ton_returns_true_after_time_preset() { assert_eq!(main_inst.tp_et, 0); } +#[test] +fn ton_q_defaults_to_false() { + let prog = r#" + VAR_GLOBAL + ton_test: TON; + END_VAR + + PROGRAM main + VAR + tp_out : BOOL; + tp_et : TIME; + tp_inst : TON; + END_VAR + ton_test(IN:=TRUE, PT:=T#2s); + tp_out = ton_test.Q; + END_PROGRAM + "#; + + let source = add_std!(prog, "timers.st"); + let context = CodegenContext::create(); + let module = compile_with_native(&context, source); + let mut main_inst = MainType { value: true, ..MainType::default() }; + // Value true First call -> false + module.run::<_, ()>("main", &mut main_inst); + assert!(!main_inst.tp_out); +} + #[test] fn ton_counts_elapsed_time_while_waiting() { let prog = r#" From 8204311133ffbf7464adfc7a5da2dab31c49cc53 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 23 Jan 2024 14:04:33 +0100 Subject: [PATCH 24/33] chore: Bump h2 from 0.3.22 to 0.3.24 (#1073) Bumps [h2](https://github.com/hyperium/h2) from 0.3.22 to 0.3.24. - [Release notes](https://github.com/hyperium/h2/releases) - [Changelog](https://github.com/hyperium/h2/blob/v0.3.24/CHANGELOG.md) - [Commits](https://github.com/hyperium/h2/compare/v0.3.22...v0.3.24) --- updated-dependencies: - dependency-name: h2 dependency-type: indirect ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- Cargo.lock | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 181d4a7f7f..6f5bc9f2d6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1071,9 +1071,9 @@ dependencies = [ [[package]] name = "h2" -version = "0.3.22" +version = "0.3.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4d6250322ef6e60f93f9a2162799302cd6f68f79f6e5d85c8c16f14d1d958178" +checksum = "bb2c4422095b67ee78da96fbb51a4cc413b3b25883c7717ff7ca1ab31022c9c9" dependencies = [ "bytes", "fnv", From baea0879113d4102a3e282566afeb00cf57f85a0 Mon Sep 17 00:00:00 2001 From: Ghaith Hachem Date: Wed, 24 Jan 2024 13:02:40 +0100 Subject: [PATCH 25/33] refactor: use the buffered validator (#1076) * refactor: use the buffered validator All the validation tests now use the buffered validator this makes it easy to refactor the diagnostics without worrying about breaking the location of the tests. Ideally these tests should no longer change if we change diagnostics * Empty diagnostics are no longer snapshots --- .../initialization_test/type_initializers.rs | 12 +- ...expressions_should_not_change_the_ast.snap | 25 -- src/validation/tests.rs | 12 - .../tests/assignment_validation_tests.rs | 81 ++-- .../tests/bitaccess_validation_test.rs | 39 +- .../tests/builtin_validation_tests.rs | 21 +- .../tests/duplicates_validation_test.rs | 76 ++-- .../tests/generic_validation_tests.rs | 407 +++++++++--------- .../tests/literals_validation_tests.rs | 37 +- .../tests/naming_validation_test.rs | 8 +- src/validation/tests/pou_validation_tests.rs | 49 +-- .../tests/recursive_validation_tests.rs | 127 +++--- .../tests/reference_resolve_tests.rs | 50 +-- ...on_tests__array_assignment_validation.snap | 121 +++++- ...patible_encoding_to_char_is_validated.snap | 16 +- ..._should_deliver_improvment_suggestion.snap | 9 +- ...tion_tests__bit_assignment_validation.snap | 51 ++- ...ion_tests__char_assignment_validation.snap | 177 ++++++-- ...tests__constant_assignment_validation.snap | 9 +- ...ion_tests__date_assignment_validation.snap | 51 ++- ...tests__duration_assignment_validation.snap | 51 ++- ...idation_tests__enum_variants_mismatch.snap | 30 +- ...plicit_action_downcasts_are_validated.snap | 9 +- ...action_call_assignments_are_validated.snap | 16 +- ...tion_tests__int_assignment_validation.snap | 100 ++++- ...tion_block_instantiation_is_validated.snap | 30 +- ...method_call_assignments_are_validated.snap | 16 +- ..._tests__pointer_assignment_validation.snap | 65 ++- ...ion_tests__real_assignment_validation.snap | 51 ++- ...n_tests__string_assignment_validation.snap | 135 +++++- ...ype_alias_assignment_can_be_validated.snap | 16 +- ...n_tests__struct_assignment_validation.snap | 79 +++- ...ment_validation_tests__trimmed_slices.snap | 11 - ...ion_test__bitaccess_only_on_bit_types.snap | 23 +- ...validation_test__bitaccess_range_test.snap | 30 +- ...test__byteaccess_only_on_bigger_sizes.snap | 23 +- ...alidation_test__byteaccess_range_test.snap | 23 +- ...est__dwordaccess_only_on_bigger_sizes.snap | 23 +- ...lidation_test__dwordaccess_range_test.snap | 9 +- ...eference_direct_access_only_with_ints.snap | 16 +- ...test__wordaccess_only_on_bigger_sizes.snap | 23 +- ...alidation_test__wordaccess_range_test.snap | 16 +- ...ltins_called_with_invalid_param_count.snap | 37 +- ...ltins_called_with_invalid_param_count.snap | 23 +- ..._duplicate_action_should_be_a_problem.snap | 22 +- ...dation_test__duplicate_enum_variables.snap | 20 +- ..._test__duplicate_fb_inst_and_function.snap | 22 +- ...on_test__duplicate_global_and_program.snap | 22 +- ...tion_test__duplicate_global_variables.snap | 22 +- ...__duplicate_pous_and_types_validation.snap | 20 +- ...ation_test__duplicate_pous_validation.snap | 61 ++- ...test__duplicate_variables_in_same_pou.snap | 22 +- ...n_tests__any_bit_does_not_allow_chars.snap | 30 +- ...on_tests__any_bit_does_not_allow_date.snap | 37 +- ...on_tests__any_bit_does_not_allow_ints.snap | 58 ++- ...n_tests__any_bit_does_not_allow_reals.snap | 16 +- ..._tests__any_bit_does_not_allow_string.snap | 30 +- ...on_tests__any_bit_does_not_allow_time.snap | 16 +- ...on_tests__any_bit_multiple_parameters.snap | 65 ++- ...n_tests__any_char_does_not_allow_bits.snap | 72 +++- ...n_tests__any_char_does_not_allow_date.snap | 72 +++- ...n_tests__any_char_does_not_allow_ints.snap | 114 ++++- ..._tests__any_char_does_not_allow_reals.snap | 30 +- ...tests__any_char_does_not_allow_string.snap | 30 +- ...n_tests__any_char_does_not_allow_time.snap | 30 +- ...n_tests__any_char_multiple_parameters.snap | 100 ++++- ..._tests__any_chars_does_not_allow_bits.snap | 72 +++- ..._tests__any_chars_does_not_allow_date.snap | 72 +++- ..._tests__any_chars_does_not_allow_ints.snap | 114 ++++- ...tests__any_chars_does_not_allow_reals.snap | 30 +- ..._tests__any_chars_does_not_allow_time.snap | 30 +- ..._tests__any_chars_multiple_parameters.snap | 93 +++- ...n_tests__any_date_does_not_allow_bits.snap | 37 +- ..._tests__any_date_does_not_allow_chars.snap | 30 +- ...n_tests__any_date_does_not_allow_ints.snap | 58 ++- ..._tests__any_date_does_not_allow_reals.snap | 16 +- ...tests__any_date_does_not_allow_string.snap | 30 +- ...n_tests__any_date_does_not_allow_time.snap | 16 +- ...n_tests__any_date_multiple_parameters.snap | 65 ++- ...sts__any_duration_does_not_allow_bits.snap | 37 +- ...ts__any_duration_does_not_allow_chars.snap | 30 +- ...sts__any_duration_does_not_allow_date.snap | 37 +- ...sts__any_duration_does_not_allow_ints.snap | 58 ++- ...ts__any_duration_does_not_allow_reals.snap | 16 +- ...s__any_duration_does_not_allow_string.snap | 30 +- ...sts__any_duration_multiple_parameters.snap | 65 ++- ...on_tests__any_int_does_not_allow_bits.snap | 37 +- ...n_tests__any_int_does_not_allow_chars.snap | 30 +- ...on_tests__any_int_does_not_allow_date.snap | 37 +- ...n_tests__any_int_does_not_allow_reals.snap | 16 +- ..._tests__any_int_does_not_allow_string.snap | 30 +- ...on_tests__any_int_does_not_allow_time.snap | 16 +- ...on_tests__any_int_multiple_parameters.snap | 58 ++- ...ts__any_magnitude_does_not_allow_bits.snap | 37 +- ...s__any_magnitude_does_not_allow_chars.snap | 30 +- ...ts__any_magnitude_does_not_allow_date.snap | 37 +- ..._any_magnitude_does_not_allow_strings.snap | 30 +- ...ts__any_magnitude_multiple_parameters.snap | 44 +- ...dation_tests__any_multiple_parameters.snap | 16 +- ...on_tests__any_num_does_not_allow_bits.snap | 37 +- ...n_tests__any_num_does_not_allow_chars.snap | 30 +- ...on_tests__any_num_does_not_allow_date.snap | 37 +- ...tests__any_num_does_not_allow_strings.snap | 30 +- ...on_tests__any_num_does_not_allow_time.snap | 16 +- ...on_tests__any_num_multiple_parameters.snap | 51 ++- ...n_tests__any_real_does_not_allow_bits.snap | 37 +- ..._tests__any_real_does_not_allow_chars.snap | 30 +- ...n_tests__any_real_does_not_allow_date.snap | 37 +- ...tests__any_real_does_not_allow_string.snap | 30 +- ...n_tests__any_real_does_not_allow_time.snap | 16 +- ...n_tests__any_real_multiple_parameters.snap | 51 ++- ...tests__any_signed_does_not_allow_bits.snap | 37 +- ...ests__any_signed_does_not_allow_chars.snap | 30 +- ...tests__any_signed_does_not_allow_date.snap | 37 +- ...ests__any_signed_does_not_allow_reals.snap | 16 +- ...sts__any_signed_does_not_allow_string.snap | 30 +- ...tests__any_signed_does_not_allow_time.snap | 16 +- ...y_signed_does_not_allow_unsigned_ints.snap | 30 +- ...tests__any_signed_multiple_parameters.snap | 65 ++- ...tests__any_string_does_not_allow_bits.snap | 72 +++- ...ests__any_string_does_not_allow_chars.snap | 30 +- ...tests__any_string_does_not_allow_date.snap | 72 +++- ...tests__any_string_does_not_allow_ints.snap | 114 ++++- ...ests__any_string_does_not_allow_reals.snap | 30 +- ...tests__any_string_does_not_allow_time.snap | 30 +- ...tests__any_string_multiple_parameters.snap | 100 ++++- ...sts__any_unsigned_does_not_allow_bits.snap | 37 +- ...ts__any_unsigned_does_not_allow_chars.snap | 30 +- ...sts__any_unsigned_does_not_allow_date.snap | 37 +- ...ts__any_unsigned_does_not_allow_reals.snap | 16 +- ...y_unsigned_does_not_allow_signed_ints.snap | 30 +- ...s__any_unsigned_does_not_allow_string.snap | 30 +- ...sts__any_unsigned_does_not_allow_time.snap | 16 +- ...sts__any_unsigned_multiple_parameters.snap | 65 ++- ...tests__non_resolved_generics_reported.snap | 9 +- ...sts__bool_literal_casts_are_validated.snap | 23 +- ..._validation_tests__char_cast_validate.snap | 16 +- ...sts__date_literal_casts_are_validated.snap | 86 +++- ...iteral_casts_max_values_are_validated.snap | 23 +- ..._tests__literal_cast_with_non_literal.snap | 9 +- ...sts__real_literal_casts_are_validated.snap | 16 +- ...s__string_literal_casts_are_validated.snap | 44 +- ...__tests__naming_validation_test__BOOL.snap | 16 +- ...__tests__naming_validation_test__BYTE.snap | 16 +- ...__tests__naming_validation_test__CHAR.snap | 16 +- ...ion__tests__naming_validation_test__D.snap | 16 +- ...__tests__naming_validation_test__DATE.snap | 16 +- ...naming_validation_test__DATE_AND_TIME.snap | 16 +- ...__tests__naming_validation_test__DINT.snap | 16 +- ...on__tests__naming_validation_test__DT.snap | 16 +- ..._tests__naming_validation_test__DWORD.snap | 16 +- ...n__tests__naming_validation_test__INT.snap | 16 +- ...on__tests__naming_validation_test__LD.snap | 16 +- ..._tests__naming_validation_test__LDATE.snap | 16 +- ...aming_validation_test__LDATE_AND_TIME.snap | 16 +- ...n__tests__naming_validation_test__LDT.snap | 16 +- ...__tests__naming_validation_test__LINT.snap | 16 +- ..._tests__naming_validation_test__LREAL.snap | 16 +- ...on__tests__naming_validation_test__LT.snap | 16 +- ..._tests__naming_validation_test__LTIME.snap | 16 +- ..._naming_validation_test__LTIME_OF_DAY.snap | 16 +- ...__tests__naming_validation_test__LTOD.snap | 16 +- ..._tests__naming_validation_test__LWORD.snap | 16 +- ...__tests__naming_validation_test__REAL.snap | 16 +- ...__tests__naming_validation_test__SINT.snap | 16 +- ...tests__naming_validation_test__STRING.snap | 16 +- ...ion__tests__naming_validation_test__T.snap | 16 +- ...__tests__naming_validation_test__TIME.snap | 16 +- ...__naming_validation_test__TIME_OF_DAY.snap | 16 +- ...n__tests__naming_validation_test__TOD.snap | 16 +- ..._tests__naming_validation_test__UDINT.snap | 16 +- ...__tests__naming_validation_test__UINT.snap | 16 +- ..._tests__naming_validation_test__ULINT.snap | 16 +- ..._tests__naming_validation_test__USINT.snap | 16 +- ..._tests__naming_validation_test__WCHAR.snap | 16 +- ...__tests__naming_validation_test__WORD.snap | 16 +- ...ests__naming_validation_test__WSTRING.snap | 16 +- ...__tests__naming_validation_test____U1.snap | 16 +- ...tion_tests__actions_container_no_name.snap | 9 +- ...ation_tests__class_has_implementation.snap | 10 +- ...idation_tests__class_with_return_type.snap | 16 +- ...ation_tests__function_has_super_class.snap | 16 +- ...tests__function_no_return_unsupported.snap | 9 +- ..._in_out_variable_not_allowed_in_class.snap | 9 +- ...n_tests__in_out_variable_out_of_order.snap | 23 +- ...__input_variable_not_allowed_in_class.snap | 9 +- ..._output_variable_not_allowed_in_class.snap | 9 +- ...dation_tests__program_has_super_class.snap | 9 +- ...on_tests__arrays__one_cycle_aba_input.snap | 12 +- ...n_tests__arrays__one_cycle_aba_output.snap | 12 +- ...lidation_tests__arrays__one_cycle_bcb.snap | 12 +- ...e_with_multiple_identical_members_aba.snap | 12 +- ..._tests__arrays__two_cycles_aa_and_aba.snap | 19 +- ..._arrays__two_cycles_with_branch_input.snap | 34 +- ...__functionblocks__one_cycle_aba_input.snap | 12 +- ..._functionblocks__one_cycle_aba_output.snap | 12 +- ...ts__functionblocks__one_cycle_aba_var.snap | 12 +- ...nblocks__two_cycles_with_branch_input.snap | 34 +- ...d_functionblocks__one_cycle_aba_input.snap | 12 +- ..._functionblocks__one_cycle_aba_output.snap | 12 +- ...nblocks__two_cycles_with_branch_input.snap | 34 +- ...idation_tests__structs__one_cycle_aba.snap | 12 +- ...dation_tests__structs__one_cycle_abca.snap | 15 +- ...idation_tests__structs__one_cycle_bcb.snap | 12 +- ...s__structs__one_cycle_multiple_self_a.snap | 9 +- ...tion_tests__structs__one_cycle_self_a.snap | 9 +- ...e_with_multiple_identical_members_aba.snap | 12 +- ...tests__structs__two_cycles_aa_and_aba.snap | 19 +- ...structs__two_cycles_branch_cc_and_cec.snap | 19 +- ...ests__structs__two_cycles_with_branch.snap | 34 +- ...o_private_variable_in_intermediate_fb.snap | 9 +- ...erence_to_private_variable_is_illegal.snap | 9 +- ...ve_tests__resole_struct_member_access.snap | 44 +- ...ock_calls_in_structs_and_field_access.snap | 44 +- ...resolve_function_calls_and_parameters.snap | 30 +- ...esolve_function_members_via_qualifier.snap | 23 +- ...s__resolve_simple_variable_references.snap | 16 +- ...ation_tests__action_implicit_downcast.snap | 16 +- ..._to_too_small_type_result_in_an_error.snap | 16 +- ...ll_type_to_pointer_result_in_an_error.snap | 16 +- ...validation_tests__assigning_to_rvalue.snap | 23 +- ...nment_to_constants_result_in_an_error.snap | 16 +- ...ent_to_enum_literals_results_in_error.snap | 23 +- ...ith_incorrect_operator_causes_warning.snap | 16 +- ...condition_used_outside_case_statement.snap | 16 +- ...sts__function_block_implicit_downcast.snap | 9 +- ...s__function_call_parameter_validation.snap | 58 ++- ...licit_param_downcast_in_function_call.snap | 9 +- ...__invalid_cast_statement_causes_error.snap | 9 +- ...ation_tests__invalid_char_assignments.snap | 86 +++- ...ation_tests__method_implicit_downcast.snap | 9 +- ..._string_compare_function_causes_error.snap | 58 ++- ...wstring_compare_function_causes_error.snap | 58 ++- ...ts__program_call_parameter_validation.snap | 58 ++- ...tion_tests__program_implicit_downcast.snap | 9 +- ...sts__program_missing_inout_assignment.snap | 30 +- ..._function_reports_invalid_param_count.snap | 16 +- ...nce_assignments_in_function_arguments.snap | 44 +- ...ion_with_wrong_signature_causes_error.snap | 9 +- ..._tests__switch_case_duplicate_integer.snap | 30 +- ...icate_integer_non_const_var_reference.snap | 30 +- ...__switch_case_invalid_case_conditions.snap | 43 +- ...y_elements_passed_to_functions_by_ref.snap | 16 +- ...__validate_arrays_passed_to_functions.snap | 58 ++- ...alidation_tests__validate_call_by_ref.snap | 58 ++- ..._tests__validate_call_by_ref_explicit.snap | 37 +- ..._access__variable_length_array_access.snap | 16 +- ...e_length_array_incompatible_datatypes.snap | 23 +- ...rray_test__assignment__function_calls.snap | 16 +- ...s__builtins_called_with_invalid_index.snap | 44 +- ..._called_with_invalid_number_of_params.snap | 86 +++- ...ns__builtins_called_with_invalid_type.snap | 58 ++- ..._variable_length_array_function_input.snap | 9 +- ...obal_vla_does_not_cause_name_conflict.snap | 9 +- ...__variable_length_array_program_inout.snap | 16 +- ...__variable_length_array_program_input.snap | 16 +- ...riable_length_array_program_input_ref.snap | 16 +- ..._variable_length_array_program_output.snap | 16 +- ...th_array_defined_as_a_global_variable.snap | 9 +- ...ts__constant_fb_instances_are_illegal.snap | 16 +- ...gal_var_blocks_cause_validation_issue.snap | 44 +- ...ts__overflows__overflows_with_aliases.snap | 23 +- ...ows__overflows_with_array_initializer.snap | 9 +- ...__overflows__overflows_with_constants.snap | 11 +- ...overflows__overflows_with_expressions.snap | 142 +++++- ...ts__overflows__overflows_with_globals.snap | 16 +- ..._tests__overflows__overflows_with_hex.snap | 16 +- ...s__overflows__overflows_with_literals.snap | 142 +++++- ...__overflows_with_non_global_constants.snap | 11 + ..._tests__overflows__overflows_with_not.snap | 9 +- ...ion_tests__sized_varargs_require_type.snap | 9 +- ...__unresolvable_variables_are_reported.snap | 23 +- .../tests/statement_validation_tests.rs | 164 ++++--- .../tests/variable_length_array_test.rs | 87 ++-- .../tests/variable_validation_tests.rs | 64 ++- 275 files changed, 7374 insertions(+), 1958 deletions(-) delete mode 100644 src/parser/tests/snapshots/rusty__parser__tests__expressions_parser_tests__parenthesis_expressions_should_not_change_the_ast.snap delete mode 100644 src/validation/tests/snapshots/rusty__validation__tests__assignment_validation_tests__trimmed_slices.snap create mode 100644 src/validation/tests/snapshots/rusty__validation__tests__variable_validation_tests__overflows__overflows_with_non_global_constants.snap diff --git a/src/codegen/tests/initialization_test/type_initializers.rs b/src/codegen/tests/initialization_test/type_initializers.rs index 1ee022b89f..31a313395a 100644 --- a/src/codegen/tests/initialization_test/type_initializers.rs +++ b/src/codegen/tests/initialization_test/type_initializers.rs @@ -1,7 +1,9 @@ use insta::assert_snapshot; use crate::{ - test_utils::tests::{codegen, codegen_debug_without_unwrap, codegen_without_unwrap, parse_and_validate}, + test_utils::tests::{ + codegen, codegen_debug_without_unwrap, codegen_without_unwrap, parse_and_validate_buffered, + }, DebugLevel, }; @@ -538,7 +540,7 @@ fn partly_uninitialized_const_struct_will_get_default_values() { #[test] fn partly_uninitialized_const_struct_will_not_report_errors() { - let diagnostics = parse_and_validate( + let diagnostics = parse_and_validate_buffered( r#" TYPE MyOtherDINT : DINT := 2 ; END_TYPE TYPE MyDINT : MyOtherDINT; END_TYPE @@ -556,12 +558,12 @@ fn partly_uninitialized_const_struct_will_not_report_errors() { END_VAR "#, ); - assert_eq!(diagnostics, vec![]); + assert!(diagnostics.is_empty()) } #[test] fn enums_with_inline_initializer_do_not_report_errors() { - let diagnostics = parse_and_validate( + let diagnostics = parse_and_validate_buffered( r#" VAR_GLOBAL x : (red, yellow, green) := red; @@ -579,7 +581,7 @@ fn enums_with_inline_initializer_do_not_report_errors() { END_FUNCTION "#, ); - assert_eq!(diagnostics, vec![]); + assert!(diagnostics.is_empty()) } #[test] diff --git a/src/parser/tests/snapshots/rusty__parser__tests__expressions_parser_tests__parenthesis_expressions_should_not_change_the_ast.snap b/src/parser/tests/snapshots/rusty__parser__tests__expressions_parser_tests__parenthesis_expressions_should_not_change_the_ast.snap deleted file mode 100644 index 7b5fbfaf07..0000000000 --- a/src/parser/tests/snapshots/rusty__parser__tests__expressions_parser_tests__parenthesis_expressions_should_not_change_the_ast.snap +++ /dev/null @@ -1,25 +0,0 @@ ---- -source: src/parser/tests/expressions_parser_tests.rs -expression: statement ---- -ParenthesizedExpression { - expression: BinaryExpression { - operator: Plus, - left: ReferenceExpr { - kind: Member( - Identifier { - name: "x", - }, - ), - base: None, - }, - right: ReferenceExpr { - kind: Member( - Identifier { - name: "y", - }, - ), - base: None, - }, - }, -} diff --git a/src/validation/tests.rs b/src/validation/tests.rs index 2b27ea2eb0..527738a191 100644 --- a/src/validation/tests.rs +++ b/src/validation/tests.rs @@ -13,15 +13,3 @@ mod reference_resolve_tests; mod statement_validation_tests; mod variable_length_array_test; mod variable_validation_tests; - -#[macro_export] -macro_rules! assert_validation_snapshot { - ($diagnostics:expr) => {{ - let mut res = String::new(); - for ele in $diagnostics { - res.push_str(&format!("{:?}\n", ele)); - } - - insta::assert_snapshot!(res); - }}; -} diff --git a/src/validation/tests/assignment_validation_tests.rs b/src/validation/tests/assignment_validation_tests.rs index ee80bd54b4..fb18df0655 100644 --- a/src/validation/tests/assignment_validation_tests.rs +++ b/src/validation/tests/assignment_validation_tests.rs @@ -1,9 +1,10 @@ -use crate::assert_validation_snapshot; -use crate::test_utils::tests::{parse_and_validate, parse_and_validate_buffered}; +use insta::assert_snapshot; + +use crate::test_utils::tests::parse_and_validate_buffered; #[test] fn constant_assignment_validation() { - let diagnostics = parse_and_validate( + let diagnostics = parse_and_validate_buffered( r#" VAR_GLOBAL CONSTANT v_global : BOOL; @@ -16,12 +17,12 @@ fn constant_assignment_validation() { "#, ); - assert_validation_snapshot!(&diagnostics); + assert_snapshot!(diagnostics) } #[test] fn real_assignment_validation() { - let diagnostics = parse_and_validate( + let diagnostics = parse_and_validate_buffered( r#" FUNCTION main : DINT VAR @@ -75,12 +76,12 @@ fn real_assignment_validation() { "#, ); - assert_validation_snapshot!(&diagnostics); + assert_snapshot!(diagnostics) } #[test] fn int_assignment_validation() { - let diagnostics = parse_and_validate( + let diagnostics = parse_and_validate_buffered( r#" FUNCTION main : DINT VAR @@ -159,12 +160,12 @@ fn int_assignment_validation() { "#, ); - assert_validation_snapshot!(&diagnostics); + assert_snapshot!(diagnostics) } #[test] fn duration_assignment_validation() { - let diagnostics = parse_and_validate( + let diagnostics = parse_and_validate_buffered( r#" FUNCTION main : DINT VAR @@ -218,12 +219,12 @@ fn duration_assignment_validation() { "#, ); - assert_validation_snapshot!(&diagnostics); + assert_snapshot!(diagnostics) } #[test] fn bit_assignment_validation() { - let diagnostics = parse_and_validate( + let diagnostics = parse_and_validate_buffered( r#" FUNCTION main : DINT VAR @@ -277,12 +278,12 @@ fn bit_assignment_validation() { "#, ); - assert_validation_snapshot!(&diagnostics); + assert_snapshot!(diagnostics) } #[test] fn string_assignment_validation() { - let diagnostics = parse_and_validate( + let diagnostics = parse_and_validate_buffered( r#" FUNCTION main : DINT VAR @@ -341,12 +342,12 @@ fn string_assignment_validation() { "#, ); - assert_validation_snapshot!(&diagnostics); + assert_snapshot!(&diagnostics); } #[test] fn char_assignment_validation() { - let diagnostics = parse_and_validate( + let diagnostics = parse_and_validate_buffered( r#" FUNCTION main : DINT VAR @@ -409,12 +410,12 @@ fn char_assignment_validation() { "#, ); - assert_validation_snapshot!(&diagnostics); + assert_snapshot!(&diagnostics); } #[test] fn date_assignment_validation() { - let diagnostics = parse_and_validate( + let diagnostics = parse_and_validate_buffered( r#" FUNCTION main : DINT VAR @@ -468,12 +469,12 @@ fn date_assignment_validation() { "#, ); - assert_validation_snapshot!(&diagnostics); + assert_snapshot!(&diagnostics); } #[test] fn pointer_assignment_validation() { - let diagnostics = parse_and_validate( + let diagnostics = parse_and_validate_buffered( r#" FUNCTION main : DINT VAR @@ -526,12 +527,12 @@ fn pointer_assignment_validation() { "#, ); - assert_validation_snapshot!(&diagnostics); + assert_snapshot!(&diagnostics); } #[test] fn array_assignment_validation() { - let diagnostics = parse_and_validate( + let diagnostics = parse_and_validate_buffered( r#" FUNCTION main : DINT VAR @@ -588,12 +589,12 @@ fn array_assignment_validation() { "#, ); - assert_validation_snapshot!(&diagnostics); + assert_snapshot!(&diagnostics); } #[test] fn struct_assignment_validation() { - let diagnostics = parse_and_validate( + let diagnostics = parse_and_validate_buffered( r#" TYPE STRUCT1 : STRUCT @@ -671,12 +672,12 @@ fn struct_assignment_validation() { "#, ); - assert_validation_snapshot!(&diagnostics); + assert_snapshot!(&diagnostics); } #[test] fn assigning_literal_with_incompatible_encoding_to_char_is_validated() { - let diagnostics = parse_and_validate( + let diagnostics = parse_and_validate_buffered( r#" FUNCTION main : DINT VAR @@ -688,7 +689,7 @@ fn assigning_literal_with_incompatible_encoding_to_char_is_validated() { END_FUNCTION"#, ); - assert_validation_snapshot!(&diagnostics); + assert_snapshot!(&diagnostics); } #[test] @@ -775,7 +776,7 @@ fn action_call_parameters_are_only_validated_outside_of_parent_pou_contexts() { #[test] fn implicit_invalid_action_call_assignments_are_validated() { - let diagnostics = parse_and_validate( + let diagnostics = parse_and_validate_buffered( r#" FUNCTION_BLOCK fb_t VAR @@ -804,12 +805,12 @@ fn implicit_invalid_action_call_assignments_are_validated() { "#, ); - assert_validation_snapshot!(&diagnostics) + assert_snapshot!(&diagnostics) } #[test] fn invalid_method_call_assignments_are_validated() { - let diagnostics = parse_and_validate( + let diagnostics = parse_and_validate_buffered( r#" CLASS cl_t VAR @@ -836,12 +837,12 @@ fn invalid_method_call_assignments_are_validated() { "#, ); - assert_validation_snapshot!(&diagnostics) + assert_snapshot!(&diagnostics) } #[test] fn invalid_function_block_instantiation_is_validated() { - let diagnostics = parse_and_validate( + let diagnostics = parse_and_validate_buffered( r#" FUNCTION_BLOCK fb_t VAR_INPUT @@ -861,12 +862,12 @@ fn invalid_function_block_instantiation_is_validated() { END_PROGRAM"#, ); - assert_validation_snapshot!(&diagnostics); + assert_snapshot!(&diagnostics); } #[test] fn implicit_action_downcasts_are_validated() { - let diagnostics = parse_and_validate( + let diagnostics = parse_and_validate_buffered( r#" FUNCTION_BLOCK fb_t VAR @@ -897,12 +898,12 @@ fn implicit_action_downcasts_are_validated() { "#, ); - assert_validation_snapshot!(&diagnostics); + assert_snapshot!(&diagnostics); } #[test] fn assigning_to_input_by_ref_should_deliver_improvment_suggestion() { - let diagnostics = parse_and_validate( + let diagnostics = parse_and_validate_buffered( " FUNCTION fn : DINT VAR_INPUT @@ -937,12 +938,12 @@ fn assigning_to_input_by_ref_should_deliver_improvment_suggestion() { ", ); - assert_validation_snapshot!(diagnostics); + assert_snapshot!(diagnostics); } #[test] fn enum_variants_mismatch() { - let diagnostics = parse_and_validate( + let diagnostics = parse_and_validate_buffered( " TYPE Animal: (Dog, Cat, Horse); END_TYPE @@ -960,12 +961,12 @@ fn enum_variants_mismatch() { END_PROGRAM", ); - assert_validation_snapshot!(diagnostics); + assert_snapshot!(diagnostics); } #[test] fn string_type_alias_assignment_can_be_validated() { - let diagnostics = parse_and_validate( + let diagnostics = parse_and_validate_buffered( " TYPE MY_STR : STRING; END_TYPE TYPE MY_OTHER_STR: STRING[256]; END_TYPE @@ -982,5 +983,5 @@ fn string_type_alias_assignment_can_be_validated() { ", ); - assert_validation_snapshot!(diagnostics); + assert_snapshot!(diagnostics); } diff --git a/src/validation/tests/bitaccess_validation_test.rs b/src/validation/tests/bitaccess_validation_test.rs index fbfb4d0cba..cd40622be6 100644 --- a/src/validation/tests/bitaccess_validation_test.rs +++ b/src/validation/tests/bitaccess_validation_test.rs @@ -1,8 +1,9 @@ -use crate::{assert_validation_snapshot, test_utils::tests::parse_and_validate}; +use crate::test_utils::tests::parse_and_validate_buffered; +use insta::assert_snapshot; #[test] fn bitaccess_only_on_bit_types() { - let diagnostics = parse_and_validate( + let diagnostics = parse_and_validate_buffered( " PROGRAM prg VAR @@ -23,12 +24,12 @@ fn bitaccess_only_on_bit_types() { ", ); - assert_validation_snapshot!(&diagnostics); + assert_snapshot!(&diagnostics); } #[test] fn byteaccess_only_on_bigger_sizes() { - let diagnostics = parse_and_validate( + let diagnostics = parse_and_validate_buffered( " PROGRAM prg VAR @@ -46,12 +47,12 @@ fn byteaccess_only_on_bigger_sizes() { ", ); - assert_validation_snapshot!(&diagnostics); + assert_snapshot!(&diagnostics); } #[test] fn wordaccess_only_on_bigger_sizes() { - let diagnostics = parse_and_validate( + let diagnostics = parse_and_validate_buffered( " PROGRAM prg VAR @@ -69,12 +70,12 @@ fn wordaccess_only_on_bigger_sizes() { ", ); - assert_validation_snapshot!(&diagnostics); + assert_snapshot!(&diagnostics); } #[test] fn dwordaccess_only_on_bigger_sizes() { - let diagnostics = parse_and_validate( + let diagnostics = parse_and_validate_buffered( " PROGRAM prg VAR @@ -92,12 +93,12 @@ fn dwordaccess_only_on_bigger_sizes() { ", ); - assert_validation_snapshot!(&diagnostics); + assert_snapshot!(&diagnostics); } #[test] fn bitaccess_range_test() { - let diagnostics = parse_and_validate( + let diagnostics = parse_and_validate_buffered( " PROGRAM prg VAR @@ -111,12 +112,12 @@ fn bitaccess_range_test() { ", ); - assert_validation_snapshot!(&diagnostics); + assert_snapshot!(&diagnostics); } #[test] fn byteaccess_range_test() { - let diagnostics = parse_and_validate( + let diagnostics = parse_and_validate_buffered( " PROGRAM prg VAR @@ -129,12 +130,12 @@ fn byteaccess_range_test() { ", ); - assert_validation_snapshot!(&diagnostics); + assert_snapshot!(&diagnostics); } #[test] fn wordaccess_range_test() { - let diagnostics = parse_and_validate( + let diagnostics = parse_and_validate_buffered( " PROGRAM prg VAR @@ -146,12 +147,12 @@ fn wordaccess_range_test() { ", ); - assert_validation_snapshot!(&diagnostics); + assert_snapshot!(&diagnostics); } #[test] fn dwordaccess_range_test() { - let diagnostics = parse_and_validate( + let diagnostics = parse_and_validate_buffered( " PROGRAM prg VAR @@ -162,12 +163,12 @@ fn dwordaccess_range_test() { ", ); - assert_validation_snapshot!(&diagnostics); + assert_snapshot!(&diagnostics); } #[test] fn reference_direct_access_only_with_ints() { - let diagnostics = parse_and_validate( + let diagnostics = parse_and_validate_buffered( " PROGRAM prg VAR @@ -180,5 +181,5 @@ fn reference_direct_access_only_with_ints() { ", ); - assert_validation_snapshot!(&diagnostics); + assert_snapshot!(&diagnostics); } diff --git a/src/validation/tests/builtin_validation_tests.rs b/src/validation/tests/builtin_validation_tests.rs index 4f61b1a0e3..d59f82d946 100644 --- a/src/validation/tests/builtin_validation_tests.rs +++ b/src/validation/tests/builtin_validation_tests.rs @@ -1,8 +1,9 @@ -use crate::{assert_validation_snapshot, test_utils::tests::parse_and_validate}; +use crate::test_utils::tests::parse_and_validate_buffered; +use insta::assert_snapshot; #[test] fn arithmetic_builtins_allow_mixing_of_fp_and_int_params() { - let diagnostics = parse_and_validate( + let diagnostics = parse_and_validate_buffered( " FUNCTION main : LINT VAR @@ -25,7 +26,7 @@ fn arithmetic_builtins_allow_mixing_of_fp_and_int_params() { #[test] #[ignore = "FIXME: no validation for incompatible types for arithmetic operations"] fn arithmetic_builtins_called_with_incompatible_types() { - let diagnostics = parse_and_validate( + let diagnostics = parse_and_validate_buffered( " FUNCTION main : DINT VAR @@ -40,12 +41,12 @@ fn arithmetic_builtins_called_with_incompatible_types() { ", ); - assert_validation_snapshot!(&diagnostics); + assert_snapshot!(&diagnostics); } #[test] fn arithmetic_builtins_called_with_invalid_param_count() { - let diagnostics = parse_and_validate( + let diagnostics = parse_and_validate_buffered( " FUNCTION main : DINT VAR @@ -60,13 +61,13 @@ fn arithmetic_builtins_called_with_invalid_param_count() { ", ); - assert_validation_snapshot!(&diagnostics); + assert_snapshot!(&diagnostics); } #[test] #[ignore = "FIXME: no validation for incompatible type comparisons"] fn comparison_builtins_called_with_incompatible_types() { - let diagnostics = parse_and_validate( + let diagnostics = parse_and_validate_buffered( " FUNCTION main : DINT VAR @@ -81,12 +82,12 @@ fn comparison_builtins_called_with_incompatible_types() { ", ); - assert_validation_snapshot!(&diagnostics); + assert_snapshot!(&diagnostics); } #[test] fn comparison_builtins_called_with_invalid_param_count() { - let diagnostics = parse_and_validate( + let diagnostics = parse_and_validate_buffered( " FUNCTION main : DINT VAR @@ -101,5 +102,5 @@ fn comparison_builtins_called_with_invalid_param_count() { ", ); - assert_validation_snapshot!(&diagnostics); + assert_snapshot!(&diagnostics); } diff --git a/src/validation/tests/duplicates_validation_test.rs b/src/validation/tests/duplicates_validation_test.rs index aaeb5e9023..46599a033c 100644 --- a/src/validation/tests/duplicates_validation_test.rs +++ b/src/validation/tests/duplicates_validation_test.rs @@ -7,20 +7,20 @@ use plc_source::source_location::SourceLocationFactory; use plc_source::SourceCode; use crate::{ - assert_validation_snapshot, index::{visitor, Index}, lexer, parser, resolver::TypeAnnotator, - test_utils::tests::parse_and_validate, + test_utils::tests::parse_and_validate_buffered, typesystem, validation::Validator, }; +use insta::assert_snapshot; #[test] fn duplicate_pous_validation() { // GIVEN two POUs witht he same name // WHEN parse_and_validate is done - let diagnostics = parse_and_validate( + let diagnostics = parse_and_validate_buffered( r#" FUNCTION foo : INT END_FUNCTION @@ -30,42 +30,42 @@ fn duplicate_pous_validation() { "#, ); // THEN there should be 3 duplication diagnostics - assert_validation_snapshot!(&diagnostics); + assert_snapshot!(&diagnostics); } #[test] fn duplicate_pous_and_types_validation() { // GIVEN a POU and a Type with the same name // WHEN parse_and_validate is done - let diagnostics = parse_and_validate( + let diagnostics = parse_and_validate_buffered( r#" FUNCTION_BLOCK foo END_FUNCTION_BLOCK TYPE foo : INT; END_TYPE "#, ); // THEN there should be 3 duplication diagnostics - assert_validation_snapshot!(&diagnostics); + assert_snapshot!(&diagnostics); } #[test] fn duplicate_function_and_type_is_no_issue() { // GIVEN a Function and a Type with the same name // WHEN parse_and_validate is done - let diagnostics = parse_and_validate( + let diagnostics = parse_and_validate_buffered( r#" FUNCTION foo: INT END_FUNCTION TYPE foo : INT; END_TYPE "#, ); // THEN there should be 0 duplication diagnostics - assert_eq!(diagnostics, vec![]); + assert!(diagnostics.is_empty()); } #[test] fn duplicate_global_variables() { // GIVEN some duplicate global variables // WHEN parse_and_validate is done - let diagnostics = parse_and_validate( + let diagnostics = parse_and_validate_buffered( r#" VAR_GLOBAL a: INT; @@ -80,14 +80,14 @@ fn duplicate_global_variables() { "#, ); // THEN there should be 0 duplication diagnostics - assert_validation_snapshot!(&diagnostics); + assert_snapshot!(&diagnostics); } #[test] fn duplicate_variables_in_same_pou() { // GIVEN a POU with a duplicate variable // WHEN parse_and_validate is done - let diagnostics = parse_and_validate( + let diagnostics = parse_and_validate_buffered( r#" PROGRAM prg VAR @@ -102,28 +102,28 @@ fn duplicate_variables_in_same_pou() { "#, ); // THEN there should be 2 duplication diagnostics - assert_validation_snapshot!(&diagnostics); + assert_snapshot!(&diagnostics); } #[test] fn duplicate_enum_members_in_different_types_is_no_issue() { // GIVEN a two enums with the same elements // WHEN parse_and_validate is done - let diagnostics = parse_and_validate( + let diagnostics = parse_and_validate_buffered( r#" TYPE enum1 : (red, green, yellow); END_TYPE TYPE enum2 : (red, green, yellow); END_TYPE "#, ); // THEN there should be no issues - assert_eq!(diagnostics, vec![]); + assert!(diagnostics.is_empty()); } #[test] fn duplicate_fb_inst_and_function() { // GIVEN a global fb-instance called foo and a function called foo // WHEN parse_and_validate is done - let diagnostics = parse_and_validate( + let diagnostics = parse_and_validate_buffered( r#" FUNCTION_BLOCK FooFB VAR x : INT; END_VAR @@ -141,27 +141,27 @@ fn duplicate_fb_inst_and_function() { "#, ); // THEN there should be 2 duplication diagnostics - assert_validation_snapshot!(&diagnostics); + assert_snapshot!(&diagnostics); } #[test] fn duplicate_enum_variables() { // GIVEN an enum with two identical elements // WHEN parse_and_validate is done - let diagnostics = parse_and_validate( + let diagnostics = parse_and_validate_buffered( r#" TYPE enum1 : (red, green, yellow, red); END_TYPE "#, ); // THEN there should be 2 duplication diagnostics - assert_validation_snapshot!(&diagnostics); + assert_snapshot!(&diagnostics); } #[test] fn duplicate_global_and_program() { // GIVEN a global variable `prg` and a Program `prg` // WHEN parse_and_validate is done - let diagnostics = parse_and_validate( + let diagnostics = parse_and_validate_buffered( r#" VAR_GLOBAL a: INT; @@ -177,14 +177,14 @@ fn duplicate_global_and_program() { "#, ); // THEN there should be 2 duplication diagnostics - assert_validation_snapshot!(&diagnostics); + assert_snapshot!(&diagnostics); } #[test] fn duplicate_action_should_be_a_problem() { // GIVEN a program with two actions with the same name // WHEN parse_and_validate is done - let diagnostics = parse_and_validate( + let diagnostics = parse_and_validate_buffered( r#" PROGRAM prg VAR_INPUT @@ -210,14 +210,14 @@ fn duplicate_action_should_be_a_problem() { ); // THEN there should be 2 duplication diagnostics - assert_validation_snapshot!(&diagnostics); + assert_snapshot!(&diagnostics); } #[test] fn duplicate_actions_in_different_pous_are_no_issue() { // GIVEN two POUs with actions with the same name // WHEN parse_and_validate is done - let diagnostics = parse_and_validate( + let diagnostics = parse_and_validate_buffered( r#" PROGRAM prg END_PROGRAM @@ -236,14 +236,14 @@ fn duplicate_actions_in_different_pous_are_no_issue() { ); // THEN there should be no duplication diagnostics - assert_eq!(diagnostics, vec![]); + assert!(diagnostics.is_empty()); } #[test] fn automatically_generated_ptr_types_dont_cause_duplication_issues() { // GIVEN some code that automatically generates a pointer type // WHEN parse_and_validate is done - let diagnostics = parse_and_validate( + let diagnostics = parse_and_validate_buffered( r#" PROGRAM prg VAR @@ -258,14 +258,14 @@ fn automatically_generated_ptr_types_dont_cause_duplication_issues() { ); // THEN there should be no duplication diagnostics - assert_eq!(diagnostics, vec![]); + assert!(diagnostics.is_empty()); } #[test] fn automatically_generated_string_types_dont_cause_duplication_issues() { // GIVEN some code that automatically generates a pointer type // WHEN parse_and_validate is done - let diagnostics = parse_and_validate( + let diagnostics = parse_and_validate_buffered( r#" PROGRAM prg VAR @@ -279,14 +279,14 @@ fn automatically_generated_string_types_dont_cause_duplication_issues() { ); // THEN there should be no duplication diagnostics - assert_eq!(diagnostics, vec![]); + assert!(diagnostics.is_empty()); } #[test] fn automatically_generated_byref_types_dont_cause_duplication_issues() { // GIVEN some code that automatically generates a ref-types // WHEN parse_and_validate is done - let diagnostics = parse_and_validate( + let diagnostics = parse_and_validate_buffered( r#" FUNCTION foo : INT VAR_INPUT {ref} @@ -298,14 +298,14 @@ fn automatically_generated_byref_types_dont_cause_duplication_issues() { ); // THEN there should be no duplication diagnostics - assert_eq!(diagnostics, vec![]); + assert!(diagnostics.is_empty()); } #[test] fn automatically_generated_inout_types_dont_cause_duplication_issues() { // GIVEN some code that automatically generates a ptr-types // WHEN parse_and_validate is done - let diagnostics = parse_and_validate( + let diagnostics = parse_and_validate_buffered( r#" FUNCTION foo : INT VAR_IN_OUT @@ -317,14 +317,14 @@ fn automatically_generated_inout_types_dont_cause_duplication_issues() { ); // THEN there should be no duplication diagnostics - assert_eq!(diagnostics, vec![]); + assert!(diagnostics.is_empty()); } #[test] fn automatically_generated_output_types_dont_cause_duplication_issues() { // GIVEN some code that automatically generates a ptr-types // WHEN parse_and_validate is done - let diagnostics = parse_and_validate( + let diagnostics = parse_and_validate_buffered( r#" FUNCTION foo : INT VAR_OUTPUT @@ -336,7 +336,7 @@ fn automatically_generated_output_types_dont_cause_duplication_issues() { ); // THEN there should be no duplication diagnostics - assert_eq!(diagnostics, vec![]); + assert!(diagnostics.is_empty()); } #[test] @@ -396,7 +396,7 @@ fn automatically_generated_output_types_in_different_files_dont_cause_duplicatio let mut validator = Validator::new(&ctxt); validator.perform_global_validation(&global_index); let diagnostics = validator.diagnostics(); - assert_eq!(diagnostics, vec![]); + assert!(diagnostics.is_empty()); } #[test] @@ -497,7 +497,7 @@ fn duplicate_with_generic() { let mut validator = Validator::new(&ctxt); validator.perform_global_validation(&global_index); let diagnostics = validator.diagnostics(); - assert_eq!(diagnostics, vec![]); + assert!(diagnostics.is_empty()); } #[test] @@ -510,7 +510,7 @@ fn generics_with_duplicate_symbol_dont_err() { // END_FUNCTION // WHEN it is indexed and validated with other generic functions with the same name - let diagnostics = parse_and_validate( + let diagnostics = parse_and_validate_buffered( r#" FUNCTION ADD < T1: ANY, T2: ANY >: T1 VAR_INPUT @@ -529,7 +529,7 @@ fn generics_with_duplicate_symbol_dont_err() { ); // THEN there should be no duplication diagnostics - assert_eq!(diagnostics, vec![]); + assert!(diagnostics.is_empty()); } // #[test] diff --git a/src/validation/tests/generic_validation_tests.rs b/src/validation/tests/generic_validation_tests.rs index 4660c7f5c1..4c26cc74e6 100644 --- a/src/validation/tests/generic_validation_tests.rs +++ b/src/validation/tests/generic_validation_tests.rs @@ -1,4 +1,5 @@ -use crate::{assert_validation_snapshot, test_utils::tests::parse_and_validate}; +use crate::test_utils::tests::parse_and_validate_buffered; +use insta::assert_snapshot; #[test] fn any_allows_all_natures() { @@ -17,8 +18,8 @@ fn any_allows_all_natures() { FUNCTION func10 : INT VAR x : str; END_VAR test(x); END_FUNCTION "; - let diagnostics = parse_and_validate(src); - assert_eq!(diagnostics, vec![]); + let diagnostics = parse_and_validate_buffered(src); + assert!(diagnostics.is_empty()); } #[test] @@ -43,8 +44,8 @@ fn any_multiple_parameters() { END_FUNCTION "; - let diagnostics = parse_and_validate(src); - assert_validation_snapshot!(&diagnostics); + let diagnostics = parse_and_validate_buffered(src); + assert_snapshot!(&diagnostics); } #[test] @@ -54,8 +55,8 @@ fn non_resolved_generics_reported() { FUNCTION func : INT test(); END_FUNCTION "; - let diagnostics = parse_and_validate(src); - assert_validation_snapshot!(&diagnostics); + let diagnostics = parse_and_validate_buffered(src); + assert_snapshot!(&diagnostics); } // ########## ANY_MAGNITUDE ########## @@ -68,8 +69,8 @@ fn any_magnitude_allows_reals() { FUNCTION func2 : INT VAR x : LREAL; END_VAR test(x); END_FUNCTION "; - let diagnostics = parse_and_validate(src); - assert_eq!(diagnostics, vec![]); + let diagnostics = parse_and_validate_buffered(src); + assert!(diagnostics.is_empty()); } #[test] @@ -87,8 +88,8 @@ fn any_magnitude_allows_ints() { FUNCTION func8 : INT VAR x : ULINT; END_VAR test(x); END_FUNCTION "; - let diagnostics = parse_and_validate(src); - assert_eq!(diagnostics, vec![]); + let diagnostics = parse_and_validate_buffered(src); + assert!(diagnostics.is_empty()); } #[test] @@ -99,8 +100,8 @@ fn any_magnitude_allows_time() { FUNCTION func2 : INT VAR x : LTIME; END_VAR test(x); END_FUNCTION "; - let diagnostics = parse_and_validate(src); - assert_eq!(diagnostics, vec![]); + let diagnostics = parse_and_validate_buffered(src); + assert!(diagnostics.is_empty()); } #[test] @@ -114,8 +115,8 @@ fn any_magnitude_does_not_allow_bits() { FUNCTION func5 : INT VAR x : LWORD; END_VAR test(x); END_FUNCTION "; - let diagnostics = parse_and_validate(src); - assert_validation_snapshot!(&diagnostics); + let diagnostics = parse_and_validate_buffered(src); + assert_snapshot!(&diagnostics); } #[test] @@ -126,8 +127,8 @@ fn any_magnitude_does_not_allow_strings() { FUNCTION func2 : INT VAR x : WSTRING; END_VAR test(x); END_FUNCTION "; - let diagnostics = parse_and_validate(src); - assert_validation_snapshot!(&diagnostics); + let diagnostics = parse_and_validate_buffered(src); + assert_snapshot!(&diagnostics); } #[test] @@ -138,8 +139,8 @@ fn any_magnitude_does_not_allow_chars() { FUNCTION func2 : INT VAR x : WCHAR; END_VAR test(x); END_FUNCTION "; - let diagnostics = parse_and_validate(src); - assert_validation_snapshot!(&diagnostics); + let diagnostics = parse_and_validate_buffered(src); + assert_snapshot!(&diagnostics); } #[test] @@ -153,8 +154,8 @@ fn any_magnitude_does_not_allow_date() { FUNCTION func5 : INT VAR x : LTOD; END_VAR test(x); END_FUNCTION "; - let diagnostics = parse_and_validate(src); - assert_validation_snapshot!(&diagnostics); + let diagnostics = parse_and_validate_buffered(src); + assert_snapshot!(&diagnostics); } #[test] @@ -179,8 +180,8 @@ fn any_magnitude_multiple_parameters() { END_FUNCTION "; - let diagnostics = parse_and_validate(src); - assert_validation_snapshot!(&diagnostics); + let diagnostics = parse_and_validate_buffered(src); + assert_snapshot!(&diagnostics); } // ########## ANY_NUMBER ########## @@ -193,8 +194,8 @@ fn any_num_allows_reals() { FUNCTION func2 : INT VAR x : LREAL; END_VAR test(x); END_FUNCTION "; - let diagnostics = parse_and_validate(src); - assert_eq!(diagnostics, vec![]); + let diagnostics = parse_and_validate_buffered(src); + assert!(diagnostics.is_empty()); } #[test] @@ -212,8 +213,8 @@ fn any_num_allows_ints() { FUNCTION func8 : INT VAR x : ULINT; END_VAR test(x); END_FUNCTION "; - let diagnostics = parse_and_validate(src); - assert_eq!(diagnostics, vec![]); + let diagnostics = parse_and_validate_buffered(src); + assert!(diagnostics.is_empty()); } #[test] @@ -224,8 +225,8 @@ fn any_num_does_not_allow_time() { FUNCTION func2 : INT VAR x : LTIME; END_VAR test(x); END_FUNCTION "; - let diagnostics = parse_and_validate(src); - assert_validation_snapshot!(&diagnostics); + let diagnostics = parse_and_validate_buffered(src); + assert_snapshot!(&diagnostics); } #[test] @@ -239,8 +240,8 @@ fn any_num_does_not_allow_bits() { FUNCTION func5 : INT VAR x : LWORD; END_VAR test(x); END_FUNCTION "; - let diagnostics = parse_and_validate(src); - assert_validation_snapshot!(&diagnostics); + let diagnostics = parse_and_validate_buffered(src); + assert_snapshot!(&diagnostics); } #[test] @@ -251,8 +252,8 @@ fn any_num_does_not_allow_strings() { FUNCTION func2 : INT VAR x : WSTRING; END_VAR test(x); END_FUNCTION "; - let diagnostics = parse_and_validate(src); - assert_validation_snapshot!(&diagnostics); + let diagnostics = parse_and_validate_buffered(src); + assert_snapshot!(&diagnostics); } #[test] @@ -263,8 +264,8 @@ fn any_num_does_not_allow_chars() { FUNCTION func2 : INT VAR x : WCHAR; END_VAR test(x); END_FUNCTION "; - let diagnostics = parse_and_validate(src); - assert_validation_snapshot!(&diagnostics); + let diagnostics = parse_and_validate_buffered(src); + assert_snapshot!(&diagnostics); } #[test] @@ -278,8 +279,8 @@ fn any_num_does_not_allow_date() { FUNCTION func5 : INT VAR x : LTOD; END_VAR test(x); END_FUNCTION "; - let diagnostics = parse_and_validate(src); - assert_validation_snapshot!(&diagnostics); + let diagnostics = parse_and_validate_buffered(src); + assert_snapshot!(&diagnostics); } #[test] @@ -304,8 +305,8 @@ fn any_num_multiple_parameters() { END_FUNCTION "; - let diagnostics = parse_and_validate(src); - assert_validation_snapshot!(&diagnostics); + let diagnostics = parse_and_validate_buffered(src); + assert_snapshot!(&diagnostics); } // ########## ANY_REAL ########## @@ -318,8 +319,8 @@ fn any_real_allows_reals() { FUNCTION func1 : INT VAR x : LREAL; END_VAR test(x); END_FUNCTION "; - let diagnostics = parse_and_validate(src); - assert_eq!(diagnostics, vec![]); + let diagnostics = parse_and_validate_buffered(src); + assert!(diagnostics.is_empty()); } #[test] @@ -339,8 +340,8 @@ fn any_real_allows_ints() { FUNCTION func8 : INT VAR x : ULINT; END_VAR test(x); END_FUNCTION "; - let diagnostics = parse_and_validate(src); - assert_eq!(diagnostics, vec![]); + let diagnostics = parse_and_validate_buffered(src); + assert!(diagnostics.is_empty()); } #[test] @@ -351,8 +352,8 @@ fn any_real_does_not_allow_time() { FUNCTION func2 : INT VAR x : LTIME; END_VAR test(x); END_FUNCTION "; - let diagnostics = parse_and_validate(src); - assert_validation_snapshot!(&diagnostics); + let diagnostics = parse_and_validate_buffered(src); + assert_snapshot!(&diagnostics); } #[test] @@ -366,8 +367,8 @@ fn any_real_does_not_allow_bits() { FUNCTION func5 : INT VAR x : LWORD; END_VAR test(x); END_FUNCTION "; - let diagnostics = parse_and_validate(src); - assert_validation_snapshot!(&diagnostics); + let diagnostics = parse_and_validate_buffered(src); + assert_snapshot!(&diagnostics); } #[test] @@ -378,8 +379,8 @@ fn any_real_does_not_allow_chars() { FUNCTION func2 : INT VAR x : WCHAR; END_VAR test(x); END_FUNCTION "; - let diagnostics = parse_and_validate(src); - assert_validation_snapshot!(&diagnostics); + let diagnostics = parse_and_validate_buffered(src); + assert_snapshot!(&diagnostics); } #[test] @@ -390,8 +391,8 @@ fn any_real_does_not_allow_string() { FUNCTION func2 : INT VAR x : WSTRING; END_VAR test(x); END_FUNCTION "; - let diagnostics = parse_and_validate(src); - assert_validation_snapshot!(&diagnostics); + let diagnostics = parse_and_validate_buffered(src); + assert_snapshot!(&diagnostics); } #[test] @@ -405,8 +406,8 @@ fn any_real_does_not_allow_date() { FUNCTION func5 : INT VAR x : LTOD; END_VAR test(x); END_FUNCTION "; - let diagnostics = parse_and_validate(src); - assert_validation_snapshot!(&diagnostics); + let diagnostics = parse_and_validate_buffered(src); + assert_snapshot!(&diagnostics); } #[test] @@ -431,8 +432,8 @@ fn any_real_multiple_parameters() { END_FUNCTION "; - let diagnostics = parse_and_validate(src); - assert_validation_snapshot!(&diagnostics); + let diagnostics = parse_and_validate_buffered(src); + assert_snapshot!(&diagnostics); } // ########## ANY_INT ########## @@ -445,8 +446,8 @@ fn any_int_does_not_allow_reals() { FUNCTION func1 : INT VAR x : LREAL; END_VAR test(x); END_FUNCTION "; - let diagnostics = parse_and_validate(src); - assert_validation_snapshot!(&diagnostics); + let diagnostics = parse_and_validate_buffered(src); + assert_snapshot!(&diagnostics); } #[test] @@ -465,8 +466,8 @@ fn any_int_allows_ints() { FUNCTION func8 : INT VAR x : ULINT; END_VAR test(x); END_FUNCTION "; - let diagnostics = parse_and_validate(src); - assert_eq!(diagnostics, vec![]); + let diagnostics = parse_and_validate_buffered(src); + assert!(diagnostics.is_empty()); } #[test] @@ -477,8 +478,8 @@ fn any_int_does_not_allow_time() { FUNCTION func2 : INT VAR x : LTIME; END_VAR test(x); END_FUNCTION "; - let diagnostics = parse_and_validate(src); - assert_validation_snapshot!(&diagnostics); + let diagnostics = parse_and_validate_buffered(src); + assert_snapshot!(&diagnostics); } #[test] @@ -492,8 +493,8 @@ fn any_int_does_not_allow_bits() { FUNCTION func5 : INT VAR x : LWORD; END_VAR test(x); END_FUNCTION "; - let diagnostics = parse_and_validate(src); - assert_validation_snapshot!(&diagnostics); + let diagnostics = parse_and_validate_buffered(src); + assert_snapshot!(&diagnostics); } #[test] @@ -504,8 +505,8 @@ fn any_int_does_not_allow_chars() { FUNCTION func2 : INT VAR x : WCHAR; END_VAR test(x); END_FUNCTION "; - let diagnostics = parse_and_validate(src); - assert_validation_snapshot!(&diagnostics); + let diagnostics = parse_and_validate_buffered(src); + assert_snapshot!(&diagnostics); } #[test] @@ -516,8 +517,8 @@ fn any_int_does_not_allow_string() { FUNCTION func2 : INT VAR x : WSTRING; END_VAR test(x); END_FUNCTION "; - let diagnostics = parse_and_validate(src); - assert_validation_snapshot!(&diagnostics); + let diagnostics = parse_and_validate_buffered(src); + assert_snapshot!(&diagnostics); } #[test] @@ -531,8 +532,8 @@ fn any_int_does_not_allow_date() { FUNCTION func5 : INT VAR x : LTOD; END_VAR test(x); END_FUNCTION "; - let diagnostics = parse_and_validate(src); - assert_validation_snapshot!(&diagnostics); + let diagnostics = parse_and_validate_buffered(src); + assert_snapshot!(&diagnostics); } #[test] @@ -557,8 +558,8 @@ fn any_int_multiple_parameters() { END_FUNCTION "; - let diagnostics = parse_and_validate(src); - assert_validation_snapshot!(&diagnostics); + let diagnostics = parse_and_validate_buffered(src); + assert_snapshot!(&diagnostics); } // ########## ANY_UNSIGNED ########## @@ -571,8 +572,8 @@ fn any_unsigned_does_not_allow_reals() { FUNCTION func1 : INT VAR x : LREAL; END_VAR test(x); END_FUNCTION "; - let diagnostics = parse_and_validate(src); - assert_validation_snapshot!(&diagnostics); + let diagnostics = parse_and_validate_buffered(src); + assert_snapshot!(&diagnostics); } #[test] @@ -585,8 +586,8 @@ fn any_unsigned_allows_unsigned_ints() { FUNCTION func4 : INT VAR x : ULINT; END_VAR test(x); END_FUNCTION "; - let diagnostics = parse_and_validate(src); - assert_eq!(diagnostics, vec![]); + let diagnostics = parse_and_validate_buffered(src); + assert!(diagnostics.is_empty()); } #[test] @@ -599,8 +600,8 @@ fn any_unsigned_does_not_allow_signed_ints() { FUNCTION func4 : INT VAR x : LINT; END_VAR test(x); END_FUNCTION "; - let diagnostics = parse_and_validate(src); - assert_validation_snapshot!(&diagnostics); + let diagnostics = parse_and_validate_buffered(src); + assert_snapshot!(&diagnostics); } #[test] @@ -611,8 +612,8 @@ fn any_unsigned_does_not_allow_time() { FUNCTION func2 : INT VAR x : LTIME; END_VAR test(x); END_FUNCTION "; - let diagnostics = parse_and_validate(src); - assert_validation_snapshot!(&diagnostics); + let diagnostics = parse_and_validate_buffered(src); + assert_snapshot!(&diagnostics); } #[test] @@ -626,8 +627,8 @@ fn any_unsigned_does_not_allow_bits() { FUNCTION func5 : INT VAR x : LWORD; END_VAR test(x); END_FUNCTION "; - let diagnostics = parse_and_validate(src); - assert_validation_snapshot!(&diagnostics); + let diagnostics = parse_and_validate_buffered(src); + assert_snapshot!(&diagnostics); } #[test] @@ -638,8 +639,8 @@ fn any_unsigned_does_not_allow_chars() { FUNCTION func2 : INT VAR x : WCHAR; END_VAR test(x); END_FUNCTION "; - let diagnostics = parse_and_validate(src); - assert_validation_snapshot!(&diagnostics); + let diagnostics = parse_and_validate_buffered(src); + assert_snapshot!(&diagnostics); } #[test] @@ -650,8 +651,8 @@ fn any_unsigned_does_not_allow_string() { FUNCTION func2 : INT VAR x : WSTRING; END_VAR test(x); END_FUNCTION "; - let diagnostics = parse_and_validate(src); - assert_validation_snapshot!(&diagnostics); + let diagnostics = parse_and_validate_buffered(src); + assert_snapshot!(&diagnostics); } #[test] @@ -665,8 +666,8 @@ fn any_unsigned_does_not_allow_date() { FUNCTION func5 : INT VAR x : LTOD; END_VAR test(x); END_FUNCTION "; - let diagnostics = parse_and_validate(src); - assert_validation_snapshot!(&diagnostics); + let diagnostics = parse_and_validate_buffered(src); + assert_snapshot!(&diagnostics); } #[test] @@ -691,8 +692,8 @@ fn any_unsigned_multiple_parameters() { END_FUNCTION "; - let diagnostics = parse_and_validate(src); - assert_validation_snapshot!(&diagnostics); + let diagnostics = parse_and_validate_buffered(src); + assert_snapshot!(&diagnostics); } // ########## ANY_SIGNED ########## @@ -705,8 +706,8 @@ fn any_signed_does_not_allow_reals() { FUNCTION func1 : INT VAR x : LREAL; END_VAR test(x); END_FUNCTION "; - let diagnostics = parse_and_validate(src); - assert_validation_snapshot!(&diagnostics); + let diagnostics = parse_and_validate_buffered(src); + assert_snapshot!(&diagnostics); } #[test] @@ -719,8 +720,8 @@ fn any_signed_allows_signed_ints() { FUNCTION func4 : INT VAR x : LINT; END_VAR test(x); END_FUNCTION "; - let diagnostics = parse_and_validate(src); - assert_eq!(diagnostics, vec![]); + let diagnostics = parse_and_validate_buffered(src); + assert!(diagnostics.is_empty()); } #[test] @@ -733,8 +734,8 @@ fn any_signed_does_not_allow_unsigned_ints() { FUNCTION func4 : INT VAR x : ULINT; END_VAR test(x); END_FUNCTION "; - let diagnostics = parse_and_validate(src); - assert_validation_snapshot!(&diagnostics); + let diagnostics = parse_and_validate_buffered(src); + assert_snapshot!(&diagnostics); } #[test] @@ -745,8 +746,8 @@ fn any_signed_does_not_allow_time() { FUNCTION func2 : INT VAR x : LTIME; END_VAR test(x); END_FUNCTION "; - let diagnostics = parse_and_validate(src); - assert_validation_snapshot!(&diagnostics); + let diagnostics = parse_and_validate_buffered(src); + assert_snapshot!(&diagnostics); } #[test] @@ -760,8 +761,8 @@ fn any_signed_does_not_allow_bits() { FUNCTION func5 : INT VAR x : LWORD; END_VAR test(x); END_FUNCTION "; - let diagnostics = parse_and_validate(src); - assert_validation_snapshot!(&diagnostics); + let diagnostics = parse_and_validate_buffered(src); + assert_snapshot!(&diagnostics); } #[test] @@ -772,8 +773,8 @@ fn any_signed_does_not_allow_chars() { FUNCTION func2 : INT VAR x : WCHAR; END_VAR test(x); END_FUNCTION "; - let diagnostics = parse_and_validate(src); - assert_validation_snapshot!(&diagnostics); + let diagnostics = parse_and_validate_buffered(src); + assert_snapshot!(&diagnostics); } #[test] @@ -784,8 +785,8 @@ fn any_signed_does_not_allow_string() { FUNCTION func2 : INT VAR x : WSTRING; END_VAR test(x); END_FUNCTION "; - let diagnostics = parse_and_validate(src); - assert_validation_snapshot!(&diagnostics); + let diagnostics = parse_and_validate_buffered(src); + assert_snapshot!(&diagnostics); } #[test] @@ -799,8 +800,8 @@ fn any_signed_does_not_allow_date() { FUNCTION func5 : INT VAR x : LTOD; END_VAR test(x); END_FUNCTION "; - let diagnostics = parse_and_validate(src); - assert_validation_snapshot!(&diagnostics); + let diagnostics = parse_and_validate_buffered(src); + assert_snapshot!(&diagnostics); } #[test] @@ -825,8 +826,8 @@ fn any_signed_multiple_parameters() { END_FUNCTION "; - let diagnostics = parse_and_validate(src); - assert_validation_snapshot!(&diagnostics); + let diagnostics = parse_and_validate_buffered(src); + assert_snapshot!(&diagnostics); } // ########## ANY_DURATION ########## @@ -839,8 +840,8 @@ fn any_duration_does_not_allow_reals() { FUNCTION func1 : INT VAR x : LREAL; END_VAR test(x); END_FUNCTION "; - let diagnostics = parse_and_validate(src); - assert_validation_snapshot!(&diagnostics); + let diagnostics = parse_and_validate_buffered(src); + assert_snapshot!(&diagnostics); } #[test] @@ -859,8 +860,8 @@ fn any_duration_does_not_allow_ints() { FUNCTION func8 : INT VAR x : LINT; END_VAR test(x); END_FUNCTION "; - let diagnostics = parse_and_validate(src); - assert_validation_snapshot!(&diagnostics); + let diagnostics = parse_and_validate_buffered(src); + assert_snapshot!(&diagnostics); } #[test] @@ -871,8 +872,8 @@ fn any_duration_allows_time() { FUNCTION func2 : INT VAR x : LTIME; END_VAR test(x); END_FUNCTION "; - let diagnostics = parse_and_validate(src); - assert_eq!(diagnostics, vec![]); + let diagnostics = parse_and_validate_buffered(src); + assert!(diagnostics.is_empty()); } #[test] @@ -886,8 +887,8 @@ fn any_duration_does_not_allow_bits() { FUNCTION func5 : INT VAR x : LWORD; END_VAR test(x); END_FUNCTION "; - let diagnostics = parse_and_validate(src); - assert_validation_snapshot!(&diagnostics); + let diagnostics = parse_and_validate_buffered(src); + assert_snapshot!(&diagnostics); } #[test] @@ -898,8 +899,8 @@ fn any_duration_does_not_allow_chars() { FUNCTION func2 : INT VAR x : WCHAR; END_VAR test(x); END_FUNCTION "; - let diagnostics = parse_and_validate(src); - assert_validation_snapshot!(&diagnostics); + let diagnostics = parse_and_validate_buffered(src); + assert_snapshot!(&diagnostics); } #[test] @@ -910,8 +911,8 @@ fn any_duration_does_not_allow_string() { FUNCTION func2 : INT VAR x : WSTRING; END_VAR test(x); END_FUNCTION "; - let diagnostics = parse_and_validate(src); - assert_validation_snapshot!(&diagnostics); + let diagnostics = parse_and_validate_buffered(src); + assert_snapshot!(&diagnostics); } #[test] @@ -925,8 +926,8 @@ fn any_duration_does_not_allow_date() { FUNCTION func5 : INT VAR x : LTOD; END_VAR test(x); END_FUNCTION "; - let diagnostics = parse_and_validate(src); - assert_validation_snapshot!(&diagnostics); + let diagnostics = parse_and_validate_buffered(src); + assert_snapshot!(&diagnostics); } #[test] @@ -951,8 +952,8 @@ fn any_duration_multiple_parameters() { END_FUNCTION "; - let diagnostics = parse_and_validate(src); - assert_validation_snapshot!(&diagnostics); + let diagnostics = parse_and_validate_buffered(src); + assert_snapshot!(&diagnostics); } // ########## ANY_BIT ########## @@ -965,8 +966,8 @@ fn any_bit_does_not_allow_reals() { FUNCTION func1 : INT VAR x : LREAL; END_VAR test(x); END_FUNCTION "; - let diagnostics = parse_and_validate(src); - assert_validation_snapshot!(&diagnostics); + let diagnostics = parse_and_validate_buffered(src); + assert_snapshot!(&diagnostics); } #[test] @@ -985,8 +986,8 @@ fn any_bit_does_not_allow_ints() { FUNCTION func8 : INT VAR x : LINT; END_VAR test(x); END_FUNCTION "; - let diagnostics = parse_and_validate(src); - assert_validation_snapshot!(&diagnostics); + let diagnostics = parse_and_validate_buffered(src); + assert_snapshot!(&diagnostics); } #[test] @@ -997,8 +998,8 @@ fn any_bit_does_not_allow_time() { FUNCTION func2 : INT VAR x : LTIME; END_VAR test(x); END_FUNCTION "; - let diagnostics = parse_and_validate(src); - assert_validation_snapshot!(&diagnostics); + let diagnostics = parse_and_validate_buffered(src); + assert_snapshot!(&diagnostics); } #[test] @@ -1026,8 +1027,8 @@ fn any_bit_allows_bits() { END_FUNCTION "; - let diagnostics = parse_and_validate(src); - assert_eq!(diagnostics, vec![]); + let diagnostics = parse_and_validate_buffered(src); + assert!(diagnostics.is_empty()); } #[test] @@ -1038,8 +1039,8 @@ fn any_bit_does_not_allow_chars() { FUNCTION func2 : INT VAR x : WCHAR; END_VAR test(x); END_FUNCTION "; - let diagnostics = parse_and_validate(src); - assert_validation_snapshot!(&diagnostics); + let diagnostics = parse_and_validate_buffered(src); + assert_snapshot!(&diagnostics); } #[test] @@ -1050,8 +1051,8 @@ fn any_bit_does_not_allow_string() { FUNCTION func2 : INT VAR x : WSTRING; END_VAR test(x); END_FUNCTION "; - let diagnostics = parse_and_validate(src); - assert_validation_snapshot!(&diagnostics); + let diagnostics = parse_and_validate_buffered(src); + assert_snapshot!(&diagnostics); } #[test] @@ -1065,8 +1066,8 @@ fn any_bit_does_not_allow_date() { FUNCTION func5 : INT VAR x : LTOD; END_VAR test(x); END_FUNCTION "; - let diagnostics = parse_and_validate(src); - assert_validation_snapshot!(&diagnostics); + let diagnostics = parse_and_validate_buffered(src); + assert_snapshot!(&diagnostics); } #[test] @@ -1091,8 +1092,8 @@ fn any_bit_multiple_parameters() { END_FUNCTION "; - let diagnostics = parse_and_validate(src); - assert_validation_snapshot!(&diagnostics); + let diagnostics = parse_and_validate_buffered(src); + assert_snapshot!(&diagnostics); } // ########## ANY_CHARS ########## @@ -1105,8 +1106,8 @@ fn any_chars_does_not_allow_reals() { FUNCTION func1 : INT VAR x : LREAL; END_VAR test(x); END_FUNCTION "; - let diagnostics = parse_and_validate(src); - assert_validation_snapshot!(&diagnostics); + let diagnostics = parse_and_validate_buffered(src); + assert_snapshot!(&diagnostics); } #[test] @@ -1125,8 +1126,8 @@ fn any_chars_does_not_allow_ints() { FUNCTION func8 : INT VAR x : LINT; END_VAR test(x); END_FUNCTION "; - let diagnostics = parse_and_validate(src); - assert_validation_snapshot!(&diagnostics); + let diagnostics = parse_and_validate_buffered(src); + assert_snapshot!(&diagnostics); } #[test] @@ -1137,8 +1138,8 @@ fn any_chars_does_not_allow_time() { FUNCTION func2 : INT VAR x : LTIME; END_VAR test(x); END_FUNCTION "; - let diagnostics = parse_and_validate(src); - assert_validation_snapshot!(&diagnostics); + let diagnostics = parse_and_validate_buffered(src); + assert_snapshot!(&diagnostics); } #[test] @@ -1152,8 +1153,8 @@ fn any_chars_does_not_allow_bits() { FUNCTION func5 : INT VAR x : LWORD; END_VAR test(x); END_FUNCTION "; - let diagnostics = parse_and_validate(src); - assert_validation_snapshot!(&diagnostics); + let diagnostics = parse_and_validate_buffered(src); + assert_snapshot!(&diagnostics); } #[test] @@ -1164,8 +1165,8 @@ fn any_chars_allows_chars() { FUNCTION func2 : INT VAR x : WCHAR; END_VAR test(x); END_FUNCTION "; - let diagnostics = parse_and_validate(src); - assert_eq!(diagnostics, vec![]); + let diagnostics = parse_and_validate_buffered(src); + assert!(diagnostics.is_empty()); } #[test] @@ -1176,8 +1177,8 @@ fn any_chars_allows_string() { FUNCTION func2 : INT VAR x : WSTRING; END_VAR test(x); END_FUNCTION "; - let diagnostics = parse_and_validate(src); - assert_eq!(diagnostics, vec![]); + let diagnostics = parse_and_validate_buffered(src); + assert!(diagnostics.is_empty()); } #[test] @@ -1191,8 +1192,8 @@ fn any_chars_does_not_allow_date() { FUNCTION func5 : INT VAR x : LTOD; END_VAR test(x); END_FUNCTION "; - let diagnostics = parse_and_validate(src); - assert_validation_snapshot!(&diagnostics); + let diagnostics = parse_and_validate_buffered(src); + assert_snapshot!(&diagnostics); } #[test] @@ -1217,8 +1218,8 @@ fn any_chars_multiple_parameters() { END_FUNCTION "; - let diagnostics = parse_and_validate(src); - assert_validation_snapshot!(&diagnostics); + let diagnostics = parse_and_validate_buffered(src); + assert_snapshot!(&diagnostics); } // ########## ANY_STRING ########## @@ -1231,8 +1232,8 @@ fn any_string_does_not_allow_reals() { FUNCTION func1 : INT VAR x : LREAL; END_VAR test(x); END_FUNCTION "; - let diagnostics = parse_and_validate(src); - assert_validation_snapshot!(&diagnostics); + let diagnostics = parse_and_validate_buffered(src); + assert_snapshot!(&diagnostics); } #[test] @@ -1251,8 +1252,8 @@ fn any_string_does_not_allow_ints() { FUNCTION func8 : INT VAR x : LINT; END_VAR test(x); END_FUNCTION "; - let diagnostics = parse_and_validate(src); - assert_validation_snapshot!(&diagnostics); + let diagnostics = parse_and_validate_buffered(src); + assert_snapshot!(&diagnostics); } #[test] @@ -1263,8 +1264,8 @@ fn any_string_does_not_allow_time() { FUNCTION func2 : INT VAR x : LTIME; END_VAR test(x); END_FUNCTION "; - let diagnostics = parse_and_validate(src); - assert_validation_snapshot!(&diagnostics); + let diagnostics = parse_and_validate_buffered(src); + assert_snapshot!(&diagnostics); } #[test] @@ -1278,8 +1279,8 @@ fn any_string_does_not_allow_bits() { FUNCTION func5 : INT VAR x : LWORD; END_VAR test(x); END_FUNCTION "; - let diagnostics = parse_and_validate(src); - assert_validation_snapshot!(&diagnostics); + let diagnostics = parse_and_validate_buffered(src); + assert_snapshot!(&diagnostics); } #[test] @@ -1290,8 +1291,8 @@ fn any_string_does_not_allow_chars() { FUNCTION func2 : INT VAR x : WCHAR; END_VAR test(x); END_FUNCTION "; - let diagnostics = parse_and_validate(src); - assert_validation_snapshot!(&diagnostics); + let diagnostics = parse_and_validate_buffered(src); + assert_snapshot!(&diagnostics); } #[test] @@ -1302,8 +1303,8 @@ fn any_string_allows_string() { FUNCTION func2 : INT VAR x : WSTRING; END_VAR test(x); END_FUNCTION "; - let diagnostics = parse_and_validate(src); - assert_eq!(diagnostics, vec![]); + let diagnostics = parse_and_validate_buffered(src); + assert!(diagnostics.is_empty()); } #[test] @@ -1317,8 +1318,8 @@ fn any_string_does_not_allow_date() { FUNCTION func5 : INT VAR x : LTOD; END_VAR test(x); END_FUNCTION "; - let diagnostics = parse_and_validate(src); - assert_validation_snapshot!(&diagnostics); + let diagnostics = parse_and_validate_buffered(src); + assert_snapshot!(&diagnostics); } #[test] @@ -1343,8 +1344,8 @@ fn any_string_multiple_parameters() { END_FUNCTION "; - let diagnostics = parse_and_validate(src); - assert_validation_snapshot!(&diagnostics); + let diagnostics = parse_and_validate_buffered(src); + assert_snapshot!(&diagnostics); } // ########## ANY_CHAR ########## @@ -1357,8 +1358,8 @@ fn any_char_does_not_allow_reals() { FUNCTION func1 : INT VAR x : LREAL; END_VAR test(x); END_FUNCTION "; - let diagnostics = parse_and_validate(src); - assert_validation_snapshot!(&diagnostics); + let diagnostics = parse_and_validate_buffered(src); + assert_snapshot!(&diagnostics); } #[test] @@ -1377,8 +1378,8 @@ fn any_char_does_not_allow_ints() { FUNCTION func8 : INT VAR x : LINT; END_VAR test(x); END_FUNCTION "; - let diagnostics = parse_and_validate(src); - assert_validation_snapshot!(&diagnostics); + let diagnostics = parse_and_validate_buffered(src); + assert_snapshot!(&diagnostics); } #[test] @@ -1389,8 +1390,8 @@ fn any_char_does_not_allow_time() { FUNCTION func2 : INT VAR x : LTIME; END_VAR test(x); END_FUNCTION "; - let diagnostics = parse_and_validate(src); - assert_validation_snapshot!(&diagnostics); + let diagnostics = parse_and_validate_buffered(src); + assert_snapshot!(&diagnostics); } #[test] @@ -1404,8 +1405,8 @@ fn any_char_does_not_allow_bits() { FUNCTION func5 : INT VAR x : LWORD; END_VAR test(x); END_FUNCTION "; - let diagnostics = parse_and_validate(src); - assert_validation_snapshot!(&diagnostics); + let diagnostics = parse_and_validate_buffered(src); + assert_snapshot!(&diagnostics); } #[test] @@ -1416,8 +1417,8 @@ fn any_char_allows_chars() { FUNCTION func2 : INT VAR x : WCHAR; END_VAR test(x); END_FUNCTION "; - let diagnostics = parse_and_validate(src); - assert_eq!(diagnostics, vec![]); + let diagnostics = parse_and_validate_buffered(src); + assert!(diagnostics.is_empty()); } #[test] @@ -1428,8 +1429,8 @@ fn any_char_does_not_allow_string() { FUNCTION func2 : INT VAR x : WSTRING; END_VAR test(x); END_FUNCTION "; - let diagnostics = parse_and_validate(src); - assert_validation_snapshot!(&diagnostics); + let diagnostics = parse_and_validate_buffered(src); + assert_snapshot!(&diagnostics); } #[test] @@ -1443,8 +1444,8 @@ fn any_char_does_not_allow_date() { FUNCTION func5 : INT VAR x : LTOD; END_VAR test(x); END_FUNCTION "; - let diagnostics = parse_and_validate(src); - assert_validation_snapshot!(&diagnostics); + let diagnostics = parse_and_validate_buffered(src); + assert_snapshot!(&diagnostics); } #[test] @@ -1469,8 +1470,8 @@ fn any_char_multiple_parameters() { END_FUNCTION "; - let diagnostics = parse_and_validate(src); - assert_validation_snapshot!(&diagnostics); + let diagnostics = parse_and_validate_buffered(src); + assert_snapshot!(&diagnostics); } // ########## ANY_DATE ########## @@ -1483,8 +1484,8 @@ fn any_date_does_not_allow_reals() { FUNCTION func1 : INT VAR x : LREAL; END_VAR test(x); END_FUNCTION "; - let diagnostics = parse_and_validate(src); - assert_validation_snapshot!(&diagnostics); + let diagnostics = parse_and_validate_buffered(src); + assert_snapshot!(&diagnostics); } #[test] @@ -1503,8 +1504,8 @@ fn any_date_does_not_allow_ints() { FUNCTION func8 : INT VAR x : LINT; END_VAR test(x); END_FUNCTION "; - let diagnostics = parse_and_validate(src); - assert_validation_snapshot!(&diagnostics); + let diagnostics = parse_and_validate_buffered(src); + assert_snapshot!(&diagnostics); } #[test] @@ -1515,8 +1516,8 @@ fn any_date_does_not_allow_time() { FUNCTION func2 : INT VAR x : LTIME; END_VAR test(x); END_FUNCTION "; - let diagnostics = parse_and_validate(src); - assert_validation_snapshot!(&diagnostics); + let diagnostics = parse_and_validate_buffered(src); + assert_snapshot!(&diagnostics); } #[test] @@ -1530,8 +1531,8 @@ fn any_date_does_not_allow_bits() { FUNCTION func5 : INT VAR x : LWORD; END_VAR test(x); END_FUNCTION "; - let diagnostics = parse_and_validate(src); - assert_validation_snapshot!(&diagnostics); + let diagnostics = parse_and_validate_buffered(src); + assert_snapshot!(&diagnostics); } #[test] @@ -1542,8 +1543,8 @@ fn any_date_does_not_allow_chars() { FUNCTION func2 : INT VAR x : WCHAR; END_VAR test(x); END_FUNCTION "; - let diagnostics = parse_and_validate(src); - assert_validation_snapshot!(&diagnostics); + let diagnostics = parse_and_validate_buffered(src); + assert_snapshot!(&diagnostics); } #[test] @@ -1554,8 +1555,8 @@ fn any_date_does_not_allow_string() { FUNCTION func2 : INT VAR x : WSTRING; END_VAR test(x); END_FUNCTION "; - let diagnostics = parse_and_validate(src); - assert_validation_snapshot!(&diagnostics); + let diagnostics = parse_and_validate_buffered(src); + assert_snapshot!(&diagnostics); } #[test] @@ -1569,8 +1570,8 @@ fn any_date_allows_date() { FUNCTION func5 : INT VAR x : LTOD; END_VAR test(x); END_FUNCTION "; - let diagnostics = parse_and_validate(src); - assert_eq!(diagnostics, vec![]); + let diagnostics = parse_and_validate_buffered(src); + assert!(diagnostics.is_empty()); } #[test] @@ -1595,6 +1596,6 @@ fn any_date_multiple_parameters() { END_FUNCTION "; - let diagnostics = parse_and_validate(src); - assert_validation_snapshot!(&diagnostics); + let diagnostics = parse_and_validate_buffered(src); + assert_snapshot!(&diagnostics); } diff --git a/src/validation/tests/literals_validation_tests.rs b/src/validation/tests/literals_validation_tests.rs index 62069e2905..c7cda24620 100644 --- a/src/validation/tests/literals_validation_tests.rs +++ b/src/validation/tests/literals_validation_tests.rs @@ -1,10 +1,10 @@ -use plc_diagnostics::diagnostics::Diagnostic; +use insta::assert_snapshot; -use crate::{assert_validation_snapshot, test_utils::tests::parse_and_validate}; +use crate::test_utils::tests::parse_and_validate_buffered; #[test] fn int_literal_casts_max_values_are_validated() { - let diagnostics = parse_and_validate( + let diagnostics = parse_and_validate_buffered( " PROGRAM prg BYTE#255; @@ -22,12 +22,12 @@ fn int_literal_casts_max_values_are_validated() { ", ); - assert_validation_snapshot!(&diagnostics); + assert_snapshot!(&diagnostics); } #[test] fn bool_literal_casts_are_validated() { - let diagnostics = parse_and_validate( + let diagnostics = parse_and_validate_buffered( " PROGRAM prg BOOL#TRUE; @@ -41,12 +41,12 @@ fn bool_literal_casts_are_validated() { ", ); - assert_validation_snapshot!(&diagnostics); + assert_snapshot!(&diagnostics); } #[test] fn string_literal_casts_are_validated() { - let diagnostics = parse_and_validate( + let diagnostics = parse_and_validate_buffered( r#" PROGRAM prg @@ -67,12 +67,12 @@ fn string_literal_casts_are_validated() { "#, ); - assert_validation_snapshot!(&diagnostics); + assert_snapshot!(&diagnostics); } #[test] fn real_literal_casts_are_validated() { - let diagnostics = parse_and_validate( + let diagnostics = parse_and_validate_buffered( r#" PROGRAM prg @@ -92,24 +92,24 @@ fn real_literal_casts_are_validated() { "#, ); - assert_validation_snapshot!(&diagnostics); + assert_snapshot!(&diagnostics); } #[test] fn literal_cast_with_non_literal() { - let diagnostics = parse_and_validate( + let diagnostics = parse_and_validate_buffered( "PROGRAM exp INT#[x]; END_PROGRAM VAR_GLOBAL x : INT; END_VAR", ); - assert_validation_snapshot!(&diagnostics); + assert_snapshot!(&diagnostics); } #[test] fn literal_enum_elements_validate_without_errors() { - let diagnostics = parse_and_validate( + let diagnostics = parse_and_validate_buffered( " TYPE Animal: (Dog, Cat, Horse); END_TYPE TYPE Color: (Red, Yellow, Green); END_TYPE @@ -120,13 +120,12 @@ fn literal_enum_elements_validate_without_errors() { END_PROGRAM", ); - let empty: Vec = Vec::new(); - assert_eq!(empty, diagnostics); + assert!(diagnostics.is_empty()); } #[test] fn date_literal_casts_are_validated() { - let diagnostics = parse_and_validate( + let diagnostics = parse_and_validate_buffered( r#" PROGRAM prg LINT#DT#1989-06-15-13:56:14.77; @@ -147,12 +146,12 @@ fn date_literal_casts_are_validated() { "#, ); - assert_validation_snapshot!(&diagnostics); + assert_snapshot!(&diagnostics); } #[test] fn char_cast_validate() { - let diagnostics = parse_and_validate( + let diagnostics = parse_and_validate_buffered( r#" PROGRAM prg @@ -166,5 +165,5 @@ fn char_cast_validate() { "#, ); - assert_validation_snapshot!(&diagnostics); + assert_snapshot!(&diagnostics); } diff --git a/src/validation/tests/naming_validation_test.rs b/src/validation/tests/naming_validation_test.rs index b0e5647a79..d256c0b86b 100644 --- a/src/validation/tests/naming_validation_test.rs +++ b/src/validation/tests/naming_validation_test.rs @@ -1,4 +1,5 @@ -use crate::{assert_validation_snapshot, test_utils::tests::parse_and_validate}; +use crate::test_utils::tests::parse_and_validate_buffered; +use insta::assert_snapshot; macro_rules! assert_with_type_name { ($name:ident) => { @@ -6,8 +7,9 @@ macro_rules! assert_with_type_name { #[allow(non_snake_case)] fn $name() { let name = stringify!($name); - let result = parse_and_validate(&format!("TYPE {name} : STRUCT x : DINT; END_STRUCT END_TYPE")); - assert_validation_snapshot!(&result) + let result = + parse_and_validate_buffered(&format!("TYPE {name} : STRUCT x : DINT; END_STRUCT END_TYPE")); + assert_snapshot!(&result) } }; } diff --git a/src/validation/tests/pou_validation_tests.rs b/src/validation/tests/pou_validation_tests.rs index c769b59f01..fa185b20b8 100644 --- a/src/validation/tests/pou_validation_tests.rs +++ b/src/validation/tests/pou_validation_tests.rs @@ -1,28 +1,29 @@ -use crate::{assert_validation_snapshot, test_utils::tests::parse_and_validate}; +use crate::test_utils::tests::parse_and_validate_buffered; +use insta::assert_snapshot; #[test] fn function_no_return_unsupported() { // GIVEN FUNCTION with no return type // WHEN parse_and_validate is done - let diagnostics = parse_and_validate("FUNCTION foo VAR_INPUT END_VAR END_FUNCTION"); + let diagnostics = parse_and_validate_buffered("FUNCTION foo VAR_INPUT END_VAR END_FUNCTION"); // THEN there should be one diagnostic -> missing return type - assert_validation_snapshot!(&diagnostics); + assert_snapshot!(&diagnostics); } #[test] fn actions_container_no_name() { // GIVEN ACTIONS without a name // WHEN parse_and_validate is done - let diagnostics = parse_and_validate("ACTIONS ACTION myAction END_ACTION END_ACTIONS"); + let diagnostics = parse_and_validate_buffered("ACTIONS ACTION myAction END_ACTION END_ACTIONS"); // THEN there should be one diagnostic -> missing action container name - assert_validation_snapshot!(&diagnostics); + assert_snapshot!(&diagnostics); } #[test] fn class_has_implementation() { // GIVEN CLASS with an implementation // WHEN parse_and_validate is done - let diagnostics = parse_and_validate( + let diagnostics = parse_and_validate_buffered( " CLASS myCLASS VAR @@ -33,14 +34,14 @@ fn class_has_implementation() { ", ); // THEN there should be one diagnostic -> Class cannot have implementation - assert_validation_snapshot!(&diagnostics); + assert_snapshot!(&diagnostics); } #[test] fn program_has_super_class() { // GIVEN PROGRAM with a super class // WHEN parse_and_validate is done - let diagnostics = parse_and_validate( + let diagnostics = parse_and_validate_buffered( " CLASS cls END_CLASS @@ -50,14 +51,14 @@ fn program_has_super_class() { ", ); // THEN there should be one diagnostic -> Program cannot have super class - assert_validation_snapshot!(&diagnostics); + assert_snapshot!(&diagnostics); } #[test] fn function_has_super_class() { // GIVEN FUNCTION with a super class // WHEN parse_and_validate is done - let diagnostics = parse_and_validate( + let diagnostics = parse_and_validate_buffered( " CLASS cls END_CLASS @@ -67,28 +68,28 @@ fn function_has_super_class() { ", ); // THEN there should be one diagnostic -> Function cannot have super class - assert_validation_snapshot!(&diagnostics); + assert_snapshot!(&diagnostics); } #[test] fn class_with_return_type() { // GIVEN class with a return type // WHEN parse_and_validate is done - let diagnostics = parse_and_validate( + let diagnostics = parse_and_validate_buffered( " CLASS cls : INT END_CLASS ", ); // THEN there should be one diagnostic -> Class cannot have a return type - assert_validation_snapshot!(&diagnostics); + assert_snapshot!(&diagnostics); } #[test] fn in_out_variable_not_allowed_in_class() { // GIVEN class with a VAR_IN_OUT // WHEN parse_and_validate is done - let diagnostics = parse_and_validate( + let diagnostics = parse_and_validate_buffered( " CLASS cls VAR_IN_OUT @@ -98,14 +99,14 @@ fn in_out_variable_not_allowed_in_class() { ", ); // THEN there should be one diagnostic -> Class cannot have a var in/out/inout block - assert_validation_snapshot!(&diagnostics); + assert_snapshot!(&diagnostics); } #[test] fn input_variable_not_allowed_in_class() { // GIVEN class with a VAR_INPUT // WHEN parse_and_validate is done - let diagnostics = parse_and_validate( + let diagnostics = parse_and_validate_buffered( " CLASS cls VAR_INPUT @@ -115,14 +116,14 @@ fn input_variable_not_allowed_in_class() { ", ); // THEN there should be one diagnostic -> Class cannot have a var in/out/inout block - assert_validation_snapshot!(&diagnostics); + assert_snapshot!(&diagnostics); } #[test] fn output_variable_not_allowed_in_class() { // GIVEN class with a VAR_OUTPUT // WHEN parse_and_validate is done - let diagnostics = parse_and_validate( + let diagnostics = parse_and_validate_buffered( " CLASS cls VAR_OUTPUT @@ -132,14 +133,14 @@ fn output_variable_not_allowed_in_class() { ", ); // THEN there should be one diagnostic -> Class cannot have a var in/out/inout block - assert_validation_snapshot!(&diagnostics); + assert_snapshot!(&diagnostics); } #[test] fn local_variable_allowed_in_class() { // GIVEN class with a VAR // WHEN parse_and_validate is done - let diagnostics = parse_and_validate( + let diagnostics = parse_and_validate_buffered( " CLASS cls VAR @@ -149,7 +150,7 @@ fn local_variable_allowed_in_class() { ", ); // THEN there should be no diagnostic -> Class can have local var block - assert_validation_snapshot!(&diagnostics); + assert_snapshot!(&diagnostics); } #[test] @@ -158,7 +159,7 @@ fn do_not_validate_external() { // for this kind of assignment our validator would report // potential loss of information (assigning bigger to smaller type) // WHEN ... - let diagnostics = parse_and_validate( + let diagnostics = parse_and_validate_buffered( " PROGRAM main END_PROGRAM @@ -179,7 +180,7 @@ fn do_not_validate_external() { #[test] fn in_out_variable_out_of_order() { - let diagnostics = parse_and_validate( + let diagnostics = parse_and_validate_buffered( " PROGRAM mainProg VAR @@ -220,5 +221,5 @@ fn in_out_variable_out_of_order() { ", ); - assert_validation_snapshot!(diagnostics); + assert_snapshot!(diagnostics); } diff --git a/src/validation/tests/recursive_validation_tests.rs b/src/validation/tests/recursive_validation_tests.rs index 2efa35ee9a..37ecbed936 100644 --- a/src/validation/tests/recursive_validation_tests.rs +++ b/src/validation/tests/recursive_validation_tests.rs @@ -1,9 +1,9 @@ mod edgecases { - use crate::test_utils::tests::parse_and_validate; + use crate::test_utils::tests::parse_and_validate_buffered; #[test] fn pointers_should_not_be_considered_as_cycle() { - let diagnostics = parse_and_validate( + let diagnostics = parse_and_validate_buffered( " TYPE A : STRUCT b : B; @@ -15,7 +15,7 @@ mod edgecases { ", ); - assert_eq!(diagnostics.len(), 0); + assert!(diagnostics.is_empty()); } // From https://github.com/PLC-lang/rusty/pull/748: @@ -26,7 +26,7 @@ mod edgecases { // This test covers the above edge-case #[test] fn external_function_should_not_trigger() { - let diagnostics = parse_and_validate( + let diagnostics = parse_and_validate_buffered( " {external} FUNCTION TIME : TIME @@ -40,12 +40,12 @@ mod edgecases { ", ); - assert_eq!(diagnostics.len(), 0); + assert!(diagnostics.is_empty()); } #[test] fn struct_and_function_with_same_name() { - let diagnostics = parse_and_validate( + let diagnostics = parse_and_validate_buffered( " FUNCTION TM : TM END_FUNCTION @@ -57,12 +57,12 @@ mod edgecases { ", ); - assert_eq!(diagnostics.len(), 0); + assert!(diagnostics.is_empty()); } #[test] fn struct_and_function_with_same_name_2() { - let diagnostics = parse_and_validate( + let diagnostics = parse_and_validate_buffered( " FUNCTION TM : DINT VAR_INPUT @@ -77,12 +77,12 @@ mod edgecases { ", ); - assert_eq!(diagnostics.len(), 0); + assert!(diagnostics.is_empty()); } #[test] fn struct_and_function_with_same_name_3() { - let diagnostics = parse_and_validate( + let diagnostics = parse_and_validate_buffered( " FUNCTION TM : DINT VAR_INPUT @@ -97,16 +97,17 @@ mod edgecases { ", ); - assert_eq!(diagnostics.len(), 0); + assert!(diagnostics.is_empty()); } } mod structs { - use crate::{assert_validation_snapshot, test_utils::tests::parse_and_validate}; + use crate::test_utils::tests::parse_and_validate_buffered; + use insta::assert_snapshot; #[test] fn one_cycle_abca() { - let diagnostics = parse_and_validate( + let diagnostics = parse_and_validate_buffered( " TYPE A : STRUCT b : B; @@ -127,12 +128,12 @@ mod structs { ", ); - assert_validation_snapshot!(&diagnostics); + assert_snapshot!(&diagnostics); } #[test] fn one_cycle_self_a() { - let diagnostics = parse_and_validate( + let diagnostics = parse_and_validate_buffered( " TYPE A : STRUCT a : A; @@ -140,12 +141,12 @@ mod structs { ", ); - assert_validation_snapshot!(&diagnostics); + assert_snapshot!(&diagnostics); } #[test] fn one_cycle_multiple_self_a() { - let diagnostics = parse_and_validate( + let diagnostics = parse_and_validate_buffered( " TYPE A : STRUCT a1 : A; @@ -155,12 +156,12 @@ mod structs { ", ); - assert_validation_snapshot!(&diagnostics); + assert_snapshot!(&diagnostics); } #[test] fn one_cycle_aba() { - let diagnostics = parse_and_validate( + let diagnostics = parse_and_validate_buffered( " TYPE A : STRUCT b : B; @@ -172,12 +173,12 @@ mod structs { ", ); - assert_validation_snapshot!(&diagnostics); + assert_snapshot!(&diagnostics); } #[test] fn one_cycle_bcb() { - let diagnostics = parse_and_validate( + let diagnostics = parse_and_validate_buffered( " TYPE A : STRUCT b : B; @@ -193,12 +194,12 @@ mod structs { ", ); - assert_validation_snapshot!(&diagnostics); + assert_snapshot!(&diagnostics); } #[test] fn one_cycle_with_multiple_identical_members_aba() { - let diagnostics = parse_and_validate( + let diagnostics = parse_and_validate_buffered( " TYPE A : STRUCT b1 : B; @@ -212,12 +213,12 @@ mod structs { ", ); - assert_validation_snapshot!(&diagnostics); + assert_snapshot!(&diagnostics); } #[test] fn two_cycles_aa_and_aba() { - let diagnostics = parse_and_validate( + let diagnostics = parse_and_validate_buffered( " TYPE A : STRUCT a : A; @@ -230,12 +231,12 @@ mod structs { ", ); - assert_validation_snapshot!(&diagnostics); + assert_snapshot!(&diagnostics); } #[test] fn two_cycles_branch_cc_and_cec() { - let diagnostics = parse_and_validate( + let diagnostics = parse_and_validate_buffered( " TYPE A : STRUCT b : B; @@ -256,12 +257,12 @@ mod structs { ", ); - assert_validation_snapshot!(&diagnostics); + assert_snapshot!(&diagnostics); } #[test] fn two_cycles_with_branch() { - let diagnostics = parse_and_validate( + let diagnostics = parse_and_validate_buffered( " TYPE A : STRUCT b : B; @@ -298,17 +299,17 @@ mod structs { ", ); - assert_validation_snapshot!(&diagnostics); + assert_snapshot!(&diagnostics); } } mod arrays { - - use crate::{assert_validation_snapshot, test_utils::tests::parse_and_validate}; + use crate::test_utils::tests::parse_and_validate_buffered; + use insta::assert_snapshot; #[test] fn two_cycles_aa_and_aba() { - let diagnostics = parse_and_validate( + let diagnostics = parse_and_validate_buffered( " TYPE A : STRUCT a : ARRAY[0..1] OF A; @@ -321,12 +322,12 @@ mod arrays { ", ); - assert_validation_snapshot!(&diagnostics); + assert_snapshot!(&diagnostics); } #[test] fn one_cycle_bcb() { - let diagnostics = parse_and_validate( + let diagnostics = parse_and_validate_buffered( " TYPE A : STRUCT b : ARRAY[0..1] OF B; @@ -342,12 +343,12 @@ mod arrays { ", ); - assert_validation_snapshot!(&diagnostics); + assert_snapshot!(&diagnostics); } #[test] fn one_cycle_with_multiple_identical_members_aba() { - let diagnostics = parse_and_validate( + let diagnostics = parse_and_validate_buffered( " TYPE A : STRUCT b1 : ARRAY[0..1] OF B; @@ -361,12 +362,12 @@ mod arrays { ", ); - assert_validation_snapshot!(&diagnostics); + assert_snapshot!(&diagnostics); } #[test] fn one_cycle_aba_output() { - let diagnostics = parse_and_validate( + let diagnostics = parse_and_validate_buffered( " TYPE A : STRUCT b : ARRAY [0..1] OF B; @@ -380,12 +381,12 @@ mod arrays { ", ); - assert_validation_snapshot!(&diagnostics); + assert_snapshot!(&diagnostics); } #[test] fn one_cycle_aba_input() { - let diagnostics = parse_and_validate( + let diagnostics = parse_and_validate_buffered( " TYPE A : STRUCT b : ARRAY [0..1] OF B; @@ -399,12 +400,12 @@ mod arrays { ", ); - assert_validation_snapshot!(&diagnostics); + assert_snapshot!(&diagnostics); } #[test] fn two_cycles_with_branch_input() { - let diagnostics = parse_and_validate( + let diagnostics = parse_and_validate_buffered( " FUNCTION_BLOCK A VAR_INPUT @@ -449,16 +450,17 @@ mod arrays { ", ); - assert_validation_snapshot!(&diagnostics); + assert_snapshot!(&diagnostics); } } mod functionblocks { - use crate::{assert_validation_snapshot, test_utils::tests::parse_and_validate}; + use crate::test_utils::tests::parse_and_validate_buffered; + use insta::assert_snapshot; #[test] fn one_cycle_aba_var() { - let diagnostics = parse_and_validate( + let diagnostics = parse_and_validate_buffered( " FUNCTION_BLOCK A VAR @@ -475,12 +477,12 @@ mod functionblocks { ", ); - assert_validation_snapshot!(&diagnostics); + assert_snapshot!(&diagnostics); } #[test] fn one_cycle_aba_input() { - let diagnostics = parse_and_validate( + let diagnostics = parse_and_validate_buffered( " FUNCTION_BLOCK A VAR_INPUT @@ -497,12 +499,12 @@ mod functionblocks { ", ); - assert_validation_snapshot!(&diagnostics); + assert_snapshot!(&diagnostics); } #[test] fn one_cycle_aba_output() { - let diagnostics = parse_and_validate( + let diagnostics = parse_and_validate_buffered( " FUNCTION_BLOCK A VAR_OUTPUT @@ -519,12 +521,12 @@ mod functionblocks { ", ); - assert_validation_snapshot!(&diagnostics); + assert_snapshot!(&diagnostics); } #[test] fn one_cycle_aba_inout() { - let diagnostics = parse_and_validate( + let diagnostics = parse_and_validate_buffered( " FUNCTION_BLOCK A VAR_IN_OUT @@ -542,12 +544,12 @@ mod functionblocks { ); // No recursion because VAR_IN_OUT are treated as pointers - assert_eq!(diagnostics.len(), 0); + assert!(diagnostics.is_empty()); } #[test] fn two_cycles_with_branch_input() { - let diagnostics = parse_and_validate( + let diagnostics = parse_and_validate_buffered( " FUNCTION_BLOCK A VAR_INPUT @@ -600,17 +602,18 @@ mod functionblocks { ", ); - assert_validation_snapshot!(&diagnostics); + assert_snapshot!(&diagnostics); } } mod mixed_structs_and_functionblocks { - use crate::{assert_validation_snapshot, test_utils::tests::parse_and_validate}; + use crate::test_utils::tests::parse_and_validate_buffered; + use insta::assert_snapshot; #[test] fn one_cycle_aba_output() { - let diagnostics = parse_and_validate( + let diagnostics = parse_and_validate_buffered( " TYPE A : STRUCT b : B; @@ -624,12 +627,12 @@ mod mixed_structs_and_functionblocks { ", ); - assert_validation_snapshot!(&diagnostics); + assert_snapshot!(&diagnostics); } #[test] fn one_cycle_aba_input() { - let diagnostics = parse_and_validate( + let diagnostics = parse_and_validate_buffered( " TYPE A : STRUCT b : B; @@ -643,12 +646,12 @@ mod mixed_structs_and_functionblocks { ", ); - assert_validation_snapshot!(&diagnostics); + assert_snapshot!(&diagnostics); } #[test] fn two_cycles_with_branch_input() { - let diagnostics = parse_and_validate( + let diagnostics = parse_and_validate_buffered( " FUNCTION_BLOCK A VAR_INPUT @@ -693,6 +696,6 @@ mod mixed_structs_and_functionblocks { ", ); - assert_validation_snapshot!(&diagnostics); + assert_snapshot!(&diagnostics); } } diff --git a/src/validation/tests/reference_resolve_tests.rs b/src/validation/tests/reference_resolve_tests.rs index 646afe2970..3cf519d5a9 100644 --- a/src/validation/tests/reference_resolve_tests.rs +++ b/src/validation/tests/reference_resolve_tests.rs @@ -1,11 +1,11 @@ -use crate::assert_validation_snapshot; -use crate::test_utils::tests::parse_and_validate; +use crate::test_utils::tests::parse_and_validate_buffered; +use insta::assert_snapshot; /// tests wheter simple local and global variables can be resolved and /// errors are reported properly #[test] fn resolve_simple_variable_references() { - let diagnostics = parse_and_validate( + let diagnostics = parse_and_validate_buffered( " VAR_GLOBAL ga : INT; @@ -23,14 +23,14 @@ fn resolve_simple_variable_references() { ", ); - assert_validation_snapshot!(&diagnostics); + assert_snapshot!(diagnostics); } /// tests wheter functions and function parameters can be resolved and /// errors are reported properly #[test] fn resolve_function_calls_and_parameters() { - let diagnostics = parse_and_validate( + let diagnostics = parse_and_validate_buffered( " PROGRAM prg VAR a : INT; END_VAR @@ -47,14 +47,14 @@ fn resolve_function_calls_and_parameters() { ", ); - assert_validation_snapshot!(&diagnostics); + assert_snapshot!(&diagnostics); } /// tests wheter structs and struct member variables can be resolved and /// errors are reported properly #[test] fn resole_struct_member_access() { - let diagnostics = parse_and_validate( + let diagnostics = parse_and_validate_buffered( " TYPE MySubStruct: STRUCT subfield1: INT; @@ -99,14 +99,14 @@ fn resole_struct_member_access() { ", ); - assert_validation_snapshot!(&diagnostics); + assert_snapshot!(&diagnostics); } /// tests wheter function_block members can be resolved and /// errors are reported properly #[test] fn resolve_function_block_calls_field_access() { - let diagnostics = parse_and_validate( + let diagnostics = parse_and_validate_buffered( " FUNCTION_BLOCK FB VAR_INPUT @@ -130,14 +130,14 @@ fn resolve_function_block_calls_field_access() { ", ); - assert_eq!(diagnostics, vec![]); + assert!(diagnostics.is_empty()); } /// tests wheter function_block types and member variables can be resolved and /// errors are reported properly #[test] fn resolve_function_block_calls_in_structs_and_field_access() { - let diagnostics = parse_and_validate( + let diagnostics = parse_and_validate_buffered( " FUNCTION_BLOCK FB VAR_INPUT @@ -167,13 +167,13 @@ fn resolve_function_block_calls_in_structs_and_field_access() { ", ); - assert_validation_snapshot!(&diagnostics); + assert_snapshot!(&diagnostics); } /// tests wheter function's members cannot be access using the function's name as a qualifier #[test] fn resolve_function_members_via_qualifier() { - let diagnostics = parse_and_validate( + let diagnostics = parse_and_validate_buffered( " PROGRAM prg VAR @@ -193,13 +193,13 @@ fn resolve_function_members_via_qualifier() { ", ); - assert_validation_snapshot!(&diagnostics); + assert_snapshot!(&diagnostics); } /// tests whether references to privater variables do resolve, but end up in an validation problem #[test] fn reference_to_private_variable_is_illegal() { - let diagnostics = parse_and_validate( + let diagnostics = parse_and_validate_buffered( " PROGRAM prg VAR @@ -213,7 +213,7 @@ fn reference_to_private_variable_is_illegal() { ", ); - assert_validation_snapshot!(&diagnostics); + assert_snapshot!(&diagnostics); } /// tests whether an intermediate access like: `a.priv.b` (where priv is a var_local) @@ -223,7 +223,7 @@ fn reference_to_private_variable_in_intermediate_fb() { // GIVEN a qualified reference prg.a.f.x where f is a // private member of a functionblock (VAR) // WHEN this is validated - let diagnostics = parse_and_validate( + let diagnostics = parse_and_validate_buffered( " FUNCTION_BLOCK fb1 VAR @@ -249,12 +249,12 @@ fn reference_to_private_variable_in_intermediate_fb() { // THEN we get a validtion-error for accessing fb1.f, but no follow-up errors for // the access of fb2 which is legit - assert_validation_snapshot!(&diagnostics); + assert_snapshot!(&diagnostics); } #[test] fn program_vars_are_allowed_in_their_actions() { - let diagnostics = parse_and_validate( + let diagnostics = parse_and_validate_buffered( " PROGRAM prg VAR @@ -269,12 +269,12 @@ fn program_vars_are_allowed_in_their_actions() { ", ); - assert_eq!(diagnostics, vec![]); + assert!(diagnostics.is_empty()); } #[test] fn fb_pointer_access_call_statement_resolves_without_validation_errors() { - let diagnostics = parse_and_validate( + let diagnostics = parse_and_validate_buffered( " PROGRAM main VAR @@ -296,12 +296,12 @@ fn fb_pointer_access_call_statement_resolves_without_validation_errors() { ", ); - assert_eq!(diagnostics, vec![]); + assert!(diagnostics.is_empty()); } #[test] fn resolve_array_of_struct_as_member_of_another_struct_initializer() { - let diagnostics = parse_and_validate( + let diagnostics = parse_and_validate_buffered( " PROGRAM mainProg VAR @@ -327,12 +327,12 @@ fn resolve_array_of_struct_as_member_of_another_struct_initializer() { ", ); - assert_eq!(diagnostics, vec![]); + assert!(diagnostics.is_empty()); } #[test] fn array_of_struct_as_member_of_another_struct_and_variable_declaration_is_initialized() { - let diagnostics = parse_and_validate( + let diagnostics = parse_and_validate_buffered( " PROGRAM mainProg VAR diff --git a/src/validation/tests/snapshots/rusty__validation__tests__assignment_validation_tests__array_assignment_validation.snap b/src/validation/tests/snapshots/rusty__validation__tests__assignment_validation_tests__array_assignment_validation.snap index b40cb3862d..2769636a30 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__assignment_validation_tests__array_assignment_validation.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__assignment_validation_tests__array_assignment_validation.snap @@ -1,22 +1,107 @@ --- source: src/validation/tests/assignment_validation_tests.rs -expression: res +expression: "&diagnostics" --- -SyntaxError { message: "Invalid assignment: cannot assign 'ARRAY[0..8] OF STRING[1256]' to 'ARRAY[0..3] OF STRING[256]'", range: [SourceLocation { span: Range(TextLocation { line: 29, column: 4, offset: 729 }..TextLocation { line: 29, column: 45, offset: 770 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid assignment: cannot assign 'ARRAY[0..2] OF INT' to 'ARRAY[0..3] OF INT'", range: [SourceLocation { span: Range(TextLocation { line: 30, column: 4, offset: 787 }..TextLocation { line: 30, column: 30, offset: 813 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid assignment: cannot assign 'ARRAY[0..4] OF INT' to 'ARRAY[0..3] OF INT'", range: [SourceLocation { span: Range(TextLocation { line: 32, column: 4, offset: 871 }..TextLocation { line: 32, column: 30, offset: 897 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid assignment: cannot assign 'ARRAY[0..3] OF REAL' to 'ARRAY[0..3] OF INT'", range: [SourceLocation { span: Range(TextLocation { line: 33, column: 4, offset: 914 }..TextLocation { line: 33, column: 31, offset: 941 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid assignment: cannot assign 'ARRAY[0..3] OF STRING' to 'ARRAY[0..3] OF INT'", range: [SourceLocation { span: Range(TextLocation { line: 34, column: 4, offset: 958 }..TextLocation { line: 34, column: 33, offset: 987 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid assignment: cannot assign 'ARRAY[0..3] OF CHAR' to 'ARRAY[0..3] OF INT'", range: [SourceLocation { span: Range(TextLocation { line: 35, column: 4, offset: 1004 }..TextLocation { line: 35, column: 31, offset: 1031 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Array assignments must be surrounded with `[]`", range: [SourceLocation { span: Range(TextLocation { line: 36, column: 19, offset: 1063 }..TextLocation { line: 36, column: 20, offset: 1064 }) }], err_no: arr__invalid_array_assignment } -SyntaxError { message: "Array assignments must be surrounded with `[]`", range: [SourceLocation { span: Range(TextLocation { line: 37, column: 20, offset: 1106 }..TextLocation { line: 37, column: 30, offset: 1116 }) }], err_no: arr__invalid_array_assignment } -SyntaxError { message: "Array assignments must be surrounded with `[]`", range: [SourceLocation { span: Range(TextLocation { line: 38, column: 20, offset: 1148 }..TextLocation { line: 38, column: 36, offset: 1164 }) }], err_no: arr__invalid_array_assignment } -SyntaxError { message: "Invalid assignment: cannot assign 'STRING' to 'INT'", range: [SourceLocation { span: Range(TextLocation { line: 43, column: 4, offset: 1352 }..TextLocation { line: 43, column: 30, offset: 1378 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid assignment: cannot assign 'STRING' to 'INT'", range: [SourceLocation { span: Range(TextLocation { line: 44, column: 4, offset: 1395 }..TextLocation { line: 44, column: 37, offset: 1428 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid assignment: cannot assign 'STRING' to 'INT'", range: [SourceLocation { span: Range(TextLocation { line: 45, column: 4, offset: 1445 }..TextLocation { line: 45, column: 30, offset: 1471 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid assignment: cannot assign 'CHAR' to 'INT'", range: [SourceLocation { span: Range(TextLocation { line: 46, column: 4, offset: 1488 }..TextLocation { line: 46, column: 28, offset: 1512 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid assignment: cannot assign 'CHAR' to 'INT'", range: [SourceLocation { span: Range(TextLocation { line: 47, column: 4, offset: 1529 }..TextLocation { line: 47, column: 30, offset: 1555 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid assignment: cannot assign 'STRING' to 'INT'", range: [SourceLocation { span: Range(TextLocation { line: 49, column: 4, offset: 1615 }..TextLocation { line: 49, column: 35, offset: 1646 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid assignment: cannot assign 'DINT' to 'ARRAY[0..3] OF INT'", range: [SourceLocation { span: Range(TextLocation { line: 50, column: 4, offset: 1663 }..TextLocation { line: 50, column: 25, offset: 1684 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid assignment: cannot assign 'ARRAY[0..3] OF INT' to 'DINT'", range: [SourceLocation { span: Range(TextLocation { line: 51, column: 4, offset: 1701 }..TextLocation { line: 51, column: 25, offset: 1722 }) }], err_no: var__invalid_assignment } +error: Invalid assignment: cannot assign 'ARRAY[0..8] OF STRING[1256]' to 'ARRAY[0..3] OF STRING[256]' + ┌─ :30:5 + │ +30 │ v_arr_sized_string := v_arr_sized_string2; // INVALID + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Invalid assignment: cannot assign 'ARRAY[0..8] OF STRING[1256]' to 'ARRAY[0..3] OF STRING[256]' + +error: Invalid assignment: cannot assign 'ARRAY[0..2] OF INT' to 'ARRAY[0..3] OF INT' + ┌─ :31:5 + │ +31 │ v_arr_int_3 := v_arr_int_2; // INVALID + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^ Invalid assignment: cannot assign 'ARRAY[0..2] OF INT' to 'ARRAY[0..3] OF INT' + +error: Invalid assignment: cannot assign 'ARRAY[0..4] OF INT' to 'ARRAY[0..3] OF INT' + ┌─ :33:5 + │ +33 │ v_arr_int_3 := v_arr_int_4; // INVALID + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^ Invalid assignment: cannot assign 'ARRAY[0..4] OF INT' to 'ARRAY[0..3] OF INT' + +error: Invalid assignment: cannot assign 'ARRAY[0..3] OF REAL' to 'ARRAY[0..3] OF INT' + ┌─ :34:5 + │ +34 │ v_arr_int_3 := v_arr_real_3; // INVALID + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^ Invalid assignment: cannot assign 'ARRAY[0..3] OF REAL' to 'ARRAY[0..3] OF INT' + +error: Invalid assignment: cannot assign 'ARRAY[0..3] OF STRING' to 'ARRAY[0..3] OF INT' + ┌─ :35:5 + │ +35 │ v_arr_int_3 := v_arr_string_3; // INVALID + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Invalid assignment: cannot assign 'ARRAY[0..3] OF STRING' to 'ARRAY[0..3] OF INT' + +error: Invalid assignment: cannot assign 'ARRAY[0..3] OF CHAR' to 'ARRAY[0..3] OF INT' + ┌─ :36:5 + │ +36 │ v_arr_int_3 := v_arr_char_3; // INVALID + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^ Invalid assignment: cannot assign 'ARRAY[0..3] OF CHAR' to 'ARRAY[0..3] OF INT' + +error: Array assignments must be surrounded with `[]` + ┌─ :37:20 + │ +37 │ v_arr_int_3 := 1, 2, 3, 4; // INVALID + │ ^ Array assignments must be surrounded with `[]` + +error: Array assignments must be surrounded with `[]` + ┌─ :38:21 + │ +38 │ v_arr_int_3 := (1, 2, 3, 4); // valid + │ ^^^^^^^^^^ Array assignments must be surrounded with `[]` + +error: Array assignments must be surrounded with `[]` + ┌─ :39:21 + │ +39 │ v_arr_int_3 := (1, 2, 3, 4, 5, 6); // INVALID -> missing + │ ^^^^^^^^^^^^^^^^ Array assignments must be surrounded with `[]` + +error: Invalid assignment: cannot assign 'STRING' to 'INT' + ┌─ :44:5 + │ +44 │ v_arr_int_3[0] := v_string; // INVALID + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^ Invalid assignment: cannot assign 'STRING' to 'INT' + +error: Invalid assignment: cannot assign 'STRING' to 'INT' + ┌─ :45:5 + │ +45 │ v_arr_int_3[0] := STRING#'string'; // INVALID + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Invalid assignment: cannot assign 'STRING' to 'INT' + +error: Invalid assignment: cannot assign 'STRING' to 'INT' + ┌─ :46:5 + │ +46 │ v_arr_int_3[0] := 'string'; // INVALID + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^ Invalid assignment: cannot assign 'STRING' to 'INT' + +error: Invalid assignment: cannot assign 'CHAR' to 'INT' + ┌─ :47:5 + │ +47 │ v_arr_int_3[0] := v_char; // INVALID + │ ^^^^^^^^^^^^^^^^^^^^^^^^ Invalid assignment: cannot assign 'CHAR' to 'INT' + +error: Invalid assignment: cannot assign 'CHAR' to 'INT' + ┌─ :48:5 + │ +48 │ v_arr_int_3[0] := CHAR#'a'; // INVALID + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^ Invalid assignment: cannot assign 'CHAR' to 'INT' + +error: Invalid assignment: cannot assign 'STRING' to 'INT' + ┌─ :50:5 + │ +50 │ v_arr_int_3[0] := v_ptr_string^; // INVALID + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Invalid assignment: cannot assign 'STRING' to 'INT' + +error: Invalid assignment: cannot assign 'DINT' to 'ARRAY[0..3] OF INT' + ┌─ :51:5 + │ +51 │ v_arr_int_3 := v_dint; // INVALID + │ ^^^^^^^^^^^^^^^^^^^^^ Invalid assignment: cannot assign 'DINT' to 'ARRAY[0..3] OF INT' + +error: Invalid assignment: cannot assign 'ARRAY[0..3] OF INT' to 'DINT' + ┌─ :52:5 + │ +52 │ v_dint := v_arr_int_3; // INVALID + │ ^^^^^^^^^^^^^^^^^^^^^ Invalid assignment: cannot assign 'ARRAY[0..3] OF INT' to 'DINT' + diff --git a/src/validation/tests/snapshots/rusty__validation__tests__assignment_validation_tests__assigning_literal_with_incompatible_encoding_to_char_is_validated.snap b/src/validation/tests/snapshots/rusty__validation__tests__assignment_validation_tests__assigning_literal_with_incompatible_encoding_to_char_is_validated.snap index 6706da7938..61519d68f3 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__assignment_validation_tests__assigning_literal_with_incompatible_encoding_to_char_is_validated.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__assignment_validation_tests__assigning_literal_with_incompatible_encoding_to_char_is_validated.snap @@ -1,7 +1,17 @@ --- source: src/validation/tests/assignment_validation_tests.rs -expression: res +expression: "&diagnostics" --- -SyntaxError { message: "Invalid assignment: cannot assign 'WSTRING' to 'CHAR'", range: [SourceLocation { span: Range(TextLocation { line: 6, column: 12, offset: 115 }..TextLocation { line: 6, column: 20, offset: 123 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid assignment: cannot assign 'STRING' to 'WCHAR'", range: [SourceLocation { span: Range(TextLocation { line: 7, column: 12, offset: 137 }..TextLocation { line: 7, column: 20, offset: 145 }) }], err_no: var__invalid_assignment } +error: Invalid assignment: cannot assign 'WSTRING' to 'CHAR' + ┌─ :7:13 + │ +7 │ x := "A"; + │ ^^^^^^^^ Invalid assignment: cannot assign 'WSTRING' to 'CHAR' + +error: Invalid assignment: cannot assign 'STRING' to 'WCHAR' + ┌─ :8:13 + │ +8 │ y := 'B'; + │ ^^^^^^^^ Invalid assignment: cannot assign 'STRING' to 'WCHAR' + diff --git a/src/validation/tests/snapshots/rusty__validation__tests__assignment_validation_tests__assigning_to_input_by_ref_should_deliver_improvment_suggestion.snap b/src/validation/tests/snapshots/rusty__validation__tests__assignment_validation_tests__assigning_to_input_by_ref_should_deliver_improvment_suggestion.snap index 8846984a5b..209468fdb0 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__assignment_validation_tests__assigning_to_input_by_ref_should_deliver_improvment_suggestion.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__assignment_validation_tests__assigning_to_input_by_ref_should_deliver_improvment_suggestion.snap @@ -1,6 +1,11 @@ --- source: src/validation/tests/assignment_validation_tests.rs -expression: res +expression: diagnostics --- -ImprovementSuggestion { message: "VAR_INPUT {ref} variables are mutable and changes to them will also affect the referenced variable. For increased clarity use VAR_IN_OUT instead.", range: [SourceLocation { span: Range(TextLocation { line: 16, column: 16, offset: 353 }..TextLocation { line: 16, column: 24, offset: 361 }) }] } +warning: VAR_INPUT {ref} variables are mutable and changes to them will also affect the referenced variable. For increased clarity use VAR_IN_OUT instead. + ┌─ :17:17 + │ +17 │ b := 1.0; // This should trigger an improvment suggestion, because we are assigning a value + │ ^^^^^^^^ VAR_INPUT {ref} variables are mutable and changes to them will also affect the referenced variable. For increased clarity use VAR_IN_OUT instead. + diff --git a/src/validation/tests/snapshots/rusty__validation__tests__assignment_validation_tests__bit_assignment_validation.snap b/src/validation/tests/snapshots/rusty__validation__tests__assignment_validation_tests__bit_assignment_validation.snap index 0a8291248b..207101cfbe 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__assignment_validation_tests__bit_assignment_validation.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__assignment_validation_tests__bit_assignment_validation.snap @@ -1,12 +1,47 @@ --- source: src/validation/tests/assignment_validation_tests.rs -expression: res +expression: diagnostics --- -SyntaxError { message: "Invalid assignment: cannot assign 'STRING' to 'BYTE'", range: [SourceLocation { span: Range(TextLocation { line: 38, column: 4, offset: 775 }..TextLocation { line: 38, column: 22, offset: 793 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid assignment: cannot assign 'STRING' to 'BYTE'", range: [SourceLocation { span: Range(TextLocation { line: 39, column: 4, offset: 810 }..TextLocation { line: 39, column: 29, offset: 835 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid assignment: cannot assign 'STRING' to 'BYTE'", range: [SourceLocation { span: Range(TextLocation { line: 40, column: 4, offset: 852 }..TextLocation { line: 40, column: 22, offset: 870 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid assignment: cannot assign 'CHAR' to 'BYTE'", range: [SourceLocation { span: Range(TextLocation { line: 41, column: 4, offset: 887 }..TextLocation { line: 41, column: 20, offset: 903 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid assignment: cannot assign 'CHAR' to 'BYTE'", range: [SourceLocation { span: Range(TextLocation { line: 42, column: 4, offset: 920 }..TextLocation { line: 42, column: 22, offset: 938 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid assignment: cannot assign 'STRING' to 'BYTE'", range: [SourceLocation { span: Range(TextLocation { line: 46, column: 4, offset: 1057 }..TextLocation { line: 46, column: 27, offset: 1080 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid assignment: cannot assign 'STRING' to 'BYTE'", range: [SourceLocation { span: Range(TextLocation { line: 48, column: 4, offset: 1136 }..TextLocation { line: 48, column: 31, offset: 1163 }) }], err_no: var__invalid_assignment } +error: Invalid assignment: cannot assign 'STRING' to 'BYTE' + ┌─ :39:5 + │ +39 │ v_byte := v_string; // INVALID + │ ^^^^^^^^^^^^^^^^^^ Invalid assignment: cannot assign 'STRING' to 'BYTE' + +error: Invalid assignment: cannot assign 'STRING' to 'BYTE' + ┌─ :40:5 + │ +40 │ v_byte := STRING#'string'; // INVALID + │ ^^^^^^^^^^^^^^^^^^^^^^^^^ Invalid assignment: cannot assign 'STRING' to 'BYTE' + +error: Invalid assignment: cannot assign 'STRING' to 'BYTE' + ┌─ :41:5 + │ +41 │ v_byte := 'string'; // INVALID + │ ^^^^^^^^^^^^^^^^^^ Invalid assignment: cannot assign 'STRING' to 'BYTE' + +error: Invalid assignment: cannot assign 'CHAR' to 'BYTE' + ┌─ :42:5 + │ +42 │ v_byte := v_char; // INVALID + │ ^^^^^^^^^^^^^^^^ Invalid assignment: cannot assign 'CHAR' to 'BYTE' + +error: Invalid assignment: cannot assign 'CHAR' to 'BYTE' + ┌─ :43:5 + │ +43 │ v_byte := CHAR#'c'; // INVALID + │ ^^^^^^^^^^^^^^^^^^ Invalid assignment: cannot assign 'CHAR' to 'BYTE' + +error: Invalid assignment: cannot assign 'STRING' to 'BYTE' + ┌─ :47:5 + │ +47 │ v_byte := v_ptr_string^; // INVALID + │ ^^^^^^^^^^^^^^^^^^^^^^^ Invalid assignment: cannot assign 'STRING' to 'BYTE' + +error: Invalid assignment: cannot assign 'STRING' to 'BYTE' + ┌─ :49:5 + │ +49 │ v_byte := v_arr_string_3[0]; // INVALID + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^ Invalid assignment: cannot assign 'STRING' to 'BYTE' + diff --git a/src/validation/tests/snapshots/rusty__validation__tests__assignment_validation_tests__char_assignment_validation.snap b/src/validation/tests/snapshots/rusty__validation__tests__assignment_validation_tests__char_assignment_validation.snap index 23e12c83d2..6b980a2d5b 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__assignment_validation_tests__char_assignment_validation.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__assignment_validation_tests__char_assignment_validation.snap @@ -1,30 +1,155 @@ --- source: src/validation/tests/assignment_validation_tests.rs -expression: res +expression: "&diagnostics" --- -SyntaxError { message: "Invalid assignment: cannot assign 'LREAL' to 'CHAR'", range: [SourceLocation { span: Range(TextLocation { line: 31, column: 4, offset: 531 }..TextLocation { line: 31, column: 21, offset: 548 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid assignment: cannot assign 'REAL' to 'CHAR'", range: [SourceLocation { span: Range(TextLocation { line: 32, column: 4, offset: 565 }..TextLocation { line: 32, column: 22, offset: 583 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid assignment: cannot assign 'UDINT' to 'CHAR'", range: [SourceLocation { span: Range(TextLocation { line: 33, column: 4, offset: 600 }..TextLocation { line: 33, column: 21, offset: 617 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid assignment: cannot assign 'UDINT' to 'CHAR'", range: [SourceLocation { span: Range(TextLocation { line: 34, column: 4, offset: 634 }..TextLocation { line: 34, column: 22, offset: 652 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid assignment: cannot assign 'DINT' to 'CHAR'", range: [SourceLocation { span: Range(TextLocation { line: 35, column: 4, offset: 669 }..TextLocation { line: 35, column: 20, offset: 685 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid assignment: cannot assign 'DINT' to 'CHAR'", range: [SourceLocation { span: Range(TextLocation { line: 36, column: 4, offset: 702 }..TextLocation { line: 36, column: 21, offset: 719 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid assignment: cannot assign 'TIME' to 'CHAR'", range: [SourceLocation { span: Range(TextLocation { line: 37, column: 4, offset: 736 }..TextLocation { line: 37, column: 20, offset: 752 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid assignment: cannot assign 'TIME' to 'CHAR'", range: [SourceLocation { span: Range(TextLocation { line: 38, column: 4, offset: 769 }..TextLocation { line: 38, column: 28, offset: 793 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid assignment: cannot assign 'WORD' to 'CHAR'", range: [SourceLocation { span: Range(TextLocation { line: 39, column: 4, offset: 810 }..TextLocation { line: 39, column: 20, offset: 826 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid assignment: cannot assign 'WORD' to 'CHAR'", range: [SourceLocation { span: Range(TextLocation { line: 40, column: 4, offset: 843 }..TextLocation { line: 40, column: 26, offset: 865 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid assignment: cannot assign 'STRING[1]' to 'CHAR'", range: [SourceLocation { span: Range(TextLocation { line: 41, column: 4, offset: 882 }..TextLocation { line: 41, column: 23, offset: 901 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid assignment: cannot assign 'STRING' to 'CHAR'", range: [SourceLocation { span: Range(TextLocation { line: 42, column: 4, offset: 933 }..TextLocation { line: 42, column: 24, offset: 953 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid assignment: cannot assign 'WSTRING' to 'CHAR'", range: [SourceLocation { span: Range(TextLocation { line: 44, column: 4, offset: 1013 }..TextLocation { line: 44, column: 17, offset: 1026 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid assignment: cannot assign 'STRING' to 'CHAR'", range: [SourceLocation { span: Range(TextLocation { line: 45, column: 4, offset: 1043 }..TextLocation { line: 45, column: 22, offset: 1061 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid assignment: cannot assign 'STRING' to 'CHAR'", range: [SourceLocation { span: Range(TextLocation { line: 46, column: 4, offset: 1078 }..TextLocation { line: 46, column: 29, offset: 1103 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Value: 'string' exceeds length for type: CHAR", range: [SourceLocation { span: Range(TextLocation { line: 47, column: 4, offset: 1120 }..TextLocation { line: 47, column: 22, offset: 1138 }) }], err_no: syntax__generic_error } -SyntaxError { message: "Invalid assignment: cannot assign 'STRING' to 'CHAR'", range: [SourceLocation { span: Range(TextLocation { line: 47, column: 4, offset: 1120 }..TextLocation { line: 47, column: 22, offset: 1138 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid assignment: cannot assign 'WCHAR' to 'CHAR'", range: [SourceLocation { span: Range(TextLocation { line: 50, column: 4, offset: 1219 }..TextLocation { line: 50, column: 21, offset: 1236 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid assignment: cannot assign 'WCHAR' to 'CHAR'", range: [SourceLocation { span: Range(TextLocation { line: 51, column: 4, offset: 1253 }..TextLocation { line: 51, column: 23, offset: 1272 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid assignment: cannot assign 'TIME_OF_DAY' to 'CHAR'", range: [SourceLocation { span: Range(TextLocation { line: 52, column: 4, offset: 1289 }..TextLocation { line: 52, column: 19, offset: 1304 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid assignment: cannot assign 'TIME_OF_DAY' to 'CHAR'", range: [SourceLocation { span: Range(TextLocation { line: 53, column: 4, offset: 1321 }..TextLocation { line: 53, column: 26, offset: 1343 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid assignment: cannot assign 'INT' to 'CHAR'", range: [SourceLocation { span: Range(TextLocation { line: 54, column: 4, offset: 1360 }..TextLocation { line: 54, column: 24, offset: 1380 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid assignment: cannot assign 'STRING' to 'CHAR'", range: [SourceLocation { span: Range(TextLocation { line: 55, column: 4, offset: 1397 }..TextLocation { line: 55, column: 27, offset: 1420 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid assignment: cannot assign 'INT' to 'CHAR'", range: [SourceLocation { span: Range(TextLocation { line: 56, column: 4, offset: 1437 }..TextLocation { line: 56, column: 28, offset: 1461 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid assignment: cannot assign 'STRING' to 'CHAR'", range: [SourceLocation { span: Range(TextLocation { line: 57, column: 4, offset: 1478 }..TextLocation { line: 57, column: 31, offset: 1505 }) }], err_no: var__invalid_assignment } +error: Invalid assignment: cannot assign 'LREAL' to 'CHAR' + ┌─ :32:5 + │ +32 │ v_char := v_lreal; // INVALID + │ ^^^^^^^^^^^^^^^^^ Invalid assignment: cannot assign 'LREAL' to 'CHAR' + +error: Invalid assignment: cannot assign 'REAL' to 'CHAR' + ┌─ :33:5 + │ +33 │ v_char := REAL#2.0; // INVALID + │ ^^^^^^^^^^^^^^^^^^ Invalid assignment: cannot assign 'REAL' to 'CHAR' + +error: Invalid assignment: cannot assign 'UDINT' to 'CHAR' + ┌─ :34:5 + │ +34 │ v_char := v_udint; // INVALID + │ ^^^^^^^^^^^^^^^^^ Invalid assignment: cannot assign 'UDINT' to 'CHAR' + +error: Invalid assignment: cannot assign 'UDINT' to 'CHAR' + ┌─ :35:5 + │ +35 │ v_char := UDINT#10; // INVALID + │ ^^^^^^^^^^^^^^^^^^ Invalid assignment: cannot assign 'UDINT' to 'CHAR' + +error: Invalid assignment: cannot assign 'DINT' to 'CHAR' + ┌─ :36:5 + │ +36 │ v_char := v_dint; // INVALID + │ ^^^^^^^^^^^^^^^^ Invalid assignment: cannot assign 'DINT' to 'CHAR' + +error: Invalid assignment: cannot assign 'DINT' to 'CHAR' + ┌─ :37:5 + │ +37 │ v_char := DINT#20; // INVALID + │ ^^^^^^^^^^^^^^^^^ Invalid assignment: cannot assign 'DINT' to 'CHAR' + +error: Invalid assignment: cannot assign 'TIME' to 'CHAR' + ┌─ :38:5 + │ +38 │ v_char := v_time; // INVALID + │ ^^^^^^^^^^^^^^^^ Invalid assignment: cannot assign 'TIME' to 'CHAR' + +error: Invalid assignment: cannot assign 'TIME' to 'CHAR' + ┌─ :39:5 + │ +39 │ v_char := TIME#10h20m30s; // INVALID + │ ^^^^^^^^^^^^^^^^^^^^^^^^ Invalid assignment: cannot assign 'TIME' to 'CHAR' + +error: Invalid assignment: cannot assign 'WORD' to 'CHAR' + ┌─ :40:5 + │ +40 │ v_char := v_word; // INVALID + │ ^^^^^^^^^^^^^^^^ Invalid assignment: cannot assign 'WORD' to 'CHAR' + +error: Invalid assignment: cannot assign 'WORD' to 'CHAR' + ┌─ :41:5 + │ +41 │ v_char := WORD#16#ffff; // INVALID + │ ^^^^^^^^^^^^^^^^^^^^^^ Invalid assignment: cannot assign 'WORD' to 'CHAR' + +error: Invalid assignment: cannot assign 'STRING[1]' to 'CHAR' + ┌─ :42:5 + │ +42 │ v_char := v_string1; // INVALID -> should work + │ ^^^^^^^^^^^^^^^^^^^ Invalid assignment: cannot assign 'STRING[1]' to 'CHAR' + +error: Invalid assignment: cannot assign 'STRING' to 'CHAR' + ┌─ :43:5 + │ +43 │ v_char := STRING#'a'; // INVALID -> should work + │ ^^^^^^^^^^^^^^^^^^^^ Invalid assignment: cannot assign 'STRING' to 'CHAR' + +error: Invalid assignment: cannot assign 'WSTRING' to 'CHAR' + ┌─ :45:5 + │ +45 │ v_char := "a"; // INVALID + │ ^^^^^^^^^^^^^ Invalid assignment: cannot assign 'WSTRING' to 'CHAR' + +error: Invalid assignment: cannot assign 'STRING' to 'CHAR' + ┌─ :46:5 + │ +46 │ v_char := v_string; // INVALID + │ ^^^^^^^^^^^^^^^^^^ Invalid assignment: cannot assign 'STRING' to 'CHAR' + +error: Invalid assignment: cannot assign 'STRING' to 'CHAR' + ┌─ :47:5 + │ +47 │ v_char := STRING#'string'; // INVALID + │ ^^^^^^^^^^^^^^^^^^^^^^^^^ Invalid assignment: cannot assign 'STRING' to 'CHAR' + +error: Value: 'string' exceeds length for type: CHAR + ┌─ :48:5 + │ +48 │ v_char := 'string'; // INVALID + │ ^^^^^^^^^^^^^^^^^^ Value: 'string' exceeds length for type: CHAR + +error: Invalid assignment: cannot assign 'STRING' to 'CHAR' + ┌─ :48:5 + │ +48 │ v_char := 'string'; // INVALID + │ ^^^^^^^^^^^^^^^^^^ Invalid assignment: cannot assign 'STRING' to 'CHAR' + +error: Invalid assignment: cannot assign 'WCHAR' to 'CHAR' + ┌─ :51:5 + │ +51 │ v_char := v_wchar; // INVALID + │ ^^^^^^^^^^^^^^^^^ Invalid assignment: cannot assign 'WCHAR' to 'CHAR' + +error: Invalid assignment: cannot assign 'WCHAR' to 'CHAR' + ┌─ :52:5 + │ +52 │ v_char := WCHAR#"c"; // INVALID + │ ^^^^^^^^^^^^^^^^^^^ Invalid assignment: cannot assign 'WCHAR' to 'CHAR' + +error: Invalid assignment: cannot assign 'TIME_OF_DAY' to 'CHAR' + ┌─ :53:5 + │ +53 │ v_char := v_tod; // INVALID + │ ^^^^^^^^^^^^^^^ Invalid assignment: cannot assign 'TIME_OF_DAY' to 'CHAR' + +error: Invalid assignment: cannot assign 'TIME_OF_DAY' to 'CHAR' + ┌─ :54:5 + │ +54 │ v_char := TOD#15:36:30; // INVALID + │ ^^^^^^^^^^^^^^^^^^^^^^ Invalid assignment: cannot assign 'TIME_OF_DAY' to 'CHAR' + +error: Invalid assignment: cannot assign 'INT' to 'CHAR' + ┌─ :55:5 + │ +55 │ v_char := v_ptr_int^; // INVALID + │ ^^^^^^^^^^^^^^^^^^^^ Invalid assignment: cannot assign 'INT' to 'CHAR' + +error: Invalid assignment: cannot assign 'STRING' to 'CHAR' + ┌─ :56:5 + │ +56 │ v_char := v_ptr_string^; // INVALID + │ ^^^^^^^^^^^^^^^^^^^^^^^ Invalid assignment: cannot assign 'STRING' to 'CHAR' + +error: Invalid assignment: cannot assign 'INT' to 'CHAR' + ┌─ :57:5 + │ +57 │ v_char := v_arr_int_3[0]; // INVALID + │ ^^^^^^^^^^^^^^^^^^^^^^^^ Invalid assignment: cannot assign 'INT' to 'CHAR' + +error: Invalid assignment: cannot assign 'STRING' to 'CHAR' + ┌─ :58:5 + │ +58 │ v_char := v_arr_string_3[0]; // INVALID + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^ Invalid assignment: cannot assign 'STRING' to 'CHAR' + diff --git a/src/validation/tests/snapshots/rusty__validation__tests__assignment_validation_tests__constant_assignment_validation.snap b/src/validation/tests/snapshots/rusty__validation__tests__assignment_validation_tests__constant_assignment_validation.snap index a667b02c5f..b97ae087de 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__assignment_validation_tests__constant_assignment_validation.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__assignment_validation_tests__constant_assignment_validation.snap @@ -1,6 +1,11 @@ --- source: src/validation/tests/assignment_validation_tests.rs -expression: res +expression: diagnostics --- -SyntaxError { message: "Cannot assign to CONSTANT 'v_global'", range: [SourceLocation { span: Range(TextLocation { line: 7, column: 4, offset: 119 }..TextLocation { line: 7, column: 12, offset: 127 }) }], err_no: var__cannot_assign_to_const } +error: Cannot assign to CONSTANT 'v_global' + ┌─ :8:5 + │ +8 │ v_global := TRUE; // INVALID + │ ^^^^^^^^ Cannot assign to CONSTANT 'v_global' + diff --git a/src/validation/tests/snapshots/rusty__validation__tests__assignment_validation_tests__date_assignment_validation.snap b/src/validation/tests/snapshots/rusty__validation__tests__assignment_validation_tests__date_assignment_validation.snap index 47da84344e..9dbdcf2ba8 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__assignment_validation_tests__date_assignment_validation.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__assignment_validation_tests__date_assignment_validation.snap @@ -1,12 +1,47 @@ --- source: src/validation/tests/assignment_validation_tests.rs -expression: res +expression: "&diagnostics" --- -SyntaxError { message: "Invalid assignment: cannot assign 'STRING' to 'DATE'", range: [SourceLocation { span: Range(TextLocation { line: 38, column: 4, offset: 776 }..TextLocation { line: 38, column: 22, offset: 794 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid assignment: cannot assign 'STRING' to 'DATE'", range: [SourceLocation { span: Range(TextLocation { line: 39, column: 4, offset: 811 }..TextLocation { line: 39, column: 29, offset: 836 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid assignment: cannot assign 'STRING' to 'DATE'", range: [SourceLocation { span: Range(TextLocation { line: 40, column: 4, offset: 853 }..TextLocation { line: 40, column: 22, offset: 871 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid assignment: cannot assign 'CHAR' to 'DATE'", range: [SourceLocation { span: Range(TextLocation { line: 41, column: 4, offset: 888 }..TextLocation { line: 41, column: 20, offset: 904 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid assignment: cannot assign 'CHAR' to 'DATE'", range: [SourceLocation { span: Range(TextLocation { line: 42, column: 4, offset: 921 }..TextLocation { line: 42, column: 22, offset: 939 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid assignment: cannot assign 'STRING' to 'DATE'", range: [SourceLocation { span: Range(TextLocation { line: 46, column: 4, offset: 1058 }..TextLocation { line: 46, column: 27, offset: 1081 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid assignment: cannot assign 'STRING' to 'DATE'", range: [SourceLocation { span: Range(TextLocation { line: 48, column: 4, offset: 1137 }..TextLocation { line: 48, column: 31, offset: 1164 }) }], err_no: var__invalid_assignment } +error: Invalid assignment: cannot assign 'STRING' to 'DATE' + ┌─ :39:5 + │ +39 │ v_date := v_string; // INVALID + │ ^^^^^^^^^^^^^^^^^^ Invalid assignment: cannot assign 'STRING' to 'DATE' + +error: Invalid assignment: cannot assign 'STRING' to 'DATE' + ┌─ :40:5 + │ +40 │ v_date := STRING#'string'; // INVALID + │ ^^^^^^^^^^^^^^^^^^^^^^^^^ Invalid assignment: cannot assign 'STRING' to 'DATE' + +error: Invalid assignment: cannot assign 'STRING' to 'DATE' + ┌─ :41:5 + │ +41 │ v_date := 'string'; // INVALID + │ ^^^^^^^^^^^^^^^^^^ Invalid assignment: cannot assign 'STRING' to 'DATE' + +error: Invalid assignment: cannot assign 'CHAR' to 'DATE' + ┌─ :42:5 + │ +42 │ v_date := v_char; // INVALID + │ ^^^^^^^^^^^^^^^^ Invalid assignment: cannot assign 'CHAR' to 'DATE' + +error: Invalid assignment: cannot assign 'CHAR' to 'DATE' + ┌─ :43:5 + │ +43 │ v_date := CHAR#'c'; // INVALID + │ ^^^^^^^^^^^^^^^^^^ Invalid assignment: cannot assign 'CHAR' to 'DATE' + +error: Invalid assignment: cannot assign 'STRING' to 'DATE' + ┌─ :47:5 + │ +47 │ v_date := v_ptr_string^; // INVALID + │ ^^^^^^^^^^^^^^^^^^^^^^^ Invalid assignment: cannot assign 'STRING' to 'DATE' + +error: Invalid assignment: cannot assign 'STRING' to 'DATE' + ┌─ :49:5 + │ +49 │ v_date := v_arr_string_3[0]; // INVALID + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^ Invalid assignment: cannot assign 'STRING' to 'DATE' + diff --git a/src/validation/tests/snapshots/rusty__validation__tests__assignment_validation_tests__duration_assignment_validation.snap b/src/validation/tests/snapshots/rusty__validation__tests__assignment_validation_tests__duration_assignment_validation.snap index d31c506dfb..f0a8f83eb4 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__assignment_validation_tests__duration_assignment_validation.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__assignment_validation_tests__duration_assignment_validation.snap @@ -1,12 +1,47 @@ --- source: src/validation/tests/assignment_validation_tests.rs -expression: res +expression: diagnostics --- -SyntaxError { message: "Invalid assignment: cannot assign 'STRING' to 'TIME'", range: [SourceLocation { span: Range(TextLocation { line: 38, column: 4, offset: 780 }..TextLocation { line: 38, column: 22, offset: 798 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid assignment: cannot assign 'STRING' to 'TIME'", range: [SourceLocation { span: Range(TextLocation { line: 39, column: 4, offset: 815 }..TextLocation { line: 39, column: 29, offset: 840 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid assignment: cannot assign 'STRING' to 'TIME'", range: [SourceLocation { span: Range(TextLocation { line: 40, column: 4, offset: 857 }..TextLocation { line: 40, column: 22, offset: 875 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid assignment: cannot assign 'CHAR' to 'TIME'", range: [SourceLocation { span: Range(TextLocation { line: 41, column: 4, offset: 892 }..TextLocation { line: 41, column: 20, offset: 908 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid assignment: cannot assign 'CHAR' to 'TIME'", range: [SourceLocation { span: Range(TextLocation { line: 42, column: 4, offset: 925 }..TextLocation { line: 42, column: 22, offset: 943 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid assignment: cannot assign 'STRING' to 'TIME'", range: [SourceLocation { span: Range(TextLocation { line: 46, column: 4, offset: 1062 }..TextLocation { line: 46, column: 27, offset: 1085 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid assignment: cannot assign 'STRING' to 'TIME'", range: [SourceLocation { span: Range(TextLocation { line: 48, column: 4, offset: 1141 }..TextLocation { line: 48, column: 31, offset: 1168 }) }], err_no: var__invalid_assignment } +error: Invalid assignment: cannot assign 'STRING' to 'TIME' + ┌─ :39:5 + │ +39 │ v_time := v_string; // INVALID + │ ^^^^^^^^^^^^^^^^^^ Invalid assignment: cannot assign 'STRING' to 'TIME' + +error: Invalid assignment: cannot assign 'STRING' to 'TIME' + ┌─ :40:5 + │ +40 │ v_time := STRING#'string'; // INVALID + │ ^^^^^^^^^^^^^^^^^^^^^^^^^ Invalid assignment: cannot assign 'STRING' to 'TIME' + +error: Invalid assignment: cannot assign 'STRING' to 'TIME' + ┌─ :41:5 + │ +41 │ v_time := 'string'; // INVALID + │ ^^^^^^^^^^^^^^^^^^ Invalid assignment: cannot assign 'STRING' to 'TIME' + +error: Invalid assignment: cannot assign 'CHAR' to 'TIME' + ┌─ :42:5 + │ +42 │ v_time := v_char; // INVALID + │ ^^^^^^^^^^^^^^^^ Invalid assignment: cannot assign 'CHAR' to 'TIME' + +error: Invalid assignment: cannot assign 'CHAR' to 'TIME' + ┌─ :43:5 + │ +43 │ v_time := CHAR#'c'; // INVALID + │ ^^^^^^^^^^^^^^^^^^ Invalid assignment: cannot assign 'CHAR' to 'TIME' + +error: Invalid assignment: cannot assign 'STRING' to 'TIME' + ┌─ :47:5 + │ +47 │ v_time := v_ptr_string^; // INVALID + │ ^^^^^^^^^^^^^^^^^^^^^^^ Invalid assignment: cannot assign 'STRING' to 'TIME' + +error: Invalid assignment: cannot assign 'STRING' to 'TIME' + ┌─ :49:5 + │ +49 │ v_time := v_arr_string_3[0]; // INVALID + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^ Invalid assignment: cannot assign 'STRING' to 'TIME' + diff --git a/src/validation/tests/snapshots/rusty__validation__tests__assignment_validation_tests__enum_variants_mismatch.snap b/src/validation/tests/snapshots/rusty__validation__tests__assignment_validation_tests__enum_variants_mismatch.snap index efacb1a32d..3a498a1f57 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__assignment_validation_tests__enum_variants_mismatch.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__assignment_validation_tests__enum_variants_mismatch.snap @@ -1,9 +1,29 @@ --- source: src/validation/tests/assignment_validation_tests.rs -expression: res +expression: diagnostics --- -SemanticError { message: "Assigned value is not a variant of main.color", range: [SourceLocation { span: Range(TextLocation { line: 10, column: 21, offset: 283 }..TextLocation { line: 10, column: 24, offset: 286 }) }], err_no: var__invalid_enum_variant } -SemanticError { message: "Assigned value is not a variant of main.water", range: [SourceLocation { span: Range(TextLocation { line: 11, column: 21, offset: 326 }..TextLocation { line: 11, column: 25, offset: 330 }) }], err_no: var__invalid_enum_variant } -SemanticError { message: "Assigned value is not a variant of main.color", range: [SourceLocation { span: Range(TextLocation { line: 12, column: 21, offset: 369 }..TextLocation { line: 12, column: 30, offset: 378 }) }], err_no: var__invalid_enum_variant } -SemanticError { message: "Assigned value is not a variant of main.color", range: [SourceLocation { span: Range(TextLocation { line: 13, column: 21, offset: 412 }..TextLocation { line: 13, column: 22, offset: 413 }) }], err_no: var__invalid_enum_variant } +error: Assigned value is not a variant of main.color + ┌─ :11:22 + │ +11 │ color := Dog; // warning + │ ^^^ Assigned value is not a variant of main.color + +error: Assigned value is not a variant of main.water + ┌─ :12:22 + │ +12 │ water := blue; // warning + │ ^^^^ Assigned value is not a variant of main.water + +error: Assigned value is not a variant of main.color + ┌─ :13:22 + │ +13 │ color := sparkling; // warning + │ ^^^^^^^^^ Assigned value is not a variant of main.color + +error: Assigned value is not a variant of main.color + ┌─ :14:22 + │ +14 │ color := 2; // warning + │ ^ Assigned value is not a variant of main.color + diff --git a/src/validation/tests/snapshots/rusty__validation__tests__assignment_validation_tests__implicit_action_downcasts_are_validated.snap b/src/validation/tests/snapshots/rusty__validation__tests__assignment_validation_tests__implicit_action_downcasts_are_validated.snap index 1d1336ec39..b2e56db257 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__assignment_validation_tests__implicit_action_downcasts_are_validated.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__assignment_validation_tests__implicit_action_downcasts_are_validated.snap @@ -1,6 +1,11 @@ --- source: src/validation/tests/assignment_validation_tests.rs -expression: res +expression: "&diagnostics" --- -SyntaxError { message: "Invalid assignment: cannot assign 'STRING' to 'BYTE'", range: [SourceLocation { span: Range(TextLocation { line: 25, column: 31, offset: 548 }..TextLocation { line: 25, column: 35, offset: 552 }) }], err_no: var__invalid_assignment } +error: Invalid assignment: cannot assign 'STRING' to 'BYTE' + ┌─ :26:32 + │ +26 │ fb.foo(var1, var2, var3); + │ ^^^^ Invalid assignment: cannot assign 'STRING' to 'BYTE' + diff --git a/src/validation/tests/snapshots/rusty__validation__tests__assignment_validation_tests__implicit_invalid_action_call_assignments_are_validated.snap b/src/validation/tests/snapshots/rusty__validation__tests__assignment_validation_tests__implicit_invalid_action_call_assignments_are_validated.snap index fb6e7e6a54..de86e52f4e 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__assignment_validation_tests__implicit_invalid_action_call_assignments_are_validated.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__assignment_validation_tests__implicit_invalid_action_call_assignments_are_validated.snap @@ -1,7 +1,17 @@ --- source: src/validation/tests/assignment_validation_tests.rs -expression: res +expression: "&diagnostics" --- -SyntaxError { message: "Invalid assignment: cannot assign 'ARRAY[0..10] OF WSTRING' to 'DINT'", range: [SourceLocation { span: Range(TextLocation { line: 23, column: 19, offset: 516 }..TextLocation { line: 23, column: 22, offset: 519 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid assignment: cannot assign 'ARRAY[0..10] OF WSTRING' to 'STRING'", range: [SourceLocation { span: Range(TextLocation { line: 23, column: 24, offset: 521 }..TextLocation { line: 23, column: 27, offset: 524 }) }], err_no: var__invalid_assignment } +error: Invalid assignment: cannot assign 'ARRAY[0..10] OF WSTRING' to 'DINT' + ┌─ :24:20 + │ +24 │ fb.foo(arr, arr); // invalid + │ ^^^ Invalid assignment: cannot assign 'ARRAY[0..10] OF WSTRING' to 'DINT' + +error: Invalid assignment: cannot assign 'ARRAY[0..10] OF WSTRING' to 'STRING' + ┌─ :24:25 + │ +24 │ fb.foo(arr, arr); // invalid + │ ^^^ Invalid assignment: cannot assign 'ARRAY[0..10] OF WSTRING' to 'STRING' + diff --git a/src/validation/tests/snapshots/rusty__validation__tests__assignment_validation_tests__int_assignment_validation.snap b/src/validation/tests/snapshots/rusty__validation__tests__assignment_validation_tests__int_assignment_validation.snap index 8432940d79..c66ebccacf 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__assignment_validation_tests__int_assignment_validation.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__assignment_validation_tests__int_assignment_validation.snap @@ -1,19 +1,89 @@ --- source: src/validation/tests/assignment_validation_tests.rs -expression: res +expression: diagnostics --- -SyntaxError { message: "Invalid assignment: cannot assign 'STRING' to 'UDINT'", range: [SourceLocation { span: Range(TextLocation { line: 40, column: 4, offset: 840 }..TextLocation { line: 40, column: 23, offset: 859 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid assignment: cannot assign 'STRING' to 'UDINT'", range: [SourceLocation { span: Range(TextLocation { line: 41, column: 4, offset: 876 }..TextLocation { line: 41, column: 30, offset: 902 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid assignment: cannot assign 'STRING' to 'UDINT'", range: [SourceLocation { span: Range(TextLocation { line: 42, column: 4, offset: 919 }..TextLocation { line: 42, column: 23, offset: 938 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid assignment: cannot assign 'CHAR' to 'UDINT'", range: [SourceLocation { span: Range(TextLocation { line: 43, column: 4, offset: 955 }..TextLocation { line: 43, column: 21, offset: 972 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid assignment: cannot assign 'CHAR' to 'UDINT'", range: [SourceLocation { span: Range(TextLocation { line: 44, column: 4, offset: 989 }..TextLocation { line: 44, column: 23, offset: 1008 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid assignment: cannot assign 'STRING' to 'UDINT'", range: [SourceLocation { span: Range(TextLocation { line: 48, column: 4, offset: 1130 }..TextLocation { line: 48, column: 28, offset: 1154 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid assignment: cannot assign 'STRING' to 'UDINT'", range: [SourceLocation { span: Range(TextLocation { line: 50, column: 4, offset: 1211 }..TextLocation { line: 50, column: 32, offset: 1239 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid assignment: cannot assign 'STRING' to 'DINT'", range: [SourceLocation { span: Range(TextLocation { line: 63, column: 4, offset: 1602 }..TextLocation { line: 63, column: 22, offset: 1620 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid assignment: cannot assign 'STRING' to 'DINT'", range: [SourceLocation { span: Range(TextLocation { line: 64, column: 4, offset: 1637 }..TextLocation { line: 64, column: 29, offset: 1662 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid assignment: cannot assign 'STRING' to 'DINT'", range: [SourceLocation { span: Range(TextLocation { line: 65, column: 4, offset: 1679 }..TextLocation { line: 65, column: 22, offset: 1697 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid assignment: cannot assign 'CHAR' to 'DINT'", range: [SourceLocation { span: Range(TextLocation { line: 66, column: 4, offset: 1714 }..TextLocation { line: 66, column: 20, offset: 1730 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid assignment: cannot assign 'CHAR' to 'DINT'", range: [SourceLocation { span: Range(TextLocation { line: 67, column: 4, offset: 1747 }..TextLocation { line: 67, column: 22, offset: 1765 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid assignment: cannot assign 'STRING' to 'DINT'", range: [SourceLocation { span: Range(TextLocation { line: 71, column: 4, offset: 1884 }..TextLocation { line: 71, column: 27, offset: 1907 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid assignment: cannot assign 'STRING' to 'DINT'", range: [SourceLocation { span: Range(TextLocation { line: 73, column: 4, offset: 1963 }..TextLocation { line: 73, column: 31, offset: 1990 }) }], err_no: var__invalid_assignment } +error: Invalid assignment: cannot assign 'STRING' to 'UDINT' + ┌─ :41:5 + │ +41 │ v_udint := v_string; // INVALID + │ ^^^^^^^^^^^^^^^^^^^ Invalid assignment: cannot assign 'STRING' to 'UDINT' + +error: Invalid assignment: cannot assign 'STRING' to 'UDINT' + ┌─ :42:5 + │ +42 │ v_udint := STRING#'string'; // INVALID + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^ Invalid assignment: cannot assign 'STRING' to 'UDINT' + +error: Invalid assignment: cannot assign 'STRING' to 'UDINT' + ┌─ :43:5 + │ +43 │ v_udint := 'string'; // INVALID + │ ^^^^^^^^^^^^^^^^^^^ Invalid assignment: cannot assign 'STRING' to 'UDINT' + +error: Invalid assignment: cannot assign 'CHAR' to 'UDINT' + ┌─ :44:5 + │ +44 │ v_udint := v_char; // INVALID + │ ^^^^^^^^^^^^^^^^^ Invalid assignment: cannot assign 'CHAR' to 'UDINT' + +error: Invalid assignment: cannot assign 'CHAR' to 'UDINT' + ┌─ :45:5 + │ +45 │ v_udint := CHAR#'c'; // INVALID + │ ^^^^^^^^^^^^^^^^^^^ Invalid assignment: cannot assign 'CHAR' to 'UDINT' + +error: Invalid assignment: cannot assign 'STRING' to 'UDINT' + ┌─ :49:5 + │ +49 │ v_udint := v_ptr_string^; // INVALID + │ ^^^^^^^^^^^^^^^^^^^^^^^^ Invalid assignment: cannot assign 'STRING' to 'UDINT' + +error: Invalid assignment: cannot assign 'STRING' to 'UDINT' + ┌─ :51:5 + │ +51 │ v_udint := v_arr_string_3[0]; // INVALID + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Invalid assignment: cannot assign 'STRING' to 'UDINT' + +error: Invalid assignment: cannot assign 'STRING' to 'DINT' + ┌─ :64:5 + │ +64 │ v_dint := v_string; // INVALID + │ ^^^^^^^^^^^^^^^^^^ Invalid assignment: cannot assign 'STRING' to 'DINT' + +error: Invalid assignment: cannot assign 'STRING' to 'DINT' + ┌─ :65:5 + │ +65 │ v_dint := STRING#'string'; // INVALID + │ ^^^^^^^^^^^^^^^^^^^^^^^^^ Invalid assignment: cannot assign 'STRING' to 'DINT' + +error: Invalid assignment: cannot assign 'STRING' to 'DINT' + ┌─ :66:5 + │ +66 │ v_dint := 'string'; // INVALID + │ ^^^^^^^^^^^^^^^^^^ Invalid assignment: cannot assign 'STRING' to 'DINT' + +error: Invalid assignment: cannot assign 'CHAR' to 'DINT' + ┌─ :67:5 + │ +67 │ v_dint := v_char; // INVALID + │ ^^^^^^^^^^^^^^^^ Invalid assignment: cannot assign 'CHAR' to 'DINT' + +error: Invalid assignment: cannot assign 'CHAR' to 'DINT' + ┌─ :68:5 + │ +68 │ v_dint := CHAR#'c'; // INVALID + │ ^^^^^^^^^^^^^^^^^^ Invalid assignment: cannot assign 'CHAR' to 'DINT' + +error: Invalid assignment: cannot assign 'STRING' to 'DINT' + ┌─ :72:5 + │ +72 │ v_dint := v_ptr_string^; // INVALID + │ ^^^^^^^^^^^^^^^^^^^^^^^ Invalid assignment: cannot assign 'STRING' to 'DINT' + +error: Invalid assignment: cannot assign 'STRING' to 'DINT' + ┌─ :74:5 + │ +74 │ v_dint := v_arr_string_3[0]; // INVALID + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^ Invalid assignment: cannot assign 'STRING' to 'DINT' + diff --git a/src/validation/tests/snapshots/rusty__validation__tests__assignment_validation_tests__invalid_function_block_instantiation_is_validated.snap b/src/validation/tests/snapshots/rusty__validation__tests__assignment_validation_tests__invalid_function_block_instantiation_is_validated.snap index 002af10fc2..68b274bc82 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__assignment_validation_tests__invalid_function_block_instantiation_is_validated.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__assignment_validation_tests__invalid_function_block_instantiation_is_validated.snap @@ -1,9 +1,29 @@ --- source: src/validation/tests/assignment_validation_tests.rs -expression: res +expression: "&diagnostics" --- -SyntaxError { message: "Invalid assignment: cannot assign 'STRING' to 'WSTRING'", range: [SourceLocation { span: Range(TextLocation { line: 14, column: 15, offset: 319 }..TextLocation { line: 14, column: 22, offset: 326 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid assignment: cannot assign 'ARRAY[0..1] OF LINT' to 'ARRAY[0..1] OF DINT'", range: [SourceLocation { span: Range(TextLocation { line: 14, column: 24, offset: 328 }..TextLocation { line: 14, column: 40, offset: 344 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid assignment: cannot assign 'STRING' to 'WSTRING'", range: [SourceLocation { span: Range(TextLocation { line: 15, column: 15, offset: 382 }..TextLocation { line: 15, column: 16, offset: 383 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid assignment: cannot assign 'ARRAY[0..1] OF LINT' to 'ARRAY[0..1] OF DINT'", range: [SourceLocation { span: Range(TextLocation { line: 15, column: 18, offset: 385 }..TextLocation { line: 15, column: 24, offset: 391 }) }], err_no: var__invalid_assignment } +error: Invalid assignment: cannot assign 'STRING' to 'WSTRING' + ┌─ :15:16 + │ +15 │ fb(ws := s, arr_32 := arr_64); // invalid explicit + │ ^^^^^^^ Invalid assignment: cannot assign 'STRING' to 'WSTRING' + +error: Invalid assignment: cannot assign 'ARRAY[0..1] OF LINT' to 'ARRAY[0..1] OF DINT' + ┌─ :15:25 + │ +15 │ fb(ws := s, arr_32 := arr_64); // invalid explicit + │ ^^^^^^^^^^^^^^^^ Invalid assignment: cannot assign 'ARRAY[0..1] OF LINT' to 'ARRAY[0..1] OF DINT' + +error: Invalid assignment: cannot assign 'STRING' to 'WSTRING' + ┌─ :16:16 + │ +16 │ fb(s, arr_64); // invalid implicit + │ ^ Invalid assignment: cannot assign 'STRING' to 'WSTRING' + +error: Invalid assignment: cannot assign 'ARRAY[0..1] OF LINT' to 'ARRAY[0..1] OF DINT' + ┌─ :16:19 + │ +16 │ fb(s, arr_64); // invalid implicit + │ ^^^^^^ Invalid assignment: cannot assign 'ARRAY[0..1] OF LINT' to 'ARRAY[0..1] OF DINT' + diff --git a/src/validation/tests/snapshots/rusty__validation__tests__assignment_validation_tests__invalid_method_call_assignments_are_validated.snap b/src/validation/tests/snapshots/rusty__validation__tests__assignment_validation_tests__invalid_method_call_assignments_are_validated.snap index b1a87cc139..2b758be796 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__assignment_validation_tests__invalid_method_call_assignments_are_validated.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__assignment_validation_tests__invalid_method_call_assignments_are_validated.snap @@ -1,7 +1,17 @@ --- source: src/validation/tests/assignment_validation_tests.rs -expression: res +expression: "&diagnostics" --- -SyntaxError { message: "Invalid assignment: cannot assign 'ARRAY[0..10] OF WSTRING' to 'DINT'", range: [SourceLocation { span: Range(TextLocation { line: 21, column: 19, offset: 425 }..TextLocation { line: 21, column: 22, offset: 428 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid assignment: cannot assign 'ARRAY[0..10] OF WSTRING' to 'STRING'", range: [SourceLocation { span: Range(TextLocation { line: 21, column: 24, offset: 430 }..TextLocation { line: 21, column: 27, offset: 433 }) }], err_no: var__invalid_assignment } +error: Invalid assignment: cannot assign 'ARRAY[0..10] OF WSTRING' to 'DINT' + ┌─ :22:20 + │ +22 │ cl.foo(arr, arr); // invalid + │ ^^^ Invalid assignment: cannot assign 'ARRAY[0..10] OF WSTRING' to 'DINT' + +error: Invalid assignment: cannot assign 'ARRAY[0..10] OF WSTRING' to 'STRING' + ┌─ :22:25 + │ +22 │ cl.foo(arr, arr); // invalid + │ ^^^ Invalid assignment: cannot assign 'ARRAY[0..10] OF WSTRING' to 'STRING' + diff --git a/src/validation/tests/snapshots/rusty__validation__tests__assignment_validation_tests__pointer_assignment_validation.snap b/src/validation/tests/snapshots/rusty__validation__tests__assignment_validation_tests__pointer_assignment_validation.snap index 569348292b..b6fe039abc 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__assignment_validation_tests__pointer_assignment_validation.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__assignment_validation_tests__pointer_assignment_validation.snap @@ -1,14 +1,59 @@ --- source: src/validation/tests/assignment_validation_tests.rs -expression: res +expression: "&diagnostics" --- -SyntaxError { message: "The type DINT 32 is too small to hold a Pointer", range: [SourceLocation { span: Range(TextLocation { line: 27, column: 4, offset: 412 }..TextLocation { line: 27, column: 23, offset: 431 }) }], err_no: type__incompatible_size } -SyntaxError { message: "Invalid assignment: cannot assign 'REF_TO INT' to 'DINT'", range: [SourceLocation { span: Range(TextLocation { line: 27, column: 4, offset: 412 }..TextLocation { line: 27, column: 23, offset: 431 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "The type WORD 16 is too small to hold a Pointer", range: [SourceLocation { span: Range(TextLocation { line: 28, column: 4, offset: 448 }..TextLocation { line: 28, column: 23, offset: 467 }) }], err_no: type__incompatible_size } -SyntaxError { message: "Invalid assignment: cannot assign 'REF_TO INT' to 'WORD'", range: [SourceLocation { span: Range(TextLocation { line: 28, column: 4, offset: 448 }..TextLocation { line: 28, column: 23, offset: 467 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid assignment: cannot assign '__POINTER_TO_REAL' to 'REF_TO INT'", range: [SourceLocation { span: Range(TextLocation { line: 30, column: 4, offset: 519 }..TextLocation { line: 30, column: 24, offset: 539 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid assignment: cannot assign '__POINTER_TO_STRING' to 'REF_TO INT'", range: [SourceLocation { span: Range(TextLocation { line: 40, column: 4, offset: 898 }..TextLocation { line: 40, column: 26, offset: 920 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid assignment: cannot assign 'STRING' to 'INT'", range: [SourceLocation { span: Range(TextLocation { line: 41, column: 4, offset: 937 }..TextLocation { line: 41, column: 26, offset: 959 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid assignment: cannot assign 'CHAR' to 'INT'", range: [SourceLocation { span: Range(TextLocation { line: 43, column: 4, offset: 1041 }..TextLocation { line: 43, column: 24, offset: 1061 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid assignment: cannot assign 'STRING' to 'INT'", range: [SourceLocation { span: Range(TextLocation { line: 47, column: 4, offset: 1191 }..TextLocation { line: 47, column: 35, offset: 1222 }) }], err_no: var__invalid_assignment } +error: The type DINT 32 is too small to hold a Pointer + ┌─ :28:5 + │ +28 │ v_dint := v_ptr_int; // INVALID + │ ^^^^^^^^^^^^^^^^^^^ The type DINT 32 is too small to hold a Pointer + +error: Invalid assignment: cannot assign 'REF_TO INT' to 'DINT' + ┌─ :28:5 + │ +28 │ v_dint := v_ptr_int; // INVALID + │ ^^^^^^^^^^^^^^^^^^^ Invalid assignment: cannot assign 'REF_TO INT' to 'DINT' + +error: The type WORD 16 is too small to hold a Pointer + ┌─ :29:5 + │ +29 │ v_word := v_ptr_int; // INVALID + │ ^^^^^^^^^^^^^^^^^^^ The type WORD 16 is too small to hold a Pointer + +error: Invalid assignment: cannot assign 'REF_TO INT' to 'WORD' + ┌─ :29:5 + │ +29 │ v_word := v_ptr_int; // INVALID + │ ^^^^^^^^^^^^^^^^^^^ Invalid assignment: cannot assign 'REF_TO INT' to 'WORD' + +error: Invalid assignment: cannot assign '__POINTER_TO_REAL' to 'REF_TO INT' + ┌─ :31:5 + │ +31 │ v_ptr_int := &v_real; // INVALID -> TODO: should be valid + │ ^^^^^^^^^^^^^^^^^^^^ Invalid assignment: cannot assign '__POINTER_TO_REAL' to 'REF_TO INT' + +error: Invalid assignment: cannot assign '__POINTER_TO_STRING' to 'REF_TO INT' + ┌─ :41:5 + │ +41 │ v_ptr_int := &v_string; // INVALID + │ ^^^^^^^^^^^^^^^^^^^^^^ Invalid assignment: cannot assign '__POINTER_TO_STRING' to 'REF_TO INT' + +error: Invalid assignment: cannot assign 'STRING' to 'INT' + ┌─ :42:5 + │ +42 │ v_ptr_int^ := v_string; // INVALID + │ ^^^^^^^^^^^^^^^^^^^^^^ Invalid assignment: cannot assign 'STRING' to 'INT' + +error: Invalid assignment: cannot assign 'CHAR' to 'INT' + ┌─ :44:5 + │ +44 │ v_ptr_int^ := v_char; // INVALID + │ ^^^^^^^^^^^^^^^^^^^^ Invalid assignment: cannot assign 'CHAR' to 'INT' + +error: Invalid assignment: cannot assign 'STRING' to 'INT' + ┌─ :48:5 + │ +48 │ v_ptr_int^ := v_arr_string_3[0]; // INVALID + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Invalid assignment: cannot assign 'STRING' to 'INT' + diff --git a/src/validation/tests/snapshots/rusty__validation__tests__assignment_validation_tests__real_assignment_validation.snap b/src/validation/tests/snapshots/rusty__validation__tests__assignment_validation_tests__real_assignment_validation.snap index 9126bdd1a2..61295ea521 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__assignment_validation_tests__real_assignment_validation.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__assignment_validation_tests__real_assignment_validation.snap @@ -1,12 +1,47 @@ --- source: src/validation/tests/assignment_validation_tests.rs -expression: res +expression: diagnostics --- -SyntaxError { message: "Invalid assignment: cannot assign 'STRING' to 'REAL'", range: [SourceLocation { span: Range(TextLocation { line: 38, column: 4, offset: 776 }..TextLocation { line: 38, column: 22, offset: 794 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid assignment: cannot assign 'STRING' to 'REAL'", range: [SourceLocation { span: Range(TextLocation { line: 39, column: 4, offset: 811 }..TextLocation { line: 39, column: 29, offset: 836 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid assignment: cannot assign 'STRING' to 'REAL'", range: [SourceLocation { span: Range(TextLocation { line: 40, column: 4, offset: 853 }..TextLocation { line: 40, column: 22, offset: 871 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid assignment: cannot assign 'CHAR' to 'REAL'", range: [SourceLocation { span: Range(TextLocation { line: 41, column: 4, offset: 888 }..TextLocation { line: 41, column: 20, offset: 904 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid assignment: cannot assign 'CHAR' to 'REAL'", range: [SourceLocation { span: Range(TextLocation { line: 42, column: 4, offset: 921 }..TextLocation { line: 42, column: 22, offset: 939 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid assignment: cannot assign 'STRING' to 'REAL'", range: [SourceLocation { span: Range(TextLocation { line: 46, column: 4, offset: 1058 }..TextLocation { line: 46, column: 27, offset: 1081 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid assignment: cannot assign 'STRING' to 'REAL'", range: [SourceLocation { span: Range(TextLocation { line: 48, column: 4, offset: 1137 }..TextLocation { line: 48, column: 31, offset: 1164 }) }], err_no: var__invalid_assignment } +error: Invalid assignment: cannot assign 'STRING' to 'REAL' + ┌─ :39:5 + │ +39 │ v_real := v_string; // INVALID + │ ^^^^^^^^^^^^^^^^^^ Invalid assignment: cannot assign 'STRING' to 'REAL' + +error: Invalid assignment: cannot assign 'STRING' to 'REAL' + ┌─ :40:5 + │ +40 │ v_real := STRING#'string'; // INVALID + │ ^^^^^^^^^^^^^^^^^^^^^^^^^ Invalid assignment: cannot assign 'STRING' to 'REAL' + +error: Invalid assignment: cannot assign 'STRING' to 'REAL' + ┌─ :41:5 + │ +41 │ v_real := 'string'; // INVALID + │ ^^^^^^^^^^^^^^^^^^ Invalid assignment: cannot assign 'STRING' to 'REAL' + +error: Invalid assignment: cannot assign 'CHAR' to 'REAL' + ┌─ :42:5 + │ +42 │ v_real := v_char; // INVALID + │ ^^^^^^^^^^^^^^^^ Invalid assignment: cannot assign 'CHAR' to 'REAL' + +error: Invalid assignment: cannot assign 'CHAR' to 'REAL' + ┌─ :43:5 + │ +43 │ v_real := CHAR#'c'; // INVALID + │ ^^^^^^^^^^^^^^^^^^ Invalid assignment: cannot assign 'CHAR' to 'REAL' + +error: Invalid assignment: cannot assign 'STRING' to 'REAL' + ┌─ :47:5 + │ +47 │ v_real := v_ptr_string^; // INVALID + │ ^^^^^^^^^^^^^^^^^^^^^^^ Invalid assignment: cannot assign 'STRING' to 'REAL' + +error: Invalid assignment: cannot assign 'STRING' to 'REAL' + ┌─ :49:5 + │ +49 │ v_real := v_arr_string_3[0]; // INVALID + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^ Invalid assignment: cannot assign 'STRING' to 'REAL' + diff --git a/src/validation/tests/snapshots/rusty__validation__tests__assignment_validation_tests__string_assignment_validation.snap b/src/validation/tests/snapshots/rusty__validation__tests__assignment_validation_tests__string_assignment_validation.snap index e647402cbb..3c503a7221 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__assignment_validation_tests__string_assignment_validation.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__assignment_validation_tests__string_assignment_validation.snap @@ -1,24 +1,119 @@ --- source: src/validation/tests/assignment_validation_tests.rs -expression: res +expression: "&diagnostics" --- -SyntaxError { message: "Invalid assignment: cannot assign 'LREAL' to 'STRING'", range: [SourceLocation { span: Range(TextLocation { line: 30, column: 4, offset: 508 }..TextLocation { line: 30, column: 23, offset: 527 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid assignment: cannot assign 'REAL' to 'STRING'", range: [SourceLocation { span: Range(TextLocation { line: 31, column: 4, offset: 544 }..TextLocation { line: 31, column: 24, offset: 564 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid assignment: cannot assign 'UDINT' to 'STRING'", range: [SourceLocation { span: Range(TextLocation { line: 32, column: 4, offset: 581 }..TextLocation { line: 32, column: 23, offset: 600 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid assignment: cannot assign 'UDINT' to 'STRING'", range: [SourceLocation { span: Range(TextLocation { line: 33, column: 4, offset: 617 }..TextLocation { line: 33, column: 24, offset: 637 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid assignment: cannot assign 'DINT' to 'STRING'", range: [SourceLocation { span: Range(TextLocation { line: 34, column: 4, offset: 654 }..TextLocation { line: 34, column: 22, offset: 672 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid assignment: cannot assign 'DINT' to 'STRING'", range: [SourceLocation { span: Range(TextLocation { line: 35, column: 4, offset: 689 }..TextLocation { line: 35, column: 23, offset: 708 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid assignment: cannot assign 'TIME' to 'STRING'", range: [SourceLocation { span: Range(TextLocation { line: 36, column: 4, offset: 725 }..TextLocation { line: 36, column: 22, offset: 743 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid assignment: cannot assign 'TIME' to 'STRING'", range: [SourceLocation { span: Range(TextLocation { line: 37, column: 4, offset: 760 }..TextLocation { line: 37, column: 30, offset: 786 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid assignment: cannot assign 'WORD' to 'STRING'", range: [SourceLocation { span: Range(TextLocation { line: 38, column: 4, offset: 803 }..TextLocation { line: 38, column: 22, offset: 821 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid assignment: cannot assign 'WORD' to 'STRING'", range: [SourceLocation { span: Range(TextLocation { line: 39, column: 4, offset: 838 }..TextLocation { line: 39, column: 28, offset: 862 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid assignment: cannot assign 'WSTRING' to 'STRING'", range: [SourceLocation { span: Range(TextLocation { line: 43, column: 4, offset: 988 }..TextLocation { line: 43, column: 25, offset: 1009 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid assignment: cannot assign 'WSTRING' to 'STRING'", range: [SourceLocation { span: Range(TextLocation { line: 44, column: 4, offset: 1026 }..TextLocation { line: 44, column: 33, offset: 1055 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid assignment: cannot assign 'WSTRING' to 'STRING'", range: [SourceLocation { span: Range(TextLocation { line: 45, column: 4, offset: 1072 }..TextLocation { line: 45, column: 25, offset: 1093 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid assignment: cannot assign 'CHAR' to 'STRING'", range: [SourceLocation { span: Range(TextLocation { line: 46, column: 4, offset: 1110 }..TextLocation { line: 46, column: 22, offset: 1128 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid assignment: cannot assign 'CHAR' to 'STRING'", range: [SourceLocation { span: Range(TextLocation { line: 47, column: 4, offset: 1145 }..TextLocation { line: 47, column: 24, offset: 1165 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid assignment: cannot assign 'TIME_OF_DAY' to 'STRING'", range: [SourceLocation { span: Range(TextLocation { line: 48, column: 4, offset: 1182 }..TextLocation { line: 48, column: 21, offset: 1199 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid assignment: cannot assign 'TIME_OF_DAY' to 'STRING'", range: [SourceLocation { span: Range(TextLocation { line: 49, column: 4, offset: 1216 }..TextLocation { line: 49, column: 28, offset: 1240 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid assignment: cannot assign 'INT' to 'STRING'", range: [SourceLocation { span: Range(TextLocation { line: 50, column: 4, offset: 1257 }..TextLocation { line: 50, column: 26, offset: 1279 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid assignment: cannot assign 'INT' to 'STRING'", range: [SourceLocation { span: Range(TextLocation { line: 52, column: 4, offset: 1336 }..TextLocation { line: 52, column: 30, offset: 1362 }) }], err_no: var__invalid_assignment } +error: Invalid assignment: cannot assign 'LREAL' to 'STRING' + ┌─ :31:5 + │ +31 │ v_string := v_lreal; // INVALID + │ ^^^^^^^^^^^^^^^^^^^ Invalid assignment: cannot assign 'LREAL' to 'STRING' + +error: Invalid assignment: cannot assign 'REAL' to 'STRING' + ┌─ :32:5 + │ +32 │ v_string := REAL#2.0; // INVALID + │ ^^^^^^^^^^^^^^^^^^^^ Invalid assignment: cannot assign 'REAL' to 'STRING' + +error: Invalid assignment: cannot assign 'UDINT' to 'STRING' + ┌─ :33:5 + │ +33 │ v_string := v_udint; // INVALID + │ ^^^^^^^^^^^^^^^^^^^ Invalid assignment: cannot assign 'UDINT' to 'STRING' + +error: Invalid assignment: cannot assign 'UDINT' to 'STRING' + ┌─ :34:5 + │ +34 │ v_string := UDINT#10; // INVALID + │ ^^^^^^^^^^^^^^^^^^^^ Invalid assignment: cannot assign 'UDINT' to 'STRING' + +error: Invalid assignment: cannot assign 'DINT' to 'STRING' + ┌─ :35:5 + │ +35 │ v_string := v_dint; // INVALID + │ ^^^^^^^^^^^^^^^^^^ Invalid assignment: cannot assign 'DINT' to 'STRING' + +error: Invalid assignment: cannot assign 'DINT' to 'STRING' + ┌─ :36:5 + │ +36 │ v_string := DINT#20; // INVALID + │ ^^^^^^^^^^^^^^^^^^^ Invalid assignment: cannot assign 'DINT' to 'STRING' + +error: Invalid assignment: cannot assign 'TIME' to 'STRING' + ┌─ :37:5 + │ +37 │ v_string := v_time; // INVALID + │ ^^^^^^^^^^^^^^^^^^ Invalid assignment: cannot assign 'TIME' to 'STRING' + +error: Invalid assignment: cannot assign 'TIME' to 'STRING' + ┌─ :38:5 + │ +38 │ v_string := TIME#10h20m30s; // INVALID + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^ Invalid assignment: cannot assign 'TIME' to 'STRING' + +error: Invalid assignment: cannot assign 'WORD' to 'STRING' + ┌─ :39:5 + │ +39 │ v_string := v_word; // INVALID + │ ^^^^^^^^^^^^^^^^^^ Invalid assignment: cannot assign 'WORD' to 'STRING' + +error: Invalid assignment: cannot assign 'WORD' to 'STRING' + ┌─ :40:5 + │ +40 │ v_string := WORD#16#ffff; // INVALID + │ ^^^^^^^^^^^^^^^^^^^^^^^^ Invalid assignment: cannot assign 'WORD' to 'STRING' + +error: Invalid assignment: cannot assign 'WSTRING' to 'STRING' + ┌─ :44:5 + │ +44 │ v_string := v_wstring; // INVALID + │ ^^^^^^^^^^^^^^^^^^^^^ Invalid assignment: cannot assign 'WSTRING' to 'STRING' + +error: Invalid assignment: cannot assign 'WSTRING' to 'STRING' + ┌─ :45:5 + │ +45 │ v_string := WSTRING#"wstring"; // INVALID + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Invalid assignment: cannot assign 'WSTRING' to 'STRING' + +error: Invalid assignment: cannot assign 'WSTRING' to 'STRING' + ┌─ :46:5 + │ +46 │ v_string := "wstring"; // INVALID + │ ^^^^^^^^^^^^^^^^^^^^^ Invalid assignment: cannot assign 'WSTRING' to 'STRING' + +error: Invalid assignment: cannot assign 'CHAR' to 'STRING' + ┌─ :47:5 + │ +47 │ v_string := v_char; // INVALID + │ ^^^^^^^^^^^^^^^^^^ Invalid assignment: cannot assign 'CHAR' to 'STRING' + +error: Invalid assignment: cannot assign 'CHAR' to 'STRING' + ┌─ :48:5 + │ +48 │ v_string := CHAR#'c'; // INVALID + │ ^^^^^^^^^^^^^^^^^^^^ Invalid assignment: cannot assign 'CHAR' to 'STRING' + +error: Invalid assignment: cannot assign 'TIME_OF_DAY' to 'STRING' + ┌─ :49:5 + │ +49 │ v_string := v_tod; // INVALID + │ ^^^^^^^^^^^^^^^^^ Invalid assignment: cannot assign 'TIME_OF_DAY' to 'STRING' + +error: Invalid assignment: cannot assign 'TIME_OF_DAY' to 'STRING' + ┌─ :50:5 + │ +50 │ v_string := TOD#15:36:30; // INVALID + │ ^^^^^^^^^^^^^^^^^^^^^^^^ Invalid assignment: cannot assign 'TIME_OF_DAY' to 'STRING' + +error: Invalid assignment: cannot assign 'INT' to 'STRING' + ┌─ :51:5 + │ +51 │ v_string := v_ptr_int^; // INVALID + │ ^^^^^^^^^^^^^^^^^^^^^^ Invalid assignment: cannot assign 'INT' to 'STRING' + +error: Invalid assignment: cannot assign 'INT' to 'STRING' + ┌─ :53:5 + │ +53 │ v_string := v_arr_int_3[0]; // INVALID + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^ Invalid assignment: cannot assign 'INT' to 'STRING' + diff --git a/src/validation/tests/snapshots/rusty__validation__tests__assignment_validation_tests__string_type_alias_assignment_can_be_validated.snap b/src/validation/tests/snapshots/rusty__validation__tests__assignment_validation_tests__string_type_alias_assignment_can_be_validated.snap index d12727e38b..168fe218f1 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__assignment_validation_tests__string_type_alias_assignment_can_be_validated.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__assignment_validation_tests__string_type_alias_assignment_can_be_validated.snap @@ -1,7 +1,17 @@ --- source: src/validation/tests/assignment_validation_tests.rs -expression: res +expression: diagnostics --- -SyntaxError { message: "Invalid assignment: cannot assign 'INT' to 'STRING'", range: [SourceLocation { span: Range(TextLocation { line: 10, column: 12, offset: 241 }..TextLocation { line: 10, column: 23, offset: 252 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid assignment: cannot assign 'INT' to 'MY_OTHER_STR'", range: [SourceLocation { span: Range(TextLocation { line: 11, column: 12, offset: 266 }..TextLocation { line: 11, column: 29, offset: 283 }) }], err_no: var__invalid_assignment } +error: Invalid assignment: cannot assign 'INT' to 'STRING' + ┌─ :11:13 + │ +11 │ my_str := i; + │ ^^^^^^^^^^^ Invalid assignment: cannot assign 'INT' to 'STRING' + +error: Invalid assignment: cannot assign 'INT' to 'MY_OTHER_STR' + ┌─ :12:13 + │ +12 │ my_other_str := i; + │ ^^^^^^^^^^^^^^^^^ Invalid assignment: cannot assign 'INT' to 'MY_OTHER_STR' + diff --git a/src/validation/tests/snapshots/rusty__validation__tests__assignment_validation_tests__struct_assignment_validation.snap b/src/validation/tests/snapshots/rusty__validation__tests__assignment_validation_tests__struct_assignment_validation.snap index c5d8573f58..25d46b29bf 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__assignment_validation_tests__struct_assignment_validation.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__assignment_validation_tests__struct_assignment_validation.snap @@ -1,16 +1,71 @@ --- source: src/validation/tests/assignment_validation_tests.rs -expression: res +expression: "&diagnostics" --- -SyntaxError { message: "Invalid assignment: cannot assign 'STRUCT1' to 'REAL'", range: [SourceLocation { span: Range(TextLocation { line: 45, column: 4, offset: 754 }..TextLocation { line: 45, column: 23, offset: 773 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid assignment: cannot assign 'REAL' to 'STRUCT1'", range: [SourceLocation { span: Range(TextLocation { line: 46, column: 4, offset: 790 }..TextLocation { line: 46, column: 23, offset: 809 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid assignment: cannot assign 'STRUCT2' to 'STRUCT1'", range: [SourceLocation { span: Range(TextLocation { line: 49, column: 4, offset: 866 }..TextLocation { line: 49, column: 26, offset: 888 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid assignment: cannot assign 'STRUCT2' to 'STRUCT1'", range: [SourceLocation { span: Range(TextLocation { line: 52, column: 18, offset: 974 }..TextLocation { line: 52, column: 42, offset: 998 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid assignment: cannot assign 'STRUCT2' to 'STRUCT1'", range: [SourceLocation { span: Range(TextLocation { line: 55, column: 9, offset: 1073 }..TextLocation { line: 55, column: 39, offset: 1103 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid assignment: cannot assign '__POINTER_TO_REAL' to 'REF_TO STRUCT1'", range: [SourceLocation { span: Range(TextLocation { line: 66, column: 4, offset: 1410 }..TextLocation { line: 66, column: 35, offset: 1441 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid assignment: cannot assign '__POINTER_TO_STRING' to 'REF_TO STRUCT1'", range: [SourceLocation { span: Range(TextLocation { line: 67, column: 4, offset: 1458 }..TextLocation { line: 67, column: 37, offset: 1491 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid assignment: cannot assign '__POINTER_TO_CHAR' to 'REF_TO STRUCT1'", range: [SourceLocation { span: Range(TextLocation { line: 68, column: 4, offset: 1508 }..TextLocation { line: 68, column: 35, offset: 1539 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid assignment: cannot assign '__POINTER_TO_REAL' to 'REF_TO STRUCT1'", range: [SourceLocation { span: Range(TextLocation { line: 70, column: 4, offset: 1557 }..TextLocation { line: 70, column: 33, offset: 1586 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid assignment: cannot assign '__POINTER_TO_STRING' to 'REF_TO STRUCT1'", range: [SourceLocation { span: Range(TextLocation { line: 71, column: 4, offset: 1603 }..TextLocation { line: 71, column: 35, offset: 1634 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid assignment: cannot assign '__POINTER_TO_CHAR' to 'REF_TO STRUCT1'", range: [SourceLocation { span: Range(TextLocation { line: 72, column: 4, offset: 1651 }..TextLocation { line: 72, column: 33, offset: 1680 }) }], err_no: var__invalid_assignment } +error: Invalid assignment: cannot assign 'STRUCT1' to 'REAL' + ┌─ :46:5 + │ +46 │ v_real := v_struct1; // INVALID + │ ^^^^^^^^^^^^^^^^^^^ Invalid assignment: cannot assign 'STRUCT1' to 'REAL' + +error: Invalid assignment: cannot assign 'REAL' to 'STRUCT1' + ┌─ :47:5 + │ +47 │ v_struct1 := v_real; // INVALID + │ ^^^^^^^^^^^^^^^^^^^ Invalid assignment: cannot assign 'REAL' to 'STRUCT1' + +error: Invalid assignment: cannot assign 'STRUCT2' to 'STRUCT1' + ┌─ :50:5 + │ +50 │ v_struct1 := v_struct2; // INVALID + │ ^^^^^^^^^^^^^^^^^^^^^^ Invalid assignment: cannot assign 'STRUCT2' to 'STRUCT1' + +error: Invalid assignment: cannot assign 'STRUCT2' to 'STRUCT1' + ┌─ :53:19 + │ +53 │ v_struct3 := (var_struct1 := v_struct2); // INVALID + │ ^^^^^^^^^^^^^^^^^^^^^^^^ Invalid assignment: cannot assign 'STRUCT2' to 'STRUCT1' + +error: Invalid assignment: cannot assign 'STRUCT2' to 'STRUCT1' + ┌─ :56:10 + │ +56 │ myFB(var_inout_struct1 := v_struct2); // INVALID + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Invalid assignment: cannot assign 'STRUCT2' to 'STRUCT1' + +error: Invalid assignment: cannot assign '__POINTER_TO_REAL' to 'REF_TO STRUCT1' + ┌─ :67:5 + │ +67 │ v_ref_to_struct1 := REF(v_real); // INVALID + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Invalid assignment: cannot assign '__POINTER_TO_REAL' to 'REF_TO STRUCT1' + +error: Invalid assignment: cannot assign '__POINTER_TO_STRING' to 'REF_TO STRUCT1' + ┌─ :68:5 + │ +68 │ v_ref_to_struct1 := REF(v_string); // INVALID + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Invalid assignment: cannot assign '__POINTER_TO_STRING' to 'REF_TO STRUCT1' + +error: Invalid assignment: cannot assign '__POINTER_TO_CHAR' to 'REF_TO STRUCT1' + ┌─ :69:5 + │ +69 │ v_ref_to_struct1 := REF(v_char); // INVALID + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Invalid assignment: cannot assign '__POINTER_TO_CHAR' to 'REF_TO STRUCT1' + +error: Invalid assignment: cannot assign '__POINTER_TO_REAL' to 'REF_TO STRUCT1' + ┌─ :71:5 + │ +71 │ v_ref_to_struct1 := &(v_real); // INVALID + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Invalid assignment: cannot assign '__POINTER_TO_REAL' to 'REF_TO STRUCT1' + +error: Invalid assignment: cannot assign '__POINTER_TO_STRING' to 'REF_TO STRUCT1' + ┌─ :72:5 + │ +72 │ v_ref_to_struct1 := &(v_string); // INVALID + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Invalid assignment: cannot assign '__POINTER_TO_STRING' to 'REF_TO STRUCT1' + +error: Invalid assignment: cannot assign '__POINTER_TO_CHAR' to 'REF_TO STRUCT1' + ┌─ :73:5 + │ +73 │ v_ref_to_struct1 := &(v_char); // INVALID + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Invalid assignment: cannot assign '__POINTER_TO_CHAR' to 'REF_TO STRUCT1' + diff --git a/src/validation/tests/snapshots/rusty__validation__tests__assignment_validation_tests__trimmed_slices.snap b/src/validation/tests/snapshots/rusty__validation__tests__assignment_validation_tests__trimmed_slices.snap deleted file mode 100644 index d37f05f286..0000000000 --- a/src/validation/tests/snapshots/rusty__validation__tests__assignment_validation_tests__trimmed_slices.snap +++ /dev/null @@ -1,11 +0,0 @@ ---- -source: src/validation/tests/assignment_validation_tests.rs -expression: diagnostic ---- -error: Invalid assignment: cannot assign 'ARRAY[1..5] OF DINT' to 'ARRAY[1..1] OF DINT' - ┌─ :13:13 - │ -13 │ one := two; - │ ^^^^^^^^^^ Invalid assignment: cannot assign 'ARRAY[1..5] OF DINT' to 'ARRAY[1..1] OF DINT' - - diff --git a/src/validation/tests/snapshots/rusty__validation__tests__bitaccess_validation_test__bitaccess_only_on_bit_types.snap b/src/validation/tests/snapshots/rusty__validation__tests__bitaccess_validation_test__bitaccess_only_on_bit_types.snap index af71110414..36fab18e27 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__bitaccess_validation_test__bitaccess_only_on_bit_types.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__bitaccess_validation_test__bitaccess_only_on_bit_types.snap @@ -1,8 +1,23 @@ --- source: src/validation/tests/bitaccess_validation_test.rs -expression: res +expression: "&diagnostics" --- -SyntaxError { message: "Bit-Wise access requires a Numerical type larger than 1 bits", range: [SourceLocation { span: Range(TextLocation { line: 10, column: 20, offset: 222 }..TextLocation { line: 10, column: 21, offset: 223 }) }], err_no: type__incompatible_directaccess } -SyntaxError { message: "Bit-Wise access requires a Numerical type larger than 1 bits", range: [SourceLocation { span: Range(TextLocation { line: 11, column: 21, offset: 246 }..TextLocation { line: 11, column: 22, offset: 247 }) }], err_no: type__incompatible_directaccess } -SyntaxError { message: "Bit-Wise access requires a Numerical type larger than 1 bits", range: [SourceLocation { span: Range(TextLocation { line: 12, column: 20, offset: 269 }..TextLocation { line: 12, column: 21, offset: 270 }) }], err_no: type__incompatible_directaccess } +error: Bit-Wise access requires a Numerical type larger than 1 bits + ┌─ :11:21 + │ +11 │ invalid.1; + │ ^ Bit-Wise access requires a Numerical type larger than 1 bits + +error: Bit-Wise access requires a Numerical type larger than 1 bits + ┌─ :12:22 + │ +12 │ invalid2.1; + │ ^ Bit-Wise access requires a Numerical type larger than 1 bits + +error: Bit-Wise access requires a Numerical type larger than 1 bits + ┌─ :13:21 + │ +13 │ valid.1.2; (*Invalid*) + │ ^ Bit-Wise access requires a Numerical type larger than 1 bits + diff --git a/src/validation/tests/snapshots/rusty__validation__tests__bitaccess_validation_test__bitaccess_range_test.snap b/src/validation/tests/snapshots/rusty__validation__tests__bitaccess_validation_test__bitaccess_range_test.snap index 04e2bd713c..804d1979eb 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__bitaccess_validation_test__bitaccess_range_test.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__bitaccess_validation_test__bitaccess_range_test.snap @@ -1,9 +1,29 @@ --- source: src/validation/tests/bitaccess_validation_test.rs -expression: res +expression: "&diagnostics" --- -SyntaxError { message: "Bit-Wise access for type BYTE must be in the range 0..7", range: [SourceLocation { span: Range(TextLocation { line: 5, column: 18, offset: 137 }..TextLocation { line: 5, column: 19, offset: 138 }) }], err_no: type__incompatible_directaccess_range } -SyntaxError { message: "Bit-Wise access for type WORD must be in the range 0..15", range: [SourceLocation { span: Range(TextLocation { line: 6, column: 18, offset: 158 }..TextLocation { line: 6, column: 20, offset: 160 }) }], err_no: type__incompatible_directaccess_range } -SyntaxError { message: "Bit-Wise access for type DWORD must be in the range 0..31", range: [SourceLocation { span: Range(TextLocation { line: 7, column: 18, offset: 180 }..TextLocation { line: 7, column: 20, offset: 182 }) }], err_no: type__incompatible_directaccess_range } -SyntaxError { message: "Bit-Wise access for type LWORD must be in the range 0..63", range: [SourceLocation { span: Range(TextLocation { line: 8, column: 18, offset: 202 }..TextLocation { line: 8, column: 20, offset: 204 }) }], err_no: type__incompatible_directaccess_range } +error: Bit-Wise access for type BYTE must be in the range 0..7 + ┌─ :6:19 + │ +6 │ a.8; + │ ^ Bit-Wise access for type BYTE must be in the range 0..7 + +error: Bit-Wise access for type WORD must be in the range 0..15 + ┌─ :7:19 + │ +7 │ b.16; + │ ^^ Bit-Wise access for type WORD must be in the range 0..15 + +error: Bit-Wise access for type DWORD must be in the range 0..31 + ┌─ :8:19 + │ +8 │ c.32; + │ ^^ Bit-Wise access for type DWORD must be in the range 0..31 + +error: Bit-Wise access for type LWORD must be in the range 0..63 + ┌─ :9:19 + │ +9 │ d.64; + │ ^^ Bit-Wise access for type LWORD must be in the range 0..63 + diff --git a/src/validation/tests/snapshots/rusty__validation__tests__bitaccess_validation_test__byteaccess_only_on_bigger_sizes.snap b/src/validation/tests/snapshots/rusty__validation__tests__bitaccess_validation_test__byteaccess_only_on_bigger_sizes.snap index 6d500b3f39..3646508093 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__bitaccess_validation_test__byteaccess_only_on_bigger_sizes.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__bitaccess_validation_test__byteaccess_only_on_bigger_sizes.snap @@ -1,8 +1,23 @@ --- source: src/validation/tests/bitaccess_validation_test.rs -expression: res +expression: "&diagnostics" --- -SyntaxError { message: "Byte-Wise access requires a Numerical type larger than 8 bits", range: [SourceLocation { span: Range(TextLocation { line: 9, column: 20, offset: 194 }..TextLocation { line: 9, column: 23, offset: 197 }) }], err_no: type__incompatible_directaccess } -SyntaxError { message: "Byte-Wise access requires a Numerical type larger than 8 bits", range: [SourceLocation { span: Range(TextLocation { line: 10, column: 21, offset: 220 }..TextLocation { line: 10, column: 24, offset: 223 }) }], err_no: type__incompatible_directaccess } -SyntaxError { message: "Byte-Wise access requires a Numerical type larger than 8 bits", range: [SourceLocation { span: Range(TextLocation { line: 11, column: 21, offset: 246 }..TextLocation { line: 11, column: 24, offset: 249 }) }], err_no: type__incompatible_directaccess } +error: Byte-Wise access requires a Numerical type larger than 8 bits + ┌─ :10:21 + │ +10 │ invalid.%B1; + │ ^^^ Byte-Wise access requires a Numerical type larger than 8 bits + +error: Byte-Wise access requires a Numerical type larger than 8 bits + ┌─ :11:22 + │ +11 │ invalid2.%B1; + │ ^^^ Byte-Wise access requires a Numerical type larger than 8 bits + +error: Byte-Wise access requires a Numerical type larger than 8 bits + ┌─ :12:22 + │ +12 │ invalid3.%B1; + │ ^^^ Byte-Wise access requires a Numerical type larger than 8 bits + diff --git a/src/validation/tests/snapshots/rusty__validation__tests__bitaccess_validation_test__byteaccess_range_test.snap b/src/validation/tests/snapshots/rusty__validation__tests__bitaccess_validation_test__byteaccess_range_test.snap index 8c1c7fea53..fbdbcc2eb1 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__bitaccess_validation_test__byteaccess_range_test.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__bitaccess_validation_test__byteaccess_range_test.snap @@ -1,8 +1,23 @@ --- source: src/validation/tests/bitaccess_validation_test.rs -expression: res +expression: "&diagnostics" --- -SyntaxError { message: "Byte-Wise access for type WORD must be in the range 0..1", range: [SourceLocation { span: Range(TextLocation { line: 5, column: 18, offset: 127 }..TextLocation { line: 5, column: 21, offset: 130 }) }], err_no: type__incompatible_directaccess_range } -SyntaxError { message: "Byte-Wise access for type DWORD must be in the range 0..3", range: [SourceLocation { span: Range(TextLocation { line: 6, column: 18, offset: 150 }..TextLocation { line: 6, column: 21, offset: 153 }) }], err_no: type__incompatible_directaccess_range } -SyntaxError { message: "Byte-Wise access for type LWORD must be in the range 0..7", range: [SourceLocation { span: Range(TextLocation { line: 7, column: 18, offset: 173 }..TextLocation { line: 7, column: 21, offset: 176 }) }], err_no: type__incompatible_directaccess_range } +error: Byte-Wise access for type WORD must be in the range 0..1 + ┌─ :6:19 + │ +6 │ b.%B2; + │ ^^^ Byte-Wise access for type WORD must be in the range 0..1 + +error: Byte-Wise access for type DWORD must be in the range 0..3 + ┌─ :7:19 + │ +7 │ c.%B4; + │ ^^^ Byte-Wise access for type DWORD must be in the range 0..3 + +error: Byte-Wise access for type LWORD must be in the range 0..7 + ┌─ :8:19 + │ +8 │ d.%B8; + │ ^^^ Byte-Wise access for type LWORD must be in the range 0..7 + diff --git a/src/validation/tests/snapshots/rusty__validation__tests__bitaccess_validation_test__dwordaccess_only_on_bigger_sizes.snap b/src/validation/tests/snapshots/rusty__validation__tests__bitaccess_validation_test__dwordaccess_only_on_bigger_sizes.snap index 4d655bcabc..b0c1fb394c 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__bitaccess_validation_test__dwordaccess_only_on_bigger_sizes.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__bitaccess_validation_test__dwordaccess_only_on_bigger_sizes.snap @@ -1,8 +1,23 @@ --- source: src/validation/tests/bitaccess_validation_test.rs -expression: res +expression: "&diagnostics" --- -SyntaxError { message: "DWord-Wise access requires a Numerical type larger than 32 bits", range: [SourceLocation { span: Range(TextLocation { line: 9, column: 20, offset: 196 }..TextLocation { line: 9, column: 23, offset: 199 }) }], err_no: type__incompatible_directaccess } -SyntaxError { message: "DWord-Wise access requires a Numerical type larger than 32 bits", range: [SourceLocation { span: Range(TextLocation { line: 10, column: 21, offset: 222 }..TextLocation { line: 10, column: 24, offset: 225 }) }], err_no: type__incompatible_directaccess } -SyntaxError { message: "DWord-Wise access requires a Numerical type larger than 32 bits", range: [SourceLocation { span: Range(TextLocation { line: 11, column: 21, offset: 248 }..TextLocation { line: 11, column: 24, offset: 251 }) }], err_no: type__incompatible_directaccess } +error: DWord-Wise access requires a Numerical type larger than 32 bits + ┌─ :10:21 + │ +10 │ invalid.%D1; + │ ^^^ DWord-Wise access requires a Numerical type larger than 32 bits + +error: DWord-Wise access requires a Numerical type larger than 32 bits + ┌─ :11:22 + │ +11 │ invalid2.%D1; + │ ^^^ DWord-Wise access requires a Numerical type larger than 32 bits + +error: DWord-Wise access requires a Numerical type larger than 32 bits + ┌─ :12:22 + │ +12 │ invalid3.%D1; + │ ^^^ DWord-Wise access requires a Numerical type larger than 32 bits + diff --git a/src/validation/tests/snapshots/rusty__validation__tests__bitaccess_validation_test__dwordaccess_range_test.snap b/src/validation/tests/snapshots/rusty__validation__tests__bitaccess_validation_test__dwordaccess_range_test.snap index 419f2365ff..7cb499e1b8 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__bitaccess_validation_test__dwordaccess_range_test.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__bitaccess_validation_test__dwordaccess_range_test.snap @@ -1,6 +1,11 @@ --- source: src/validation/tests/bitaccess_validation_test.rs -expression: res +expression: "&diagnostics" --- -SyntaxError { message: "DWord-Wise access for type LWORD must be in the range 0..1", range: [SourceLocation { span: Range(TextLocation { line: 5, column: 18, offset: 106 }..TextLocation { line: 5, column: 21, offset: 109 }) }], err_no: type__incompatible_directaccess_range } +error: DWord-Wise access for type LWORD must be in the range 0..1 + ┌─ :6:19 + │ +6 │ d.%D2; + │ ^^^ DWord-Wise access for type LWORD must be in the range 0..1 + diff --git a/src/validation/tests/snapshots/rusty__validation__tests__bitaccess_validation_test__reference_direct_access_only_with_ints.snap b/src/validation/tests/snapshots/rusty__validation__tests__bitaccess_validation_test__reference_direct_access_only_with_ints.snap index e613224530..100d366e3e 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__bitaccess_validation_test__reference_direct_access_only_with_ints.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__bitaccess_validation_test__reference_direct_access_only_with_ints.snap @@ -1,7 +1,17 @@ --- source: src/validation/tests/bitaccess_validation_test.rs -expression: res +expression: "&diagnostics" --- -SyntaxError { message: "Invalid type LREAL for direct variable access. Only variables of Integer types are allowed", range: [SourceLocation { span: Range(TextLocation { line: 6, column: 18, offset: 159 }..TextLocation { line: 6, column: 21, offset: 162 }) }], err_no: type__incompatible_directaccess_variable } -SyntaxError { message: "Invalid type REAL for direct variable access. Only variables of Integer types are allowed", range: [SourceLocation { span: Range(TextLocation { line: 7, column: 18, offset: 182 }..TextLocation { line: 7, column: 21, offset: 185 }) }], err_no: type__incompatible_directaccess_variable } +error: Invalid type LREAL for direct variable access. Only variables of Integer types are allowed + ┌─ :7:19 + │ +7 │ c.%Xe; + │ ^^^ Invalid type LREAL for direct variable access. Only variables of Integer types are allowed + +error: Invalid type REAL for direct variable access. Only variables of Integer types are allowed + ┌─ :8:19 + │ +8 │ c.%Xf; + │ ^^^ Invalid type REAL for direct variable access. Only variables of Integer types are allowed + diff --git a/src/validation/tests/snapshots/rusty__validation__tests__bitaccess_validation_test__wordaccess_only_on_bigger_sizes.snap b/src/validation/tests/snapshots/rusty__validation__tests__bitaccess_validation_test__wordaccess_only_on_bigger_sizes.snap index 2713560021..47a8f630b8 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__bitaccess_validation_test__wordaccess_only_on_bigger_sizes.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__bitaccess_validation_test__wordaccess_only_on_bigger_sizes.snap @@ -1,8 +1,23 @@ --- source: src/validation/tests/bitaccess_validation_test.rs -expression: res +expression: "&diagnostics" --- -SyntaxError { message: "Word-Wise access requires a Numerical type larger than 16 bits", range: [SourceLocation { span: Range(TextLocation { line: 9, column: 20, offset: 193 }..TextLocation { line: 9, column: 23, offset: 196 }) }], err_no: type__incompatible_directaccess } -SyntaxError { message: "Word-Wise access requires a Numerical type larger than 16 bits", range: [SourceLocation { span: Range(TextLocation { line: 10, column: 21, offset: 219 }..TextLocation { line: 10, column: 24, offset: 222 }) }], err_no: type__incompatible_directaccess } -SyntaxError { message: "Word-Wise access requires a Numerical type larger than 16 bits", range: [SourceLocation { span: Range(TextLocation { line: 11, column: 21, offset: 245 }..TextLocation { line: 11, column: 24, offset: 248 }) }], err_no: type__incompatible_directaccess } +error: Word-Wise access requires a Numerical type larger than 16 bits + ┌─ :10:21 + │ +10 │ invalid.%W1; + │ ^^^ Word-Wise access requires a Numerical type larger than 16 bits + +error: Word-Wise access requires a Numerical type larger than 16 bits + ┌─ :11:22 + │ +11 │ invalid2.%W1; + │ ^^^ Word-Wise access requires a Numerical type larger than 16 bits + +error: Word-Wise access requires a Numerical type larger than 16 bits + ┌─ :12:22 + │ +12 │ invalid3.%W1; + │ ^^^ Word-Wise access requires a Numerical type larger than 16 bits + diff --git a/src/validation/tests/snapshots/rusty__validation__tests__bitaccess_validation_test__wordaccess_range_test.snap b/src/validation/tests/snapshots/rusty__validation__tests__bitaccess_validation_test__wordaccess_range_test.snap index 568aac496f..2a33cc4578 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__bitaccess_validation_test__wordaccess_range_test.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__bitaccess_validation_test__wordaccess_range_test.snap @@ -1,7 +1,17 @@ --- source: src/validation/tests/bitaccess_validation_test.rs -expression: res +expression: "&diagnostics" --- -SyntaxError { message: "Word-Wise access for type DWORD must be in the range 0..1", range: [SourceLocation { span: Range(TextLocation { line: 5, column: 18, offset: 117 }..TextLocation { line: 5, column: 21, offset: 120 }) }], err_no: type__incompatible_directaccess_range } -SyntaxError { message: "Word-Wise access for type LWORD must be in the range 0..3", range: [SourceLocation { span: Range(TextLocation { line: 6, column: 18, offset: 140 }..TextLocation { line: 6, column: 21, offset: 143 }) }], err_no: type__incompatible_directaccess_range } +error: Word-Wise access for type DWORD must be in the range 0..1 + ┌─ :6:19 + │ +6 │ c.%W2; + │ ^^^ Word-Wise access for type DWORD must be in the range 0..1 + +error: Word-Wise access for type LWORD must be in the range 0..3 + ┌─ :7:19 + │ +7 │ d.%W4; + │ ^^^ Word-Wise access for type LWORD must be in the range 0..3 + diff --git a/src/validation/tests/snapshots/rusty__validation__tests__builtin_validation_tests__arithmetic_builtins_called_with_invalid_param_count.snap b/src/validation/tests/snapshots/rusty__validation__tests__builtin_validation_tests__arithmetic_builtins_called_with_invalid_param_count.snap index 4e5c52b823..98b76750af 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__builtin_validation_tests__arithmetic_builtins_called_with_invalid_param_count.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__builtin_validation_tests__arithmetic_builtins_called_with_invalid_param_count.snap @@ -1,10 +1,35 @@ --- source: src/validation/tests/builtin_validation_tests.rs -expression: res +expression: "&diagnostics" --- -SyntaxError { message: "Invalid parameter count. Received 0 parameters while 2 parameters were expected.", range: [SourceLocation { span: Range(TextLocation { line: 6, column: 12, offset: 116 }..TextLocation { line: 6, column: 15, offset: 119 }) }], err_no: call__invalid_parameter_count } -SyntaxError { message: "Could not resolve generic type T with nature Num", range: [SourceLocation { span: Range(TextLocation { line: 6, column: 12, offset: 116 }..TextLocation { line: 6, column: 18, offset: 122 }) }], err_no: type__unresolved_generic } -SyntaxError { message: "Invalid parameter count. Received 1 parameters while 2 parameters were expected.", range: [SourceLocation { span: Range(TextLocation { line: 7, column: 12, offset: 135 }..TextLocation { line: 7, column: 15, offset: 138 }) }], err_no: call__invalid_parameter_count } -SyntaxError { message: "Invalid parameter count. Received 4 parameters while 2 parameters were expected.", range: [SourceLocation { span: Range(TextLocation { line: 8, column: 12, offset: 156 }..TextLocation { line: 8, column: 15, offset: 159 }) }], err_no: call__invalid_parameter_count } -SyntaxError { message: "Invalid parameter count. Received 4 parameters while 2 parameters were expected.", range: [SourceLocation { span: Range(TextLocation { line: 9, column: 12, offset: 223 }..TextLocation { line: 9, column: 15, offset: 226 }) }], err_no: call__invalid_parameter_count } +error: Invalid parameter count. Received 0 parameters while 2 parameters were expected. + ┌─ :7:13 + │ +7 │ ADD(); + │ ^^^ Invalid parameter count. Received 0 parameters while 2 parameters were expected. + +error: Could not resolve generic type T with nature Num + ┌─ :7:13 + │ +7 │ ADD(); + │ ^^^^^^ Could not resolve generic type T with nature Num + +error: Invalid parameter count. Received 1 parameters while 2 parameters were expected. + ┌─ :8:13 + │ +8 │ MUL(x1); + │ ^^^ Invalid parameter count. Received 1 parameters while 2 parameters were expected. + +error: Invalid parameter count. Received 4 parameters while 2 parameters were expected. + ┌─ :9:13 + │ +9 │ DIV(x2, x2, x1, x2); // DIV and SUB are not extensible + │ ^^^ Invalid parameter count. Received 4 parameters while 2 parameters were expected. + +error: Invalid parameter count. Received 4 parameters while 2 parameters were expected. + ┌─ :10:13 + │ +10 │ SUB(x2, x2, x1, x2); + │ ^^^ Invalid parameter count. Received 4 parameters while 2 parameters were expected. + diff --git a/src/validation/tests/snapshots/rusty__validation__tests__builtin_validation_tests__comparison_builtins_called_with_invalid_param_count.snap b/src/validation/tests/snapshots/rusty__validation__tests__builtin_validation_tests__comparison_builtins_called_with_invalid_param_count.snap index db7017f941..dba22dbe94 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__builtin_validation_tests__comparison_builtins_called_with_invalid_param_count.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__builtin_validation_tests__comparison_builtins_called_with_invalid_param_count.snap @@ -1,8 +1,23 @@ --- source: src/validation/tests/builtin_validation_tests.rs -expression: res +expression: "&diagnostics" --- -SyntaxError { message: "Invalid parameter count. Received 0 parameters while 2 parameters were expected.", range: [SourceLocation { span: Range(TextLocation { line: 6, column: 12, offset: 116 }..TextLocation { line: 6, column: 14, offset: 118 }) }], err_no: call__invalid_parameter_count } -SyntaxError { message: "Invalid parameter count. Received 1 parameters while 2 parameters were expected.", range: [SourceLocation { span: Range(TextLocation { line: 7, column: 12, offset: 134 }..TextLocation { line: 7, column: 14, offset: 136 }) }], err_no: call__invalid_parameter_count } -SyntaxError { message: "Invalid parameter count. Received 4 parameters while 2 parameters were expected.", range: [SourceLocation { span: Range(TextLocation { line: 9, column: 12, offset: 192 }..TextLocation { line: 9, column: 14, offset: 194 }) }], err_no: call__invalid_parameter_count } +error: Invalid parameter count. Received 0 parameters while 2 parameters were expected. + ┌─ :7:13 + │ +7 │ EQ(); + │ ^^ Invalid parameter count. Received 0 parameters while 2 parameters were expected. + +error: Invalid parameter count. Received 1 parameters while 2 parameters were expected. + ┌─ :8:13 + │ +8 │ GT(x1); + │ ^^ Invalid parameter count. Received 1 parameters while 2 parameters were expected. + +error: Invalid parameter count. Received 4 parameters while 2 parameters were expected. + ┌─ :10:13 + │ +10 │ NE(x2, x2, x1, x2); // NE is not extensible + │ ^^ Invalid parameter count. Received 4 parameters while 2 parameters were expected. + diff --git a/src/validation/tests/snapshots/rusty__validation__tests__duplicates_validation_test__duplicate_action_should_be_a_problem.snap b/src/validation/tests/snapshots/rusty__validation__tests__duplicates_validation_test__duplicate_action_should_be_a_problem.snap index ac1ddf51bc..b4fb709018 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__duplicates_validation_test__duplicate_action_should_be_a_problem.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__duplicates_validation_test__duplicate_action_should_be_a_problem.snap @@ -1,7 +1,23 @@ --- source: src/validation/tests/duplicates_validation_test.rs -expression: res +expression: "&diagnostics" --- -SyntaxError { message: "prg.foo: Ambiguous callable symbol.", range: [SourceLocation { span: Range(TextLocation { line: 8, column: 19, offset: 167 }..TextLocation { line: 8, column: 22, offset: 170 }) }, SourceLocation { span: Range(TextLocation { line: 16, column: 19, offset: 309 }..TextLocation { line: 16, column: 22, offset: 312 }) }], err_no: duplicate_symbol } -SyntaxError { message: "prg.foo: Ambiguous callable symbol.", range: [SourceLocation { span: Range(TextLocation { line: 16, column: 19, offset: 309 }..TextLocation { line: 16, column: 22, offset: 312 }) }, SourceLocation { span: Range(TextLocation { line: 8, column: 19, offset: 167 }..TextLocation { line: 8, column: 22, offset: 170 }) }], err_no: duplicate_symbol } +error: prg.foo: Ambiguous callable symbol. + ┌─ :9:20 + │ + 9 │ ACTION foo + │ ^^^ prg.foo: Ambiguous callable symbol. + · +17 │ ACTION foo + │ --- see also + +error: prg.foo: Ambiguous callable symbol. + ┌─ :17:20 + │ + 9 │ ACTION foo + │ --- see also + · +17 │ ACTION foo + │ ^^^ prg.foo: Ambiguous callable symbol. + diff --git a/src/validation/tests/snapshots/rusty__validation__tests__duplicates_validation_test__duplicate_enum_variables.snap b/src/validation/tests/snapshots/rusty__validation__tests__duplicates_validation_test__duplicate_enum_variables.snap index bf2e581ec0..b08848eb1c 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__duplicates_validation_test__duplicate_enum_variables.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__duplicates_validation_test__duplicate_enum_variables.snap @@ -1,7 +1,21 @@ --- source: src/validation/tests/duplicates_validation_test.rs -expression: res +expression: "&diagnostics" --- -SyntaxError { message: "enum1.red: Duplicate symbol.", range: [SourceLocation { span: Range(TextLocation { line: 1, column: 26, offset: 27 }..TextLocation { line: 1, column: 29, offset: 30 }) }, SourceLocation { span: Range(TextLocation { line: 1, column: 46, offset: 47 }..TextLocation { line: 1, column: 49, offset: 50 }) }], err_no: duplicate_symbol } -SyntaxError { message: "enum1.red: Duplicate symbol.", range: [SourceLocation { span: Range(TextLocation { line: 1, column: 46, offset: 47 }..TextLocation { line: 1, column: 49, offset: 50 }) }, SourceLocation { span: Range(TextLocation { line: 1, column: 26, offset: 27 }..TextLocation { line: 1, column: 29, offset: 30 }) }], err_no: duplicate_symbol } +error: enum1.red: Duplicate symbol. + ┌─ :2:27 + │ +2 │ TYPE enum1 : (red, green, yellow, red); END_TYPE + │ ^^^ --- see also + │ │ + │ enum1.red: Duplicate symbol. + +error: enum1.red: Duplicate symbol. + ┌─ :2:47 + │ +2 │ TYPE enum1 : (red, green, yellow, red); END_TYPE + │ --- ^^^ enum1.red: Duplicate symbol. + │ │ + │ see also + diff --git a/src/validation/tests/snapshots/rusty__validation__tests__duplicates_validation_test__duplicate_fb_inst_and_function.snap b/src/validation/tests/snapshots/rusty__validation__tests__duplicates_validation_test__duplicate_fb_inst_and_function.snap index ad9f790cdd..0876655057 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__duplicates_validation_test__duplicate_fb_inst_and_function.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__duplicates_validation_test__duplicate_fb_inst_and_function.snap @@ -1,7 +1,23 @@ --- source: src/validation/tests/duplicates_validation_test.rs -expression: res +expression: "&diagnostics" --- -SyntaxError { message: "foo: Ambiguous callable symbol.", range: [SourceLocation { span: Range(TextLocation { line: 6, column: 16, offset: 142 }..TextLocation { line: 6, column: 19, offset: 145 }) }, SourceLocation { span: Range(TextLocation { line: 9, column: 21, offset: 196 }..TextLocation { line: 9, column: 24, offset: 199 }) }], err_no: duplicate_symbol } -SyntaxError { message: "foo: Ambiguous callable symbol.", range: [SourceLocation { span: Range(TextLocation { line: 9, column: 21, offset: 196 }..TextLocation { line: 9, column: 24, offset: 199 }) }, SourceLocation { span: Range(TextLocation { line: 6, column: 16, offset: 142 }..TextLocation { line: 6, column: 19, offset: 145 }) }], err_no: duplicate_symbol } +error: foo: Ambiguous callable symbol. + ┌─ :7:17 + │ + 7 │ foo: FooFB; + │ ^^^ foo: Ambiguous callable symbol. + · +10 │ FUNCTION foo: INT + │ --- see also + +error: foo: Ambiguous callable symbol. + ┌─ :10:22 + │ + 7 │ foo: FooFB; + │ --- see also + · +10 │ FUNCTION foo: INT + │ ^^^ foo: Ambiguous callable symbol. + diff --git a/src/validation/tests/snapshots/rusty__validation__tests__duplicates_validation_test__duplicate_global_and_program.snap b/src/validation/tests/snapshots/rusty__validation__tests__duplicates_validation_test__duplicate_global_and_program.snap index d9dd5a1518..52dc16e4e6 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__duplicates_validation_test__duplicate_global_and_program.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__duplicates_validation_test__duplicate_global_and_program.snap @@ -1,7 +1,23 @@ --- source: src/validation/tests/duplicates_validation_test.rs -expression: res +expression: "&diagnostics" --- -SyntaxError { message: "prg: Ambiguous global variable.", range: [SourceLocation { span: Range(TextLocation { line: 3, column: 16, offset: 64 }..TextLocation { line: 3, column: 19, offset: 67 }) }, SourceLocation { span: Range(TextLocation { line: 7, column: 20, offset: 139 }..TextLocation { line: 7, column: 23, offset: 142 }) }], err_no: duplicate_symbol } -SyntaxError { message: "prg: Ambiguous global variable.", range: [SourceLocation { span: Range(TextLocation { line: 7, column: 20, offset: 139 }..TextLocation { line: 7, column: 23, offset: 142 }) }, SourceLocation { span: Range(TextLocation { line: 3, column: 16, offset: 64 }..TextLocation { line: 3, column: 19, offset: 67 }) }], err_no: duplicate_symbol } +error: prg: Ambiguous global variable. + ┌─ :4:17 + │ +4 │ prg: INT; + │ ^^^ prg: Ambiguous global variable. + · +8 │ PROGRAM prg + │ --- see also + +error: prg: Ambiguous global variable. + ┌─ :8:21 + │ +4 │ prg: INT; + │ --- see also + · +8 │ PROGRAM prg + │ ^^^ prg: Ambiguous global variable. + diff --git a/src/validation/tests/snapshots/rusty__validation__tests__duplicates_validation_test__duplicate_global_variables.snap b/src/validation/tests/snapshots/rusty__validation__tests__duplicates_validation_test__duplicate_global_variables.snap index a34f169907..e259bb1e93 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__duplicates_validation_test__duplicate_global_variables.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__duplicates_validation_test__duplicate_global_variables.snap @@ -1,7 +1,23 @@ --- source: src/validation/tests/duplicates_validation_test.rs -expression: res +expression: "&diagnostics" --- -SyntaxError { message: "a: Ambiguous global variable.", range: [SourceLocation { span: Range(TextLocation { line: 2, column: 12, offset: 32 }..TextLocation { line: 2, column: 13, offset: 33 }) }, SourceLocation { span: Range(TextLocation { line: 8, column: 12, offset: 128 }..TextLocation { line: 8, column: 13, offset: 129 }) }], err_no: duplicate_symbol } -SyntaxError { message: "a: Ambiguous global variable.", range: [SourceLocation { span: Range(TextLocation { line: 8, column: 12, offset: 128 }..TextLocation { line: 8, column: 13, offset: 129 }) }, SourceLocation { span: Range(TextLocation { line: 2, column: 12, offset: 32 }..TextLocation { line: 2, column: 13, offset: 33 }) }], err_no: duplicate_symbol } +error: a: Ambiguous global variable. + ┌─ :3:13 + │ +3 │ a: INT; + │ ^ a: Ambiguous global variable. + · +9 │ a: BOOL; + │ - see also + +error: a: Ambiguous global variable. + ┌─ :9:13 + │ +3 │ a: INT; + │ - see also + · +9 │ a: BOOL; + │ ^ a: Ambiguous global variable. + diff --git a/src/validation/tests/snapshots/rusty__validation__tests__duplicates_validation_test__duplicate_pous_and_types_validation.snap b/src/validation/tests/snapshots/rusty__validation__tests__duplicates_validation_test__duplicate_pous_and_types_validation.snap index 18d4032cef..2d81d9c5b3 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__duplicates_validation_test__duplicate_pous_and_types_validation.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__duplicates_validation_test__duplicate_pous_and_types_validation.snap @@ -1,7 +1,21 @@ --- source: src/validation/tests/duplicates_validation_test.rs -expression: res +expression: "&diagnostics" --- -SyntaxError { message: "foo: Ambiguous datatype.", range: [SourceLocation { span: Range(TextLocation { line: 2, column: 13, offset: 62 }..TextLocation { line: 2, column: 16, offset: 65 }) }, SourceLocation { span: Range(TextLocation { line: 1, column: 24, offset: 25 }..TextLocation { line: 1, column: 27, offset: 28 }) }], err_no: duplicate_symbol } -SyntaxError { message: "foo: Ambiguous datatype.", range: [SourceLocation { span: Range(TextLocation { line: 1, column: 24, offset: 25 }..TextLocation { line: 1, column: 27, offset: 28 }) }, SourceLocation { span: Range(TextLocation { line: 2, column: 13, offset: 62 }..TextLocation { line: 2, column: 16, offset: 65 }) }], err_no: duplicate_symbol } +error: foo: Ambiguous datatype. + ┌─ :3:14 + │ +2 │ FUNCTION_BLOCK foo END_FUNCTION_BLOCK + │ --- see also +3 │ TYPE foo : INT; END_TYPE + │ ^^^ foo: Ambiguous datatype. + +error: foo: Ambiguous datatype. + ┌─ :2:25 + │ +2 │ FUNCTION_BLOCK foo END_FUNCTION_BLOCK + │ ^^^ foo: Ambiguous datatype. +3 │ TYPE foo : INT; END_TYPE + │ --- see also + diff --git a/src/validation/tests/snapshots/rusty__validation__tests__duplicates_validation_test__duplicate_pous_validation.snap b/src/validation/tests/snapshots/rusty__validation__tests__duplicates_validation_test__duplicate_pous_validation.snap index 31edd25c4d..9023458c5e 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__duplicates_validation_test__duplicate_pous_validation.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__duplicates_validation_test__duplicate_pous_validation.snap @@ -1,10 +1,59 @@ --- source: src/validation/tests/duplicates_validation_test.rs -expression: res +expression: "&diagnostics" --- -SyntaxError { message: "foo: Ambiguous callable symbol.", range: [SourceLocation { span: Range(TextLocation { line: 3, column: 24, offset: 74 }..TextLocation { line: 3, column: 27, offset: 77 }) }, SourceLocation { span: Range(TextLocation { line: 1, column: 24, offset: 25 }..TextLocation { line: 1, column: 27, offset: 28 }) }], err_no: duplicate_symbol } -SyntaxError { message: "foo: Ambiguous callable symbol.", range: [SourceLocation { span: Range(TextLocation { line: 1, column: 24, offset: 25 }..TextLocation { line: 1, column: 27, offset: 28 }) }, SourceLocation { span: Range(TextLocation { line: 3, column: 24, offset: 74 }..TextLocation { line: 3, column: 27, offset: 77 }) }], err_no: duplicate_symbol } -SyntaxError { message: "foo: Duplicate symbol.", range: [SourceLocation { span: Range(TextLocation { line: 1, column: 24, offset: 25 }..TextLocation { line: 1, column: 27, offset: 28 }) }, SourceLocation { span: Range(TextLocation { line: 3, column: 24, offset: 74 }..TextLocation { line: 3, column: 27, offset: 77 }) }, SourceLocation { span: Range(TextLocation { line: 5, column: 24, offset: 116 }..TextLocation { line: 5, column: 27, offset: 119 }) }], err_no: duplicate_symbol } -SyntaxError { message: "foo: Duplicate symbol.", range: [SourceLocation { span: Range(TextLocation { line: 3, column: 24, offset: 74 }..TextLocation { line: 3, column: 27, offset: 77 }) }, SourceLocation { span: Range(TextLocation { line: 1, column: 24, offset: 25 }..TextLocation { line: 1, column: 27, offset: 28 }) }, SourceLocation { span: Range(TextLocation { line: 5, column: 24, offset: 116 }..TextLocation { line: 5, column: 27, offset: 119 }) }], err_no: duplicate_symbol } -SyntaxError { message: "foo: Duplicate symbol.", range: [SourceLocation { span: Range(TextLocation { line: 5, column: 24, offset: 116 }..TextLocation { line: 5, column: 27, offset: 119 }) }, SourceLocation { span: Range(TextLocation { line: 1, column: 24, offset: 25 }..TextLocation { line: 1, column: 27, offset: 28 }) }, SourceLocation { span: Range(TextLocation { line: 3, column: 24, offset: 74 }..TextLocation { line: 3, column: 27, offset: 77 }) }], err_no: duplicate_symbol } +error: foo: Ambiguous callable symbol. + ┌─ :4:25 + │ +2 │ FUNCTION foo : INT END_FUNCTION + │ --- see also +3 │ +4 │ PROGRAM foo END_PROGRAM + │ ^^^ foo: Ambiguous callable symbol. + +error: foo: Ambiguous callable symbol. + ┌─ :2:25 + │ +2 │ FUNCTION foo : INT END_FUNCTION + │ ^^^ foo: Ambiguous callable symbol. +3 │ +4 │ PROGRAM foo END_PROGRAM + │ --- see also + +error: foo: Duplicate symbol. + ┌─ :2:25 + │ +2 │ FUNCTION foo : INT END_FUNCTION + │ ^^^ foo: Duplicate symbol. +3 │ +4 │ PROGRAM foo END_PROGRAM + │ --- see also +5 │ +6 │ FUNCTION_BLOCK foo END_FUNCTION_BLOCK + │ --- see also + +error: foo: Duplicate symbol. + ┌─ :4:25 + │ +2 │ FUNCTION foo : INT END_FUNCTION + │ --- see also +3 │ +4 │ PROGRAM foo END_PROGRAM + │ ^^^ foo: Duplicate symbol. +5 │ +6 │ FUNCTION_BLOCK foo END_FUNCTION_BLOCK + │ --- see also + +error: foo: Duplicate symbol. + ┌─ :6:25 + │ +2 │ FUNCTION foo : INT END_FUNCTION + │ --- see also +3 │ +4 │ PROGRAM foo END_PROGRAM + │ --- see also +5 │ +6 │ FUNCTION_BLOCK foo END_FUNCTION_BLOCK + │ ^^^ foo: Duplicate symbol. + diff --git a/src/validation/tests/snapshots/rusty__validation__tests__duplicates_validation_test__duplicate_variables_in_same_pou.snap b/src/validation/tests/snapshots/rusty__validation__tests__duplicates_validation_test__duplicate_variables_in_same_pou.snap index 6ff406b2ee..79e0882c2e 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__duplicates_validation_test__duplicate_variables_in_same_pou.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__duplicates_validation_test__duplicate_variables_in_same_pou.snap @@ -1,7 +1,23 @@ --- source: src/validation/tests/duplicates_validation_test.rs -expression: res +expression: "&diagnostics" --- -SyntaxError { message: "prg.b: Duplicate symbol.", range: [SourceLocation { span: Range(TextLocation { line: 4, column: 12, offset: 65 }..TextLocation { line: 4, column: 13, offset: 66 }) }, SourceLocation { span: Range(TextLocation { line: 8, column: 12, offset: 133 }..TextLocation { line: 8, column: 13, offset: 134 }) }], err_no: duplicate_symbol } -SyntaxError { message: "prg.b: Duplicate symbol.", range: [SourceLocation { span: Range(TextLocation { line: 8, column: 12, offset: 133 }..TextLocation { line: 8, column: 13, offset: 134 }) }, SourceLocation { span: Range(TextLocation { line: 4, column: 12, offset: 65 }..TextLocation { line: 4, column: 13, offset: 66 }) }], err_no: duplicate_symbol } +error: prg.b: Duplicate symbol. + ┌─ :5:13 + │ +5 │ b: INT; + │ ^ prg.b: Duplicate symbol. + · +9 │ b: BOOL; + │ - see also + +error: prg.b: Duplicate symbol. + ┌─ :9:13 + │ +5 │ b: INT; + │ - see also + · +9 │ b: BOOL; + │ ^ prg.b: Duplicate symbol. + diff --git a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_bit_does_not_allow_chars.snap b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_bit_does_not_allow_chars.snap index e6b58999b4..020ab54286 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_bit_does_not_allow_chars.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_bit_does_not_allow_chars.snap @@ -1,9 +1,29 @@ --- source: src/validation/tests/generic_validation_tests.rs -expression: res +expression: "&diagnostics" --- -SyntaxError { message: "Invalid assignment: cannot assign 'CHAR' to 'BOOL'", range: [SourceLocation { span: Range(TextLocation { line: 2, column: 57, offset: 137 }..TextLocation { line: 2, column: 58, offset: 138 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid type nature for generic argument. CHAR is no Bit.", range: [SourceLocation { span: Range(TextLocation { line: 2, column: 57, offset: 137 }..TextLocation { line: 2, column: 58, offset: 138 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid assignment: cannot assign 'WCHAR' to 'BOOL'", range: [SourceLocation { span: Range(TextLocation { line: 3, column: 58, offset: 212 }..TextLocation { line: 3, column: 59, offset: 213 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid type nature for generic argument. WCHAR is no Bit.", range: [SourceLocation { span: Range(TextLocation { line: 3, column: 58, offset: 212 }..TextLocation { line: 3, column: 59, offset: 213 }) }], err_no: type__invalid_nature } +error: Invalid assignment: cannot assign 'CHAR' to 'BOOL' + ┌─ :3:58 + │ +3 │ FUNCTION func1 : INT VAR x : CHAR; END_VAR test(x); END_FUNCTION + │ ^ Invalid assignment: cannot assign 'CHAR' to 'BOOL' + +error: Invalid type nature for generic argument. CHAR is no Bit. + ┌─ :3:58 + │ +3 │ FUNCTION func1 : INT VAR x : CHAR; END_VAR test(x); END_FUNCTION + │ ^ Invalid type nature for generic argument. CHAR is no Bit. + +error: Invalid assignment: cannot assign 'WCHAR' to 'BOOL' + ┌─ :4:59 + │ +4 │ FUNCTION func2 : INT VAR x : WCHAR; END_VAR test(x); END_FUNCTION + │ ^ Invalid assignment: cannot assign 'WCHAR' to 'BOOL' + +error: Invalid type nature for generic argument. WCHAR is no Bit. + ┌─ :4:59 + │ +4 │ FUNCTION func2 : INT VAR x : WCHAR; END_VAR test(x); END_FUNCTION + │ ^ Invalid type nature for generic argument. WCHAR is no Bit. + diff --git a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_bit_does_not_allow_date.snap b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_bit_does_not_allow_date.snap index 237bef9b7c..7227a62e07 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_bit_does_not_allow_date.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_bit_does_not_allow_date.snap @@ -1,10 +1,35 @@ --- source: src/validation/tests/generic_validation_tests.rs -expression: res +expression: "&diagnostics" --- -SyntaxError { message: "Invalid type nature for generic argument. DATE_AND_TIME is no Bit.", range: [SourceLocation { span: Range(TextLocation { line: 2, column: 55, offset: 135 }..TextLocation { line: 2, column: 56, offset: 136 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid type nature for generic argument. DATE_AND_TIME is no Bit.", range: [SourceLocation { span: Range(TextLocation { line: 3, column: 56, offset: 208 }..TextLocation { line: 3, column: 57, offset: 209 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid type nature for generic argument. DATE is no Bit.", range: [SourceLocation { span: Range(TextLocation { line: 4, column: 57, offset: 282 }..TextLocation { line: 4, column: 58, offset: 283 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid type nature for generic argument. TIME_OF_DAY is no Bit.", range: [SourceLocation { span: Range(TextLocation { line: 5, column: 56, offset: 355 }..TextLocation { line: 5, column: 57, offset: 356 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid type nature for generic argument. TIME_OF_DAY is no Bit.", range: [SourceLocation { span: Range(TextLocation { line: 6, column: 57, offset: 429 }..TextLocation { line: 6, column: 58, offset: 430 }) }], err_no: type__invalid_nature } +error: Invalid type nature for generic argument. DATE_AND_TIME is no Bit. + ┌─ :3:56 + │ +3 │ FUNCTION func1 : INT VAR x : DT; END_VAR test(x); END_FUNCTION + │ ^ Invalid type nature for generic argument. DATE_AND_TIME is no Bit. + +error: Invalid type nature for generic argument. DATE_AND_TIME is no Bit. + ┌─ :4:57 + │ +4 │ FUNCTION func2 : INT VAR x : LDT; END_VAR test(x); END_FUNCTION + │ ^ Invalid type nature for generic argument. DATE_AND_TIME is no Bit. + +error: Invalid type nature for generic argument. DATE is no Bit. + ┌─ :5:58 + │ +5 │ FUNCTION func3 : INT VAR x : DATE; END_VAR test(x); END_FUNCTION + │ ^ Invalid type nature for generic argument. DATE is no Bit. + +error: Invalid type nature for generic argument. TIME_OF_DAY is no Bit. + ┌─ :6:57 + │ +6 │ FUNCTION func4 : INT VAR x : TOD; END_VAR test(x); END_FUNCTION + │ ^ Invalid type nature for generic argument. TIME_OF_DAY is no Bit. + +error: Invalid type nature for generic argument. TIME_OF_DAY is no Bit. + ┌─ :7:58 + │ +7 │ FUNCTION func5 : INT VAR x : LTOD; END_VAR test(x); END_FUNCTION + │ ^ Invalid type nature for generic argument. TIME_OF_DAY is no Bit. + diff --git a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_bit_does_not_allow_ints.snap b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_bit_does_not_allow_ints.snap index 247d3ad4ba..8341e11c46 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_bit_does_not_allow_ints.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_bit_does_not_allow_ints.snap @@ -1,13 +1,53 @@ --- source: src/validation/tests/generic_validation_tests.rs -expression: res +expression: "&diagnostics" --- -SyntaxError { message: "Invalid type nature for generic argument. USINT is no Bit.", range: [SourceLocation { span: Range(TextLocation { line: 3, column: 58, offset: 139 }..TextLocation { line: 3, column: 59, offset: 140 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid type nature for generic argument. UINT is no Bit.", range: [SourceLocation { span: Range(TextLocation { line: 4, column: 57, offset: 213 }..TextLocation { line: 4, column: 58, offset: 214 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid type nature for generic argument. UDINT is no Bit.", range: [SourceLocation { span: Range(TextLocation { line: 5, column: 58, offset: 288 }..TextLocation { line: 5, column: 59, offset: 289 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid type nature for generic argument. ULINT is no Bit.", range: [SourceLocation { span: Range(TextLocation { line: 6, column: 58, offset: 363 }..TextLocation { line: 6, column: 59, offset: 364 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid type nature for generic argument. SINT is no Bit.", range: [SourceLocation { span: Range(TextLocation { line: 8, column: 57, offset: 438 }..TextLocation { line: 8, column: 58, offset: 439 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid type nature for generic argument. INT is no Bit.", range: [SourceLocation { span: Range(TextLocation { line: 9, column: 56, offset: 511 }..TextLocation { line: 9, column: 57, offset: 512 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid type nature for generic argument. DINT is no Bit.", range: [SourceLocation { span: Range(TextLocation { line: 10, column: 57, offset: 585 }..TextLocation { line: 10, column: 58, offset: 586 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid type nature for generic argument. LINT is no Bit.", range: [SourceLocation { span: Range(TextLocation { line: 11, column: 57, offset: 659 }..TextLocation { line: 11, column: 58, offset: 660 }) }], err_no: type__invalid_nature } +error: Invalid type nature for generic argument. USINT is no Bit. + ┌─ :4:59 + │ +4 │ FUNCTION func1 : INT VAR x : USINT; END_VAR test(x); END_FUNCTION + │ ^ Invalid type nature for generic argument. USINT is no Bit. + +error: Invalid type nature for generic argument. UINT is no Bit. + ┌─ :5:58 + │ +5 │ FUNCTION func2 : INT VAR x : UINT; END_VAR test(x); END_FUNCTION + │ ^ Invalid type nature for generic argument. UINT is no Bit. + +error: Invalid type nature for generic argument. UDINT is no Bit. + ┌─ :6:59 + │ +6 │ FUNCTION func3 : INT VAR x : UDINT; END_VAR test(x); END_FUNCTION + │ ^ Invalid type nature for generic argument. UDINT is no Bit. + +error: Invalid type nature for generic argument. ULINT is no Bit. + ┌─ :7:59 + │ +7 │ FUNCTION func4 : INT VAR x : ULINT; END_VAR test(x); END_FUNCTION + │ ^ Invalid type nature for generic argument. ULINT is no Bit. + +error: Invalid type nature for generic argument. SINT is no Bit. + ┌─ :9:58 + │ +9 │ FUNCTION func5 : INT VAR x : SINT; END_VAR test(x); END_FUNCTION + │ ^ Invalid type nature for generic argument. SINT is no Bit. + +error: Invalid type nature for generic argument. INT is no Bit. + ┌─ :10:57 + │ +10 │ FUNCTION func6 : INT VAR x : INT; END_VAR test(x); END_FUNCTION + │ ^ Invalid type nature for generic argument. INT is no Bit. + +error: Invalid type nature for generic argument. DINT is no Bit. + ┌─ :11:58 + │ +11 │ FUNCTION func7 : INT VAR x : DINT; END_VAR test(x); END_FUNCTION + │ ^ Invalid type nature for generic argument. DINT is no Bit. + +error: Invalid type nature for generic argument. LINT is no Bit. + ┌─ :12:58 + │ +12 │ FUNCTION func8 : INT VAR x : LINT; END_VAR test(x); END_FUNCTION + │ ^ Invalid type nature for generic argument. LINT is no Bit. + diff --git a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_bit_does_not_allow_reals.snap b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_bit_does_not_allow_reals.snap index d23e05d940..4071b5e73e 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_bit_does_not_allow_reals.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_bit_does_not_allow_reals.snap @@ -1,7 +1,17 @@ --- source: src/validation/tests/generic_validation_tests.rs -expression: res +expression: "&diagnostics" --- -SyntaxError { message: "Invalid type nature for generic argument. REAL is no Bit.", range: [SourceLocation { span: Range(TextLocation { line: 2, column: 56, offset: 136 }..TextLocation { line: 2, column: 57, offset: 137 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid type nature for generic argument. LREAL is no Bit.", range: [SourceLocation { span: Range(TextLocation { line: 3, column: 58, offset: 211 }..TextLocation { line: 3, column: 59, offset: 212 }) }], err_no: type__invalid_nature } +error: Invalid type nature for generic argument. REAL is no Bit. + ┌─ :3:57 + │ +3 │ FUNCTION func : INT VAR x : REAL; END_VAR test(x); END_FUNCTION + │ ^ Invalid type nature for generic argument. REAL is no Bit. + +error: Invalid type nature for generic argument. LREAL is no Bit. + ┌─ :4:59 + │ +4 │ FUNCTION func1 : INT VAR x : LREAL; END_VAR test(x); END_FUNCTION + │ ^ Invalid type nature for generic argument. LREAL is no Bit. + diff --git a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_bit_does_not_allow_string.snap b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_bit_does_not_allow_string.snap index 0a311e2dde..dbb485e496 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_bit_does_not_allow_string.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_bit_does_not_allow_string.snap @@ -1,9 +1,29 @@ --- source: src/validation/tests/generic_validation_tests.rs -expression: res +expression: "&diagnostics" --- -SyntaxError { message: "Invalid assignment: cannot assign 'STRING' to 'BOOL'", range: [SourceLocation { span: Range(TextLocation { line: 2, column: 60, offset: 140 }..TextLocation { line: 2, column: 61, offset: 141 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid type nature for generic argument. STRING is no Bit.", range: [SourceLocation { span: Range(TextLocation { line: 2, column: 60, offset: 140 }..TextLocation { line: 2, column: 61, offset: 141 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid assignment: cannot assign 'WSTRING' to 'BOOL'", range: [SourceLocation { span: Range(TextLocation { line: 3, column: 60, offset: 217 }..TextLocation { line: 3, column: 61, offset: 218 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid type nature for generic argument. WSTRING is no Bit.", range: [SourceLocation { span: Range(TextLocation { line: 3, column: 60, offset: 217 }..TextLocation { line: 3, column: 61, offset: 218 }) }], err_no: type__invalid_nature } +error: Invalid assignment: cannot assign 'STRING' to 'BOOL' + ┌─ :3:61 + │ +3 │ FUNCTION func1 : INT VAR x : STRING; END_VAR test(x); END_FUNCTION + │ ^ Invalid assignment: cannot assign 'STRING' to 'BOOL' + +error: Invalid type nature for generic argument. STRING is no Bit. + ┌─ :3:61 + │ +3 │ FUNCTION func1 : INT VAR x : STRING; END_VAR test(x); END_FUNCTION + │ ^ Invalid type nature for generic argument. STRING is no Bit. + +error: Invalid assignment: cannot assign 'WSTRING' to 'BOOL' + ┌─ :4:61 + │ +4 │ FUNCTION func2 : INT VAR x : WSTRING; END_VAR test(x); END_FUNCTION + │ ^ Invalid assignment: cannot assign 'WSTRING' to 'BOOL' + +error: Invalid type nature for generic argument. WSTRING is no Bit. + ┌─ :4:61 + │ +4 │ FUNCTION func2 : INT VAR x : WSTRING; END_VAR test(x); END_FUNCTION + │ ^ Invalid type nature for generic argument. WSTRING is no Bit. + diff --git a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_bit_does_not_allow_time.snap b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_bit_does_not_allow_time.snap index a15b9832f1..24689e2db5 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_bit_does_not_allow_time.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_bit_does_not_allow_time.snap @@ -1,7 +1,17 @@ --- source: src/validation/tests/generic_validation_tests.rs -expression: res +expression: "&diagnostics" --- -SyntaxError { message: "Invalid type nature for generic argument. TIME is no Bit.", range: [SourceLocation { span: Range(TextLocation { line: 2, column: 57, offset: 137 }..TextLocation { line: 2, column: 58, offset: 138 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid type nature for generic argument. TIME is no Bit.", range: [SourceLocation { span: Range(TextLocation { line: 3, column: 58, offset: 212 }..TextLocation { line: 3, column: 59, offset: 213 }) }], err_no: type__invalid_nature } +error: Invalid type nature for generic argument. TIME is no Bit. + ┌─ :3:58 + │ +3 │ FUNCTION func1 : INT VAR x : TIME; END_VAR test(x); END_FUNCTION + │ ^ Invalid type nature for generic argument. TIME is no Bit. + +error: Invalid type nature for generic argument. TIME is no Bit. + ┌─ :4:59 + │ +4 │ FUNCTION func2 : INT VAR x : LTIME; END_VAR test(x); END_FUNCTION + │ ^ Invalid type nature for generic argument. TIME is no Bit. + diff --git a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_bit_multiple_parameters.snap b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_bit_multiple_parameters.snap index e305ff16fa..11905946ad 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_bit_multiple_parameters.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_bit_multiple_parameters.snap @@ -1,14 +1,59 @@ --- source: src/validation/tests/generic_validation_tests.rs -expression: res +expression: "&diagnostics" --- -SyntaxError { message: "Invalid type nature for generic argument. REAL is no Bit.", range: [SourceLocation { span: Range(TextLocation { line: 14, column: 13, offset: 429 }..TextLocation { line: 14, column: 21, offset: 437 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid type nature for generic argument. UDINT is no Bit.", range: [SourceLocation { span: Range(TextLocation { line: 14, column: 23, offset: 439 }..TextLocation { line: 14, column: 35, offset: 451 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid type nature for generic argument. DINT is no Bit.", range: [SourceLocation { span: Range(TextLocation { line: 14, column: 37, offset: 453 }..TextLocation { line: 14, column: 47, offset: 463 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid type nature for generic argument. TIME is no Bit.", range: [SourceLocation { span: Range(TextLocation { line: 14, column: 49, offset: 465 }..TextLocation { line: 14, column: 57, offset: 473 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid assignment: cannot assign 'STRING' to 'BYTE'", range: [SourceLocation { span: Range(TextLocation { line: 14, column: 69, offset: 485 }..TextLocation { line: 14, column: 76, offset: 492 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid type nature for generic argument. STRING is no Bit.", range: [SourceLocation { span: Range(TextLocation { line: 14, column: 69, offset: 485 }..TextLocation { line: 14, column: 76, offset: 492 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid assignment: cannot assign 'CHAR' to 'BYTE'", range: [SourceLocation { span: Range(TextLocation { line: 14, column: 78, offset: 494 }..TextLocation { line: 14, column: 86, offset: 502 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid type nature for generic argument. CHAR is no Bit.", range: [SourceLocation { span: Range(TextLocation { line: 14, column: 78, offset: 494 }..TextLocation { line: 14, column: 86, offset: 502 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid type nature for generic argument. DATE is no Bit.", range: [SourceLocation { span: Range(TextLocation { line: 14, column: 88, offset: 504 }..TextLocation { line: 14, column: 96, offset: 512 }) }], err_no: type__invalid_nature } +error: Invalid type nature for generic argument. REAL is no Bit. + ┌─ :15:14 + │ +15 │ func(var_real, var_unsigned, var_signed, var_time, var_byte, var_str, var_char, var_date); + │ ^^^^^^^^ Invalid type nature for generic argument. REAL is no Bit. + +error: Invalid type nature for generic argument. UDINT is no Bit. + ┌─ :15:24 + │ +15 │ func(var_real, var_unsigned, var_signed, var_time, var_byte, var_str, var_char, var_date); + │ ^^^^^^^^^^^^ Invalid type nature for generic argument. UDINT is no Bit. + +error: Invalid type nature for generic argument. DINT is no Bit. + ┌─ :15:38 + │ +15 │ func(var_real, var_unsigned, var_signed, var_time, var_byte, var_str, var_char, var_date); + │ ^^^^^^^^^^ Invalid type nature for generic argument. DINT is no Bit. + +error: Invalid type nature for generic argument. TIME is no Bit. + ┌─ :15:50 + │ +15 │ func(var_real, var_unsigned, var_signed, var_time, var_byte, var_str, var_char, var_date); + │ ^^^^^^^^ Invalid type nature for generic argument. TIME is no Bit. + +error: Invalid assignment: cannot assign 'STRING' to 'BYTE' + ┌─ :15:70 + │ +15 │ func(var_real, var_unsigned, var_signed, var_time, var_byte, var_str, var_char, var_date); + │ ^^^^^^^ Invalid assignment: cannot assign 'STRING' to 'BYTE' + +error: Invalid type nature for generic argument. STRING is no Bit. + ┌─ :15:70 + │ +15 │ func(var_real, var_unsigned, var_signed, var_time, var_byte, var_str, var_char, var_date); + │ ^^^^^^^ Invalid type nature for generic argument. STRING is no Bit. + +error: Invalid assignment: cannot assign 'CHAR' to 'BYTE' + ┌─ :15:79 + │ +15 │ func(var_real, var_unsigned, var_signed, var_time, var_byte, var_str, var_char, var_date); + │ ^^^^^^^^ Invalid assignment: cannot assign 'CHAR' to 'BYTE' + +error: Invalid type nature for generic argument. CHAR is no Bit. + ┌─ :15:79 + │ +15 │ func(var_real, var_unsigned, var_signed, var_time, var_byte, var_str, var_char, var_date); + │ ^^^^^^^^ Invalid type nature for generic argument. CHAR is no Bit. + +error: Invalid type nature for generic argument. DATE is no Bit. + ┌─ :15:89 + │ +15 │ func(var_real, var_unsigned, var_signed, var_time, var_byte, var_str, var_char, var_date); + │ ^^^^^^^^ Invalid type nature for generic argument. DATE is no Bit. + diff --git a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_char_does_not_allow_bits.snap b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_char_does_not_allow_bits.snap index a9179b1af6..b17146fe1e 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_char_does_not_allow_bits.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_char_does_not_allow_bits.snap @@ -1,15 +1,65 @@ --- source: src/validation/tests/generic_validation_tests.rs -expression: res +expression: "&diagnostics" --- -SyntaxError { message: "Invalid assignment: cannot assign 'BOOL' to 'CHAR'", range: [SourceLocation { span: Range(TextLocation { line: 2, column: 57, offset: 138 }..TextLocation { line: 2, column: 58, offset: 139 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid type nature for generic argument. BOOL is no Char.", range: [SourceLocation { span: Range(TextLocation { line: 2, column: 57, offset: 138 }..TextLocation { line: 2, column: 58, offset: 139 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid assignment: cannot assign 'BYTE' to 'CHAR'", range: [SourceLocation { span: Range(TextLocation { line: 3, column: 57, offset: 212 }..TextLocation { line: 3, column: 58, offset: 213 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid type nature for generic argument. BYTE is no Char.", range: [SourceLocation { span: Range(TextLocation { line: 3, column: 57, offset: 212 }..TextLocation { line: 3, column: 58, offset: 213 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid assignment: cannot assign 'WORD' to 'CHAR'", range: [SourceLocation { span: Range(TextLocation { line: 4, column: 57, offset: 286 }..TextLocation { line: 4, column: 58, offset: 287 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid type nature for generic argument. WORD is no Char.", range: [SourceLocation { span: Range(TextLocation { line: 4, column: 57, offset: 286 }..TextLocation { line: 4, column: 58, offset: 287 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid assignment: cannot assign 'DWORD' to 'CHAR'", range: [SourceLocation { span: Range(TextLocation { line: 5, column: 58, offset: 361 }..TextLocation { line: 5, column: 59, offset: 362 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid type nature for generic argument. DWORD is no Char.", range: [SourceLocation { span: Range(TextLocation { line: 5, column: 58, offset: 361 }..TextLocation { line: 5, column: 59, offset: 362 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid assignment: cannot assign 'LWORD' to 'CHAR'", range: [SourceLocation { span: Range(TextLocation { line: 6, column: 58, offset: 436 }..TextLocation { line: 6, column: 59, offset: 437 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid type nature for generic argument. LWORD is no Char.", range: [SourceLocation { span: Range(TextLocation { line: 6, column: 58, offset: 436 }..TextLocation { line: 6, column: 59, offset: 437 }) }], err_no: type__invalid_nature } +error: Invalid assignment: cannot assign 'BOOL' to 'CHAR' + ┌─ :3:58 + │ +3 │ FUNCTION func1 : INT VAR x : BOOL; END_VAR test(x); END_FUNCTION + │ ^ Invalid assignment: cannot assign 'BOOL' to 'CHAR' + +error: Invalid type nature for generic argument. BOOL is no Char. + ┌─ :3:58 + │ +3 │ FUNCTION func1 : INT VAR x : BOOL; END_VAR test(x); END_FUNCTION + │ ^ Invalid type nature for generic argument. BOOL is no Char. + +error: Invalid assignment: cannot assign 'BYTE' to 'CHAR' + ┌─ :4:58 + │ +4 │ FUNCTION func2 : INT VAR x : BYTE; END_VAR test(x); END_FUNCTION + │ ^ Invalid assignment: cannot assign 'BYTE' to 'CHAR' + +error: Invalid type nature for generic argument. BYTE is no Char. + ┌─ :4:58 + │ +4 │ FUNCTION func2 : INT VAR x : BYTE; END_VAR test(x); END_FUNCTION + │ ^ Invalid type nature for generic argument. BYTE is no Char. + +error: Invalid assignment: cannot assign 'WORD' to 'CHAR' + ┌─ :5:58 + │ +5 │ FUNCTION func3 : INT VAR x : WORD; END_VAR test(x); END_FUNCTION + │ ^ Invalid assignment: cannot assign 'WORD' to 'CHAR' + +error: Invalid type nature for generic argument. WORD is no Char. + ┌─ :5:58 + │ +5 │ FUNCTION func3 : INT VAR x : WORD; END_VAR test(x); END_FUNCTION + │ ^ Invalid type nature for generic argument. WORD is no Char. + +error: Invalid assignment: cannot assign 'DWORD' to 'CHAR' + ┌─ :6:59 + │ +6 │ FUNCTION func4 : INT VAR x : DWORD; END_VAR test(x); END_FUNCTION + │ ^ Invalid assignment: cannot assign 'DWORD' to 'CHAR' + +error: Invalid type nature for generic argument. DWORD is no Char. + ┌─ :6:59 + │ +6 │ FUNCTION func4 : INT VAR x : DWORD; END_VAR test(x); END_FUNCTION + │ ^ Invalid type nature for generic argument. DWORD is no Char. + +error: Invalid assignment: cannot assign 'LWORD' to 'CHAR' + ┌─ :7:59 + │ +7 │ FUNCTION func5 : INT VAR x : LWORD; END_VAR test(x); END_FUNCTION + │ ^ Invalid assignment: cannot assign 'LWORD' to 'CHAR' + +error: Invalid type nature for generic argument. LWORD is no Char. + ┌─ :7:59 + │ +7 │ FUNCTION func5 : INT VAR x : LWORD; END_VAR test(x); END_FUNCTION + │ ^ Invalid type nature for generic argument. LWORD is no Char. + diff --git a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_char_does_not_allow_date.snap b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_char_does_not_allow_date.snap index eff0b3584f..2dcbc188eb 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_char_does_not_allow_date.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_char_does_not_allow_date.snap @@ -1,15 +1,65 @@ --- source: src/validation/tests/generic_validation_tests.rs -expression: res +expression: "&diagnostics" --- -SyntaxError { message: "Invalid assignment: cannot assign 'DATE_AND_TIME' to 'CHAR'", range: [SourceLocation { span: Range(TextLocation { line: 2, column: 55, offset: 136 }..TextLocation { line: 2, column: 56, offset: 137 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid type nature for generic argument. DATE_AND_TIME is no Char.", range: [SourceLocation { span: Range(TextLocation { line: 2, column: 55, offset: 136 }..TextLocation { line: 2, column: 56, offset: 137 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid assignment: cannot assign 'DATE_AND_TIME' to 'CHAR'", range: [SourceLocation { span: Range(TextLocation { line: 3, column: 56, offset: 209 }..TextLocation { line: 3, column: 57, offset: 210 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid type nature for generic argument. DATE_AND_TIME is no Char.", range: [SourceLocation { span: Range(TextLocation { line: 3, column: 56, offset: 209 }..TextLocation { line: 3, column: 57, offset: 210 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid assignment: cannot assign 'DATE' to 'CHAR'", range: [SourceLocation { span: Range(TextLocation { line: 4, column: 57, offset: 283 }..TextLocation { line: 4, column: 58, offset: 284 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid type nature for generic argument. DATE is no Char.", range: [SourceLocation { span: Range(TextLocation { line: 4, column: 57, offset: 283 }..TextLocation { line: 4, column: 58, offset: 284 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid assignment: cannot assign 'TIME_OF_DAY' to 'CHAR'", range: [SourceLocation { span: Range(TextLocation { line: 5, column: 56, offset: 356 }..TextLocation { line: 5, column: 57, offset: 357 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid type nature for generic argument. TIME_OF_DAY is no Char.", range: [SourceLocation { span: Range(TextLocation { line: 5, column: 56, offset: 356 }..TextLocation { line: 5, column: 57, offset: 357 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid assignment: cannot assign 'TIME_OF_DAY' to 'CHAR'", range: [SourceLocation { span: Range(TextLocation { line: 6, column: 57, offset: 430 }..TextLocation { line: 6, column: 58, offset: 431 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid type nature for generic argument. TIME_OF_DAY is no Char.", range: [SourceLocation { span: Range(TextLocation { line: 6, column: 57, offset: 430 }..TextLocation { line: 6, column: 58, offset: 431 }) }], err_no: type__invalid_nature } +error: Invalid assignment: cannot assign 'DATE_AND_TIME' to 'CHAR' + ┌─ :3:56 + │ +3 │ FUNCTION func1 : INT VAR x : DT; END_VAR test(x); END_FUNCTION + │ ^ Invalid assignment: cannot assign 'DATE_AND_TIME' to 'CHAR' + +error: Invalid type nature for generic argument. DATE_AND_TIME is no Char. + ┌─ :3:56 + │ +3 │ FUNCTION func1 : INT VAR x : DT; END_VAR test(x); END_FUNCTION + │ ^ Invalid type nature for generic argument. DATE_AND_TIME is no Char. + +error: Invalid assignment: cannot assign 'DATE_AND_TIME' to 'CHAR' + ┌─ :4:57 + │ +4 │ FUNCTION func2 : INT VAR x : LDT; END_VAR test(x); END_FUNCTION + │ ^ Invalid assignment: cannot assign 'DATE_AND_TIME' to 'CHAR' + +error: Invalid type nature for generic argument. DATE_AND_TIME is no Char. + ┌─ :4:57 + │ +4 │ FUNCTION func2 : INT VAR x : LDT; END_VAR test(x); END_FUNCTION + │ ^ Invalid type nature for generic argument. DATE_AND_TIME is no Char. + +error: Invalid assignment: cannot assign 'DATE' to 'CHAR' + ┌─ :5:58 + │ +5 │ FUNCTION func3 : INT VAR x : DATE; END_VAR test(x); END_FUNCTION + │ ^ Invalid assignment: cannot assign 'DATE' to 'CHAR' + +error: Invalid type nature for generic argument. DATE is no Char. + ┌─ :5:58 + │ +5 │ FUNCTION func3 : INT VAR x : DATE; END_VAR test(x); END_FUNCTION + │ ^ Invalid type nature for generic argument. DATE is no Char. + +error: Invalid assignment: cannot assign 'TIME_OF_DAY' to 'CHAR' + ┌─ :6:57 + │ +6 │ FUNCTION func4 : INT VAR x : TOD; END_VAR test(x); END_FUNCTION + │ ^ Invalid assignment: cannot assign 'TIME_OF_DAY' to 'CHAR' + +error: Invalid type nature for generic argument. TIME_OF_DAY is no Char. + ┌─ :6:57 + │ +6 │ FUNCTION func4 : INT VAR x : TOD; END_VAR test(x); END_FUNCTION + │ ^ Invalid type nature for generic argument. TIME_OF_DAY is no Char. + +error: Invalid assignment: cannot assign 'TIME_OF_DAY' to 'CHAR' + ┌─ :7:58 + │ +7 │ FUNCTION func5 : INT VAR x : LTOD; END_VAR test(x); END_FUNCTION + │ ^ Invalid assignment: cannot assign 'TIME_OF_DAY' to 'CHAR' + +error: Invalid type nature for generic argument. TIME_OF_DAY is no Char. + ┌─ :7:58 + │ +7 │ FUNCTION func5 : INT VAR x : LTOD; END_VAR test(x); END_FUNCTION + │ ^ Invalid type nature for generic argument. TIME_OF_DAY is no Char. + diff --git a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_char_does_not_allow_ints.snap b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_char_does_not_allow_ints.snap index 989627379e..ef1540f3e9 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_char_does_not_allow_ints.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_char_does_not_allow_ints.snap @@ -1,21 +1,101 @@ --- source: src/validation/tests/generic_validation_tests.rs -expression: res +expression: "&diagnostics" --- -SyntaxError { message: "Invalid assignment: cannot assign 'USINT' to 'CHAR'", range: [SourceLocation { span: Range(TextLocation { line: 3, column: 58, offset: 140 }..TextLocation { line: 3, column: 59, offset: 141 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid type nature for generic argument. USINT is no Char.", range: [SourceLocation { span: Range(TextLocation { line: 3, column: 58, offset: 140 }..TextLocation { line: 3, column: 59, offset: 141 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid assignment: cannot assign 'UINT' to 'CHAR'", range: [SourceLocation { span: Range(TextLocation { line: 4, column: 57, offset: 214 }..TextLocation { line: 4, column: 58, offset: 215 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid type nature for generic argument. UINT is no Char.", range: [SourceLocation { span: Range(TextLocation { line: 4, column: 57, offset: 214 }..TextLocation { line: 4, column: 58, offset: 215 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid assignment: cannot assign 'UDINT' to 'CHAR'", range: [SourceLocation { span: Range(TextLocation { line: 5, column: 58, offset: 289 }..TextLocation { line: 5, column: 59, offset: 290 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid type nature for generic argument. UDINT is no Char.", range: [SourceLocation { span: Range(TextLocation { line: 5, column: 58, offset: 289 }..TextLocation { line: 5, column: 59, offset: 290 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid assignment: cannot assign 'ULINT' to 'CHAR'", range: [SourceLocation { span: Range(TextLocation { line: 6, column: 58, offset: 364 }..TextLocation { line: 6, column: 59, offset: 365 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid type nature for generic argument. ULINT is no Char.", range: [SourceLocation { span: Range(TextLocation { line: 6, column: 58, offset: 364 }..TextLocation { line: 6, column: 59, offset: 365 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid assignment: cannot assign 'SINT' to 'CHAR'", range: [SourceLocation { span: Range(TextLocation { line: 8, column: 57, offset: 439 }..TextLocation { line: 8, column: 58, offset: 440 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid type nature for generic argument. SINT is no Char.", range: [SourceLocation { span: Range(TextLocation { line: 8, column: 57, offset: 439 }..TextLocation { line: 8, column: 58, offset: 440 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid assignment: cannot assign 'INT' to 'CHAR'", range: [SourceLocation { span: Range(TextLocation { line: 9, column: 56, offset: 512 }..TextLocation { line: 9, column: 57, offset: 513 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid type nature for generic argument. INT is no Char.", range: [SourceLocation { span: Range(TextLocation { line: 9, column: 56, offset: 512 }..TextLocation { line: 9, column: 57, offset: 513 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid assignment: cannot assign 'DINT' to 'CHAR'", range: [SourceLocation { span: Range(TextLocation { line: 10, column: 57, offset: 586 }..TextLocation { line: 10, column: 58, offset: 587 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid type nature for generic argument. DINT is no Char.", range: [SourceLocation { span: Range(TextLocation { line: 10, column: 57, offset: 586 }..TextLocation { line: 10, column: 58, offset: 587 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid assignment: cannot assign 'LINT' to 'CHAR'", range: [SourceLocation { span: Range(TextLocation { line: 11, column: 57, offset: 660 }..TextLocation { line: 11, column: 58, offset: 661 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid type nature for generic argument. LINT is no Char.", range: [SourceLocation { span: Range(TextLocation { line: 11, column: 57, offset: 660 }..TextLocation { line: 11, column: 58, offset: 661 }) }], err_no: type__invalid_nature } +error: Invalid assignment: cannot assign 'USINT' to 'CHAR' + ┌─ :4:59 + │ +4 │ FUNCTION func1 : INT VAR x : USINT; END_VAR test(x); END_FUNCTION + │ ^ Invalid assignment: cannot assign 'USINT' to 'CHAR' + +error: Invalid type nature for generic argument. USINT is no Char. + ┌─ :4:59 + │ +4 │ FUNCTION func1 : INT VAR x : USINT; END_VAR test(x); END_FUNCTION + │ ^ Invalid type nature for generic argument. USINT is no Char. + +error: Invalid assignment: cannot assign 'UINT' to 'CHAR' + ┌─ :5:58 + │ +5 │ FUNCTION func2 : INT VAR x : UINT; END_VAR test(x); END_FUNCTION + │ ^ Invalid assignment: cannot assign 'UINT' to 'CHAR' + +error: Invalid type nature for generic argument. UINT is no Char. + ┌─ :5:58 + │ +5 │ FUNCTION func2 : INT VAR x : UINT; END_VAR test(x); END_FUNCTION + │ ^ Invalid type nature for generic argument. UINT is no Char. + +error: Invalid assignment: cannot assign 'UDINT' to 'CHAR' + ┌─ :6:59 + │ +6 │ FUNCTION func3 : INT VAR x : UDINT; END_VAR test(x); END_FUNCTION + │ ^ Invalid assignment: cannot assign 'UDINT' to 'CHAR' + +error: Invalid type nature for generic argument. UDINT is no Char. + ┌─ :6:59 + │ +6 │ FUNCTION func3 : INT VAR x : UDINT; END_VAR test(x); END_FUNCTION + │ ^ Invalid type nature for generic argument. UDINT is no Char. + +error: Invalid assignment: cannot assign 'ULINT' to 'CHAR' + ┌─ :7:59 + │ +7 │ FUNCTION func4 : INT VAR x : ULINT; END_VAR test(x); END_FUNCTION + │ ^ Invalid assignment: cannot assign 'ULINT' to 'CHAR' + +error: Invalid type nature for generic argument. ULINT is no Char. + ┌─ :7:59 + │ +7 │ FUNCTION func4 : INT VAR x : ULINT; END_VAR test(x); END_FUNCTION + │ ^ Invalid type nature for generic argument. ULINT is no Char. + +error: Invalid assignment: cannot assign 'SINT' to 'CHAR' + ┌─ :9:58 + │ +9 │ FUNCTION func5 : INT VAR x : SINT; END_VAR test(x); END_FUNCTION + │ ^ Invalid assignment: cannot assign 'SINT' to 'CHAR' + +error: Invalid type nature for generic argument. SINT is no Char. + ┌─ :9:58 + │ +9 │ FUNCTION func5 : INT VAR x : SINT; END_VAR test(x); END_FUNCTION + │ ^ Invalid type nature for generic argument. SINT is no Char. + +error: Invalid assignment: cannot assign 'INT' to 'CHAR' + ┌─ :10:57 + │ +10 │ FUNCTION func6 : INT VAR x : INT; END_VAR test(x); END_FUNCTION + │ ^ Invalid assignment: cannot assign 'INT' to 'CHAR' + +error: Invalid type nature for generic argument. INT is no Char. + ┌─ :10:57 + │ +10 │ FUNCTION func6 : INT VAR x : INT; END_VAR test(x); END_FUNCTION + │ ^ Invalid type nature for generic argument. INT is no Char. + +error: Invalid assignment: cannot assign 'DINT' to 'CHAR' + ┌─ :11:58 + │ +11 │ FUNCTION func7 : INT VAR x : DINT; END_VAR test(x); END_FUNCTION + │ ^ Invalid assignment: cannot assign 'DINT' to 'CHAR' + +error: Invalid type nature for generic argument. DINT is no Char. + ┌─ :11:58 + │ +11 │ FUNCTION func7 : INT VAR x : DINT; END_VAR test(x); END_FUNCTION + │ ^ Invalid type nature for generic argument. DINT is no Char. + +error: Invalid assignment: cannot assign 'LINT' to 'CHAR' + ┌─ :12:58 + │ +12 │ FUNCTION func8 : INT VAR x : LINT; END_VAR test(x); END_FUNCTION + │ ^ Invalid assignment: cannot assign 'LINT' to 'CHAR' + +error: Invalid type nature for generic argument. LINT is no Char. + ┌─ :12:58 + │ +12 │ FUNCTION func8 : INT VAR x : LINT; END_VAR test(x); END_FUNCTION + │ ^ Invalid type nature for generic argument. LINT is no Char. + diff --git a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_char_does_not_allow_reals.snap b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_char_does_not_allow_reals.snap index 95a1f1698e..9603ae431e 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_char_does_not_allow_reals.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_char_does_not_allow_reals.snap @@ -1,9 +1,29 @@ --- source: src/validation/tests/generic_validation_tests.rs -expression: res +expression: "&diagnostics" --- -SyntaxError { message: "Invalid assignment: cannot assign 'REAL' to 'CHAR'", range: [SourceLocation { span: Range(TextLocation { line: 2, column: 56, offset: 137 }..TextLocation { line: 2, column: 57, offset: 138 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid type nature for generic argument. REAL is no Char.", range: [SourceLocation { span: Range(TextLocation { line: 2, column: 56, offset: 137 }..TextLocation { line: 2, column: 57, offset: 138 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid assignment: cannot assign 'LREAL' to 'CHAR'", range: [SourceLocation { span: Range(TextLocation { line: 3, column: 58, offset: 212 }..TextLocation { line: 3, column: 59, offset: 213 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid type nature for generic argument. LREAL is no Char.", range: [SourceLocation { span: Range(TextLocation { line: 3, column: 58, offset: 212 }..TextLocation { line: 3, column: 59, offset: 213 }) }], err_no: type__invalid_nature } +error: Invalid assignment: cannot assign 'REAL' to 'CHAR' + ┌─ :3:57 + │ +3 │ FUNCTION func : INT VAR x : REAL; END_VAR test(x); END_FUNCTION + │ ^ Invalid assignment: cannot assign 'REAL' to 'CHAR' + +error: Invalid type nature for generic argument. REAL is no Char. + ┌─ :3:57 + │ +3 │ FUNCTION func : INT VAR x : REAL; END_VAR test(x); END_FUNCTION + │ ^ Invalid type nature for generic argument. REAL is no Char. + +error: Invalid assignment: cannot assign 'LREAL' to 'CHAR' + ┌─ :4:59 + │ +4 │ FUNCTION func1 : INT VAR x : LREAL; END_VAR test(x); END_FUNCTION + │ ^ Invalid assignment: cannot assign 'LREAL' to 'CHAR' + +error: Invalid type nature for generic argument. LREAL is no Char. + ┌─ :4:59 + │ +4 │ FUNCTION func1 : INT VAR x : LREAL; END_VAR test(x); END_FUNCTION + │ ^ Invalid type nature for generic argument. LREAL is no Char. + diff --git a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_char_does_not_allow_string.snap b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_char_does_not_allow_string.snap index c3e0aea0ee..735004186f 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_char_does_not_allow_string.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_char_does_not_allow_string.snap @@ -1,9 +1,29 @@ --- source: src/validation/tests/generic_validation_tests.rs -expression: res +expression: "&diagnostics" --- -SyntaxError { message: "Invalid assignment: cannot assign 'STRING' to 'CHAR'", range: [SourceLocation { span: Range(TextLocation { line: 2, column: 60, offset: 141 }..TextLocation { line: 2, column: 61, offset: 142 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid type nature for generic argument. STRING is no Char.", range: [SourceLocation { span: Range(TextLocation { line: 2, column: 60, offset: 141 }..TextLocation { line: 2, column: 61, offset: 142 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid assignment: cannot assign 'WSTRING' to 'CHAR'", range: [SourceLocation { span: Range(TextLocation { line: 3, column: 60, offset: 218 }..TextLocation { line: 3, column: 61, offset: 219 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid type nature for generic argument. WSTRING is no Char.", range: [SourceLocation { span: Range(TextLocation { line: 3, column: 60, offset: 218 }..TextLocation { line: 3, column: 61, offset: 219 }) }], err_no: type__invalid_nature } +error: Invalid assignment: cannot assign 'STRING' to 'CHAR' + ┌─ :3:61 + │ +3 │ FUNCTION func1 : INT VAR x : STRING; END_VAR test(x); END_FUNCTION + │ ^ Invalid assignment: cannot assign 'STRING' to 'CHAR' + +error: Invalid type nature for generic argument. STRING is no Char. + ┌─ :3:61 + │ +3 │ FUNCTION func1 : INT VAR x : STRING; END_VAR test(x); END_FUNCTION + │ ^ Invalid type nature for generic argument. STRING is no Char. + +error: Invalid assignment: cannot assign 'WSTRING' to 'CHAR' + ┌─ :4:61 + │ +4 │ FUNCTION func2 : INT VAR x : WSTRING; END_VAR test(x); END_FUNCTION + │ ^ Invalid assignment: cannot assign 'WSTRING' to 'CHAR' + +error: Invalid type nature for generic argument. WSTRING is no Char. + ┌─ :4:61 + │ +4 │ FUNCTION func2 : INT VAR x : WSTRING; END_VAR test(x); END_FUNCTION + │ ^ Invalid type nature for generic argument. WSTRING is no Char. + diff --git a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_char_does_not_allow_time.snap b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_char_does_not_allow_time.snap index 0683c8046c..9b128886f5 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_char_does_not_allow_time.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_char_does_not_allow_time.snap @@ -1,9 +1,29 @@ --- source: src/validation/tests/generic_validation_tests.rs -expression: res +expression: "&diagnostics" --- -SyntaxError { message: "Invalid assignment: cannot assign 'TIME' to 'CHAR'", range: [SourceLocation { span: Range(TextLocation { line: 2, column: 57, offset: 138 }..TextLocation { line: 2, column: 58, offset: 139 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid type nature for generic argument. TIME is no Char.", range: [SourceLocation { span: Range(TextLocation { line: 2, column: 57, offset: 138 }..TextLocation { line: 2, column: 58, offset: 139 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid assignment: cannot assign 'TIME' to 'CHAR'", range: [SourceLocation { span: Range(TextLocation { line: 3, column: 58, offset: 213 }..TextLocation { line: 3, column: 59, offset: 214 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid type nature for generic argument. TIME is no Char.", range: [SourceLocation { span: Range(TextLocation { line: 3, column: 58, offset: 213 }..TextLocation { line: 3, column: 59, offset: 214 }) }], err_no: type__invalid_nature } +error: Invalid assignment: cannot assign 'TIME' to 'CHAR' + ┌─ :3:58 + │ +3 │ FUNCTION func1 : INT VAR x : TIME; END_VAR test(x); END_FUNCTION + │ ^ Invalid assignment: cannot assign 'TIME' to 'CHAR' + +error: Invalid type nature for generic argument. TIME is no Char. + ┌─ :3:58 + │ +3 │ FUNCTION func1 : INT VAR x : TIME; END_VAR test(x); END_FUNCTION + │ ^ Invalid type nature for generic argument. TIME is no Char. + +error: Invalid assignment: cannot assign 'TIME' to 'CHAR' + ┌─ :4:59 + │ +4 │ FUNCTION func2 : INT VAR x : LTIME; END_VAR test(x); END_FUNCTION + │ ^ Invalid assignment: cannot assign 'TIME' to 'CHAR' + +error: Invalid type nature for generic argument. TIME is no Char. + ┌─ :4:59 + │ +4 │ FUNCTION func2 : INT VAR x : LTIME; END_VAR test(x); END_FUNCTION + │ ^ Invalid type nature for generic argument. TIME is no Char. + diff --git a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_char_multiple_parameters.snap b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_char_multiple_parameters.snap index 3a3d8c0549..69d138b214 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_char_multiple_parameters.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_char_multiple_parameters.snap @@ -1,19 +1,89 @@ --- source: src/validation/tests/generic_validation_tests.rs -expression: res +expression: "&diagnostics" --- -SyntaxError { message: "Invalid assignment: cannot assign 'REAL' to 'CHAR'", range: [SourceLocation { span: Range(TextLocation { line: 14, column: 13, offset: 430 }..TextLocation { line: 14, column: 21, offset: 438 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid type nature for generic argument. REAL is no Char.", range: [SourceLocation { span: Range(TextLocation { line: 14, column: 13, offset: 430 }..TextLocation { line: 14, column: 21, offset: 438 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid assignment: cannot assign 'UDINT' to 'CHAR'", range: [SourceLocation { span: Range(TextLocation { line: 14, column: 23, offset: 440 }..TextLocation { line: 14, column: 35, offset: 452 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid type nature for generic argument. UDINT is no Char.", range: [SourceLocation { span: Range(TextLocation { line: 14, column: 23, offset: 440 }..TextLocation { line: 14, column: 35, offset: 452 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid assignment: cannot assign 'DINT' to 'CHAR'", range: [SourceLocation { span: Range(TextLocation { line: 14, column: 37, offset: 454 }..TextLocation { line: 14, column: 47, offset: 464 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid type nature for generic argument. DINT is no Char.", range: [SourceLocation { span: Range(TextLocation { line: 14, column: 37, offset: 454 }..TextLocation { line: 14, column: 47, offset: 464 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid assignment: cannot assign 'TIME' to 'CHAR'", range: [SourceLocation { span: Range(TextLocation { line: 14, column: 49, offset: 466 }..TextLocation { line: 14, column: 57, offset: 474 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid type nature for generic argument. TIME is no Char.", range: [SourceLocation { span: Range(TextLocation { line: 14, column: 49, offset: 466 }..TextLocation { line: 14, column: 57, offset: 474 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid assignment: cannot assign 'BYTE' to 'CHAR'", range: [SourceLocation { span: Range(TextLocation { line: 14, column: 59, offset: 476 }..TextLocation { line: 14, column: 67, offset: 484 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid type nature for generic argument. BYTE is no Char.", range: [SourceLocation { span: Range(TextLocation { line: 14, column: 59, offset: 476 }..TextLocation { line: 14, column: 67, offset: 484 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid assignment: cannot assign 'STRING' to 'CHAR'", range: [SourceLocation { span: Range(TextLocation { line: 14, column: 69, offset: 486 }..TextLocation { line: 14, column: 76, offset: 493 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid type nature for generic argument. STRING is no Char.", range: [SourceLocation { span: Range(TextLocation { line: 14, column: 69, offset: 486 }..TextLocation { line: 14, column: 76, offset: 493 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid assignment: cannot assign 'DATE' to 'CHAR'", range: [SourceLocation { span: Range(TextLocation { line: 14, column: 88, offset: 505 }..TextLocation { line: 14, column: 96, offset: 513 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid type nature for generic argument. DATE is no Char.", range: [SourceLocation { span: Range(TextLocation { line: 14, column: 88, offset: 505 }..TextLocation { line: 14, column: 96, offset: 513 }) }], err_no: type__invalid_nature } +error: Invalid assignment: cannot assign 'REAL' to 'CHAR' + ┌─ :15:14 + │ +15 │ func(var_real, var_unsigned, var_signed, var_time, var_byte, var_str, var_char, var_date); + │ ^^^^^^^^ Invalid assignment: cannot assign 'REAL' to 'CHAR' + +error: Invalid type nature for generic argument. REAL is no Char. + ┌─ :15:14 + │ +15 │ func(var_real, var_unsigned, var_signed, var_time, var_byte, var_str, var_char, var_date); + │ ^^^^^^^^ Invalid type nature for generic argument. REAL is no Char. + +error: Invalid assignment: cannot assign 'UDINT' to 'CHAR' + ┌─ :15:24 + │ +15 │ func(var_real, var_unsigned, var_signed, var_time, var_byte, var_str, var_char, var_date); + │ ^^^^^^^^^^^^ Invalid assignment: cannot assign 'UDINT' to 'CHAR' + +error: Invalid type nature for generic argument. UDINT is no Char. + ┌─ :15:24 + │ +15 │ func(var_real, var_unsigned, var_signed, var_time, var_byte, var_str, var_char, var_date); + │ ^^^^^^^^^^^^ Invalid type nature for generic argument. UDINT is no Char. + +error: Invalid assignment: cannot assign 'DINT' to 'CHAR' + ┌─ :15:38 + │ +15 │ func(var_real, var_unsigned, var_signed, var_time, var_byte, var_str, var_char, var_date); + │ ^^^^^^^^^^ Invalid assignment: cannot assign 'DINT' to 'CHAR' + +error: Invalid type nature for generic argument. DINT is no Char. + ┌─ :15:38 + │ +15 │ func(var_real, var_unsigned, var_signed, var_time, var_byte, var_str, var_char, var_date); + │ ^^^^^^^^^^ Invalid type nature for generic argument. DINT is no Char. + +error: Invalid assignment: cannot assign 'TIME' to 'CHAR' + ┌─ :15:50 + │ +15 │ func(var_real, var_unsigned, var_signed, var_time, var_byte, var_str, var_char, var_date); + │ ^^^^^^^^ Invalid assignment: cannot assign 'TIME' to 'CHAR' + +error: Invalid type nature for generic argument. TIME is no Char. + ┌─ :15:50 + │ +15 │ func(var_real, var_unsigned, var_signed, var_time, var_byte, var_str, var_char, var_date); + │ ^^^^^^^^ Invalid type nature for generic argument. TIME is no Char. + +error: Invalid assignment: cannot assign 'BYTE' to 'CHAR' + ┌─ :15:60 + │ +15 │ func(var_real, var_unsigned, var_signed, var_time, var_byte, var_str, var_char, var_date); + │ ^^^^^^^^ Invalid assignment: cannot assign 'BYTE' to 'CHAR' + +error: Invalid type nature for generic argument. BYTE is no Char. + ┌─ :15:60 + │ +15 │ func(var_real, var_unsigned, var_signed, var_time, var_byte, var_str, var_char, var_date); + │ ^^^^^^^^ Invalid type nature for generic argument. BYTE is no Char. + +error: Invalid assignment: cannot assign 'STRING' to 'CHAR' + ┌─ :15:70 + │ +15 │ func(var_real, var_unsigned, var_signed, var_time, var_byte, var_str, var_char, var_date); + │ ^^^^^^^ Invalid assignment: cannot assign 'STRING' to 'CHAR' + +error: Invalid type nature for generic argument. STRING is no Char. + ┌─ :15:70 + │ +15 │ func(var_real, var_unsigned, var_signed, var_time, var_byte, var_str, var_char, var_date); + │ ^^^^^^^ Invalid type nature for generic argument. STRING is no Char. + +error: Invalid assignment: cannot assign 'DATE' to 'CHAR' + ┌─ :15:89 + │ +15 │ func(var_real, var_unsigned, var_signed, var_time, var_byte, var_str, var_char, var_date); + │ ^^^^^^^^ Invalid assignment: cannot assign 'DATE' to 'CHAR' + +error: Invalid type nature for generic argument. DATE is no Char. + ┌─ :15:89 + │ +15 │ func(var_real, var_unsigned, var_signed, var_time, var_byte, var_str, var_char, var_date); + │ ^^^^^^^^ Invalid type nature for generic argument. DATE is no Char. + diff --git a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_chars_does_not_allow_bits.snap b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_chars_does_not_allow_bits.snap index 8b5f560bb7..09e0e945b5 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_chars_does_not_allow_bits.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_chars_does_not_allow_bits.snap @@ -1,15 +1,65 @@ --- source: src/validation/tests/generic_validation_tests.rs -expression: res +expression: "&diagnostics" --- -SyntaxError { message: "Invalid assignment: cannot assign 'BOOL' to 'CHAR'", range: [SourceLocation { span: Range(TextLocation { line: 2, column: 57, offset: 139 }..TextLocation { line: 2, column: 58, offset: 140 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid type nature for generic argument. BOOL is no Chars.", range: [SourceLocation { span: Range(TextLocation { line: 2, column: 57, offset: 139 }..TextLocation { line: 2, column: 58, offset: 140 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid assignment: cannot assign 'BYTE' to 'CHAR'", range: [SourceLocation { span: Range(TextLocation { line: 3, column: 57, offset: 213 }..TextLocation { line: 3, column: 58, offset: 214 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid type nature for generic argument. BYTE is no Chars.", range: [SourceLocation { span: Range(TextLocation { line: 3, column: 57, offset: 213 }..TextLocation { line: 3, column: 58, offset: 214 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid assignment: cannot assign 'WORD' to 'CHAR'", range: [SourceLocation { span: Range(TextLocation { line: 4, column: 57, offset: 287 }..TextLocation { line: 4, column: 58, offset: 288 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid type nature for generic argument. WORD is no Chars.", range: [SourceLocation { span: Range(TextLocation { line: 4, column: 57, offset: 287 }..TextLocation { line: 4, column: 58, offset: 288 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid assignment: cannot assign 'DWORD' to 'CHAR'", range: [SourceLocation { span: Range(TextLocation { line: 5, column: 58, offset: 362 }..TextLocation { line: 5, column: 59, offset: 363 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid type nature for generic argument. DWORD is no Chars.", range: [SourceLocation { span: Range(TextLocation { line: 5, column: 58, offset: 362 }..TextLocation { line: 5, column: 59, offset: 363 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid assignment: cannot assign 'LWORD' to 'CHAR'", range: [SourceLocation { span: Range(TextLocation { line: 6, column: 58, offset: 437 }..TextLocation { line: 6, column: 59, offset: 438 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid type nature for generic argument. LWORD is no Chars.", range: [SourceLocation { span: Range(TextLocation { line: 6, column: 58, offset: 437 }..TextLocation { line: 6, column: 59, offset: 438 }) }], err_no: type__invalid_nature } +error: Invalid assignment: cannot assign 'BOOL' to 'CHAR' + ┌─ :3:58 + │ +3 │ FUNCTION func1 : INT VAR x : BOOL; END_VAR test(x); END_FUNCTION + │ ^ Invalid assignment: cannot assign 'BOOL' to 'CHAR' + +error: Invalid type nature for generic argument. BOOL is no Chars. + ┌─ :3:58 + │ +3 │ FUNCTION func1 : INT VAR x : BOOL; END_VAR test(x); END_FUNCTION + │ ^ Invalid type nature for generic argument. BOOL is no Chars. + +error: Invalid assignment: cannot assign 'BYTE' to 'CHAR' + ┌─ :4:58 + │ +4 │ FUNCTION func2 : INT VAR x : BYTE; END_VAR test(x); END_FUNCTION + │ ^ Invalid assignment: cannot assign 'BYTE' to 'CHAR' + +error: Invalid type nature for generic argument. BYTE is no Chars. + ┌─ :4:58 + │ +4 │ FUNCTION func2 : INT VAR x : BYTE; END_VAR test(x); END_FUNCTION + │ ^ Invalid type nature for generic argument. BYTE is no Chars. + +error: Invalid assignment: cannot assign 'WORD' to 'CHAR' + ┌─ :5:58 + │ +5 │ FUNCTION func3 : INT VAR x : WORD; END_VAR test(x); END_FUNCTION + │ ^ Invalid assignment: cannot assign 'WORD' to 'CHAR' + +error: Invalid type nature for generic argument. WORD is no Chars. + ┌─ :5:58 + │ +5 │ FUNCTION func3 : INT VAR x : WORD; END_VAR test(x); END_FUNCTION + │ ^ Invalid type nature for generic argument. WORD is no Chars. + +error: Invalid assignment: cannot assign 'DWORD' to 'CHAR' + ┌─ :6:59 + │ +6 │ FUNCTION func4 : INT VAR x : DWORD; END_VAR test(x); END_FUNCTION + │ ^ Invalid assignment: cannot assign 'DWORD' to 'CHAR' + +error: Invalid type nature for generic argument. DWORD is no Chars. + ┌─ :6:59 + │ +6 │ FUNCTION func4 : INT VAR x : DWORD; END_VAR test(x); END_FUNCTION + │ ^ Invalid type nature for generic argument. DWORD is no Chars. + +error: Invalid assignment: cannot assign 'LWORD' to 'CHAR' + ┌─ :7:59 + │ +7 │ FUNCTION func5 : INT VAR x : LWORD; END_VAR test(x); END_FUNCTION + │ ^ Invalid assignment: cannot assign 'LWORD' to 'CHAR' + +error: Invalid type nature for generic argument. LWORD is no Chars. + ┌─ :7:59 + │ +7 │ FUNCTION func5 : INT VAR x : LWORD; END_VAR test(x); END_FUNCTION + │ ^ Invalid type nature for generic argument. LWORD is no Chars. + diff --git a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_chars_does_not_allow_date.snap b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_chars_does_not_allow_date.snap index 2d80369825..da583782fd 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_chars_does_not_allow_date.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_chars_does_not_allow_date.snap @@ -1,15 +1,65 @@ --- source: src/validation/tests/generic_validation_tests.rs -expression: res +expression: "&diagnostics" --- -SyntaxError { message: "Invalid assignment: cannot assign 'DATE_AND_TIME' to 'CHAR'", range: [SourceLocation { span: Range(TextLocation { line: 2, column: 55, offset: 137 }..TextLocation { line: 2, column: 56, offset: 138 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid type nature for generic argument. DATE_AND_TIME is no Chars.", range: [SourceLocation { span: Range(TextLocation { line: 2, column: 55, offset: 137 }..TextLocation { line: 2, column: 56, offset: 138 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid assignment: cannot assign 'DATE_AND_TIME' to 'CHAR'", range: [SourceLocation { span: Range(TextLocation { line: 3, column: 56, offset: 210 }..TextLocation { line: 3, column: 57, offset: 211 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid type nature for generic argument. DATE_AND_TIME is no Chars.", range: [SourceLocation { span: Range(TextLocation { line: 3, column: 56, offset: 210 }..TextLocation { line: 3, column: 57, offset: 211 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid assignment: cannot assign 'DATE' to 'CHAR'", range: [SourceLocation { span: Range(TextLocation { line: 4, column: 57, offset: 284 }..TextLocation { line: 4, column: 58, offset: 285 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid type nature for generic argument. DATE is no Chars.", range: [SourceLocation { span: Range(TextLocation { line: 4, column: 57, offset: 284 }..TextLocation { line: 4, column: 58, offset: 285 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid assignment: cannot assign 'TIME_OF_DAY' to 'CHAR'", range: [SourceLocation { span: Range(TextLocation { line: 5, column: 56, offset: 357 }..TextLocation { line: 5, column: 57, offset: 358 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid type nature for generic argument. TIME_OF_DAY is no Chars.", range: [SourceLocation { span: Range(TextLocation { line: 5, column: 56, offset: 357 }..TextLocation { line: 5, column: 57, offset: 358 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid assignment: cannot assign 'TIME_OF_DAY' to 'CHAR'", range: [SourceLocation { span: Range(TextLocation { line: 6, column: 57, offset: 431 }..TextLocation { line: 6, column: 58, offset: 432 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid type nature for generic argument. TIME_OF_DAY is no Chars.", range: [SourceLocation { span: Range(TextLocation { line: 6, column: 57, offset: 431 }..TextLocation { line: 6, column: 58, offset: 432 }) }], err_no: type__invalid_nature } +error: Invalid assignment: cannot assign 'DATE_AND_TIME' to 'CHAR' + ┌─ :3:56 + │ +3 │ FUNCTION func1 : INT VAR x : DT; END_VAR test(x); END_FUNCTION + │ ^ Invalid assignment: cannot assign 'DATE_AND_TIME' to 'CHAR' + +error: Invalid type nature for generic argument. DATE_AND_TIME is no Chars. + ┌─ :3:56 + │ +3 │ FUNCTION func1 : INT VAR x : DT; END_VAR test(x); END_FUNCTION + │ ^ Invalid type nature for generic argument. DATE_AND_TIME is no Chars. + +error: Invalid assignment: cannot assign 'DATE_AND_TIME' to 'CHAR' + ┌─ :4:57 + │ +4 │ FUNCTION func2 : INT VAR x : LDT; END_VAR test(x); END_FUNCTION + │ ^ Invalid assignment: cannot assign 'DATE_AND_TIME' to 'CHAR' + +error: Invalid type nature for generic argument. DATE_AND_TIME is no Chars. + ┌─ :4:57 + │ +4 │ FUNCTION func2 : INT VAR x : LDT; END_VAR test(x); END_FUNCTION + │ ^ Invalid type nature for generic argument. DATE_AND_TIME is no Chars. + +error: Invalid assignment: cannot assign 'DATE' to 'CHAR' + ┌─ :5:58 + │ +5 │ FUNCTION func3 : INT VAR x : DATE; END_VAR test(x); END_FUNCTION + │ ^ Invalid assignment: cannot assign 'DATE' to 'CHAR' + +error: Invalid type nature for generic argument. DATE is no Chars. + ┌─ :5:58 + │ +5 │ FUNCTION func3 : INT VAR x : DATE; END_VAR test(x); END_FUNCTION + │ ^ Invalid type nature for generic argument. DATE is no Chars. + +error: Invalid assignment: cannot assign 'TIME_OF_DAY' to 'CHAR' + ┌─ :6:57 + │ +6 │ FUNCTION func4 : INT VAR x : TOD; END_VAR test(x); END_FUNCTION + │ ^ Invalid assignment: cannot assign 'TIME_OF_DAY' to 'CHAR' + +error: Invalid type nature for generic argument. TIME_OF_DAY is no Chars. + ┌─ :6:57 + │ +6 │ FUNCTION func4 : INT VAR x : TOD; END_VAR test(x); END_FUNCTION + │ ^ Invalid type nature for generic argument. TIME_OF_DAY is no Chars. + +error: Invalid assignment: cannot assign 'TIME_OF_DAY' to 'CHAR' + ┌─ :7:58 + │ +7 │ FUNCTION func5 : INT VAR x : LTOD; END_VAR test(x); END_FUNCTION + │ ^ Invalid assignment: cannot assign 'TIME_OF_DAY' to 'CHAR' + +error: Invalid type nature for generic argument. TIME_OF_DAY is no Chars. + ┌─ :7:58 + │ +7 │ FUNCTION func5 : INT VAR x : LTOD; END_VAR test(x); END_FUNCTION + │ ^ Invalid type nature for generic argument. TIME_OF_DAY is no Chars. + diff --git a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_chars_does_not_allow_ints.snap b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_chars_does_not_allow_ints.snap index f5c8601f0b..5b220a10a7 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_chars_does_not_allow_ints.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_chars_does_not_allow_ints.snap @@ -1,21 +1,101 @@ --- source: src/validation/tests/generic_validation_tests.rs -expression: res +expression: "&diagnostics" --- -SyntaxError { message: "Invalid assignment: cannot assign 'USINT' to 'CHAR'", range: [SourceLocation { span: Range(TextLocation { line: 3, column: 58, offset: 141 }..TextLocation { line: 3, column: 59, offset: 142 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid type nature for generic argument. USINT is no Chars.", range: [SourceLocation { span: Range(TextLocation { line: 3, column: 58, offset: 141 }..TextLocation { line: 3, column: 59, offset: 142 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid assignment: cannot assign 'UINT' to 'CHAR'", range: [SourceLocation { span: Range(TextLocation { line: 4, column: 57, offset: 215 }..TextLocation { line: 4, column: 58, offset: 216 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid type nature for generic argument. UINT is no Chars.", range: [SourceLocation { span: Range(TextLocation { line: 4, column: 57, offset: 215 }..TextLocation { line: 4, column: 58, offset: 216 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid assignment: cannot assign 'UDINT' to 'CHAR'", range: [SourceLocation { span: Range(TextLocation { line: 5, column: 58, offset: 290 }..TextLocation { line: 5, column: 59, offset: 291 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid type nature for generic argument. UDINT is no Chars.", range: [SourceLocation { span: Range(TextLocation { line: 5, column: 58, offset: 290 }..TextLocation { line: 5, column: 59, offset: 291 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid assignment: cannot assign 'ULINT' to 'CHAR'", range: [SourceLocation { span: Range(TextLocation { line: 6, column: 58, offset: 365 }..TextLocation { line: 6, column: 59, offset: 366 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid type nature for generic argument. ULINT is no Chars.", range: [SourceLocation { span: Range(TextLocation { line: 6, column: 58, offset: 365 }..TextLocation { line: 6, column: 59, offset: 366 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid assignment: cannot assign 'SINT' to 'CHAR'", range: [SourceLocation { span: Range(TextLocation { line: 8, column: 57, offset: 440 }..TextLocation { line: 8, column: 58, offset: 441 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid type nature for generic argument. SINT is no Chars.", range: [SourceLocation { span: Range(TextLocation { line: 8, column: 57, offset: 440 }..TextLocation { line: 8, column: 58, offset: 441 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid assignment: cannot assign 'INT' to 'CHAR'", range: [SourceLocation { span: Range(TextLocation { line: 9, column: 56, offset: 513 }..TextLocation { line: 9, column: 57, offset: 514 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid type nature for generic argument. INT is no Chars.", range: [SourceLocation { span: Range(TextLocation { line: 9, column: 56, offset: 513 }..TextLocation { line: 9, column: 57, offset: 514 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid assignment: cannot assign 'DINT' to 'CHAR'", range: [SourceLocation { span: Range(TextLocation { line: 10, column: 57, offset: 587 }..TextLocation { line: 10, column: 58, offset: 588 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid type nature for generic argument. DINT is no Chars.", range: [SourceLocation { span: Range(TextLocation { line: 10, column: 57, offset: 587 }..TextLocation { line: 10, column: 58, offset: 588 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid assignment: cannot assign 'LINT' to 'CHAR'", range: [SourceLocation { span: Range(TextLocation { line: 11, column: 57, offset: 661 }..TextLocation { line: 11, column: 58, offset: 662 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid type nature for generic argument. LINT is no Chars.", range: [SourceLocation { span: Range(TextLocation { line: 11, column: 57, offset: 661 }..TextLocation { line: 11, column: 58, offset: 662 }) }], err_no: type__invalid_nature } +error: Invalid assignment: cannot assign 'USINT' to 'CHAR' + ┌─ :4:59 + │ +4 │ FUNCTION func1 : INT VAR x : USINT; END_VAR test(x); END_FUNCTION + │ ^ Invalid assignment: cannot assign 'USINT' to 'CHAR' + +error: Invalid type nature for generic argument. USINT is no Chars. + ┌─ :4:59 + │ +4 │ FUNCTION func1 : INT VAR x : USINT; END_VAR test(x); END_FUNCTION + │ ^ Invalid type nature for generic argument. USINT is no Chars. + +error: Invalid assignment: cannot assign 'UINT' to 'CHAR' + ┌─ :5:58 + │ +5 │ FUNCTION func2 : INT VAR x : UINT; END_VAR test(x); END_FUNCTION + │ ^ Invalid assignment: cannot assign 'UINT' to 'CHAR' + +error: Invalid type nature for generic argument. UINT is no Chars. + ┌─ :5:58 + │ +5 │ FUNCTION func2 : INT VAR x : UINT; END_VAR test(x); END_FUNCTION + │ ^ Invalid type nature for generic argument. UINT is no Chars. + +error: Invalid assignment: cannot assign 'UDINT' to 'CHAR' + ┌─ :6:59 + │ +6 │ FUNCTION func3 : INT VAR x : UDINT; END_VAR test(x); END_FUNCTION + │ ^ Invalid assignment: cannot assign 'UDINT' to 'CHAR' + +error: Invalid type nature for generic argument. UDINT is no Chars. + ┌─ :6:59 + │ +6 │ FUNCTION func3 : INT VAR x : UDINT; END_VAR test(x); END_FUNCTION + │ ^ Invalid type nature for generic argument. UDINT is no Chars. + +error: Invalid assignment: cannot assign 'ULINT' to 'CHAR' + ┌─ :7:59 + │ +7 │ FUNCTION func4 : INT VAR x : ULINT; END_VAR test(x); END_FUNCTION + │ ^ Invalid assignment: cannot assign 'ULINT' to 'CHAR' + +error: Invalid type nature for generic argument. ULINT is no Chars. + ┌─ :7:59 + │ +7 │ FUNCTION func4 : INT VAR x : ULINT; END_VAR test(x); END_FUNCTION + │ ^ Invalid type nature for generic argument. ULINT is no Chars. + +error: Invalid assignment: cannot assign 'SINT' to 'CHAR' + ┌─ :9:58 + │ +9 │ FUNCTION func5 : INT VAR x : SINT; END_VAR test(x); END_FUNCTION + │ ^ Invalid assignment: cannot assign 'SINT' to 'CHAR' + +error: Invalid type nature for generic argument. SINT is no Chars. + ┌─ :9:58 + │ +9 │ FUNCTION func5 : INT VAR x : SINT; END_VAR test(x); END_FUNCTION + │ ^ Invalid type nature for generic argument. SINT is no Chars. + +error: Invalid assignment: cannot assign 'INT' to 'CHAR' + ┌─ :10:57 + │ +10 │ FUNCTION func6 : INT VAR x : INT; END_VAR test(x); END_FUNCTION + │ ^ Invalid assignment: cannot assign 'INT' to 'CHAR' + +error: Invalid type nature for generic argument. INT is no Chars. + ┌─ :10:57 + │ +10 │ FUNCTION func6 : INT VAR x : INT; END_VAR test(x); END_FUNCTION + │ ^ Invalid type nature for generic argument. INT is no Chars. + +error: Invalid assignment: cannot assign 'DINT' to 'CHAR' + ┌─ :11:58 + │ +11 │ FUNCTION func7 : INT VAR x : DINT; END_VAR test(x); END_FUNCTION + │ ^ Invalid assignment: cannot assign 'DINT' to 'CHAR' + +error: Invalid type nature for generic argument. DINT is no Chars. + ┌─ :11:58 + │ +11 │ FUNCTION func7 : INT VAR x : DINT; END_VAR test(x); END_FUNCTION + │ ^ Invalid type nature for generic argument. DINT is no Chars. + +error: Invalid assignment: cannot assign 'LINT' to 'CHAR' + ┌─ :12:58 + │ +12 │ FUNCTION func8 : INT VAR x : LINT; END_VAR test(x); END_FUNCTION + │ ^ Invalid assignment: cannot assign 'LINT' to 'CHAR' + +error: Invalid type nature for generic argument. LINT is no Chars. + ┌─ :12:58 + │ +12 │ FUNCTION func8 : INT VAR x : LINT; END_VAR test(x); END_FUNCTION + │ ^ Invalid type nature for generic argument. LINT is no Chars. + diff --git a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_chars_does_not_allow_reals.snap b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_chars_does_not_allow_reals.snap index ce5b49fd2b..e5cdb6434e 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_chars_does_not_allow_reals.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_chars_does_not_allow_reals.snap @@ -1,9 +1,29 @@ --- source: src/validation/tests/generic_validation_tests.rs -expression: res +expression: "&diagnostics" --- -SyntaxError { message: "Invalid assignment: cannot assign 'REAL' to 'CHAR'", range: [SourceLocation { span: Range(TextLocation { line: 2, column: 56, offset: 138 }..TextLocation { line: 2, column: 57, offset: 139 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid type nature for generic argument. REAL is no Chars.", range: [SourceLocation { span: Range(TextLocation { line: 2, column: 56, offset: 138 }..TextLocation { line: 2, column: 57, offset: 139 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid assignment: cannot assign 'LREAL' to 'CHAR'", range: [SourceLocation { span: Range(TextLocation { line: 3, column: 58, offset: 213 }..TextLocation { line: 3, column: 59, offset: 214 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid type nature for generic argument. LREAL is no Chars.", range: [SourceLocation { span: Range(TextLocation { line: 3, column: 58, offset: 213 }..TextLocation { line: 3, column: 59, offset: 214 }) }], err_no: type__invalid_nature } +error: Invalid assignment: cannot assign 'REAL' to 'CHAR' + ┌─ :3:57 + │ +3 │ FUNCTION func : INT VAR x : REAL; END_VAR test(x); END_FUNCTION + │ ^ Invalid assignment: cannot assign 'REAL' to 'CHAR' + +error: Invalid type nature for generic argument. REAL is no Chars. + ┌─ :3:57 + │ +3 │ FUNCTION func : INT VAR x : REAL; END_VAR test(x); END_FUNCTION + │ ^ Invalid type nature for generic argument. REAL is no Chars. + +error: Invalid assignment: cannot assign 'LREAL' to 'CHAR' + ┌─ :4:59 + │ +4 │ FUNCTION func1 : INT VAR x : LREAL; END_VAR test(x); END_FUNCTION + │ ^ Invalid assignment: cannot assign 'LREAL' to 'CHAR' + +error: Invalid type nature for generic argument. LREAL is no Chars. + ┌─ :4:59 + │ +4 │ FUNCTION func1 : INT VAR x : LREAL; END_VAR test(x); END_FUNCTION + │ ^ Invalid type nature for generic argument. LREAL is no Chars. + diff --git a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_chars_does_not_allow_time.snap b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_chars_does_not_allow_time.snap index 1c2fceb8c2..db90b9b0e1 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_chars_does_not_allow_time.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_chars_does_not_allow_time.snap @@ -1,9 +1,29 @@ --- source: src/validation/tests/generic_validation_tests.rs -expression: res +expression: "&diagnostics" --- -SyntaxError { message: "Invalid assignment: cannot assign 'TIME' to 'CHAR'", range: [SourceLocation { span: Range(TextLocation { line: 2, column: 57, offset: 139 }..TextLocation { line: 2, column: 58, offset: 140 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid type nature for generic argument. TIME is no Chars.", range: [SourceLocation { span: Range(TextLocation { line: 2, column: 57, offset: 139 }..TextLocation { line: 2, column: 58, offset: 140 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid assignment: cannot assign 'TIME' to 'CHAR'", range: [SourceLocation { span: Range(TextLocation { line: 3, column: 58, offset: 214 }..TextLocation { line: 3, column: 59, offset: 215 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid type nature for generic argument. TIME is no Chars.", range: [SourceLocation { span: Range(TextLocation { line: 3, column: 58, offset: 214 }..TextLocation { line: 3, column: 59, offset: 215 }) }], err_no: type__invalid_nature } +error: Invalid assignment: cannot assign 'TIME' to 'CHAR' + ┌─ :3:58 + │ +3 │ FUNCTION func1 : INT VAR x : TIME; END_VAR test(x); END_FUNCTION + │ ^ Invalid assignment: cannot assign 'TIME' to 'CHAR' + +error: Invalid type nature for generic argument. TIME is no Chars. + ┌─ :3:58 + │ +3 │ FUNCTION func1 : INT VAR x : TIME; END_VAR test(x); END_FUNCTION + │ ^ Invalid type nature for generic argument. TIME is no Chars. + +error: Invalid assignment: cannot assign 'TIME' to 'CHAR' + ┌─ :4:59 + │ +4 │ FUNCTION func2 : INT VAR x : LTIME; END_VAR test(x); END_FUNCTION + │ ^ Invalid assignment: cannot assign 'TIME' to 'CHAR' + +error: Invalid type nature for generic argument. TIME is no Chars. + ┌─ :4:59 + │ +4 │ FUNCTION func2 : INT VAR x : LTIME; END_VAR test(x); END_FUNCTION + │ ^ Invalid type nature for generic argument. TIME is no Chars. + diff --git a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_chars_multiple_parameters.snap b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_chars_multiple_parameters.snap index ee165d8b22..620c8345a4 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_chars_multiple_parameters.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_chars_multiple_parameters.snap @@ -1,18 +1,83 @@ --- source: src/validation/tests/generic_validation_tests.rs -expression: res +expression: "&diagnostics" --- -SyntaxError { message: "Invalid assignment: cannot assign 'REAL' to 'STRING'", range: [SourceLocation { span: Range(TextLocation { line: 14, column: 13, offset: 431 }..TextLocation { line: 14, column: 21, offset: 439 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid type nature for generic argument. REAL is no Chars.", range: [SourceLocation { span: Range(TextLocation { line: 14, column: 13, offset: 431 }..TextLocation { line: 14, column: 21, offset: 439 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid assignment: cannot assign 'UDINT' to 'STRING'", range: [SourceLocation { span: Range(TextLocation { line: 14, column: 23, offset: 441 }..TextLocation { line: 14, column: 35, offset: 453 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid type nature for generic argument. UDINT is no Chars.", range: [SourceLocation { span: Range(TextLocation { line: 14, column: 23, offset: 441 }..TextLocation { line: 14, column: 35, offset: 453 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid assignment: cannot assign 'DINT' to 'STRING'", range: [SourceLocation { span: Range(TextLocation { line: 14, column: 37, offset: 455 }..TextLocation { line: 14, column: 47, offset: 465 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid type nature for generic argument. DINT is no Chars.", range: [SourceLocation { span: Range(TextLocation { line: 14, column: 37, offset: 455 }..TextLocation { line: 14, column: 47, offset: 465 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid assignment: cannot assign 'TIME' to 'STRING'", range: [SourceLocation { span: Range(TextLocation { line: 14, column: 49, offset: 467 }..TextLocation { line: 14, column: 57, offset: 475 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid type nature for generic argument. TIME is no Chars.", range: [SourceLocation { span: Range(TextLocation { line: 14, column: 49, offset: 467 }..TextLocation { line: 14, column: 57, offset: 475 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid assignment: cannot assign 'BYTE' to 'STRING'", range: [SourceLocation { span: Range(TextLocation { line: 14, column: 59, offset: 477 }..TextLocation { line: 14, column: 67, offset: 485 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid type nature for generic argument. BYTE is no Chars.", range: [SourceLocation { span: Range(TextLocation { line: 14, column: 59, offset: 477 }..TextLocation { line: 14, column: 67, offset: 485 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid assignment: cannot assign 'CHAR' to 'STRING'", range: [SourceLocation { span: Range(TextLocation { line: 14, column: 78, offset: 496 }..TextLocation { line: 14, column: 86, offset: 504 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid assignment: cannot assign 'DATE' to 'STRING'", range: [SourceLocation { span: Range(TextLocation { line: 14, column: 88, offset: 506 }..TextLocation { line: 14, column: 96, offset: 514 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid type nature for generic argument. DATE is no Chars.", range: [SourceLocation { span: Range(TextLocation { line: 14, column: 88, offset: 506 }..TextLocation { line: 14, column: 96, offset: 514 }) }], err_no: type__invalid_nature } +error: Invalid assignment: cannot assign 'REAL' to 'STRING' + ┌─ :15:14 + │ +15 │ func(var_real, var_unsigned, var_signed, var_time, var_byte, var_str, var_char, var_date); + │ ^^^^^^^^ Invalid assignment: cannot assign 'REAL' to 'STRING' + +error: Invalid type nature for generic argument. REAL is no Chars. + ┌─ :15:14 + │ +15 │ func(var_real, var_unsigned, var_signed, var_time, var_byte, var_str, var_char, var_date); + │ ^^^^^^^^ Invalid type nature for generic argument. REAL is no Chars. + +error: Invalid assignment: cannot assign 'UDINT' to 'STRING' + ┌─ :15:24 + │ +15 │ func(var_real, var_unsigned, var_signed, var_time, var_byte, var_str, var_char, var_date); + │ ^^^^^^^^^^^^ Invalid assignment: cannot assign 'UDINT' to 'STRING' + +error: Invalid type nature for generic argument. UDINT is no Chars. + ┌─ :15:24 + │ +15 │ func(var_real, var_unsigned, var_signed, var_time, var_byte, var_str, var_char, var_date); + │ ^^^^^^^^^^^^ Invalid type nature for generic argument. UDINT is no Chars. + +error: Invalid assignment: cannot assign 'DINT' to 'STRING' + ┌─ :15:38 + │ +15 │ func(var_real, var_unsigned, var_signed, var_time, var_byte, var_str, var_char, var_date); + │ ^^^^^^^^^^ Invalid assignment: cannot assign 'DINT' to 'STRING' + +error: Invalid type nature for generic argument. DINT is no Chars. + ┌─ :15:38 + │ +15 │ func(var_real, var_unsigned, var_signed, var_time, var_byte, var_str, var_char, var_date); + │ ^^^^^^^^^^ Invalid type nature for generic argument. DINT is no Chars. + +error: Invalid assignment: cannot assign 'TIME' to 'STRING' + ┌─ :15:50 + │ +15 │ func(var_real, var_unsigned, var_signed, var_time, var_byte, var_str, var_char, var_date); + │ ^^^^^^^^ Invalid assignment: cannot assign 'TIME' to 'STRING' + +error: Invalid type nature for generic argument. TIME is no Chars. + ┌─ :15:50 + │ +15 │ func(var_real, var_unsigned, var_signed, var_time, var_byte, var_str, var_char, var_date); + │ ^^^^^^^^ Invalid type nature for generic argument. TIME is no Chars. + +error: Invalid assignment: cannot assign 'BYTE' to 'STRING' + ┌─ :15:60 + │ +15 │ func(var_real, var_unsigned, var_signed, var_time, var_byte, var_str, var_char, var_date); + │ ^^^^^^^^ Invalid assignment: cannot assign 'BYTE' to 'STRING' + +error: Invalid type nature for generic argument. BYTE is no Chars. + ┌─ :15:60 + │ +15 │ func(var_real, var_unsigned, var_signed, var_time, var_byte, var_str, var_char, var_date); + │ ^^^^^^^^ Invalid type nature for generic argument. BYTE is no Chars. + +error: Invalid assignment: cannot assign 'CHAR' to 'STRING' + ┌─ :15:79 + │ +15 │ func(var_real, var_unsigned, var_signed, var_time, var_byte, var_str, var_char, var_date); + │ ^^^^^^^^ Invalid assignment: cannot assign 'CHAR' to 'STRING' + +error: Invalid assignment: cannot assign 'DATE' to 'STRING' + ┌─ :15:89 + │ +15 │ func(var_real, var_unsigned, var_signed, var_time, var_byte, var_str, var_char, var_date); + │ ^^^^^^^^ Invalid assignment: cannot assign 'DATE' to 'STRING' + +error: Invalid type nature for generic argument. DATE is no Chars. + ┌─ :15:89 + │ +15 │ func(var_real, var_unsigned, var_signed, var_time, var_byte, var_str, var_char, var_date); + │ ^^^^^^^^ Invalid type nature for generic argument. DATE is no Chars. + diff --git a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_date_does_not_allow_bits.snap b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_date_does_not_allow_bits.snap index 65ab24f356..6ace8daa12 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_date_does_not_allow_bits.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_date_does_not_allow_bits.snap @@ -1,10 +1,35 @@ --- source: src/validation/tests/generic_validation_tests.rs -expression: res +expression: "&diagnostics" --- -SyntaxError { message: "Invalid type nature for generic argument. BOOL is no Date.", range: [SourceLocation { span: Range(TextLocation { line: 2, column: 57, offset: 138 }..TextLocation { line: 2, column: 58, offset: 139 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid type nature for generic argument. BYTE is no Date.", range: [SourceLocation { span: Range(TextLocation { line: 3, column: 57, offset: 212 }..TextLocation { line: 3, column: 58, offset: 213 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid type nature for generic argument. WORD is no Date.", range: [SourceLocation { span: Range(TextLocation { line: 4, column: 57, offset: 286 }..TextLocation { line: 4, column: 58, offset: 287 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid type nature for generic argument. DWORD is no Date.", range: [SourceLocation { span: Range(TextLocation { line: 5, column: 58, offset: 361 }..TextLocation { line: 5, column: 59, offset: 362 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid type nature for generic argument. LWORD is no Date.", range: [SourceLocation { span: Range(TextLocation { line: 6, column: 58, offset: 436 }..TextLocation { line: 6, column: 59, offset: 437 }) }], err_no: type__invalid_nature } +error: Invalid type nature for generic argument. BOOL is no Date. + ┌─ :3:58 + │ +3 │ FUNCTION func1 : INT VAR x : BOOL; END_VAR test(x); END_FUNCTION + │ ^ Invalid type nature for generic argument. BOOL is no Date. + +error: Invalid type nature for generic argument. BYTE is no Date. + ┌─ :4:58 + │ +4 │ FUNCTION func2 : INT VAR x : BYTE; END_VAR test(x); END_FUNCTION + │ ^ Invalid type nature for generic argument. BYTE is no Date. + +error: Invalid type nature for generic argument. WORD is no Date. + ┌─ :5:58 + │ +5 │ FUNCTION func3 : INT VAR x : WORD; END_VAR test(x); END_FUNCTION + │ ^ Invalid type nature for generic argument. WORD is no Date. + +error: Invalid type nature for generic argument. DWORD is no Date. + ┌─ :6:59 + │ +6 │ FUNCTION func4 : INT VAR x : DWORD; END_VAR test(x); END_FUNCTION + │ ^ Invalid type nature for generic argument. DWORD is no Date. + +error: Invalid type nature for generic argument. LWORD is no Date. + ┌─ :7:59 + │ +7 │ FUNCTION func5 : INT VAR x : LWORD; END_VAR test(x); END_FUNCTION + │ ^ Invalid type nature for generic argument. LWORD is no Date. + diff --git a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_date_does_not_allow_chars.snap b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_date_does_not_allow_chars.snap index 9e8bbce461..d0eac5254d 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_date_does_not_allow_chars.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_date_does_not_allow_chars.snap @@ -1,9 +1,29 @@ --- source: src/validation/tests/generic_validation_tests.rs -expression: res +expression: "&diagnostics" --- -SyntaxError { message: "Invalid assignment: cannot assign 'CHAR' to 'DATE'", range: [SourceLocation { span: Range(TextLocation { line: 2, column: 57, offset: 138 }..TextLocation { line: 2, column: 58, offset: 139 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid type nature for generic argument. CHAR is no Date.", range: [SourceLocation { span: Range(TextLocation { line: 2, column: 57, offset: 138 }..TextLocation { line: 2, column: 58, offset: 139 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid assignment: cannot assign 'WCHAR' to 'DATE'", range: [SourceLocation { span: Range(TextLocation { line: 3, column: 58, offset: 213 }..TextLocation { line: 3, column: 59, offset: 214 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid type nature for generic argument. WCHAR is no Date.", range: [SourceLocation { span: Range(TextLocation { line: 3, column: 58, offset: 213 }..TextLocation { line: 3, column: 59, offset: 214 }) }], err_no: type__invalid_nature } +error: Invalid assignment: cannot assign 'CHAR' to 'DATE' + ┌─ :3:58 + │ +3 │ FUNCTION func1 : INT VAR x : CHAR; END_VAR test(x); END_FUNCTION + │ ^ Invalid assignment: cannot assign 'CHAR' to 'DATE' + +error: Invalid type nature for generic argument. CHAR is no Date. + ┌─ :3:58 + │ +3 │ FUNCTION func1 : INT VAR x : CHAR; END_VAR test(x); END_FUNCTION + │ ^ Invalid type nature for generic argument. CHAR is no Date. + +error: Invalid assignment: cannot assign 'WCHAR' to 'DATE' + ┌─ :4:59 + │ +4 │ FUNCTION func2 : INT VAR x : WCHAR; END_VAR test(x); END_FUNCTION + │ ^ Invalid assignment: cannot assign 'WCHAR' to 'DATE' + +error: Invalid type nature for generic argument. WCHAR is no Date. + ┌─ :4:59 + │ +4 │ FUNCTION func2 : INT VAR x : WCHAR; END_VAR test(x); END_FUNCTION + │ ^ Invalid type nature for generic argument. WCHAR is no Date. + diff --git a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_date_does_not_allow_ints.snap b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_date_does_not_allow_ints.snap index 41fce0ed7d..421908b22a 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_date_does_not_allow_ints.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_date_does_not_allow_ints.snap @@ -1,13 +1,53 @@ --- source: src/validation/tests/generic_validation_tests.rs -expression: res +expression: "&diagnostics" --- -SyntaxError { message: "Invalid type nature for generic argument. USINT is no Date.", range: [SourceLocation { span: Range(TextLocation { line: 3, column: 58, offset: 140 }..TextLocation { line: 3, column: 59, offset: 141 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid type nature for generic argument. UINT is no Date.", range: [SourceLocation { span: Range(TextLocation { line: 4, column: 57, offset: 214 }..TextLocation { line: 4, column: 58, offset: 215 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid type nature for generic argument. UDINT is no Date.", range: [SourceLocation { span: Range(TextLocation { line: 5, column: 58, offset: 289 }..TextLocation { line: 5, column: 59, offset: 290 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid type nature for generic argument. ULINT is no Date.", range: [SourceLocation { span: Range(TextLocation { line: 6, column: 58, offset: 364 }..TextLocation { line: 6, column: 59, offset: 365 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid type nature for generic argument. SINT is no Date.", range: [SourceLocation { span: Range(TextLocation { line: 8, column: 57, offset: 439 }..TextLocation { line: 8, column: 58, offset: 440 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid type nature for generic argument. INT is no Date.", range: [SourceLocation { span: Range(TextLocation { line: 9, column: 56, offset: 512 }..TextLocation { line: 9, column: 57, offset: 513 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid type nature for generic argument. DINT is no Date.", range: [SourceLocation { span: Range(TextLocation { line: 10, column: 57, offset: 586 }..TextLocation { line: 10, column: 58, offset: 587 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid type nature for generic argument. LINT is no Date.", range: [SourceLocation { span: Range(TextLocation { line: 11, column: 57, offset: 660 }..TextLocation { line: 11, column: 58, offset: 661 }) }], err_no: type__invalid_nature } +error: Invalid type nature for generic argument. USINT is no Date. + ┌─ :4:59 + │ +4 │ FUNCTION func1 : INT VAR x : USINT; END_VAR test(x); END_FUNCTION + │ ^ Invalid type nature for generic argument. USINT is no Date. + +error: Invalid type nature for generic argument. UINT is no Date. + ┌─ :5:58 + │ +5 │ FUNCTION func2 : INT VAR x : UINT; END_VAR test(x); END_FUNCTION + │ ^ Invalid type nature for generic argument. UINT is no Date. + +error: Invalid type nature for generic argument. UDINT is no Date. + ┌─ :6:59 + │ +6 │ FUNCTION func3 : INT VAR x : UDINT; END_VAR test(x); END_FUNCTION + │ ^ Invalid type nature for generic argument. UDINT is no Date. + +error: Invalid type nature for generic argument. ULINT is no Date. + ┌─ :7:59 + │ +7 │ FUNCTION func4 : INT VAR x : ULINT; END_VAR test(x); END_FUNCTION + │ ^ Invalid type nature for generic argument. ULINT is no Date. + +error: Invalid type nature for generic argument. SINT is no Date. + ┌─ :9:58 + │ +9 │ FUNCTION func5 : INT VAR x : SINT; END_VAR test(x); END_FUNCTION + │ ^ Invalid type nature for generic argument. SINT is no Date. + +error: Invalid type nature for generic argument. INT is no Date. + ┌─ :10:57 + │ +10 │ FUNCTION func6 : INT VAR x : INT; END_VAR test(x); END_FUNCTION + │ ^ Invalid type nature for generic argument. INT is no Date. + +error: Invalid type nature for generic argument. DINT is no Date. + ┌─ :11:58 + │ +11 │ FUNCTION func7 : INT VAR x : DINT; END_VAR test(x); END_FUNCTION + │ ^ Invalid type nature for generic argument. DINT is no Date. + +error: Invalid type nature for generic argument. LINT is no Date. + ┌─ :12:58 + │ +12 │ FUNCTION func8 : INT VAR x : LINT; END_VAR test(x); END_FUNCTION + │ ^ Invalid type nature for generic argument. LINT is no Date. + diff --git a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_date_does_not_allow_reals.snap b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_date_does_not_allow_reals.snap index ff9da7241a..7cd736402e 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_date_does_not_allow_reals.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_date_does_not_allow_reals.snap @@ -1,7 +1,17 @@ --- source: src/validation/tests/generic_validation_tests.rs -expression: res +expression: "&diagnostics" --- -SyntaxError { message: "Invalid type nature for generic argument. REAL is no Date.", range: [SourceLocation { span: Range(TextLocation { line: 2, column: 56, offset: 137 }..TextLocation { line: 2, column: 57, offset: 138 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid type nature for generic argument. LREAL is no Date.", range: [SourceLocation { span: Range(TextLocation { line: 3, column: 58, offset: 212 }..TextLocation { line: 3, column: 59, offset: 213 }) }], err_no: type__invalid_nature } +error: Invalid type nature for generic argument. REAL is no Date. + ┌─ :3:57 + │ +3 │ FUNCTION func : INT VAR x : REAL; END_VAR test(x); END_FUNCTION + │ ^ Invalid type nature for generic argument. REAL is no Date. + +error: Invalid type nature for generic argument. LREAL is no Date. + ┌─ :4:59 + │ +4 │ FUNCTION func1 : INT VAR x : LREAL; END_VAR test(x); END_FUNCTION + │ ^ Invalid type nature for generic argument. LREAL is no Date. + diff --git a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_date_does_not_allow_string.snap b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_date_does_not_allow_string.snap index fbdacabc2f..2fc7e6a30f 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_date_does_not_allow_string.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_date_does_not_allow_string.snap @@ -1,9 +1,29 @@ --- source: src/validation/tests/generic_validation_tests.rs -expression: res +expression: "&diagnostics" --- -SyntaxError { message: "Invalid assignment: cannot assign 'STRING' to 'DATE'", range: [SourceLocation { span: Range(TextLocation { line: 2, column: 60, offset: 141 }..TextLocation { line: 2, column: 61, offset: 142 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid type nature for generic argument. STRING is no Date.", range: [SourceLocation { span: Range(TextLocation { line: 2, column: 60, offset: 141 }..TextLocation { line: 2, column: 61, offset: 142 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid assignment: cannot assign 'WSTRING' to 'DATE'", range: [SourceLocation { span: Range(TextLocation { line: 3, column: 60, offset: 218 }..TextLocation { line: 3, column: 61, offset: 219 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid type nature for generic argument. WSTRING is no Date.", range: [SourceLocation { span: Range(TextLocation { line: 3, column: 60, offset: 218 }..TextLocation { line: 3, column: 61, offset: 219 }) }], err_no: type__invalid_nature } +error: Invalid assignment: cannot assign 'STRING' to 'DATE' + ┌─ :3:61 + │ +3 │ FUNCTION func1 : INT VAR x : STRING; END_VAR test(x); END_FUNCTION + │ ^ Invalid assignment: cannot assign 'STRING' to 'DATE' + +error: Invalid type nature for generic argument. STRING is no Date. + ┌─ :3:61 + │ +3 │ FUNCTION func1 : INT VAR x : STRING; END_VAR test(x); END_FUNCTION + │ ^ Invalid type nature for generic argument. STRING is no Date. + +error: Invalid assignment: cannot assign 'WSTRING' to 'DATE' + ┌─ :4:61 + │ +4 │ FUNCTION func2 : INT VAR x : WSTRING; END_VAR test(x); END_FUNCTION + │ ^ Invalid assignment: cannot assign 'WSTRING' to 'DATE' + +error: Invalid type nature for generic argument. WSTRING is no Date. + ┌─ :4:61 + │ +4 │ FUNCTION func2 : INT VAR x : WSTRING; END_VAR test(x); END_FUNCTION + │ ^ Invalid type nature for generic argument. WSTRING is no Date. + diff --git a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_date_does_not_allow_time.snap b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_date_does_not_allow_time.snap index 4dd3ed2327..27d315be4f 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_date_does_not_allow_time.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_date_does_not_allow_time.snap @@ -1,7 +1,17 @@ --- source: src/validation/tests/generic_validation_tests.rs -expression: res +expression: "&diagnostics" --- -SyntaxError { message: "Invalid type nature for generic argument. TIME is no Date.", range: [SourceLocation { span: Range(TextLocation { line: 2, column: 57, offset: 138 }..TextLocation { line: 2, column: 58, offset: 139 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid type nature for generic argument. TIME is no Date.", range: [SourceLocation { span: Range(TextLocation { line: 3, column: 58, offset: 213 }..TextLocation { line: 3, column: 59, offset: 214 }) }], err_no: type__invalid_nature } +error: Invalid type nature for generic argument. TIME is no Date. + ┌─ :3:58 + │ +3 │ FUNCTION func1 : INT VAR x : TIME; END_VAR test(x); END_FUNCTION + │ ^ Invalid type nature for generic argument. TIME is no Date. + +error: Invalid type nature for generic argument. TIME is no Date. + ┌─ :4:59 + │ +4 │ FUNCTION func2 : INT VAR x : LTIME; END_VAR test(x); END_FUNCTION + │ ^ Invalid type nature for generic argument. TIME is no Date. + diff --git a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_date_multiple_parameters.snap b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_date_multiple_parameters.snap index 3d7c986c60..ceccf60f90 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_date_multiple_parameters.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_date_multiple_parameters.snap @@ -1,14 +1,59 @@ --- source: src/validation/tests/generic_validation_tests.rs -expression: res +expression: "&diagnostics" --- -SyntaxError { message: "Invalid type nature for generic argument. REAL is no Date.", range: [SourceLocation { span: Range(TextLocation { line: 14, column: 13, offset: 430 }..TextLocation { line: 14, column: 21, offset: 438 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid type nature for generic argument. UDINT is no Date.", range: [SourceLocation { span: Range(TextLocation { line: 14, column: 23, offset: 440 }..TextLocation { line: 14, column: 35, offset: 452 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid type nature for generic argument. DINT is no Date.", range: [SourceLocation { span: Range(TextLocation { line: 14, column: 37, offset: 454 }..TextLocation { line: 14, column: 47, offset: 464 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid type nature for generic argument. TIME is no Date.", range: [SourceLocation { span: Range(TextLocation { line: 14, column: 49, offset: 466 }..TextLocation { line: 14, column: 57, offset: 474 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid type nature for generic argument. BYTE is no Date.", range: [SourceLocation { span: Range(TextLocation { line: 14, column: 59, offset: 476 }..TextLocation { line: 14, column: 67, offset: 484 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid assignment: cannot assign 'STRING' to 'DATE'", range: [SourceLocation { span: Range(TextLocation { line: 14, column: 69, offset: 486 }..TextLocation { line: 14, column: 76, offset: 493 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid type nature for generic argument. STRING is no Date.", range: [SourceLocation { span: Range(TextLocation { line: 14, column: 69, offset: 486 }..TextLocation { line: 14, column: 76, offset: 493 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid assignment: cannot assign 'CHAR' to 'DATE'", range: [SourceLocation { span: Range(TextLocation { line: 14, column: 78, offset: 495 }..TextLocation { line: 14, column: 86, offset: 503 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid type nature for generic argument. CHAR is no Date.", range: [SourceLocation { span: Range(TextLocation { line: 14, column: 78, offset: 495 }..TextLocation { line: 14, column: 86, offset: 503 }) }], err_no: type__invalid_nature } +error: Invalid type nature for generic argument. REAL is no Date. + ┌─ :15:14 + │ +15 │ func(var_real, var_unsigned, var_signed, var_time, var_byte, var_str, var_char, var_date); + │ ^^^^^^^^ Invalid type nature for generic argument. REAL is no Date. + +error: Invalid type nature for generic argument. UDINT is no Date. + ┌─ :15:24 + │ +15 │ func(var_real, var_unsigned, var_signed, var_time, var_byte, var_str, var_char, var_date); + │ ^^^^^^^^^^^^ Invalid type nature for generic argument. UDINT is no Date. + +error: Invalid type nature for generic argument. DINT is no Date. + ┌─ :15:38 + │ +15 │ func(var_real, var_unsigned, var_signed, var_time, var_byte, var_str, var_char, var_date); + │ ^^^^^^^^^^ Invalid type nature for generic argument. DINT is no Date. + +error: Invalid type nature for generic argument. TIME is no Date. + ┌─ :15:50 + │ +15 │ func(var_real, var_unsigned, var_signed, var_time, var_byte, var_str, var_char, var_date); + │ ^^^^^^^^ Invalid type nature for generic argument. TIME is no Date. + +error: Invalid type nature for generic argument. BYTE is no Date. + ┌─ :15:60 + │ +15 │ func(var_real, var_unsigned, var_signed, var_time, var_byte, var_str, var_char, var_date); + │ ^^^^^^^^ Invalid type nature for generic argument. BYTE is no Date. + +error: Invalid assignment: cannot assign 'STRING' to 'DATE' + ┌─ :15:70 + │ +15 │ func(var_real, var_unsigned, var_signed, var_time, var_byte, var_str, var_char, var_date); + │ ^^^^^^^ Invalid assignment: cannot assign 'STRING' to 'DATE' + +error: Invalid type nature for generic argument. STRING is no Date. + ┌─ :15:70 + │ +15 │ func(var_real, var_unsigned, var_signed, var_time, var_byte, var_str, var_char, var_date); + │ ^^^^^^^ Invalid type nature for generic argument. STRING is no Date. + +error: Invalid assignment: cannot assign 'CHAR' to 'DATE' + ┌─ :15:79 + │ +15 │ func(var_real, var_unsigned, var_signed, var_time, var_byte, var_str, var_char, var_date); + │ ^^^^^^^^ Invalid assignment: cannot assign 'CHAR' to 'DATE' + +error: Invalid type nature for generic argument. CHAR is no Date. + ┌─ :15:79 + │ +15 │ func(var_real, var_unsigned, var_signed, var_time, var_byte, var_str, var_char, var_date); + │ ^^^^^^^^ Invalid type nature for generic argument. CHAR is no Date. + diff --git a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_duration_does_not_allow_bits.snap b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_duration_does_not_allow_bits.snap index 4879a7153e..e8ca3d9935 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_duration_does_not_allow_bits.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_duration_does_not_allow_bits.snap @@ -1,10 +1,35 @@ --- source: src/validation/tests/generic_validation_tests.rs -expression: res +expression: "&diagnostics" --- -SyntaxError { message: "Invalid type nature for generic argument. BOOL is no Duration.", range: [SourceLocation { span: Range(TextLocation { line: 2, column: 57, offset: 142 }..TextLocation { line: 2, column: 58, offset: 143 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid type nature for generic argument. BYTE is no Duration.", range: [SourceLocation { span: Range(TextLocation { line: 3, column: 57, offset: 216 }..TextLocation { line: 3, column: 58, offset: 217 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid type nature for generic argument. WORD is no Duration.", range: [SourceLocation { span: Range(TextLocation { line: 4, column: 57, offset: 290 }..TextLocation { line: 4, column: 58, offset: 291 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid type nature for generic argument. DWORD is no Duration.", range: [SourceLocation { span: Range(TextLocation { line: 5, column: 58, offset: 365 }..TextLocation { line: 5, column: 59, offset: 366 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid type nature for generic argument. LWORD is no Duration.", range: [SourceLocation { span: Range(TextLocation { line: 6, column: 58, offset: 440 }..TextLocation { line: 6, column: 59, offset: 441 }) }], err_no: type__invalid_nature } +error: Invalid type nature for generic argument. BOOL is no Duration. + ┌─ :3:58 + │ +3 │ FUNCTION func1 : INT VAR x : BOOL; END_VAR test(x); END_FUNCTION + │ ^ Invalid type nature for generic argument. BOOL is no Duration. + +error: Invalid type nature for generic argument. BYTE is no Duration. + ┌─ :4:58 + │ +4 │ FUNCTION func2 : INT VAR x : BYTE; END_VAR test(x); END_FUNCTION + │ ^ Invalid type nature for generic argument. BYTE is no Duration. + +error: Invalid type nature for generic argument. WORD is no Duration. + ┌─ :5:58 + │ +5 │ FUNCTION func3 : INT VAR x : WORD; END_VAR test(x); END_FUNCTION + │ ^ Invalid type nature for generic argument. WORD is no Duration. + +error: Invalid type nature for generic argument. DWORD is no Duration. + ┌─ :6:59 + │ +6 │ FUNCTION func4 : INT VAR x : DWORD; END_VAR test(x); END_FUNCTION + │ ^ Invalid type nature for generic argument. DWORD is no Duration. + +error: Invalid type nature for generic argument. LWORD is no Duration. + ┌─ :7:59 + │ +7 │ FUNCTION func5 : INT VAR x : LWORD; END_VAR test(x); END_FUNCTION + │ ^ Invalid type nature for generic argument. LWORD is no Duration. + diff --git a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_duration_does_not_allow_chars.snap b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_duration_does_not_allow_chars.snap index c338874d39..2f09f4cc9f 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_duration_does_not_allow_chars.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_duration_does_not_allow_chars.snap @@ -1,9 +1,29 @@ --- source: src/validation/tests/generic_validation_tests.rs -expression: res +expression: "&diagnostics" --- -SyntaxError { message: "Invalid assignment: cannot assign 'CHAR' to 'TIME'", range: [SourceLocation { span: Range(TextLocation { line: 2, column: 57, offset: 142 }..TextLocation { line: 2, column: 58, offset: 143 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid type nature for generic argument. CHAR is no Duration.", range: [SourceLocation { span: Range(TextLocation { line: 2, column: 57, offset: 142 }..TextLocation { line: 2, column: 58, offset: 143 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid assignment: cannot assign 'WCHAR' to 'TIME'", range: [SourceLocation { span: Range(TextLocation { line: 3, column: 58, offset: 217 }..TextLocation { line: 3, column: 59, offset: 218 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid type nature for generic argument. WCHAR is no Duration.", range: [SourceLocation { span: Range(TextLocation { line: 3, column: 58, offset: 217 }..TextLocation { line: 3, column: 59, offset: 218 }) }], err_no: type__invalid_nature } +error: Invalid assignment: cannot assign 'CHAR' to 'TIME' + ┌─ :3:58 + │ +3 │ FUNCTION func1 : INT VAR x : CHAR; END_VAR test(x); END_FUNCTION + │ ^ Invalid assignment: cannot assign 'CHAR' to 'TIME' + +error: Invalid type nature for generic argument. CHAR is no Duration. + ┌─ :3:58 + │ +3 │ FUNCTION func1 : INT VAR x : CHAR; END_VAR test(x); END_FUNCTION + │ ^ Invalid type nature for generic argument. CHAR is no Duration. + +error: Invalid assignment: cannot assign 'WCHAR' to 'TIME' + ┌─ :4:59 + │ +4 │ FUNCTION func2 : INT VAR x : WCHAR; END_VAR test(x); END_FUNCTION + │ ^ Invalid assignment: cannot assign 'WCHAR' to 'TIME' + +error: Invalid type nature for generic argument. WCHAR is no Duration. + ┌─ :4:59 + │ +4 │ FUNCTION func2 : INT VAR x : WCHAR; END_VAR test(x); END_FUNCTION + │ ^ Invalid type nature for generic argument. WCHAR is no Duration. + diff --git a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_duration_does_not_allow_date.snap b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_duration_does_not_allow_date.snap index ee99dbfb04..0e4acd19f3 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_duration_does_not_allow_date.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_duration_does_not_allow_date.snap @@ -1,10 +1,35 @@ --- source: src/validation/tests/generic_validation_tests.rs -expression: res +expression: "&diagnostics" --- -SyntaxError { message: "Invalid type nature for generic argument. DATE_AND_TIME is no Duration.", range: [SourceLocation { span: Range(TextLocation { line: 2, column: 55, offset: 140 }..TextLocation { line: 2, column: 56, offset: 141 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid type nature for generic argument. DATE_AND_TIME is no Duration.", range: [SourceLocation { span: Range(TextLocation { line: 3, column: 56, offset: 213 }..TextLocation { line: 3, column: 57, offset: 214 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid type nature for generic argument. DATE is no Duration.", range: [SourceLocation { span: Range(TextLocation { line: 4, column: 57, offset: 287 }..TextLocation { line: 4, column: 58, offset: 288 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid type nature for generic argument. TIME_OF_DAY is no Duration.", range: [SourceLocation { span: Range(TextLocation { line: 5, column: 56, offset: 360 }..TextLocation { line: 5, column: 57, offset: 361 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid type nature for generic argument. TIME_OF_DAY is no Duration.", range: [SourceLocation { span: Range(TextLocation { line: 6, column: 57, offset: 434 }..TextLocation { line: 6, column: 58, offset: 435 }) }], err_no: type__invalid_nature } +error: Invalid type nature for generic argument. DATE_AND_TIME is no Duration. + ┌─ :3:56 + │ +3 │ FUNCTION func1 : INT VAR x : DT; END_VAR test(x); END_FUNCTION + │ ^ Invalid type nature for generic argument. DATE_AND_TIME is no Duration. + +error: Invalid type nature for generic argument. DATE_AND_TIME is no Duration. + ┌─ :4:57 + │ +4 │ FUNCTION func2 : INT VAR x : LDT; END_VAR test(x); END_FUNCTION + │ ^ Invalid type nature for generic argument. DATE_AND_TIME is no Duration. + +error: Invalid type nature for generic argument. DATE is no Duration. + ┌─ :5:58 + │ +5 │ FUNCTION func3 : INT VAR x : DATE; END_VAR test(x); END_FUNCTION + │ ^ Invalid type nature for generic argument. DATE is no Duration. + +error: Invalid type nature for generic argument. TIME_OF_DAY is no Duration. + ┌─ :6:57 + │ +6 │ FUNCTION func4 : INT VAR x : TOD; END_VAR test(x); END_FUNCTION + │ ^ Invalid type nature for generic argument. TIME_OF_DAY is no Duration. + +error: Invalid type nature for generic argument. TIME_OF_DAY is no Duration. + ┌─ :7:58 + │ +7 │ FUNCTION func5 : INT VAR x : LTOD; END_VAR test(x); END_FUNCTION + │ ^ Invalid type nature for generic argument. TIME_OF_DAY is no Duration. + diff --git a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_duration_does_not_allow_ints.snap b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_duration_does_not_allow_ints.snap index d4123709c4..44ecfd8305 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_duration_does_not_allow_ints.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_duration_does_not_allow_ints.snap @@ -1,13 +1,53 @@ --- source: src/validation/tests/generic_validation_tests.rs -expression: res +expression: "&diagnostics" --- -SyntaxError { message: "Invalid type nature for generic argument. USINT is no Duration.", range: [SourceLocation { span: Range(TextLocation { line: 3, column: 58, offset: 144 }..TextLocation { line: 3, column: 59, offset: 145 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid type nature for generic argument. UINT is no Duration.", range: [SourceLocation { span: Range(TextLocation { line: 4, column: 57, offset: 218 }..TextLocation { line: 4, column: 58, offset: 219 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid type nature for generic argument. UDINT is no Duration.", range: [SourceLocation { span: Range(TextLocation { line: 5, column: 58, offset: 293 }..TextLocation { line: 5, column: 59, offset: 294 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid type nature for generic argument. ULINT is no Duration.", range: [SourceLocation { span: Range(TextLocation { line: 6, column: 58, offset: 368 }..TextLocation { line: 6, column: 59, offset: 369 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid type nature for generic argument. SINT is no Duration.", range: [SourceLocation { span: Range(TextLocation { line: 8, column: 57, offset: 443 }..TextLocation { line: 8, column: 58, offset: 444 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid type nature for generic argument. INT is no Duration.", range: [SourceLocation { span: Range(TextLocation { line: 9, column: 56, offset: 516 }..TextLocation { line: 9, column: 57, offset: 517 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid type nature for generic argument. DINT is no Duration.", range: [SourceLocation { span: Range(TextLocation { line: 10, column: 57, offset: 590 }..TextLocation { line: 10, column: 58, offset: 591 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid type nature for generic argument. LINT is no Duration.", range: [SourceLocation { span: Range(TextLocation { line: 11, column: 57, offset: 664 }..TextLocation { line: 11, column: 58, offset: 665 }) }], err_no: type__invalid_nature } +error: Invalid type nature for generic argument. USINT is no Duration. + ┌─ :4:59 + │ +4 │ FUNCTION func1 : INT VAR x : USINT; END_VAR test(x); END_FUNCTION + │ ^ Invalid type nature for generic argument. USINT is no Duration. + +error: Invalid type nature for generic argument. UINT is no Duration. + ┌─ :5:58 + │ +5 │ FUNCTION func2 : INT VAR x : UINT; END_VAR test(x); END_FUNCTION + │ ^ Invalid type nature for generic argument. UINT is no Duration. + +error: Invalid type nature for generic argument. UDINT is no Duration. + ┌─ :6:59 + │ +6 │ FUNCTION func3 : INT VAR x : UDINT; END_VAR test(x); END_FUNCTION + │ ^ Invalid type nature for generic argument. UDINT is no Duration. + +error: Invalid type nature for generic argument. ULINT is no Duration. + ┌─ :7:59 + │ +7 │ FUNCTION func4 : INT VAR x : ULINT; END_VAR test(x); END_FUNCTION + │ ^ Invalid type nature for generic argument. ULINT is no Duration. + +error: Invalid type nature for generic argument. SINT is no Duration. + ┌─ :9:58 + │ +9 │ FUNCTION func5 : INT VAR x : SINT; END_VAR test(x); END_FUNCTION + │ ^ Invalid type nature for generic argument. SINT is no Duration. + +error: Invalid type nature for generic argument. INT is no Duration. + ┌─ :10:57 + │ +10 │ FUNCTION func6 : INT VAR x : INT; END_VAR test(x); END_FUNCTION + │ ^ Invalid type nature for generic argument. INT is no Duration. + +error: Invalid type nature for generic argument. DINT is no Duration. + ┌─ :11:58 + │ +11 │ FUNCTION func7 : INT VAR x : DINT; END_VAR test(x); END_FUNCTION + │ ^ Invalid type nature for generic argument. DINT is no Duration. + +error: Invalid type nature for generic argument. LINT is no Duration. + ┌─ :12:58 + │ +12 │ FUNCTION func8 : INT VAR x : LINT; END_VAR test(x); END_FUNCTION + │ ^ Invalid type nature for generic argument. LINT is no Duration. + diff --git a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_duration_does_not_allow_reals.snap b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_duration_does_not_allow_reals.snap index 5958d2d4df..e6e156a737 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_duration_does_not_allow_reals.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_duration_does_not_allow_reals.snap @@ -1,7 +1,17 @@ --- source: src/validation/tests/generic_validation_tests.rs -expression: res +expression: "&diagnostics" --- -SyntaxError { message: "Invalid type nature for generic argument. REAL is no Duration.", range: [SourceLocation { span: Range(TextLocation { line: 2, column: 56, offset: 141 }..TextLocation { line: 2, column: 57, offset: 142 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid type nature for generic argument. LREAL is no Duration.", range: [SourceLocation { span: Range(TextLocation { line: 3, column: 58, offset: 216 }..TextLocation { line: 3, column: 59, offset: 217 }) }], err_no: type__invalid_nature } +error: Invalid type nature for generic argument. REAL is no Duration. + ┌─ :3:57 + │ +3 │ FUNCTION func : INT VAR x : REAL; END_VAR test(x); END_FUNCTION + │ ^ Invalid type nature for generic argument. REAL is no Duration. + +error: Invalid type nature for generic argument. LREAL is no Duration. + ┌─ :4:59 + │ +4 │ FUNCTION func1 : INT VAR x : LREAL; END_VAR test(x); END_FUNCTION + │ ^ Invalid type nature for generic argument. LREAL is no Duration. + diff --git a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_duration_does_not_allow_string.snap b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_duration_does_not_allow_string.snap index 416d810d78..d878b01e93 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_duration_does_not_allow_string.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_duration_does_not_allow_string.snap @@ -1,9 +1,29 @@ --- source: src/validation/tests/generic_validation_tests.rs -expression: res +expression: "&diagnostics" --- -SyntaxError { message: "Invalid assignment: cannot assign 'STRING' to 'TIME'", range: [SourceLocation { span: Range(TextLocation { line: 2, column: 60, offset: 145 }..TextLocation { line: 2, column: 61, offset: 146 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid type nature for generic argument. STRING is no Duration.", range: [SourceLocation { span: Range(TextLocation { line: 2, column: 60, offset: 145 }..TextLocation { line: 2, column: 61, offset: 146 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid assignment: cannot assign 'WSTRING' to 'TIME'", range: [SourceLocation { span: Range(TextLocation { line: 3, column: 60, offset: 222 }..TextLocation { line: 3, column: 61, offset: 223 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid type nature for generic argument. WSTRING is no Duration.", range: [SourceLocation { span: Range(TextLocation { line: 3, column: 60, offset: 222 }..TextLocation { line: 3, column: 61, offset: 223 }) }], err_no: type__invalid_nature } +error: Invalid assignment: cannot assign 'STRING' to 'TIME' + ┌─ :3:61 + │ +3 │ FUNCTION func1 : INT VAR x : STRING; END_VAR test(x); END_FUNCTION + │ ^ Invalid assignment: cannot assign 'STRING' to 'TIME' + +error: Invalid type nature for generic argument. STRING is no Duration. + ┌─ :3:61 + │ +3 │ FUNCTION func1 : INT VAR x : STRING; END_VAR test(x); END_FUNCTION + │ ^ Invalid type nature for generic argument. STRING is no Duration. + +error: Invalid assignment: cannot assign 'WSTRING' to 'TIME' + ┌─ :4:61 + │ +4 │ FUNCTION func2 : INT VAR x : WSTRING; END_VAR test(x); END_FUNCTION + │ ^ Invalid assignment: cannot assign 'WSTRING' to 'TIME' + +error: Invalid type nature for generic argument. WSTRING is no Duration. + ┌─ :4:61 + │ +4 │ FUNCTION func2 : INT VAR x : WSTRING; END_VAR test(x); END_FUNCTION + │ ^ Invalid type nature for generic argument. WSTRING is no Duration. + diff --git a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_duration_multiple_parameters.snap b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_duration_multiple_parameters.snap index 0b4b338a11..3679326b2c 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_duration_multiple_parameters.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_duration_multiple_parameters.snap @@ -1,14 +1,59 @@ --- source: src/validation/tests/generic_validation_tests.rs -expression: res +expression: "&diagnostics" --- -SyntaxError { message: "Invalid type nature for generic argument. REAL is no Duration.", range: [SourceLocation { span: Range(TextLocation { line: 14, column: 13, offset: 434 }..TextLocation { line: 14, column: 21, offset: 442 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid type nature for generic argument. UDINT is no Duration.", range: [SourceLocation { span: Range(TextLocation { line: 14, column: 23, offset: 444 }..TextLocation { line: 14, column: 35, offset: 456 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid type nature for generic argument. DINT is no Duration.", range: [SourceLocation { span: Range(TextLocation { line: 14, column: 37, offset: 458 }..TextLocation { line: 14, column: 47, offset: 468 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid type nature for generic argument. BYTE is no Duration.", range: [SourceLocation { span: Range(TextLocation { line: 14, column: 59, offset: 480 }..TextLocation { line: 14, column: 67, offset: 488 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid assignment: cannot assign 'STRING' to 'TIME'", range: [SourceLocation { span: Range(TextLocation { line: 14, column: 69, offset: 490 }..TextLocation { line: 14, column: 76, offset: 497 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid type nature for generic argument. STRING is no Duration.", range: [SourceLocation { span: Range(TextLocation { line: 14, column: 69, offset: 490 }..TextLocation { line: 14, column: 76, offset: 497 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid assignment: cannot assign 'CHAR' to 'TIME'", range: [SourceLocation { span: Range(TextLocation { line: 14, column: 78, offset: 499 }..TextLocation { line: 14, column: 86, offset: 507 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid type nature for generic argument. CHAR is no Duration.", range: [SourceLocation { span: Range(TextLocation { line: 14, column: 78, offset: 499 }..TextLocation { line: 14, column: 86, offset: 507 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid type nature for generic argument. DATE is no Duration.", range: [SourceLocation { span: Range(TextLocation { line: 14, column: 88, offset: 509 }..TextLocation { line: 14, column: 96, offset: 517 }) }], err_no: type__invalid_nature } +error: Invalid type nature for generic argument. REAL is no Duration. + ┌─ :15:14 + │ +15 │ func(var_real, var_unsigned, var_signed, var_time, var_byte, var_str, var_char, var_date); + │ ^^^^^^^^ Invalid type nature for generic argument. REAL is no Duration. + +error: Invalid type nature for generic argument. UDINT is no Duration. + ┌─ :15:24 + │ +15 │ func(var_real, var_unsigned, var_signed, var_time, var_byte, var_str, var_char, var_date); + │ ^^^^^^^^^^^^ Invalid type nature for generic argument. UDINT is no Duration. + +error: Invalid type nature for generic argument. DINT is no Duration. + ┌─ :15:38 + │ +15 │ func(var_real, var_unsigned, var_signed, var_time, var_byte, var_str, var_char, var_date); + │ ^^^^^^^^^^ Invalid type nature for generic argument. DINT is no Duration. + +error: Invalid type nature for generic argument. BYTE is no Duration. + ┌─ :15:60 + │ +15 │ func(var_real, var_unsigned, var_signed, var_time, var_byte, var_str, var_char, var_date); + │ ^^^^^^^^ Invalid type nature for generic argument. BYTE is no Duration. + +error: Invalid assignment: cannot assign 'STRING' to 'TIME' + ┌─ :15:70 + │ +15 │ func(var_real, var_unsigned, var_signed, var_time, var_byte, var_str, var_char, var_date); + │ ^^^^^^^ Invalid assignment: cannot assign 'STRING' to 'TIME' + +error: Invalid type nature for generic argument. STRING is no Duration. + ┌─ :15:70 + │ +15 │ func(var_real, var_unsigned, var_signed, var_time, var_byte, var_str, var_char, var_date); + │ ^^^^^^^ Invalid type nature for generic argument. STRING is no Duration. + +error: Invalid assignment: cannot assign 'CHAR' to 'TIME' + ┌─ :15:79 + │ +15 │ func(var_real, var_unsigned, var_signed, var_time, var_byte, var_str, var_char, var_date); + │ ^^^^^^^^ Invalid assignment: cannot assign 'CHAR' to 'TIME' + +error: Invalid type nature for generic argument. CHAR is no Duration. + ┌─ :15:79 + │ +15 │ func(var_real, var_unsigned, var_signed, var_time, var_byte, var_str, var_char, var_date); + │ ^^^^^^^^ Invalid type nature for generic argument. CHAR is no Duration. + +error: Invalid type nature for generic argument. DATE is no Duration. + ┌─ :15:89 + │ +15 │ func(var_real, var_unsigned, var_signed, var_time, var_byte, var_str, var_char, var_date); + │ ^^^^^^^^ Invalid type nature for generic argument. DATE is no Duration. + diff --git a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_int_does_not_allow_bits.snap b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_int_does_not_allow_bits.snap index e4892529d3..43419695c2 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_int_does_not_allow_bits.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_int_does_not_allow_bits.snap @@ -1,10 +1,35 @@ --- source: src/validation/tests/generic_validation_tests.rs -expression: res +expression: "&diagnostics" --- -SyntaxError { message: "Invalid type nature for generic argument. BOOL is no Int.", range: [SourceLocation { span: Range(TextLocation { line: 2, column: 57, offset: 137 }..TextLocation { line: 2, column: 58, offset: 138 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid type nature for generic argument. BYTE is no Int.", range: [SourceLocation { span: Range(TextLocation { line: 3, column: 57, offset: 211 }..TextLocation { line: 3, column: 58, offset: 212 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid type nature for generic argument. WORD is no Int.", range: [SourceLocation { span: Range(TextLocation { line: 4, column: 57, offset: 285 }..TextLocation { line: 4, column: 58, offset: 286 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid type nature for generic argument. DWORD is no Int.", range: [SourceLocation { span: Range(TextLocation { line: 5, column: 58, offset: 360 }..TextLocation { line: 5, column: 59, offset: 361 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid type nature for generic argument. LWORD is no Int.", range: [SourceLocation { span: Range(TextLocation { line: 6, column: 58, offset: 435 }..TextLocation { line: 6, column: 59, offset: 436 }) }], err_no: type__invalid_nature } +error: Invalid type nature for generic argument. BOOL is no Int. + ┌─ :3:58 + │ +3 │ FUNCTION func1 : INT VAR x : BOOL; END_VAR test(x); END_FUNCTION + │ ^ Invalid type nature for generic argument. BOOL is no Int. + +error: Invalid type nature for generic argument. BYTE is no Int. + ┌─ :4:58 + │ +4 │ FUNCTION func2 : INT VAR x : BYTE; END_VAR test(x); END_FUNCTION + │ ^ Invalid type nature for generic argument. BYTE is no Int. + +error: Invalid type nature for generic argument. WORD is no Int. + ┌─ :5:58 + │ +5 │ FUNCTION func3 : INT VAR x : WORD; END_VAR test(x); END_FUNCTION + │ ^ Invalid type nature for generic argument. WORD is no Int. + +error: Invalid type nature for generic argument. DWORD is no Int. + ┌─ :6:59 + │ +6 │ FUNCTION func4 : INT VAR x : DWORD; END_VAR test(x); END_FUNCTION + │ ^ Invalid type nature for generic argument. DWORD is no Int. + +error: Invalid type nature for generic argument. LWORD is no Int. + ┌─ :7:59 + │ +7 │ FUNCTION func5 : INT VAR x : LWORD; END_VAR test(x); END_FUNCTION + │ ^ Invalid type nature for generic argument. LWORD is no Int. + diff --git a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_int_does_not_allow_chars.snap b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_int_does_not_allow_chars.snap index f02d63128b..3f964e6123 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_int_does_not_allow_chars.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_int_does_not_allow_chars.snap @@ -1,9 +1,29 @@ --- source: src/validation/tests/generic_validation_tests.rs -expression: res +expression: "&diagnostics" --- -SyntaxError { message: "Invalid assignment: cannot assign 'CHAR' to 'USINT'", range: [SourceLocation { span: Range(TextLocation { line: 2, column: 57, offset: 137 }..TextLocation { line: 2, column: 58, offset: 138 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid type nature for generic argument. CHAR is no Int.", range: [SourceLocation { span: Range(TextLocation { line: 2, column: 57, offset: 137 }..TextLocation { line: 2, column: 58, offset: 138 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid assignment: cannot assign 'WCHAR' to 'USINT'", range: [SourceLocation { span: Range(TextLocation { line: 3, column: 58, offset: 212 }..TextLocation { line: 3, column: 59, offset: 213 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid type nature for generic argument. WCHAR is no Int.", range: [SourceLocation { span: Range(TextLocation { line: 3, column: 58, offset: 212 }..TextLocation { line: 3, column: 59, offset: 213 }) }], err_no: type__invalid_nature } +error: Invalid assignment: cannot assign 'CHAR' to 'USINT' + ┌─ :3:58 + │ +3 │ FUNCTION func1 : INT VAR x : CHAR; END_VAR test(x); END_FUNCTION + │ ^ Invalid assignment: cannot assign 'CHAR' to 'USINT' + +error: Invalid type nature for generic argument. CHAR is no Int. + ┌─ :3:58 + │ +3 │ FUNCTION func1 : INT VAR x : CHAR; END_VAR test(x); END_FUNCTION + │ ^ Invalid type nature for generic argument. CHAR is no Int. + +error: Invalid assignment: cannot assign 'WCHAR' to 'USINT' + ┌─ :4:59 + │ +4 │ FUNCTION func2 : INT VAR x : WCHAR; END_VAR test(x); END_FUNCTION + │ ^ Invalid assignment: cannot assign 'WCHAR' to 'USINT' + +error: Invalid type nature for generic argument. WCHAR is no Int. + ┌─ :4:59 + │ +4 │ FUNCTION func2 : INT VAR x : WCHAR; END_VAR test(x); END_FUNCTION + │ ^ Invalid type nature for generic argument. WCHAR is no Int. + diff --git a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_int_does_not_allow_date.snap b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_int_does_not_allow_date.snap index 7805d19cbe..27e18918e7 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_int_does_not_allow_date.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_int_does_not_allow_date.snap @@ -1,10 +1,35 @@ --- source: src/validation/tests/generic_validation_tests.rs -expression: res +expression: "&diagnostics" --- -SyntaxError { message: "Invalid type nature for generic argument. DATE_AND_TIME is no Int.", range: [SourceLocation { span: Range(TextLocation { line: 2, column: 55, offset: 135 }..TextLocation { line: 2, column: 56, offset: 136 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid type nature for generic argument. DATE_AND_TIME is no Int.", range: [SourceLocation { span: Range(TextLocation { line: 3, column: 56, offset: 208 }..TextLocation { line: 3, column: 57, offset: 209 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid type nature for generic argument. DATE is no Int.", range: [SourceLocation { span: Range(TextLocation { line: 4, column: 57, offset: 282 }..TextLocation { line: 4, column: 58, offset: 283 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid type nature for generic argument. TIME_OF_DAY is no Int.", range: [SourceLocation { span: Range(TextLocation { line: 5, column: 56, offset: 355 }..TextLocation { line: 5, column: 57, offset: 356 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid type nature for generic argument. TIME_OF_DAY is no Int.", range: [SourceLocation { span: Range(TextLocation { line: 6, column: 57, offset: 429 }..TextLocation { line: 6, column: 58, offset: 430 }) }], err_no: type__invalid_nature } +error: Invalid type nature for generic argument. DATE_AND_TIME is no Int. + ┌─ :3:56 + │ +3 │ FUNCTION func1 : INT VAR x : DT; END_VAR test(x); END_FUNCTION + │ ^ Invalid type nature for generic argument. DATE_AND_TIME is no Int. + +error: Invalid type nature for generic argument. DATE_AND_TIME is no Int. + ┌─ :4:57 + │ +4 │ FUNCTION func2 : INT VAR x : LDT; END_VAR test(x); END_FUNCTION + │ ^ Invalid type nature for generic argument. DATE_AND_TIME is no Int. + +error: Invalid type nature for generic argument. DATE is no Int. + ┌─ :5:58 + │ +5 │ FUNCTION func3 : INT VAR x : DATE; END_VAR test(x); END_FUNCTION + │ ^ Invalid type nature for generic argument. DATE is no Int. + +error: Invalid type nature for generic argument. TIME_OF_DAY is no Int. + ┌─ :6:57 + │ +6 │ FUNCTION func4 : INT VAR x : TOD; END_VAR test(x); END_FUNCTION + │ ^ Invalid type nature for generic argument. TIME_OF_DAY is no Int. + +error: Invalid type nature for generic argument. TIME_OF_DAY is no Int. + ┌─ :7:58 + │ +7 │ FUNCTION func5 : INT VAR x : LTOD; END_VAR test(x); END_FUNCTION + │ ^ Invalid type nature for generic argument. TIME_OF_DAY is no Int. + diff --git a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_int_does_not_allow_reals.snap b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_int_does_not_allow_reals.snap index 4892ddb7cb..017e924c29 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_int_does_not_allow_reals.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_int_does_not_allow_reals.snap @@ -1,7 +1,17 @@ --- source: src/validation/tests/generic_validation_tests.rs -expression: res +expression: "&diagnostics" --- -SyntaxError { message: "Invalid type nature for generic argument. REAL is no Int.", range: [SourceLocation { span: Range(TextLocation { line: 2, column: 56, offset: 136 }..TextLocation { line: 2, column: 57, offset: 137 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid type nature for generic argument. LREAL is no Int.", range: [SourceLocation { span: Range(TextLocation { line: 3, column: 58, offset: 211 }..TextLocation { line: 3, column: 59, offset: 212 }) }], err_no: type__invalid_nature } +error: Invalid type nature for generic argument. REAL is no Int. + ┌─ :3:57 + │ +3 │ FUNCTION func : INT VAR x : REAL; END_VAR test(x); END_FUNCTION + │ ^ Invalid type nature for generic argument. REAL is no Int. + +error: Invalid type nature for generic argument. LREAL is no Int. + ┌─ :4:59 + │ +4 │ FUNCTION func1 : INT VAR x : LREAL; END_VAR test(x); END_FUNCTION + │ ^ Invalid type nature for generic argument. LREAL is no Int. + diff --git a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_int_does_not_allow_string.snap b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_int_does_not_allow_string.snap index 6b9de27f26..d1ba5ec0e1 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_int_does_not_allow_string.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_int_does_not_allow_string.snap @@ -1,9 +1,29 @@ --- source: src/validation/tests/generic_validation_tests.rs -expression: res +expression: "&diagnostics" --- -SyntaxError { message: "Invalid assignment: cannot assign 'STRING' to 'USINT'", range: [SourceLocation { span: Range(TextLocation { line: 2, column: 60, offset: 140 }..TextLocation { line: 2, column: 61, offset: 141 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid type nature for generic argument. STRING is no Int.", range: [SourceLocation { span: Range(TextLocation { line: 2, column: 60, offset: 140 }..TextLocation { line: 2, column: 61, offset: 141 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid assignment: cannot assign 'WSTRING' to 'USINT'", range: [SourceLocation { span: Range(TextLocation { line: 3, column: 60, offset: 217 }..TextLocation { line: 3, column: 61, offset: 218 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid type nature for generic argument. WSTRING is no Int.", range: [SourceLocation { span: Range(TextLocation { line: 3, column: 60, offset: 217 }..TextLocation { line: 3, column: 61, offset: 218 }) }], err_no: type__invalid_nature } +error: Invalid assignment: cannot assign 'STRING' to 'USINT' + ┌─ :3:61 + │ +3 │ FUNCTION func1 : INT VAR x : STRING; END_VAR test(x); END_FUNCTION + │ ^ Invalid assignment: cannot assign 'STRING' to 'USINT' + +error: Invalid type nature for generic argument. STRING is no Int. + ┌─ :3:61 + │ +3 │ FUNCTION func1 : INT VAR x : STRING; END_VAR test(x); END_FUNCTION + │ ^ Invalid type nature for generic argument. STRING is no Int. + +error: Invalid assignment: cannot assign 'WSTRING' to 'USINT' + ┌─ :4:61 + │ +4 │ FUNCTION func2 : INT VAR x : WSTRING; END_VAR test(x); END_FUNCTION + │ ^ Invalid assignment: cannot assign 'WSTRING' to 'USINT' + +error: Invalid type nature for generic argument. WSTRING is no Int. + ┌─ :4:61 + │ +4 │ FUNCTION func2 : INT VAR x : WSTRING; END_VAR test(x); END_FUNCTION + │ ^ Invalid type nature for generic argument. WSTRING is no Int. + diff --git a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_int_does_not_allow_time.snap b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_int_does_not_allow_time.snap index 5347962903..00ff188a46 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_int_does_not_allow_time.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_int_does_not_allow_time.snap @@ -1,7 +1,17 @@ --- source: src/validation/tests/generic_validation_tests.rs -expression: res +expression: "&diagnostics" --- -SyntaxError { message: "Invalid type nature for generic argument. TIME is no Int.", range: [SourceLocation { span: Range(TextLocation { line: 2, column: 57, offset: 137 }..TextLocation { line: 2, column: 58, offset: 138 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid type nature for generic argument. TIME is no Int.", range: [SourceLocation { span: Range(TextLocation { line: 3, column: 58, offset: 212 }..TextLocation { line: 3, column: 59, offset: 213 }) }], err_no: type__invalid_nature } +error: Invalid type nature for generic argument. TIME is no Int. + ┌─ :3:58 + │ +3 │ FUNCTION func1 : INT VAR x : TIME; END_VAR test(x); END_FUNCTION + │ ^ Invalid type nature for generic argument. TIME is no Int. + +error: Invalid type nature for generic argument. TIME is no Int. + ┌─ :4:59 + │ +4 │ FUNCTION func2 : INT VAR x : LTIME; END_VAR test(x); END_FUNCTION + │ ^ Invalid type nature for generic argument. TIME is no Int. + diff --git a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_int_multiple_parameters.snap b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_int_multiple_parameters.snap index a9408a68c6..4a87c24f97 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_int_multiple_parameters.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_int_multiple_parameters.snap @@ -1,13 +1,53 @@ --- source: src/validation/tests/generic_validation_tests.rs -expression: res +expression: "&diagnostics" --- -SyntaxError { message: "Invalid type nature for generic argument. REAL is no Int.", range: [SourceLocation { span: Range(TextLocation { line: 14, column: 13, offset: 429 }..TextLocation { line: 14, column: 21, offset: 437 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid type nature for generic argument. TIME is no Int.", range: [SourceLocation { span: Range(TextLocation { line: 14, column: 49, offset: 465 }..TextLocation { line: 14, column: 57, offset: 473 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid type nature for generic argument. BYTE is no Int.", range: [SourceLocation { span: Range(TextLocation { line: 14, column: 59, offset: 475 }..TextLocation { line: 14, column: 67, offset: 483 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid assignment: cannot assign 'STRING' to 'DINT'", range: [SourceLocation { span: Range(TextLocation { line: 14, column: 69, offset: 485 }..TextLocation { line: 14, column: 76, offset: 492 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid type nature for generic argument. STRING is no Int.", range: [SourceLocation { span: Range(TextLocation { line: 14, column: 69, offset: 485 }..TextLocation { line: 14, column: 76, offset: 492 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid assignment: cannot assign 'CHAR' to 'DINT'", range: [SourceLocation { span: Range(TextLocation { line: 14, column: 78, offset: 494 }..TextLocation { line: 14, column: 86, offset: 502 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid type nature for generic argument. CHAR is no Int.", range: [SourceLocation { span: Range(TextLocation { line: 14, column: 78, offset: 494 }..TextLocation { line: 14, column: 86, offset: 502 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid type nature for generic argument. DATE is no Int.", range: [SourceLocation { span: Range(TextLocation { line: 14, column: 88, offset: 504 }..TextLocation { line: 14, column: 96, offset: 512 }) }], err_no: type__invalid_nature } +error: Invalid type nature for generic argument. REAL is no Int. + ┌─ :15:14 + │ +15 │ func(var_real, var_unsigned, var_signed, var_time, var_byte, var_str, var_char, var_date); + │ ^^^^^^^^ Invalid type nature for generic argument. REAL is no Int. + +error: Invalid type nature for generic argument. TIME is no Int. + ┌─ :15:50 + │ +15 │ func(var_real, var_unsigned, var_signed, var_time, var_byte, var_str, var_char, var_date); + │ ^^^^^^^^ Invalid type nature for generic argument. TIME is no Int. + +error: Invalid type nature for generic argument. BYTE is no Int. + ┌─ :15:60 + │ +15 │ func(var_real, var_unsigned, var_signed, var_time, var_byte, var_str, var_char, var_date); + │ ^^^^^^^^ Invalid type nature for generic argument. BYTE is no Int. + +error: Invalid assignment: cannot assign 'STRING' to 'DINT' + ┌─ :15:70 + │ +15 │ func(var_real, var_unsigned, var_signed, var_time, var_byte, var_str, var_char, var_date); + │ ^^^^^^^ Invalid assignment: cannot assign 'STRING' to 'DINT' + +error: Invalid type nature for generic argument. STRING is no Int. + ┌─ :15:70 + │ +15 │ func(var_real, var_unsigned, var_signed, var_time, var_byte, var_str, var_char, var_date); + │ ^^^^^^^ Invalid type nature for generic argument. STRING is no Int. + +error: Invalid assignment: cannot assign 'CHAR' to 'DINT' + ┌─ :15:79 + │ +15 │ func(var_real, var_unsigned, var_signed, var_time, var_byte, var_str, var_char, var_date); + │ ^^^^^^^^ Invalid assignment: cannot assign 'CHAR' to 'DINT' + +error: Invalid type nature for generic argument. CHAR is no Int. + ┌─ :15:79 + │ +15 │ func(var_real, var_unsigned, var_signed, var_time, var_byte, var_str, var_char, var_date); + │ ^^^^^^^^ Invalid type nature for generic argument. CHAR is no Int. + +error: Invalid type nature for generic argument. DATE is no Int. + ┌─ :15:89 + │ +15 │ func(var_real, var_unsigned, var_signed, var_time, var_byte, var_str, var_char, var_date); + │ ^^^^^^^^ Invalid type nature for generic argument. DATE is no Int. + diff --git a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_magnitude_does_not_allow_bits.snap b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_magnitude_does_not_allow_bits.snap index bda566f733..4d5b3a6032 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_magnitude_does_not_allow_bits.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_magnitude_does_not_allow_bits.snap @@ -1,10 +1,35 @@ --- source: src/validation/tests/generic_validation_tests.rs -expression: res +expression: "&diagnostics" --- -SyntaxError { message: "Invalid type nature for generic argument. BOOL is no Magnitude.", range: [SourceLocation { span: Range(TextLocation { line: 2, column: 57, offset: 143 }..TextLocation { line: 2, column: 58, offset: 144 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid type nature for generic argument. BYTE is no Magnitude.", range: [SourceLocation { span: Range(TextLocation { line: 3, column: 57, offset: 217 }..TextLocation { line: 3, column: 58, offset: 218 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid type nature for generic argument. WORD is no Magnitude.", range: [SourceLocation { span: Range(TextLocation { line: 4, column: 57, offset: 291 }..TextLocation { line: 4, column: 58, offset: 292 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid type nature for generic argument. DWORD is no Magnitude.", range: [SourceLocation { span: Range(TextLocation { line: 5, column: 58, offset: 366 }..TextLocation { line: 5, column: 59, offset: 367 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid type nature for generic argument. LWORD is no Magnitude.", range: [SourceLocation { span: Range(TextLocation { line: 6, column: 58, offset: 441 }..TextLocation { line: 6, column: 59, offset: 442 }) }], err_no: type__invalid_nature } +error: Invalid type nature for generic argument. BOOL is no Magnitude. + ┌─ :3:58 + │ +3 │ FUNCTION func1 : INT VAR x : BOOL; END_VAR test(x); END_FUNCTION + │ ^ Invalid type nature for generic argument. BOOL is no Magnitude. + +error: Invalid type nature for generic argument. BYTE is no Magnitude. + ┌─ :4:58 + │ +4 │ FUNCTION func2 : INT VAR x : BYTE; END_VAR test(x); END_FUNCTION + │ ^ Invalid type nature for generic argument. BYTE is no Magnitude. + +error: Invalid type nature for generic argument. WORD is no Magnitude. + ┌─ :5:58 + │ +5 │ FUNCTION func3 : INT VAR x : WORD; END_VAR test(x); END_FUNCTION + │ ^ Invalid type nature for generic argument. WORD is no Magnitude. + +error: Invalid type nature for generic argument. DWORD is no Magnitude. + ┌─ :6:59 + │ +6 │ FUNCTION func4 : INT VAR x : DWORD; END_VAR test(x); END_FUNCTION + │ ^ Invalid type nature for generic argument. DWORD is no Magnitude. + +error: Invalid type nature for generic argument. LWORD is no Magnitude. + ┌─ :7:59 + │ +7 │ FUNCTION func5 : INT VAR x : LWORD; END_VAR test(x); END_FUNCTION + │ ^ Invalid type nature for generic argument. LWORD is no Magnitude. + diff --git a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_magnitude_does_not_allow_chars.snap b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_magnitude_does_not_allow_chars.snap index aef4320187..8b76a7ff85 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_magnitude_does_not_allow_chars.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_magnitude_does_not_allow_chars.snap @@ -1,9 +1,29 @@ --- source: src/validation/tests/generic_validation_tests.rs -expression: res +expression: "&diagnostics" --- -SyntaxError { message: "Invalid assignment: cannot assign 'CHAR' to 'USINT'", range: [SourceLocation { span: Range(TextLocation { line: 2, column: 57, offset: 143 }..TextLocation { line: 2, column: 58, offset: 144 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid type nature for generic argument. CHAR is no Magnitude.", range: [SourceLocation { span: Range(TextLocation { line: 2, column: 57, offset: 143 }..TextLocation { line: 2, column: 58, offset: 144 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid assignment: cannot assign 'WCHAR' to 'USINT'", range: [SourceLocation { span: Range(TextLocation { line: 3, column: 58, offset: 218 }..TextLocation { line: 3, column: 59, offset: 219 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid type nature for generic argument. WCHAR is no Magnitude.", range: [SourceLocation { span: Range(TextLocation { line: 3, column: 58, offset: 218 }..TextLocation { line: 3, column: 59, offset: 219 }) }], err_no: type__invalid_nature } +error: Invalid assignment: cannot assign 'CHAR' to 'USINT' + ┌─ :3:58 + │ +3 │ FUNCTION func1 : INT VAR x : CHAR; END_VAR test(x); END_FUNCTION + │ ^ Invalid assignment: cannot assign 'CHAR' to 'USINT' + +error: Invalid type nature for generic argument. CHAR is no Magnitude. + ┌─ :3:58 + │ +3 │ FUNCTION func1 : INT VAR x : CHAR; END_VAR test(x); END_FUNCTION + │ ^ Invalid type nature for generic argument. CHAR is no Magnitude. + +error: Invalid assignment: cannot assign 'WCHAR' to 'USINT' + ┌─ :4:59 + │ +4 │ FUNCTION func2 : INT VAR x : WCHAR; END_VAR test(x); END_FUNCTION + │ ^ Invalid assignment: cannot assign 'WCHAR' to 'USINT' + +error: Invalid type nature for generic argument. WCHAR is no Magnitude. + ┌─ :4:59 + │ +4 │ FUNCTION func2 : INT VAR x : WCHAR; END_VAR test(x); END_FUNCTION + │ ^ Invalid type nature for generic argument. WCHAR is no Magnitude. + diff --git a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_magnitude_does_not_allow_date.snap b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_magnitude_does_not_allow_date.snap index d93f7b9e7c..923b43c2c6 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_magnitude_does_not_allow_date.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_magnitude_does_not_allow_date.snap @@ -1,10 +1,35 @@ --- source: src/validation/tests/generic_validation_tests.rs -expression: res +expression: "&diagnostics" --- -SyntaxError { message: "Invalid type nature for generic argument. DATE_AND_TIME is no Magnitude.", range: [SourceLocation { span: Range(TextLocation { line: 2, column: 55, offset: 141 }..TextLocation { line: 2, column: 56, offset: 142 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid type nature for generic argument. DATE_AND_TIME is no Magnitude.", range: [SourceLocation { span: Range(TextLocation { line: 3, column: 56, offset: 214 }..TextLocation { line: 3, column: 57, offset: 215 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid type nature for generic argument. DATE is no Magnitude.", range: [SourceLocation { span: Range(TextLocation { line: 4, column: 57, offset: 288 }..TextLocation { line: 4, column: 58, offset: 289 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid type nature for generic argument. TIME_OF_DAY is no Magnitude.", range: [SourceLocation { span: Range(TextLocation { line: 5, column: 56, offset: 361 }..TextLocation { line: 5, column: 57, offset: 362 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid type nature for generic argument. TIME_OF_DAY is no Magnitude.", range: [SourceLocation { span: Range(TextLocation { line: 6, column: 57, offset: 435 }..TextLocation { line: 6, column: 58, offset: 436 }) }], err_no: type__invalid_nature } +error: Invalid type nature for generic argument. DATE_AND_TIME is no Magnitude. + ┌─ :3:56 + │ +3 │ FUNCTION func1 : INT VAR x : DT; END_VAR test(x); END_FUNCTION + │ ^ Invalid type nature for generic argument. DATE_AND_TIME is no Magnitude. + +error: Invalid type nature for generic argument. DATE_AND_TIME is no Magnitude. + ┌─ :4:57 + │ +4 │ FUNCTION func2 : INT VAR x : LDT; END_VAR test(x); END_FUNCTION + │ ^ Invalid type nature for generic argument. DATE_AND_TIME is no Magnitude. + +error: Invalid type nature for generic argument. DATE is no Magnitude. + ┌─ :5:58 + │ +5 │ FUNCTION func3 : INT VAR x : DATE; END_VAR test(x); END_FUNCTION + │ ^ Invalid type nature for generic argument. DATE is no Magnitude. + +error: Invalid type nature for generic argument. TIME_OF_DAY is no Magnitude. + ┌─ :6:57 + │ +6 │ FUNCTION func4 : INT VAR x : TOD; END_VAR test(x); END_FUNCTION + │ ^ Invalid type nature for generic argument. TIME_OF_DAY is no Magnitude. + +error: Invalid type nature for generic argument. TIME_OF_DAY is no Magnitude. + ┌─ :7:58 + │ +7 │ FUNCTION func5 : INT VAR x : LTOD; END_VAR test(x); END_FUNCTION + │ ^ Invalid type nature for generic argument. TIME_OF_DAY is no Magnitude. + diff --git a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_magnitude_does_not_allow_strings.snap b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_magnitude_does_not_allow_strings.snap index 7b617efc1b..f0020a8736 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_magnitude_does_not_allow_strings.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_magnitude_does_not_allow_strings.snap @@ -1,9 +1,29 @@ --- source: src/validation/tests/generic_validation_tests.rs -expression: res +expression: "&diagnostics" --- -SyntaxError { message: "Invalid assignment: cannot assign 'STRING' to 'USINT'", range: [SourceLocation { span: Range(TextLocation { line: 2, column: 59, offset: 145 }..TextLocation { line: 2, column: 60, offset: 146 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid type nature for generic argument. STRING is no Magnitude.", range: [SourceLocation { span: Range(TextLocation { line: 2, column: 59, offset: 145 }..TextLocation { line: 2, column: 60, offset: 146 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid assignment: cannot assign 'WSTRING' to 'USINT'", range: [SourceLocation { span: Range(TextLocation { line: 3, column: 60, offset: 222 }..TextLocation { line: 3, column: 61, offset: 223 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid type nature for generic argument. WSTRING is no Magnitude.", range: [SourceLocation { span: Range(TextLocation { line: 3, column: 60, offset: 222 }..TextLocation { line: 3, column: 61, offset: 223 }) }], err_no: type__invalid_nature } +error: Invalid assignment: cannot assign 'STRING' to 'USINT' + ┌─ :3:60 + │ +3 │ FUNCTION func1 : INT VAR x : STRING; END_VAR test(x); END_FUNCTION + │ ^ Invalid assignment: cannot assign 'STRING' to 'USINT' + +error: Invalid type nature for generic argument. STRING is no Magnitude. + ┌─ :3:60 + │ +3 │ FUNCTION func1 : INT VAR x : STRING; END_VAR test(x); END_FUNCTION + │ ^ Invalid type nature for generic argument. STRING is no Magnitude. + +error: Invalid assignment: cannot assign 'WSTRING' to 'USINT' + ┌─ :4:61 + │ +4 │ FUNCTION func2 : INT VAR x : WSTRING; END_VAR test(x); END_FUNCTION + │ ^ Invalid assignment: cannot assign 'WSTRING' to 'USINT' + +error: Invalid type nature for generic argument. WSTRING is no Magnitude. + ┌─ :4:61 + │ +4 │ FUNCTION func2 : INT VAR x : WSTRING; END_VAR test(x); END_FUNCTION + │ ^ Invalid type nature for generic argument. WSTRING is no Magnitude. + diff --git a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_magnitude_multiple_parameters.snap b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_magnitude_multiple_parameters.snap index 1ef8a28e7b..f53e2e03a2 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_magnitude_multiple_parameters.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_magnitude_multiple_parameters.snap @@ -1,11 +1,41 @@ --- source: src/validation/tests/generic_validation_tests.rs -expression: res +expression: "&diagnostics" --- -SyntaxError { message: "Invalid type nature for generic argument. BYTE is no Magnitude.", range: [SourceLocation { span: Range(TextLocation { line: 14, column: 59, offset: 481 }..TextLocation { line: 14, column: 67, offset: 489 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid assignment: cannot assign 'STRING' to 'TIME'", range: [SourceLocation { span: Range(TextLocation { line: 14, column: 69, offset: 491 }..TextLocation { line: 14, column: 76, offset: 498 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid type nature for generic argument. STRING is no Magnitude.", range: [SourceLocation { span: Range(TextLocation { line: 14, column: 69, offset: 491 }..TextLocation { line: 14, column: 76, offset: 498 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid assignment: cannot assign 'CHAR' to 'TIME'", range: [SourceLocation { span: Range(TextLocation { line: 14, column: 78, offset: 500 }..TextLocation { line: 14, column: 86, offset: 508 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid type nature for generic argument. CHAR is no Magnitude.", range: [SourceLocation { span: Range(TextLocation { line: 14, column: 78, offset: 500 }..TextLocation { line: 14, column: 86, offset: 508 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid type nature for generic argument. DATE is no Magnitude.", range: [SourceLocation { span: Range(TextLocation { line: 14, column: 88, offset: 510 }..TextLocation { line: 14, column: 96, offset: 518 }) }], err_no: type__invalid_nature } +error: Invalid type nature for generic argument. BYTE is no Magnitude. + ┌─ :15:60 + │ +15 │ func(var_real, var_unsigned, var_signed, var_time, var_byte, var_str, var_char, var_date); + │ ^^^^^^^^ Invalid type nature for generic argument. BYTE is no Magnitude. + +error: Invalid assignment: cannot assign 'STRING' to 'TIME' + ┌─ :15:70 + │ +15 │ func(var_real, var_unsigned, var_signed, var_time, var_byte, var_str, var_char, var_date); + │ ^^^^^^^ Invalid assignment: cannot assign 'STRING' to 'TIME' + +error: Invalid type nature for generic argument. STRING is no Magnitude. + ┌─ :15:70 + │ +15 │ func(var_real, var_unsigned, var_signed, var_time, var_byte, var_str, var_char, var_date); + │ ^^^^^^^ Invalid type nature for generic argument. STRING is no Magnitude. + +error: Invalid assignment: cannot assign 'CHAR' to 'TIME' + ┌─ :15:79 + │ +15 │ func(var_real, var_unsigned, var_signed, var_time, var_byte, var_str, var_char, var_date); + │ ^^^^^^^^ Invalid assignment: cannot assign 'CHAR' to 'TIME' + +error: Invalid type nature for generic argument. CHAR is no Magnitude. + ┌─ :15:79 + │ +15 │ func(var_real, var_unsigned, var_signed, var_time, var_byte, var_str, var_char, var_date); + │ ^^^^^^^^ Invalid type nature for generic argument. CHAR is no Magnitude. + +error: Invalid type nature for generic argument. DATE is no Magnitude. + ┌─ :15:89 + │ +15 │ func(var_real, var_unsigned, var_signed, var_time, var_byte, var_str, var_char, var_date); + │ ^^^^^^^^ Invalid type nature for generic argument. DATE is no Magnitude. + diff --git a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_multiple_parameters.snap b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_multiple_parameters.snap index 60d3c380b8..1318a9be25 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_multiple_parameters.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_multiple_parameters.snap @@ -1,7 +1,17 @@ --- source: src/validation/tests/generic_validation_tests.rs -expression: res +expression: "&diagnostics" --- -SyntaxError { message: "Invalid assignment: cannot assign 'STRING' to 'DATE'", range: [SourceLocation { span: Range(TextLocation { line: 14, column: 69, offset: 481 }..TextLocation { line: 14, column: 76, offset: 488 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid assignment: cannot assign 'CHAR' to 'DATE'", range: [SourceLocation { span: Range(TextLocation { line: 14, column: 78, offset: 490 }..TextLocation { line: 14, column: 86, offset: 498 }) }], err_no: var__invalid_assignment } +error: Invalid assignment: cannot assign 'STRING' to 'DATE' + ┌─ :15:70 + │ +15 │ func(var_real, var_unsigned, var_signed, var_time, var_byte, var_str, var_char, var_date); + │ ^^^^^^^ Invalid assignment: cannot assign 'STRING' to 'DATE' + +error: Invalid assignment: cannot assign 'CHAR' to 'DATE' + ┌─ :15:79 + │ +15 │ func(var_real, var_unsigned, var_signed, var_time, var_byte, var_str, var_char, var_date); + │ ^^^^^^^^ Invalid assignment: cannot assign 'CHAR' to 'DATE' + diff --git a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_num_does_not_allow_bits.snap b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_num_does_not_allow_bits.snap index 549a365dd8..bc1dced5f7 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_num_does_not_allow_bits.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_num_does_not_allow_bits.snap @@ -1,10 +1,35 @@ --- source: src/validation/tests/generic_validation_tests.rs -expression: res +expression: "&diagnostics" --- -SyntaxError { message: "Invalid type nature for generic argument. BOOL is no Num.", range: [SourceLocation { span: Range(TextLocation { line: 2, column: 57, offset: 137 }..TextLocation { line: 2, column: 58, offset: 138 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid type nature for generic argument. BYTE is no Num.", range: [SourceLocation { span: Range(TextLocation { line: 3, column: 57, offset: 211 }..TextLocation { line: 3, column: 58, offset: 212 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid type nature for generic argument. WORD is no Num.", range: [SourceLocation { span: Range(TextLocation { line: 4, column: 57, offset: 285 }..TextLocation { line: 4, column: 58, offset: 286 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid type nature for generic argument. DWORD is no Num.", range: [SourceLocation { span: Range(TextLocation { line: 5, column: 58, offset: 360 }..TextLocation { line: 5, column: 59, offset: 361 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid type nature for generic argument. LWORD is no Num.", range: [SourceLocation { span: Range(TextLocation { line: 6, column: 58, offset: 435 }..TextLocation { line: 6, column: 59, offset: 436 }) }], err_no: type__invalid_nature } +error: Invalid type nature for generic argument. BOOL is no Num. + ┌─ :3:58 + │ +3 │ FUNCTION func1 : INT VAR x : BOOL; END_VAR test(x); END_FUNCTION + │ ^ Invalid type nature for generic argument. BOOL is no Num. + +error: Invalid type nature for generic argument. BYTE is no Num. + ┌─ :4:58 + │ +4 │ FUNCTION func2 : INT VAR x : BYTE; END_VAR test(x); END_FUNCTION + │ ^ Invalid type nature for generic argument. BYTE is no Num. + +error: Invalid type nature for generic argument. WORD is no Num. + ┌─ :5:58 + │ +5 │ FUNCTION func3 : INT VAR x : WORD; END_VAR test(x); END_FUNCTION + │ ^ Invalid type nature for generic argument. WORD is no Num. + +error: Invalid type nature for generic argument. DWORD is no Num. + ┌─ :6:59 + │ +6 │ FUNCTION func4 : INT VAR x : DWORD; END_VAR test(x); END_FUNCTION + │ ^ Invalid type nature for generic argument. DWORD is no Num. + +error: Invalid type nature for generic argument. LWORD is no Num. + ┌─ :7:59 + │ +7 │ FUNCTION func5 : INT VAR x : LWORD; END_VAR test(x); END_FUNCTION + │ ^ Invalid type nature for generic argument. LWORD is no Num. + diff --git a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_num_does_not_allow_chars.snap b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_num_does_not_allow_chars.snap index aa84d7d206..d404a5389b 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_num_does_not_allow_chars.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_num_does_not_allow_chars.snap @@ -1,9 +1,29 @@ --- source: src/validation/tests/generic_validation_tests.rs -expression: res +expression: "&diagnostics" --- -SyntaxError { message: "Invalid assignment: cannot assign 'CHAR' to 'USINT'", range: [SourceLocation { span: Range(TextLocation { line: 2, column: 57, offset: 137 }..TextLocation { line: 2, column: 58, offset: 138 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid type nature for generic argument. CHAR is no Num.", range: [SourceLocation { span: Range(TextLocation { line: 2, column: 57, offset: 137 }..TextLocation { line: 2, column: 58, offset: 138 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid assignment: cannot assign 'WCHAR' to 'USINT'", range: [SourceLocation { span: Range(TextLocation { line: 3, column: 58, offset: 212 }..TextLocation { line: 3, column: 59, offset: 213 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid type nature for generic argument. WCHAR is no Num.", range: [SourceLocation { span: Range(TextLocation { line: 3, column: 58, offset: 212 }..TextLocation { line: 3, column: 59, offset: 213 }) }], err_no: type__invalid_nature } +error: Invalid assignment: cannot assign 'CHAR' to 'USINT' + ┌─ :3:58 + │ +3 │ FUNCTION func1 : INT VAR x : CHAR; END_VAR test(x); END_FUNCTION + │ ^ Invalid assignment: cannot assign 'CHAR' to 'USINT' + +error: Invalid type nature for generic argument. CHAR is no Num. + ┌─ :3:58 + │ +3 │ FUNCTION func1 : INT VAR x : CHAR; END_VAR test(x); END_FUNCTION + │ ^ Invalid type nature for generic argument. CHAR is no Num. + +error: Invalid assignment: cannot assign 'WCHAR' to 'USINT' + ┌─ :4:59 + │ +4 │ FUNCTION func2 : INT VAR x : WCHAR; END_VAR test(x); END_FUNCTION + │ ^ Invalid assignment: cannot assign 'WCHAR' to 'USINT' + +error: Invalid type nature for generic argument. WCHAR is no Num. + ┌─ :4:59 + │ +4 │ FUNCTION func2 : INT VAR x : WCHAR; END_VAR test(x); END_FUNCTION + │ ^ Invalid type nature for generic argument. WCHAR is no Num. + diff --git a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_num_does_not_allow_date.snap b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_num_does_not_allow_date.snap index 39b7a32eed..f9ac77beea 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_num_does_not_allow_date.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_num_does_not_allow_date.snap @@ -1,10 +1,35 @@ --- source: src/validation/tests/generic_validation_tests.rs -expression: res +expression: "&diagnostics" --- -SyntaxError { message: "Invalid type nature for generic argument. DATE_AND_TIME is no Num.", range: [SourceLocation { span: Range(TextLocation { line: 2, column: 55, offset: 135 }..TextLocation { line: 2, column: 56, offset: 136 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid type nature for generic argument. DATE_AND_TIME is no Num.", range: [SourceLocation { span: Range(TextLocation { line: 3, column: 56, offset: 208 }..TextLocation { line: 3, column: 57, offset: 209 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid type nature for generic argument. DATE is no Num.", range: [SourceLocation { span: Range(TextLocation { line: 4, column: 57, offset: 282 }..TextLocation { line: 4, column: 58, offset: 283 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid type nature for generic argument. TIME_OF_DAY is no Num.", range: [SourceLocation { span: Range(TextLocation { line: 5, column: 56, offset: 355 }..TextLocation { line: 5, column: 57, offset: 356 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid type nature for generic argument. TIME_OF_DAY is no Num.", range: [SourceLocation { span: Range(TextLocation { line: 6, column: 57, offset: 429 }..TextLocation { line: 6, column: 58, offset: 430 }) }], err_no: type__invalid_nature } +error: Invalid type nature for generic argument. DATE_AND_TIME is no Num. + ┌─ :3:56 + │ +3 │ FUNCTION func1 : INT VAR x : DT; END_VAR test(x); END_FUNCTION + │ ^ Invalid type nature for generic argument. DATE_AND_TIME is no Num. + +error: Invalid type nature for generic argument. DATE_AND_TIME is no Num. + ┌─ :4:57 + │ +4 │ FUNCTION func2 : INT VAR x : LDT; END_VAR test(x); END_FUNCTION + │ ^ Invalid type nature for generic argument. DATE_AND_TIME is no Num. + +error: Invalid type nature for generic argument. DATE is no Num. + ┌─ :5:58 + │ +5 │ FUNCTION func3 : INT VAR x : DATE; END_VAR test(x); END_FUNCTION + │ ^ Invalid type nature for generic argument. DATE is no Num. + +error: Invalid type nature for generic argument. TIME_OF_DAY is no Num. + ┌─ :6:57 + │ +6 │ FUNCTION func4 : INT VAR x : TOD; END_VAR test(x); END_FUNCTION + │ ^ Invalid type nature for generic argument. TIME_OF_DAY is no Num. + +error: Invalid type nature for generic argument. TIME_OF_DAY is no Num. + ┌─ :7:58 + │ +7 │ FUNCTION func5 : INT VAR x : LTOD; END_VAR test(x); END_FUNCTION + │ ^ Invalid type nature for generic argument. TIME_OF_DAY is no Num. + diff --git a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_num_does_not_allow_strings.snap b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_num_does_not_allow_strings.snap index 01844d5bc7..4ad2e4c6a8 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_num_does_not_allow_strings.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_num_does_not_allow_strings.snap @@ -1,9 +1,29 @@ --- source: src/validation/tests/generic_validation_tests.rs -expression: res +expression: "&diagnostics" --- -SyntaxError { message: "Invalid assignment: cannot assign 'STRING' to 'USINT'", range: [SourceLocation { span: Range(TextLocation { line: 2, column: 59, offset: 139 }..TextLocation { line: 2, column: 60, offset: 140 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid type nature for generic argument. STRING is no Num.", range: [SourceLocation { span: Range(TextLocation { line: 2, column: 59, offset: 139 }..TextLocation { line: 2, column: 60, offset: 140 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid assignment: cannot assign 'WSTRING' to 'USINT'", range: [SourceLocation { span: Range(TextLocation { line: 3, column: 60, offset: 216 }..TextLocation { line: 3, column: 61, offset: 217 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid type nature for generic argument. WSTRING is no Num.", range: [SourceLocation { span: Range(TextLocation { line: 3, column: 60, offset: 216 }..TextLocation { line: 3, column: 61, offset: 217 }) }], err_no: type__invalid_nature } +error: Invalid assignment: cannot assign 'STRING' to 'USINT' + ┌─ :3:60 + │ +3 │ FUNCTION func1 : INT VAR x : STRING; END_VAR test(x); END_FUNCTION + │ ^ Invalid assignment: cannot assign 'STRING' to 'USINT' + +error: Invalid type nature for generic argument. STRING is no Num. + ┌─ :3:60 + │ +3 │ FUNCTION func1 : INT VAR x : STRING; END_VAR test(x); END_FUNCTION + │ ^ Invalid type nature for generic argument. STRING is no Num. + +error: Invalid assignment: cannot assign 'WSTRING' to 'USINT' + ┌─ :4:61 + │ +4 │ FUNCTION func2 : INT VAR x : WSTRING; END_VAR test(x); END_FUNCTION + │ ^ Invalid assignment: cannot assign 'WSTRING' to 'USINT' + +error: Invalid type nature for generic argument. WSTRING is no Num. + ┌─ :4:61 + │ +4 │ FUNCTION func2 : INT VAR x : WSTRING; END_VAR test(x); END_FUNCTION + │ ^ Invalid type nature for generic argument. WSTRING is no Num. + diff --git a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_num_does_not_allow_time.snap b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_num_does_not_allow_time.snap index dd30e69263..f51a4020d9 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_num_does_not_allow_time.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_num_does_not_allow_time.snap @@ -1,7 +1,17 @@ --- source: src/validation/tests/generic_validation_tests.rs -expression: res +expression: "&diagnostics" --- -SyntaxError { message: "Invalid type nature for generic argument. TIME is no Num.", range: [SourceLocation { span: Range(TextLocation { line: 2, column: 57, offset: 137 }..TextLocation { line: 2, column: 58, offset: 138 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid type nature for generic argument. TIME is no Num.", range: [SourceLocation { span: Range(TextLocation { line: 3, column: 58, offset: 212 }..TextLocation { line: 3, column: 59, offset: 213 }) }], err_no: type__invalid_nature } +error: Invalid type nature for generic argument. TIME is no Num. + ┌─ :3:58 + │ +3 │ FUNCTION func1 : INT VAR x : TIME; END_VAR test(x); END_FUNCTION + │ ^ Invalid type nature for generic argument. TIME is no Num. + +error: Invalid type nature for generic argument. TIME is no Num. + ┌─ :4:59 + │ +4 │ FUNCTION func2 : INT VAR x : LTIME; END_VAR test(x); END_FUNCTION + │ ^ Invalid type nature for generic argument. TIME is no Num. + diff --git a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_num_multiple_parameters.snap b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_num_multiple_parameters.snap index cb4a737f7f..9bbd34a83a 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_num_multiple_parameters.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_num_multiple_parameters.snap @@ -1,12 +1,47 @@ --- source: src/validation/tests/generic_validation_tests.rs -expression: res +expression: "&diagnostics" --- -SyntaxError { message: "Invalid type nature for generic argument. TIME is no Num.", range: [SourceLocation { span: Range(TextLocation { line: 14, column: 49, offset: 465 }..TextLocation { line: 14, column: 57, offset: 473 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid type nature for generic argument. BYTE is no Num.", range: [SourceLocation { span: Range(TextLocation { line: 14, column: 59, offset: 475 }..TextLocation { line: 14, column: 67, offset: 483 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid assignment: cannot assign 'STRING' to 'REAL'", range: [SourceLocation { span: Range(TextLocation { line: 14, column: 69, offset: 485 }..TextLocation { line: 14, column: 76, offset: 492 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid type nature for generic argument. STRING is no Num.", range: [SourceLocation { span: Range(TextLocation { line: 14, column: 69, offset: 485 }..TextLocation { line: 14, column: 76, offset: 492 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid assignment: cannot assign 'CHAR' to 'REAL'", range: [SourceLocation { span: Range(TextLocation { line: 14, column: 78, offset: 494 }..TextLocation { line: 14, column: 86, offset: 502 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid type nature for generic argument. CHAR is no Num.", range: [SourceLocation { span: Range(TextLocation { line: 14, column: 78, offset: 494 }..TextLocation { line: 14, column: 86, offset: 502 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid type nature for generic argument. DATE is no Num.", range: [SourceLocation { span: Range(TextLocation { line: 14, column: 88, offset: 504 }..TextLocation { line: 14, column: 96, offset: 512 }) }], err_no: type__invalid_nature } +error: Invalid type nature for generic argument. TIME is no Num. + ┌─ :15:50 + │ +15 │ func(var_real, var_unsigned, var_signed, var_time, var_byte, var_str, var_char, var_date); + │ ^^^^^^^^ Invalid type nature for generic argument. TIME is no Num. + +error: Invalid type nature for generic argument. BYTE is no Num. + ┌─ :15:60 + │ +15 │ func(var_real, var_unsigned, var_signed, var_time, var_byte, var_str, var_char, var_date); + │ ^^^^^^^^ Invalid type nature for generic argument. BYTE is no Num. + +error: Invalid assignment: cannot assign 'STRING' to 'REAL' + ┌─ :15:70 + │ +15 │ func(var_real, var_unsigned, var_signed, var_time, var_byte, var_str, var_char, var_date); + │ ^^^^^^^ Invalid assignment: cannot assign 'STRING' to 'REAL' + +error: Invalid type nature for generic argument. STRING is no Num. + ┌─ :15:70 + │ +15 │ func(var_real, var_unsigned, var_signed, var_time, var_byte, var_str, var_char, var_date); + │ ^^^^^^^ Invalid type nature for generic argument. STRING is no Num. + +error: Invalid assignment: cannot assign 'CHAR' to 'REAL' + ┌─ :15:79 + │ +15 │ func(var_real, var_unsigned, var_signed, var_time, var_byte, var_str, var_char, var_date); + │ ^^^^^^^^ Invalid assignment: cannot assign 'CHAR' to 'REAL' + +error: Invalid type nature for generic argument. CHAR is no Num. + ┌─ :15:79 + │ +15 │ func(var_real, var_unsigned, var_signed, var_time, var_byte, var_str, var_char, var_date); + │ ^^^^^^^^ Invalid type nature for generic argument. CHAR is no Num. + +error: Invalid type nature for generic argument. DATE is no Num. + ┌─ :15:89 + │ +15 │ func(var_real, var_unsigned, var_signed, var_time, var_byte, var_str, var_char, var_date); + │ ^^^^^^^^ Invalid type nature for generic argument. DATE is no Num. + diff --git a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_real_does_not_allow_bits.snap b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_real_does_not_allow_bits.snap index 89e7550982..afb286323d 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_real_does_not_allow_bits.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_real_does_not_allow_bits.snap @@ -1,10 +1,35 @@ --- source: src/validation/tests/generic_validation_tests.rs -expression: res +expression: "&diagnostics" --- -SyntaxError { message: "Invalid type nature for generic argument. BOOL is no Real.", range: [SourceLocation { span: Range(TextLocation { line: 2, column: 57, offset: 138 }..TextLocation { line: 2, column: 58, offset: 139 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid type nature for generic argument. BYTE is no Real.", range: [SourceLocation { span: Range(TextLocation { line: 3, column: 57, offset: 212 }..TextLocation { line: 3, column: 58, offset: 213 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid type nature for generic argument. WORD is no Real.", range: [SourceLocation { span: Range(TextLocation { line: 4, column: 57, offset: 286 }..TextLocation { line: 4, column: 58, offset: 287 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid type nature for generic argument. DWORD is no Real.", range: [SourceLocation { span: Range(TextLocation { line: 5, column: 58, offset: 361 }..TextLocation { line: 5, column: 59, offset: 362 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid type nature for generic argument. LWORD is no Real.", range: [SourceLocation { span: Range(TextLocation { line: 6, column: 58, offset: 436 }..TextLocation { line: 6, column: 59, offset: 437 }) }], err_no: type__invalid_nature } +error: Invalid type nature for generic argument. BOOL is no Real. + ┌─ :3:58 + │ +3 │ FUNCTION func1 : INT VAR x : BOOL; END_VAR test(x); END_FUNCTION + │ ^ Invalid type nature for generic argument. BOOL is no Real. + +error: Invalid type nature for generic argument. BYTE is no Real. + ┌─ :4:58 + │ +4 │ FUNCTION func2 : INT VAR x : BYTE; END_VAR test(x); END_FUNCTION + │ ^ Invalid type nature for generic argument. BYTE is no Real. + +error: Invalid type nature for generic argument. WORD is no Real. + ┌─ :5:58 + │ +5 │ FUNCTION func3 : INT VAR x : WORD; END_VAR test(x); END_FUNCTION + │ ^ Invalid type nature for generic argument. WORD is no Real. + +error: Invalid type nature for generic argument. DWORD is no Real. + ┌─ :6:59 + │ +6 │ FUNCTION func4 : INT VAR x : DWORD; END_VAR test(x); END_FUNCTION + │ ^ Invalid type nature for generic argument. DWORD is no Real. + +error: Invalid type nature for generic argument. LWORD is no Real. + ┌─ :7:59 + │ +7 │ FUNCTION func5 : INT VAR x : LWORD; END_VAR test(x); END_FUNCTION + │ ^ Invalid type nature for generic argument. LWORD is no Real. + diff --git a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_real_does_not_allow_chars.snap b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_real_does_not_allow_chars.snap index e7853d2ce5..b070f5217e 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_real_does_not_allow_chars.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_real_does_not_allow_chars.snap @@ -1,9 +1,29 @@ --- source: src/validation/tests/generic_validation_tests.rs -expression: res +expression: "&diagnostics" --- -SyntaxError { message: "Invalid assignment: cannot assign 'CHAR' to 'REAL'", range: [SourceLocation { span: Range(TextLocation { line: 2, column: 57, offset: 138 }..TextLocation { line: 2, column: 58, offset: 139 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid type nature for generic argument. CHAR is no Real.", range: [SourceLocation { span: Range(TextLocation { line: 2, column: 57, offset: 138 }..TextLocation { line: 2, column: 58, offset: 139 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid assignment: cannot assign 'WCHAR' to 'REAL'", range: [SourceLocation { span: Range(TextLocation { line: 3, column: 58, offset: 213 }..TextLocation { line: 3, column: 59, offset: 214 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid type nature for generic argument. WCHAR is no Real.", range: [SourceLocation { span: Range(TextLocation { line: 3, column: 58, offset: 213 }..TextLocation { line: 3, column: 59, offset: 214 }) }], err_no: type__invalid_nature } +error: Invalid assignment: cannot assign 'CHAR' to 'REAL' + ┌─ :3:58 + │ +3 │ FUNCTION func1 : INT VAR x : CHAR; END_VAR test(x); END_FUNCTION + │ ^ Invalid assignment: cannot assign 'CHAR' to 'REAL' + +error: Invalid type nature for generic argument. CHAR is no Real. + ┌─ :3:58 + │ +3 │ FUNCTION func1 : INT VAR x : CHAR; END_VAR test(x); END_FUNCTION + │ ^ Invalid type nature for generic argument. CHAR is no Real. + +error: Invalid assignment: cannot assign 'WCHAR' to 'REAL' + ┌─ :4:59 + │ +4 │ FUNCTION func2 : INT VAR x : WCHAR; END_VAR test(x); END_FUNCTION + │ ^ Invalid assignment: cannot assign 'WCHAR' to 'REAL' + +error: Invalid type nature for generic argument. WCHAR is no Real. + ┌─ :4:59 + │ +4 │ FUNCTION func2 : INT VAR x : WCHAR; END_VAR test(x); END_FUNCTION + │ ^ Invalid type nature for generic argument. WCHAR is no Real. + diff --git a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_real_does_not_allow_date.snap b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_real_does_not_allow_date.snap index 31fc52d197..320d5c32e7 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_real_does_not_allow_date.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_real_does_not_allow_date.snap @@ -1,10 +1,35 @@ --- source: src/validation/tests/generic_validation_tests.rs -expression: res +expression: "&diagnostics" --- -SyntaxError { message: "Invalid type nature for generic argument. DATE_AND_TIME is no Real.", range: [SourceLocation { span: Range(TextLocation { line: 2, column: 55, offset: 136 }..TextLocation { line: 2, column: 56, offset: 137 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid type nature for generic argument. DATE_AND_TIME is no Real.", range: [SourceLocation { span: Range(TextLocation { line: 3, column: 56, offset: 209 }..TextLocation { line: 3, column: 57, offset: 210 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid type nature for generic argument. DATE is no Real.", range: [SourceLocation { span: Range(TextLocation { line: 4, column: 57, offset: 283 }..TextLocation { line: 4, column: 58, offset: 284 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid type nature for generic argument. TIME_OF_DAY is no Real.", range: [SourceLocation { span: Range(TextLocation { line: 5, column: 56, offset: 356 }..TextLocation { line: 5, column: 57, offset: 357 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid type nature for generic argument. TIME_OF_DAY is no Real.", range: [SourceLocation { span: Range(TextLocation { line: 6, column: 57, offset: 430 }..TextLocation { line: 6, column: 58, offset: 431 }) }], err_no: type__invalid_nature } +error: Invalid type nature for generic argument. DATE_AND_TIME is no Real. + ┌─ :3:56 + │ +3 │ FUNCTION func1 : INT VAR x : DT; END_VAR test(x); END_FUNCTION + │ ^ Invalid type nature for generic argument. DATE_AND_TIME is no Real. + +error: Invalid type nature for generic argument. DATE_AND_TIME is no Real. + ┌─ :4:57 + │ +4 │ FUNCTION func2 : INT VAR x : LDT; END_VAR test(x); END_FUNCTION + │ ^ Invalid type nature for generic argument. DATE_AND_TIME is no Real. + +error: Invalid type nature for generic argument. DATE is no Real. + ┌─ :5:58 + │ +5 │ FUNCTION func3 : INT VAR x : DATE; END_VAR test(x); END_FUNCTION + │ ^ Invalid type nature for generic argument. DATE is no Real. + +error: Invalid type nature for generic argument. TIME_OF_DAY is no Real. + ┌─ :6:57 + │ +6 │ FUNCTION func4 : INT VAR x : TOD; END_VAR test(x); END_FUNCTION + │ ^ Invalid type nature for generic argument. TIME_OF_DAY is no Real. + +error: Invalid type nature for generic argument. TIME_OF_DAY is no Real. + ┌─ :7:58 + │ +7 │ FUNCTION func5 : INT VAR x : LTOD; END_VAR test(x); END_FUNCTION + │ ^ Invalid type nature for generic argument. TIME_OF_DAY is no Real. + diff --git a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_real_does_not_allow_string.snap b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_real_does_not_allow_string.snap index 1b05d798b1..12f605053f 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_real_does_not_allow_string.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_real_does_not_allow_string.snap @@ -1,9 +1,29 @@ --- source: src/validation/tests/generic_validation_tests.rs -expression: res +expression: "&diagnostics" --- -SyntaxError { message: "Invalid assignment: cannot assign 'STRING' to 'REAL'", range: [SourceLocation { span: Range(TextLocation { line: 2, column: 60, offset: 141 }..TextLocation { line: 2, column: 61, offset: 142 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid type nature for generic argument. STRING is no Real.", range: [SourceLocation { span: Range(TextLocation { line: 2, column: 60, offset: 141 }..TextLocation { line: 2, column: 61, offset: 142 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid assignment: cannot assign 'WSTRING' to 'REAL'", range: [SourceLocation { span: Range(TextLocation { line: 3, column: 60, offset: 218 }..TextLocation { line: 3, column: 61, offset: 219 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid type nature for generic argument. WSTRING is no Real.", range: [SourceLocation { span: Range(TextLocation { line: 3, column: 60, offset: 218 }..TextLocation { line: 3, column: 61, offset: 219 }) }], err_no: type__invalid_nature } +error: Invalid assignment: cannot assign 'STRING' to 'REAL' + ┌─ :3:61 + │ +3 │ FUNCTION func1 : INT VAR x : STRING; END_VAR test(x); END_FUNCTION + │ ^ Invalid assignment: cannot assign 'STRING' to 'REAL' + +error: Invalid type nature for generic argument. STRING is no Real. + ┌─ :3:61 + │ +3 │ FUNCTION func1 : INT VAR x : STRING; END_VAR test(x); END_FUNCTION + │ ^ Invalid type nature for generic argument. STRING is no Real. + +error: Invalid assignment: cannot assign 'WSTRING' to 'REAL' + ┌─ :4:61 + │ +4 │ FUNCTION func2 : INT VAR x : WSTRING; END_VAR test(x); END_FUNCTION + │ ^ Invalid assignment: cannot assign 'WSTRING' to 'REAL' + +error: Invalid type nature for generic argument. WSTRING is no Real. + ┌─ :4:61 + │ +4 │ FUNCTION func2 : INT VAR x : WSTRING; END_VAR test(x); END_FUNCTION + │ ^ Invalid type nature for generic argument. WSTRING is no Real. + diff --git a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_real_does_not_allow_time.snap b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_real_does_not_allow_time.snap index 1a45686ba3..1123655367 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_real_does_not_allow_time.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_real_does_not_allow_time.snap @@ -1,7 +1,17 @@ --- source: src/validation/tests/generic_validation_tests.rs -expression: res +expression: "&diagnostics" --- -SyntaxError { message: "Invalid type nature for generic argument. TIME is no Real.", range: [SourceLocation { span: Range(TextLocation { line: 2, column: 57, offset: 138 }..TextLocation { line: 2, column: 58, offset: 139 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid type nature for generic argument. TIME is no Real.", range: [SourceLocation { span: Range(TextLocation { line: 3, column: 58, offset: 213 }..TextLocation { line: 3, column: 59, offset: 214 }) }], err_no: type__invalid_nature } +error: Invalid type nature for generic argument. TIME is no Real. + ┌─ :3:58 + │ +3 │ FUNCTION func1 : INT VAR x : TIME; END_VAR test(x); END_FUNCTION + │ ^ Invalid type nature for generic argument. TIME is no Real. + +error: Invalid type nature for generic argument. TIME is no Real. + ┌─ :4:59 + │ +4 │ FUNCTION func2 : INT VAR x : LTIME; END_VAR test(x); END_FUNCTION + │ ^ Invalid type nature for generic argument. TIME is no Real. + diff --git a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_real_multiple_parameters.snap b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_real_multiple_parameters.snap index 56d4dea104..9a54a74a17 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_real_multiple_parameters.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_real_multiple_parameters.snap @@ -1,12 +1,47 @@ --- source: src/validation/tests/generic_validation_tests.rs -expression: res +expression: "&diagnostics" --- -SyntaxError { message: "Invalid type nature for generic argument. TIME is no Real.", range: [SourceLocation { span: Range(TextLocation { line: 14, column: 49, offset: 466 }..TextLocation { line: 14, column: 57, offset: 474 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid type nature for generic argument. BYTE is no Real.", range: [SourceLocation { span: Range(TextLocation { line: 14, column: 59, offset: 476 }..TextLocation { line: 14, column: 67, offset: 484 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid assignment: cannot assign 'STRING' to 'REAL'", range: [SourceLocation { span: Range(TextLocation { line: 14, column: 69, offset: 486 }..TextLocation { line: 14, column: 76, offset: 493 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid type nature for generic argument. STRING is no Real.", range: [SourceLocation { span: Range(TextLocation { line: 14, column: 69, offset: 486 }..TextLocation { line: 14, column: 76, offset: 493 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid assignment: cannot assign 'CHAR' to 'REAL'", range: [SourceLocation { span: Range(TextLocation { line: 14, column: 78, offset: 495 }..TextLocation { line: 14, column: 86, offset: 503 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid type nature for generic argument. CHAR is no Real.", range: [SourceLocation { span: Range(TextLocation { line: 14, column: 78, offset: 495 }..TextLocation { line: 14, column: 86, offset: 503 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid type nature for generic argument. DATE is no Real.", range: [SourceLocation { span: Range(TextLocation { line: 14, column: 88, offset: 505 }..TextLocation { line: 14, column: 96, offset: 513 }) }], err_no: type__invalid_nature } +error: Invalid type nature for generic argument. TIME is no Real. + ┌─ :15:50 + │ +15 │ func(var_real, var_unsigned, var_signed, var_time, var_byte, var_str, var_char, var_date); + │ ^^^^^^^^ Invalid type nature for generic argument. TIME is no Real. + +error: Invalid type nature for generic argument. BYTE is no Real. + ┌─ :15:60 + │ +15 │ func(var_real, var_unsigned, var_signed, var_time, var_byte, var_str, var_char, var_date); + │ ^^^^^^^^ Invalid type nature for generic argument. BYTE is no Real. + +error: Invalid assignment: cannot assign 'STRING' to 'REAL' + ┌─ :15:70 + │ +15 │ func(var_real, var_unsigned, var_signed, var_time, var_byte, var_str, var_char, var_date); + │ ^^^^^^^ Invalid assignment: cannot assign 'STRING' to 'REAL' + +error: Invalid type nature for generic argument. STRING is no Real. + ┌─ :15:70 + │ +15 │ func(var_real, var_unsigned, var_signed, var_time, var_byte, var_str, var_char, var_date); + │ ^^^^^^^ Invalid type nature for generic argument. STRING is no Real. + +error: Invalid assignment: cannot assign 'CHAR' to 'REAL' + ┌─ :15:79 + │ +15 │ func(var_real, var_unsigned, var_signed, var_time, var_byte, var_str, var_char, var_date); + │ ^^^^^^^^ Invalid assignment: cannot assign 'CHAR' to 'REAL' + +error: Invalid type nature for generic argument. CHAR is no Real. + ┌─ :15:79 + │ +15 │ func(var_real, var_unsigned, var_signed, var_time, var_byte, var_str, var_char, var_date); + │ ^^^^^^^^ Invalid type nature for generic argument. CHAR is no Real. + +error: Invalid type nature for generic argument. DATE is no Real. + ┌─ :15:89 + │ +15 │ func(var_real, var_unsigned, var_signed, var_time, var_byte, var_str, var_char, var_date); + │ ^^^^^^^^ Invalid type nature for generic argument. DATE is no Real. + diff --git a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_signed_does_not_allow_bits.snap b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_signed_does_not_allow_bits.snap index 8cfcae02e7..bafa2b092c 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_signed_does_not_allow_bits.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_signed_does_not_allow_bits.snap @@ -1,10 +1,35 @@ --- source: src/validation/tests/generic_validation_tests.rs -expression: res +expression: "&diagnostics" --- -SyntaxError { message: "Invalid type nature for generic argument. BOOL is no Signed.", range: [SourceLocation { span: Range(TextLocation { line: 2, column: 57, offset: 140 }..TextLocation { line: 2, column: 58, offset: 141 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid type nature for generic argument. BYTE is no Signed.", range: [SourceLocation { span: Range(TextLocation { line: 3, column: 57, offset: 214 }..TextLocation { line: 3, column: 58, offset: 215 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid type nature for generic argument. WORD is no Signed.", range: [SourceLocation { span: Range(TextLocation { line: 4, column: 57, offset: 288 }..TextLocation { line: 4, column: 58, offset: 289 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid type nature for generic argument. DWORD is no Signed.", range: [SourceLocation { span: Range(TextLocation { line: 5, column: 58, offset: 363 }..TextLocation { line: 5, column: 59, offset: 364 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid type nature for generic argument. LWORD is no Signed.", range: [SourceLocation { span: Range(TextLocation { line: 6, column: 58, offset: 438 }..TextLocation { line: 6, column: 59, offset: 439 }) }], err_no: type__invalid_nature } +error: Invalid type nature for generic argument. BOOL is no Signed. + ┌─ :3:58 + │ +3 │ FUNCTION func1 : INT VAR x : BOOL; END_VAR test(x); END_FUNCTION + │ ^ Invalid type nature for generic argument. BOOL is no Signed. + +error: Invalid type nature for generic argument. BYTE is no Signed. + ┌─ :4:58 + │ +4 │ FUNCTION func2 : INT VAR x : BYTE; END_VAR test(x); END_FUNCTION + │ ^ Invalid type nature for generic argument. BYTE is no Signed. + +error: Invalid type nature for generic argument. WORD is no Signed. + ┌─ :5:58 + │ +5 │ FUNCTION func3 : INT VAR x : WORD; END_VAR test(x); END_FUNCTION + │ ^ Invalid type nature for generic argument. WORD is no Signed. + +error: Invalid type nature for generic argument. DWORD is no Signed. + ┌─ :6:59 + │ +6 │ FUNCTION func4 : INT VAR x : DWORD; END_VAR test(x); END_FUNCTION + │ ^ Invalid type nature for generic argument. DWORD is no Signed. + +error: Invalid type nature for generic argument. LWORD is no Signed. + ┌─ :7:59 + │ +7 │ FUNCTION func5 : INT VAR x : LWORD; END_VAR test(x); END_FUNCTION + │ ^ Invalid type nature for generic argument. LWORD is no Signed. + diff --git a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_signed_does_not_allow_chars.snap b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_signed_does_not_allow_chars.snap index 2a3755c4f5..89736a966c 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_signed_does_not_allow_chars.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_signed_does_not_allow_chars.snap @@ -1,9 +1,29 @@ --- source: src/validation/tests/generic_validation_tests.rs -expression: res +expression: "&diagnostics" --- -SyntaxError { message: "Invalid assignment: cannot assign 'CHAR' to 'SINT'", range: [SourceLocation { span: Range(TextLocation { line: 2, column: 57, offset: 140 }..TextLocation { line: 2, column: 58, offset: 141 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid type nature for generic argument. CHAR is no Signed.", range: [SourceLocation { span: Range(TextLocation { line: 2, column: 57, offset: 140 }..TextLocation { line: 2, column: 58, offset: 141 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid assignment: cannot assign 'WCHAR' to 'SINT'", range: [SourceLocation { span: Range(TextLocation { line: 3, column: 58, offset: 215 }..TextLocation { line: 3, column: 59, offset: 216 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid type nature for generic argument. WCHAR is no Signed.", range: [SourceLocation { span: Range(TextLocation { line: 3, column: 58, offset: 215 }..TextLocation { line: 3, column: 59, offset: 216 }) }], err_no: type__invalid_nature } +error: Invalid assignment: cannot assign 'CHAR' to 'SINT' + ┌─ :3:58 + │ +3 │ FUNCTION func1 : INT VAR x : CHAR; END_VAR test(x); END_FUNCTION + │ ^ Invalid assignment: cannot assign 'CHAR' to 'SINT' + +error: Invalid type nature for generic argument. CHAR is no Signed. + ┌─ :3:58 + │ +3 │ FUNCTION func1 : INT VAR x : CHAR; END_VAR test(x); END_FUNCTION + │ ^ Invalid type nature for generic argument. CHAR is no Signed. + +error: Invalid assignment: cannot assign 'WCHAR' to 'SINT' + ┌─ :4:59 + │ +4 │ FUNCTION func2 : INT VAR x : WCHAR; END_VAR test(x); END_FUNCTION + │ ^ Invalid assignment: cannot assign 'WCHAR' to 'SINT' + +error: Invalid type nature for generic argument. WCHAR is no Signed. + ┌─ :4:59 + │ +4 │ FUNCTION func2 : INT VAR x : WCHAR; END_VAR test(x); END_FUNCTION + │ ^ Invalid type nature for generic argument. WCHAR is no Signed. + diff --git a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_signed_does_not_allow_date.snap b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_signed_does_not_allow_date.snap index 27bf8b80cd..a42147a337 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_signed_does_not_allow_date.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_signed_does_not_allow_date.snap @@ -1,10 +1,35 @@ --- source: src/validation/tests/generic_validation_tests.rs -expression: res +expression: "&diagnostics" --- -SyntaxError { message: "Invalid type nature for generic argument. DATE_AND_TIME is no Signed.", range: [SourceLocation { span: Range(TextLocation { line: 2, column: 55, offset: 138 }..TextLocation { line: 2, column: 56, offset: 139 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid type nature for generic argument. DATE_AND_TIME is no Signed.", range: [SourceLocation { span: Range(TextLocation { line: 3, column: 56, offset: 211 }..TextLocation { line: 3, column: 57, offset: 212 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid type nature for generic argument. DATE is no Signed.", range: [SourceLocation { span: Range(TextLocation { line: 4, column: 57, offset: 285 }..TextLocation { line: 4, column: 58, offset: 286 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid type nature for generic argument. TIME_OF_DAY is no Signed.", range: [SourceLocation { span: Range(TextLocation { line: 5, column: 56, offset: 358 }..TextLocation { line: 5, column: 57, offset: 359 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid type nature for generic argument. TIME_OF_DAY is no Signed.", range: [SourceLocation { span: Range(TextLocation { line: 6, column: 57, offset: 432 }..TextLocation { line: 6, column: 58, offset: 433 }) }], err_no: type__invalid_nature } +error: Invalid type nature for generic argument. DATE_AND_TIME is no Signed. + ┌─ :3:56 + │ +3 │ FUNCTION func1 : INT VAR x : DT; END_VAR test(x); END_FUNCTION + │ ^ Invalid type nature for generic argument. DATE_AND_TIME is no Signed. + +error: Invalid type nature for generic argument. DATE_AND_TIME is no Signed. + ┌─ :4:57 + │ +4 │ FUNCTION func2 : INT VAR x : LDT; END_VAR test(x); END_FUNCTION + │ ^ Invalid type nature for generic argument. DATE_AND_TIME is no Signed. + +error: Invalid type nature for generic argument. DATE is no Signed. + ┌─ :5:58 + │ +5 │ FUNCTION func3 : INT VAR x : DATE; END_VAR test(x); END_FUNCTION + │ ^ Invalid type nature for generic argument. DATE is no Signed. + +error: Invalid type nature for generic argument. TIME_OF_DAY is no Signed. + ┌─ :6:57 + │ +6 │ FUNCTION func4 : INT VAR x : TOD; END_VAR test(x); END_FUNCTION + │ ^ Invalid type nature for generic argument. TIME_OF_DAY is no Signed. + +error: Invalid type nature for generic argument. TIME_OF_DAY is no Signed. + ┌─ :7:58 + │ +7 │ FUNCTION func5 : INT VAR x : LTOD; END_VAR test(x); END_FUNCTION + │ ^ Invalid type nature for generic argument. TIME_OF_DAY is no Signed. + diff --git a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_signed_does_not_allow_reals.snap b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_signed_does_not_allow_reals.snap index 1ee0a53e2c..a2451a885d 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_signed_does_not_allow_reals.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_signed_does_not_allow_reals.snap @@ -1,7 +1,17 @@ --- source: src/validation/tests/generic_validation_tests.rs -expression: res +expression: "&diagnostics" --- -SyntaxError { message: "Invalid type nature for generic argument. REAL is no Signed.", range: [SourceLocation { span: Range(TextLocation { line: 2, column: 56, offset: 139 }..TextLocation { line: 2, column: 57, offset: 140 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid type nature for generic argument. LREAL is no Signed.", range: [SourceLocation { span: Range(TextLocation { line: 3, column: 58, offset: 214 }..TextLocation { line: 3, column: 59, offset: 215 }) }], err_no: type__invalid_nature } +error: Invalid type nature for generic argument. REAL is no Signed. + ┌─ :3:57 + │ +3 │ FUNCTION func : INT VAR x : REAL; END_VAR test(x); END_FUNCTION + │ ^ Invalid type nature for generic argument. REAL is no Signed. + +error: Invalid type nature for generic argument. LREAL is no Signed. + ┌─ :4:59 + │ +4 │ FUNCTION func1 : INT VAR x : LREAL; END_VAR test(x); END_FUNCTION + │ ^ Invalid type nature for generic argument. LREAL is no Signed. + diff --git a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_signed_does_not_allow_string.snap b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_signed_does_not_allow_string.snap index 75fc9045c4..6792f138d2 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_signed_does_not_allow_string.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_signed_does_not_allow_string.snap @@ -1,9 +1,29 @@ --- source: src/validation/tests/generic_validation_tests.rs -expression: res +expression: "&diagnostics" --- -SyntaxError { message: "Invalid assignment: cannot assign 'STRING' to 'SINT'", range: [SourceLocation { span: Range(TextLocation { line: 2, column: 60, offset: 143 }..TextLocation { line: 2, column: 61, offset: 144 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid type nature for generic argument. STRING is no Signed.", range: [SourceLocation { span: Range(TextLocation { line: 2, column: 60, offset: 143 }..TextLocation { line: 2, column: 61, offset: 144 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid assignment: cannot assign 'WSTRING' to 'SINT'", range: [SourceLocation { span: Range(TextLocation { line: 3, column: 60, offset: 220 }..TextLocation { line: 3, column: 61, offset: 221 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid type nature for generic argument. WSTRING is no Signed.", range: [SourceLocation { span: Range(TextLocation { line: 3, column: 60, offset: 220 }..TextLocation { line: 3, column: 61, offset: 221 }) }], err_no: type__invalid_nature } +error: Invalid assignment: cannot assign 'STRING' to 'SINT' + ┌─ :3:61 + │ +3 │ FUNCTION func1 : INT VAR x : STRING; END_VAR test(x); END_FUNCTION + │ ^ Invalid assignment: cannot assign 'STRING' to 'SINT' + +error: Invalid type nature for generic argument. STRING is no Signed. + ┌─ :3:61 + │ +3 │ FUNCTION func1 : INT VAR x : STRING; END_VAR test(x); END_FUNCTION + │ ^ Invalid type nature for generic argument. STRING is no Signed. + +error: Invalid assignment: cannot assign 'WSTRING' to 'SINT' + ┌─ :4:61 + │ +4 │ FUNCTION func2 : INT VAR x : WSTRING; END_VAR test(x); END_FUNCTION + │ ^ Invalid assignment: cannot assign 'WSTRING' to 'SINT' + +error: Invalid type nature for generic argument. WSTRING is no Signed. + ┌─ :4:61 + │ +4 │ FUNCTION func2 : INT VAR x : WSTRING; END_VAR test(x); END_FUNCTION + │ ^ Invalid type nature for generic argument. WSTRING is no Signed. + diff --git a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_signed_does_not_allow_time.snap b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_signed_does_not_allow_time.snap index ed44095305..2bc83b9ec4 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_signed_does_not_allow_time.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_signed_does_not_allow_time.snap @@ -1,7 +1,17 @@ --- source: src/validation/tests/generic_validation_tests.rs -expression: res +expression: "&diagnostics" --- -SyntaxError { message: "Invalid type nature for generic argument. TIME is no Signed.", range: [SourceLocation { span: Range(TextLocation { line: 2, column: 57, offset: 140 }..TextLocation { line: 2, column: 58, offset: 141 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid type nature for generic argument. TIME is no Signed.", range: [SourceLocation { span: Range(TextLocation { line: 3, column: 58, offset: 215 }..TextLocation { line: 3, column: 59, offset: 216 }) }], err_no: type__invalid_nature } +error: Invalid type nature for generic argument. TIME is no Signed. + ┌─ :3:58 + │ +3 │ FUNCTION func1 : INT VAR x : TIME; END_VAR test(x); END_FUNCTION + │ ^ Invalid type nature for generic argument. TIME is no Signed. + +error: Invalid type nature for generic argument. TIME is no Signed. + ┌─ :4:59 + │ +4 │ FUNCTION func2 : INT VAR x : LTIME; END_VAR test(x); END_FUNCTION + │ ^ Invalid type nature for generic argument. TIME is no Signed. + diff --git a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_signed_does_not_allow_unsigned_ints.snap b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_signed_does_not_allow_unsigned_ints.snap index dae2f20f80..0575ab186d 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_signed_does_not_allow_unsigned_ints.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_signed_does_not_allow_unsigned_ints.snap @@ -1,9 +1,29 @@ --- source: src/validation/tests/generic_validation_tests.rs -expression: res +expression: "&diagnostics" --- -SyntaxError { message: "Invalid type nature for generic argument. USINT is no Signed.", range: [SourceLocation { span: Range(TextLocation { line: 2, column: 58, offset: 141 }..TextLocation { line: 2, column: 59, offset: 142 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid type nature for generic argument. UINT is no Signed.", range: [SourceLocation { span: Range(TextLocation { line: 3, column: 57, offset: 215 }..TextLocation { line: 3, column: 58, offset: 216 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid type nature for generic argument. UDINT is no Signed.", range: [SourceLocation { span: Range(TextLocation { line: 4, column: 58, offset: 290 }..TextLocation { line: 4, column: 59, offset: 291 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid type nature for generic argument. ULINT is no Signed.", range: [SourceLocation { span: Range(TextLocation { line: 5, column: 58, offset: 365 }..TextLocation { line: 5, column: 59, offset: 366 }) }], err_no: type__invalid_nature } +error: Invalid type nature for generic argument. USINT is no Signed. + ┌─ :3:59 + │ +3 │ FUNCTION func1 : INT VAR x : USINT; END_VAR test(x); END_FUNCTION + │ ^ Invalid type nature for generic argument. USINT is no Signed. + +error: Invalid type nature for generic argument. UINT is no Signed. + ┌─ :4:58 + │ +4 │ FUNCTION func2 : INT VAR x : UINT; END_VAR test(x); END_FUNCTION + │ ^ Invalid type nature for generic argument. UINT is no Signed. + +error: Invalid type nature for generic argument. UDINT is no Signed. + ┌─ :5:59 + │ +5 │ FUNCTION func3 : INT VAR x : UDINT; END_VAR test(x); END_FUNCTION + │ ^ Invalid type nature for generic argument. UDINT is no Signed. + +error: Invalid type nature for generic argument. ULINT is no Signed. + ┌─ :6:59 + │ +6 │ FUNCTION func4 : INT VAR x : ULINT; END_VAR test(x); END_FUNCTION + │ ^ Invalid type nature for generic argument. ULINT is no Signed. + diff --git a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_signed_multiple_parameters.snap b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_signed_multiple_parameters.snap index d1a5222f99..59c8109954 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_signed_multiple_parameters.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_signed_multiple_parameters.snap @@ -1,14 +1,59 @@ --- source: src/validation/tests/generic_validation_tests.rs -expression: res +expression: "&diagnostics" --- -SyntaxError { message: "Invalid type nature for generic argument. REAL is no Signed.", range: [SourceLocation { span: Range(TextLocation { line: 14, column: 13, offset: 432 }..TextLocation { line: 14, column: 21, offset: 440 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid type nature for generic argument. UDINT is no Signed.", range: [SourceLocation { span: Range(TextLocation { line: 14, column: 23, offset: 442 }..TextLocation { line: 14, column: 35, offset: 454 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid type nature for generic argument. TIME is no Signed.", range: [SourceLocation { span: Range(TextLocation { line: 14, column: 49, offset: 468 }..TextLocation { line: 14, column: 57, offset: 476 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid type nature for generic argument. BYTE is no Signed.", range: [SourceLocation { span: Range(TextLocation { line: 14, column: 59, offset: 478 }..TextLocation { line: 14, column: 67, offset: 486 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid assignment: cannot assign 'STRING' to 'DINT'", range: [SourceLocation { span: Range(TextLocation { line: 14, column: 69, offset: 488 }..TextLocation { line: 14, column: 76, offset: 495 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid type nature for generic argument. STRING is no Signed.", range: [SourceLocation { span: Range(TextLocation { line: 14, column: 69, offset: 488 }..TextLocation { line: 14, column: 76, offset: 495 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid assignment: cannot assign 'CHAR' to 'DINT'", range: [SourceLocation { span: Range(TextLocation { line: 14, column: 78, offset: 497 }..TextLocation { line: 14, column: 86, offset: 505 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid type nature for generic argument. CHAR is no Signed.", range: [SourceLocation { span: Range(TextLocation { line: 14, column: 78, offset: 497 }..TextLocation { line: 14, column: 86, offset: 505 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid type nature for generic argument. DATE is no Signed.", range: [SourceLocation { span: Range(TextLocation { line: 14, column: 88, offset: 507 }..TextLocation { line: 14, column: 96, offset: 515 }) }], err_no: type__invalid_nature } +error: Invalid type nature for generic argument. REAL is no Signed. + ┌─ :15:14 + │ +15 │ func(var_real, var_unsigned, var_signed, var_time, var_byte, var_str, var_char, var_date); + │ ^^^^^^^^ Invalid type nature for generic argument. REAL is no Signed. + +error: Invalid type nature for generic argument. UDINT is no Signed. + ┌─ :15:24 + │ +15 │ func(var_real, var_unsigned, var_signed, var_time, var_byte, var_str, var_char, var_date); + │ ^^^^^^^^^^^^ Invalid type nature for generic argument. UDINT is no Signed. + +error: Invalid type nature for generic argument. TIME is no Signed. + ┌─ :15:50 + │ +15 │ func(var_real, var_unsigned, var_signed, var_time, var_byte, var_str, var_char, var_date); + │ ^^^^^^^^ Invalid type nature for generic argument. TIME is no Signed. + +error: Invalid type nature for generic argument. BYTE is no Signed. + ┌─ :15:60 + │ +15 │ func(var_real, var_unsigned, var_signed, var_time, var_byte, var_str, var_char, var_date); + │ ^^^^^^^^ Invalid type nature for generic argument. BYTE is no Signed. + +error: Invalid assignment: cannot assign 'STRING' to 'DINT' + ┌─ :15:70 + │ +15 │ func(var_real, var_unsigned, var_signed, var_time, var_byte, var_str, var_char, var_date); + │ ^^^^^^^ Invalid assignment: cannot assign 'STRING' to 'DINT' + +error: Invalid type nature for generic argument. STRING is no Signed. + ┌─ :15:70 + │ +15 │ func(var_real, var_unsigned, var_signed, var_time, var_byte, var_str, var_char, var_date); + │ ^^^^^^^ Invalid type nature for generic argument. STRING is no Signed. + +error: Invalid assignment: cannot assign 'CHAR' to 'DINT' + ┌─ :15:79 + │ +15 │ func(var_real, var_unsigned, var_signed, var_time, var_byte, var_str, var_char, var_date); + │ ^^^^^^^^ Invalid assignment: cannot assign 'CHAR' to 'DINT' + +error: Invalid type nature for generic argument. CHAR is no Signed. + ┌─ :15:79 + │ +15 │ func(var_real, var_unsigned, var_signed, var_time, var_byte, var_str, var_char, var_date); + │ ^^^^^^^^ Invalid type nature for generic argument. CHAR is no Signed. + +error: Invalid type nature for generic argument. DATE is no Signed. + ┌─ :15:89 + │ +15 │ func(var_real, var_unsigned, var_signed, var_time, var_byte, var_str, var_char, var_date); + │ ^^^^^^^^ Invalid type nature for generic argument. DATE is no Signed. + diff --git a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_string_does_not_allow_bits.snap b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_string_does_not_allow_bits.snap index 11c387aaa2..a5fa4cc826 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_string_does_not_allow_bits.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_string_does_not_allow_bits.snap @@ -1,15 +1,65 @@ --- source: src/validation/tests/generic_validation_tests.rs -expression: res +expression: "&diagnostics" --- -SyntaxError { message: "Invalid assignment: cannot assign 'BOOL' to 'STRING'", range: [SourceLocation { span: Range(TextLocation { line: 2, column: 57, offset: 140 }..TextLocation { line: 2, column: 58, offset: 141 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid type nature for generic argument. BOOL is no String.", range: [SourceLocation { span: Range(TextLocation { line: 2, column: 57, offset: 140 }..TextLocation { line: 2, column: 58, offset: 141 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid assignment: cannot assign 'BYTE' to 'STRING'", range: [SourceLocation { span: Range(TextLocation { line: 3, column: 57, offset: 214 }..TextLocation { line: 3, column: 58, offset: 215 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid type nature for generic argument. BYTE is no String.", range: [SourceLocation { span: Range(TextLocation { line: 3, column: 57, offset: 214 }..TextLocation { line: 3, column: 58, offset: 215 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid assignment: cannot assign 'WORD' to 'STRING'", range: [SourceLocation { span: Range(TextLocation { line: 4, column: 57, offset: 288 }..TextLocation { line: 4, column: 58, offset: 289 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid type nature for generic argument. WORD is no String.", range: [SourceLocation { span: Range(TextLocation { line: 4, column: 57, offset: 288 }..TextLocation { line: 4, column: 58, offset: 289 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid assignment: cannot assign 'DWORD' to 'STRING'", range: [SourceLocation { span: Range(TextLocation { line: 5, column: 58, offset: 363 }..TextLocation { line: 5, column: 59, offset: 364 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid type nature for generic argument. DWORD is no String.", range: [SourceLocation { span: Range(TextLocation { line: 5, column: 58, offset: 363 }..TextLocation { line: 5, column: 59, offset: 364 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid assignment: cannot assign 'LWORD' to 'STRING'", range: [SourceLocation { span: Range(TextLocation { line: 6, column: 58, offset: 438 }..TextLocation { line: 6, column: 59, offset: 439 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid type nature for generic argument. LWORD is no String.", range: [SourceLocation { span: Range(TextLocation { line: 6, column: 58, offset: 438 }..TextLocation { line: 6, column: 59, offset: 439 }) }], err_no: type__invalid_nature } +error: Invalid assignment: cannot assign 'BOOL' to 'STRING' + ┌─ :3:58 + │ +3 │ FUNCTION func1 : INT VAR x : BOOL; END_VAR test(x); END_FUNCTION + │ ^ Invalid assignment: cannot assign 'BOOL' to 'STRING' + +error: Invalid type nature for generic argument. BOOL is no String. + ┌─ :3:58 + │ +3 │ FUNCTION func1 : INT VAR x : BOOL; END_VAR test(x); END_FUNCTION + │ ^ Invalid type nature for generic argument. BOOL is no String. + +error: Invalid assignment: cannot assign 'BYTE' to 'STRING' + ┌─ :4:58 + │ +4 │ FUNCTION func2 : INT VAR x : BYTE; END_VAR test(x); END_FUNCTION + │ ^ Invalid assignment: cannot assign 'BYTE' to 'STRING' + +error: Invalid type nature for generic argument. BYTE is no String. + ┌─ :4:58 + │ +4 │ FUNCTION func2 : INT VAR x : BYTE; END_VAR test(x); END_FUNCTION + │ ^ Invalid type nature for generic argument. BYTE is no String. + +error: Invalid assignment: cannot assign 'WORD' to 'STRING' + ┌─ :5:58 + │ +5 │ FUNCTION func3 : INT VAR x : WORD; END_VAR test(x); END_FUNCTION + │ ^ Invalid assignment: cannot assign 'WORD' to 'STRING' + +error: Invalid type nature for generic argument. WORD is no String. + ┌─ :5:58 + │ +5 │ FUNCTION func3 : INT VAR x : WORD; END_VAR test(x); END_FUNCTION + │ ^ Invalid type nature for generic argument. WORD is no String. + +error: Invalid assignment: cannot assign 'DWORD' to 'STRING' + ┌─ :6:59 + │ +6 │ FUNCTION func4 : INT VAR x : DWORD; END_VAR test(x); END_FUNCTION + │ ^ Invalid assignment: cannot assign 'DWORD' to 'STRING' + +error: Invalid type nature for generic argument. DWORD is no String. + ┌─ :6:59 + │ +6 │ FUNCTION func4 : INT VAR x : DWORD; END_VAR test(x); END_FUNCTION + │ ^ Invalid type nature for generic argument. DWORD is no String. + +error: Invalid assignment: cannot assign 'LWORD' to 'STRING' + ┌─ :7:59 + │ +7 │ FUNCTION func5 : INT VAR x : LWORD; END_VAR test(x); END_FUNCTION + │ ^ Invalid assignment: cannot assign 'LWORD' to 'STRING' + +error: Invalid type nature for generic argument. LWORD is no String. + ┌─ :7:59 + │ +7 │ FUNCTION func5 : INT VAR x : LWORD; END_VAR test(x); END_FUNCTION + │ ^ Invalid type nature for generic argument. LWORD is no String. + diff --git a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_string_does_not_allow_chars.snap b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_string_does_not_allow_chars.snap index 9c182c5061..9ea8bfc1de 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_string_does_not_allow_chars.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_string_does_not_allow_chars.snap @@ -1,9 +1,29 @@ --- source: src/validation/tests/generic_validation_tests.rs -expression: res +expression: "&diagnostics" --- -SyntaxError { message: "Invalid assignment: cannot assign 'CHAR' to 'STRING'", range: [SourceLocation { span: Range(TextLocation { line: 2, column: 57, offset: 140 }..TextLocation { line: 2, column: 58, offset: 141 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid type nature for generic argument. CHAR is no String.", range: [SourceLocation { span: Range(TextLocation { line: 2, column: 57, offset: 140 }..TextLocation { line: 2, column: 58, offset: 141 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid assignment: cannot assign 'WCHAR' to 'STRING'", range: [SourceLocation { span: Range(TextLocation { line: 3, column: 58, offset: 215 }..TextLocation { line: 3, column: 59, offset: 216 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid type nature for generic argument. WCHAR is no String.", range: [SourceLocation { span: Range(TextLocation { line: 3, column: 58, offset: 215 }..TextLocation { line: 3, column: 59, offset: 216 }) }], err_no: type__invalid_nature } +error: Invalid assignment: cannot assign 'CHAR' to 'STRING' + ┌─ :3:58 + │ +3 │ FUNCTION func1 : INT VAR x : CHAR; END_VAR test(x); END_FUNCTION + │ ^ Invalid assignment: cannot assign 'CHAR' to 'STRING' + +error: Invalid type nature for generic argument. CHAR is no String. + ┌─ :3:58 + │ +3 │ FUNCTION func1 : INT VAR x : CHAR; END_VAR test(x); END_FUNCTION + │ ^ Invalid type nature for generic argument. CHAR is no String. + +error: Invalid assignment: cannot assign 'WCHAR' to 'STRING' + ┌─ :4:59 + │ +4 │ FUNCTION func2 : INT VAR x : WCHAR; END_VAR test(x); END_FUNCTION + │ ^ Invalid assignment: cannot assign 'WCHAR' to 'STRING' + +error: Invalid type nature for generic argument. WCHAR is no String. + ┌─ :4:59 + │ +4 │ FUNCTION func2 : INT VAR x : WCHAR; END_VAR test(x); END_FUNCTION + │ ^ Invalid type nature for generic argument. WCHAR is no String. + diff --git a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_string_does_not_allow_date.snap b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_string_does_not_allow_date.snap index 3eb8916b5c..f9a298da7b 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_string_does_not_allow_date.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_string_does_not_allow_date.snap @@ -1,15 +1,65 @@ --- source: src/validation/tests/generic_validation_tests.rs -expression: res +expression: "&diagnostics" --- -SyntaxError { message: "Invalid assignment: cannot assign 'DATE_AND_TIME' to 'STRING'", range: [SourceLocation { span: Range(TextLocation { line: 2, column: 55, offset: 138 }..TextLocation { line: 2, column: 56, offset: 139 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid type nature for generic argument. DATE_AND_TIME is no String.", range: [SourceLocation { span: Range(TextLocation { line: 2, column: 55, offset: 138 }..TextLocation { line: 2, column: 56, offset: 139 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid assignment: cannot assign 'DATE_AND_TIME' to 'STRING'", range: [SourceLocation { span: Range(TextLocation { line: 3, column: 56, offset: 211 }..TextLocation { line: 3, column: 57, offset: 212 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid type nature for generic argument. DATE_AND_TIME is no String.", range: [SourceLocation { span: Range(TextLocation { line: 3, column: 56, offset: 211 }..TextLocation { line: 3, column: 57, offset: 212 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid assignment: cannot assign 'DATE' to 'STRING'", range: [SourceLocation { span: Range(TextLocation { line: 4, column: 57, offset: 285 }..TextLocation { line: 4, column: 58, offset: 286 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid type nature for generic argument. DATE is no String.", range: [SourceLocation { span: Range(TextLocation { line: 4, column: 57, offset: 285 }..TextLocation { line: 4, column: 58, offset: 286 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid assignment: cannot assign 'TIME_OF_DAY' to 'STRING'", range: [SourceLocation { span: Range(TextLocation { line: 5, column: 56, offset: 358 }..TextLocation { line: 5, column: 57, offset: 359 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid type nature for generic argument. TIME_OF_DAY is no String.", range: [SourceLocation { span: Range(TextLocation { line: 5, column: 56, offset: 358 }..TextLocation { line: 5, column: 57, offset: 359 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid assignment: cannot assign 'TIME_OF_DAY' to 'STRING'", range: [SourceLocation { span: Range(TextLocation { line: 6, column: 57, offset: 432 }..TextLocation { line: 6, column: 58, offset: 433 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid type nature for generic argument. TIME_OF_DAY is no String.", range: [SourceLocation { span: Range(TextLocation { line: 6, column: 57, offset: 432 }..TextLocation { line: 6, column: 58, offset: 433 }) }], err_no: type__invalid_nature } +error: Invalid assignment: cannot assign 'DATE_AND_TIME' to 'STRING' + ┌─ :3:56 + │ +3 │ FUNCTION func1 : INT VAR x : DT; END_VAR test(x); END_FUNCTION + │ ^ Invalid assignment: cannot assign 'DATE_AND_TIME' to 'STRING' + +error: Invalid type nature for generic argument. DATE_AND_TIME is no String. + ┌─ :3:56 + │ +3 │ FUNCTION func1 : INT VAR x : DT; END_VAR test(x); END_FUNCTION + │ ^ Invalid type nature for generic argument. DATE_AND_TIME is no String. + +error: Invalid assignment: cannot assign 'DATE_AND_TIME' to 'STRING' + ┌─ :4:57 + │ +4 │ FUNCTION func2 : INT VAR x : LDT; END_VAR test(x); END_FUNCTION + │ ^ Invalid assignment: cannot assign 'DATE_AND_TIME' to 'STRING' + +error: Invalid type nature for generic argument. DATE_AND_TIME is no String. + ┌─ :4:57 + │ +4 │ FUNCTION func2 : INT VAR x : LDT; END_VAR test(x); END_FUNCTION + │ ^ Invalid type nature for generic argument. DATE_AND_TIME is no String. + +error: Invalid assignment: cannot assign 'DATE' to 'STRING' + ┌─ :5:58 + │ +5 │ FUNCTION func3 : INT VAR x : DATE; END_VAR test(x); END_FUNCTION + │ ^ Invalid assignment: cannot assign 'DATE' to 'STRING' + +error: Invalid type nature for generic argument. DATE is no String. + ┌─ :5:58 + │ +5 │ FUNCTION func3 : INT VAR x : DATE; END_VAR test(x); END_FUNCTION + │ ^ Invalid type nature for generic argument. DATE is no String. + +error: Invalid assignment: cannot assign 'TIME_OF_DAY' to 'STRING' + ┌─ :6:57 + │ +6 │ FUNCTION func4 : INT VAR x : TOD; END_VAR test(x); END_FUNCTION + │ ^ Invalid assignment: cannot assign 'TIME_OF_DAY' to 'STRING' + +error: Invalid type nature for generic argument. TIME_OF_DAY is no String. + ┌─ :6:57 + │ +6 │ FUNCTION func4 : INT VAR x : TOD; END_VAR test(x); END_FUNCTION + │ ^ Invalid type nature for generic argument. TIME_OF_DAY is no String. + +error: Invalid assignment: cannot assign 'TIME_OF_DAY' to 'STRING' + ┌─ :7:58 + │ +7 │ FUNCTION func5 : INT VAR x : LTOD; END_VAR test(x); END_FUNCTION + │ ^ Invalid assignment: cannot assign 'TIME_OF_DAY' to 'STRING' + +error: Invalid type nature for generic argument. TIME_OF_DAY is no String. + ┌─ :7:58 + │ +7 │ FUNCTION func5 : INT VAR x : LTOD; END_VAR test(x); END_FUNCTION + │ ^ Invalid type nature for generic argument. TIME_OF_DAY is no String. + diff --git a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_string_does_not_allow_ints.snap b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_string_does_not_allow_ints.snap index f422281cd8..99cf46a912 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_string_does_not_allow_ints.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_string_does_not_allow_ints.snap @@ -1,21 +1,101 @@ --- source: src/validation/tests/generic_validation_tests.rs -expression: res +expression: "&diagnostics" --- -SyntaxError { message: "Invalid assignment: cannot assign 'USINT' to 'STRING'", range: [SourceLocation { span: Range(TextLocation { line: 3, column: 58, offset: 142 }..TextLocation { line: 3, column: 59, offset: 143 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid type nature for generic argument. USINT is no String.", range: [SourceLocation { span: Range(TextLocation { line: 3, column: 58, offset: 142 }..TextLocation { line: 3, column: 59, offset: 143 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid assignment: cannot assign 'UINT' to 'STRING'", range: [SourceLocation { span: Range(TextLocation { line: 4, column: 57, offset: 216 }..TextLocation { line: 4, column: 58, offset: 217 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid type nature for generic argument. UINT is no String.", range: [SourceLocation { span: Range(TextLocation { line: 4, column: 57, offset: 216 }..TextLocation { line: 4, column: 58, offset: 217 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid assignment: cannot assign 'UDINT' to 'STRING'", range: [SourceLocation { span: Range(TextLocation { line: 5, column: 58, offset: 291 }..TextLocation { line: 5, column: 59, offset: 292 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid type nature for generic argument. UDINT is no String.", range: [SourceLocation { span: Range(TextLocation { line: 5, column: 58, offset: 291 }..TextLocation { line: 5, column: 59, offset: 292 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid assignment: cannot assign 'ULINT' to 'STRING'", range: [SourceLocation { span: Range(TextLocation { line: 6, column: 58, offset: 366 }..TextLocation { line: 6, column: 59, offset: 367 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid type nature for generic argument. ULINT is no String.", range: [SourceLocation { span: Range(TextLocation { line: 6, column: 58, offset: 366 }..TextLocation { line: 6, column: 59, offset: 367 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid assignment: cannot assign 'SINT' to 'STRING'", range: [SourceLocation { span: Range(TextLocation { line: 8, column: 57, offset: 441 }..TextLocation { line: 8, column: 58, offset: 442 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid type nature for generic argument. SINT is no String.", range: [SourceLocation { span: Range(TextLocation { line: 8, column: 57, offset: 441 }..TextLocation { line: 8, column: 58, offset: 442 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid assignment: cannot assign 'INT' to 'STRING'", range: [SourceLocation { span: Range(TextLocation { line: 9, column: 56, offset: 514 }..TextLocation { line: 9, column: 57, offset: 515 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid type nature for generic argument. INT is no String.", range: [SourceLocation { span: Range(TextLocation { line: 9, column: 56, offset: 514 }..TextLocation { line: 9, column: 57, offset: 515 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid assignment: cannot assign 'DINT' to 'STRING'", range: [SourceLocation { span: Range(TextLocation { line: 10, column: 57, offset: 588 }..TextLocation { line: 10, column: 58, offset: 589 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid type nature for generic argument. DINT is no String.", range: [SourceLocation { span: Range(TextLocation { line: 10, column: 57, offset: 588 }..TextLocation { line: 10, column: 58, offset: 589 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid assignment: cannot assign 'LINT' to 'STRING'", range: [SourceLocation { span: Range(TextLocation { line: 11, column: 57, offset: 662 }..TextLocation { line: 11, column: 58, offset: 663 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid type nature for generic argument. LINT is no String.", range: [SourceLocation { span: Range(TextLocation { line: 11, column: 57, offset: 662 }..TextLocation { line: 11, column: 58, offset: 663 }) }], err_no: type__invalid_nature } +error: Invalid assignment: cannot assign 'USINT' to 'STRING' + ┌─ :4:59 + │ +4 │ FUNCTION func1 : INT VAR x : USINT; END_VAR test(x); END_FUNCTION + │ ^ Invalid assignment: cannot assign 'USINT' to 'STRING' + +error: Invalid type nature for generic argument. USINT is no String. + ┌─ :4:59 + │ +4 │ FUNCTION func1 : INT VAR x : USINT; END_VAR test(x); END_FUNCTION + │ ^ Invalid type nature for generic argument. USINT is no String. + +error: Invalid assignment: cannot assign 'UINT' to 'STRING' + ┌─ :5:58 + │ +5 │ FUNCTION func2 : INT VAR x : UINT; END_VAR test(x); END_FUNCTION + │ ^ Invalid assignment: cannot assign 'UINT' to 'STRING' + +error: Invalid type nature for generic argument. UINT is no String. + ┌─ :5:58 + │ +5 │ FUNCTION func2 : INT VAR x : UINT; END_VAR test(x); END_FUNCTION + │ ^ Invalid type nature for generic argument. UINT is no String. + +error: Invalid assignment: cannot assign 'UDINT' to 'STRING' + ┌─ :6:59 + │ +6 │ FUNCTION func3 : INT VAR x : UDINT; END_VAR test(x); END_FUNCTION + │ ^ Invalid assignment: cannot assign 'UDINT' to 'STRING' + +error: Invalid type nature for generic argument. UDINT is no String. + ┌─ :6:59 + │ +6 │ FUNCTION func3 : INT VAR x : UDINT; END_VAR test(x); END_FUNCTION + │ ^ Invalid type nature for generic argument. UDINT is no String. + +error: Invalid assignment: cannot assign 'ULINT' to 'STRING' + ┌─ :7:59 + │ +7 │ FUNCTION func4 : INT VAR x : ULINT; END_VAR test(x); END_FUNCTION + │ ^ Invalid assignment: cannot assign 'ULINT' to 'STRING' + +error: Invalid type nature for generic argument. ULINT is no String. + ┌─ :7:59 + │ +7 │ FUNCTION func4 : INT VAR x : ULINT; END_VAR test(x); END_FUNCTION + │ ^ Invalid type nature for generic argument. ULINT is no String. + +error: Invalid assignment: cannot assign 'SINT' to 'STRING' + ┌─ :9:58 + │ +9 │ FUNCTION func5 : INT VAR x : SINT; END_VAR test(x); END_FUNCTION + │ ^ Invalid assignment: cannot assign 'SINT' to 'STRING' + +error: Invalid type nature for generic argument. SINT is no String. + ┌─ :9:58 + │ +9 │ FUNCTION func5 : INT VAR x : SINT; END_VAR test(x); END_FUNCTION + │ ^ Invalid type nature for generic argument. SINT is no String. + +error: Invalid assignment: cannot assign 'INT' to 'STRING' + ┌─ :10:57 + │ +10 │ FUNCTION func6 : INT VAR x : INT; END_VAR test(x); END_FUNCTION + │ ^ Invalid assignment: cannot assign 'INT' to 'STRING' + +error: Invalid type nature for generic argument. INT is no String. + ┌─ :10:57 + │ +10 │ FUNCTION func6 : INT VAR x : INT; END_VAR test(x); END_FUNCTION + │ ^ Invalid type nature for generic argument. INT is no String. + +error: Invalid assignment: cannot assign 'DINT' to 'STRING' + ┌─ :11:58 + │ +11 │ FUNCTION func7 : INT VAR x : DINT; END_VAR test(x); END_FUNCTION + │ ^ Invalid assignment: cannot assign 'DINT' to 'STRING' + +error: Invalid type nature for generic argument. DINT is no String. + ┌─ :11:58 + │ +11 │ FUNCTION func7 : INT VAR x : DINT; END_VAR test(x); END_FUNCTION + │ ^ Invalid type nature for generic argument. DINT is no String. + +error: Invalid assignment: cannot assign 'LINT' to 'STRING' + ┌─ :12:58 + │ +12 │ FUNCTION func8 : INT VAR x : LINT; END_VAR test(x); END_FUNCTION + │ ^ Invalid assignment: cannot assign 'LINT' to 'STRING' + +error: Invalid type nature for generic argument. LINT is no String. + ┌─ :12:58 + │ +12 │ FUNCTION func8 : INT VAR x : LINT; END_VAR test(x); END_FUNCTION + │ ^ Invalid type nature for generic argument. LINT is no String. + diff --git a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_string_does_not_allow_reals.snap b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_string_does_not_allow_reals.snap index d58447e904..a6984ba6e8 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_string_does_not_allow_reals.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_string_does_not_allow_reals.snap @@ -1,9 +1,29 @@ --- source: src/validation/tests/generic_validation_tests.rs -expression: res +expression: "&diagnostics" --- -SyntaxError { message: "Invalid assignment: cannot assign 'REAL' to 'STRING'", range: [SourceLocation { span: Range(TextLocation { line: 2, column: 56, offset: 139 }..TextLocation { line: 2, column: 57, offset: 140 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid type nature for generic argument. REAL is no String.", range: [SourceLocation { span: Range(TextLocation { line: 2, column: 56, offset: 139 }..TextLocation { line: 2, column: 57, offset: 140 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid assignment: cannot assign 'LREAL' to 'STRING'", range: [SourceLocation { span: Range(TextLocation { line: 3, column: 58, offset: 214 }..TextLocation { line: 3, column: 59, offset: 215 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid type nature for generic argument. LREAL is no String.", range: [SourceLocation { span: Range(TextLocation { line: 3, column: 58, offset: 214 }..TextLocation { line: 3, column: 59, offset: 215 }) }], err_no: type__invalid_nature } +error: Invalid assignment: cannot assign 'REAL' to 'STRING' + ┌─ :3:57 + │ +3 │ FUNCTION func : INT VAR x : REAL; END_VAR test(x); END_FUNCTION + │ ^ Invalid assignment: cannot assign 'REAL' to 'STRING' + +error: Invalid type nature for generic argument. REAL is no String. + ┌─ :3:57 + │ +3 │ FUNCTION func : INT VAR x : REAL; END_VAR test(x); END_FUNCTION + │ ^ Invalid type nature for generic argument. REAL is no String. + +error: Invalid assignment: cannot assign 'LREAL' to 'STRING' + ┌─ :4:59 + │ +4 │ FUNCTION func1 : INT VAR x : LREAL; END_VAR test(x); END_FUNCTION + │ ^ Invalid assignment: cannot assign 'LREAL' to 'STRING' + +error: Invalid type nature for generic argument. LREAL is no String. + ┌─ :4:59 + │ +4 │ FUNCTION func1 : INT VAR x : LREAL; END_VAR test(x); END_FUNCTION + │ ^ Invalid type nature for generic argument. LREAL is no String. + diff --git a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_string_does_not_allow_time.snap b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_string_does_not_allow_time.snap index 69895eaf1b..1189636e09 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_string_does_not_allow_time.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_string_does_not_allow_time.snap @@ -1,9 +1,29 @@ --- source: src/validation/tests/generic_validation_tests.rs -expression: res +expression: "&diagnostics" --- -SyntaxError { message: "Invalid assignment: cannot assign 'TIME' to 'STRING'", range: [SourceLocation { span: Range(TextLocation { line: 2, column: 57, offset: 140 }..TextLocation { line: 2, column: 58, offset: 141 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid type nature for generic argument. TIME is no String.", range: [SourceLocation { span: Range(TextLocation { line: 2, column: 57, offset: 140 }..TextLocation { line: 2, column: 58, offset: 141 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid assignment: cannot assign 'TIME' to 'STRING'", range: [SourceLocation { span: Range(TextLocation { line: 3, column: 58, offset: 215 }..TextLocation { line: 3, column: 59, offset: 216 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid type nature for generic argument. TIME is no String.", range: [SourceLocation { span: Range(TextLocation { line: 3, column: 58, offset: 215 }..TextLocation { line: 3, column: 59, offset: 216 }) }], err_no: type__invalid_nature } +error: Invalid assignment: cannot assign 'TIME' to 'STRING' + ┌─ :3:58 + │ +3 │ FUNCTION func1 : INT VAR x : TIME; END_VAR test(x); END_FUNCTION + │ ^ Invalid assignment: cannot assign 'TIME' to 'STRING' + +error: Invalid type nature for generic argument. TIME is no String. + ┌─ :3:58 + │ +3 │ FUNCTION func1 : INT VAR x : TIME; END_VAR test(x); END_FUNCTION + │ ^ Invalid type nature for generic argument. TIME is no String. + +error: Invalid assignment: cannot assign 'TIME' to 'STRING' + ┌─ :4:59 + │ +4 │ FUNCTION func2 : INT VAR x : LTIME; END_VAR test(x); END_FUNCTION + │ ^ Invalid assignment: cannot assign 'TIME' to 'STRING' + +error: Invalid type nature for generic argument. TIME is no String. + ┌─ :4:59 + │ +4 │ FUNCTION func2 : INT VAR x : LTIME; END_VAR test(x); END_FUNCTION + │ ^ Invalid type nature for generic argument. TIME is no String. + diff --git a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_string_multiple_parameters.snap b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_string_multiple_parameters.snap index a09170cb8c..7d29372c74 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_string_multiple_parameters.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_string_multiple_parameters.snap @@ -1,19 +1,89 @@ --- source: src/validation/tests/generic_validation_tests.rs -expression: res +expression: "&diagnostics" --- -SyntaxError { message: "Invalid assignment: cannot assign 'REAL' to 'STRING'", range: [SourceLocation { span: Range(TextLocation { line: 14, column: 13, offset: 432 }..TextLocation { line: 14, column: 21, offset: 440 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid type nature for generic argument. REAL is no String.", range: [SourceLocation { span: Range(TextLocation { line: 14, column: 13, offset: 432 }..TextLocation { line: 14, column: 21, offset: 440 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid assignment: cannot assign 'UDINT' to 'STRING'", range: [SourceLocation { span: Range(TextLocation { line: 14, column: 23, offset: 442 }..TextLocation { line: 14, column: 35, offset: 454 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid type nature for generic argument. UDINT is no String.", range: [SourceLocation { span: Range(TextLocation { line: 14, column: 23, offset: 442 }..TextLocation { line: 14, column: 35, offset: 454 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid assignment: cannot assign 'DINT' to 'STRING'", range: [SourceLocation { span: Range(TextLocation { line: 14, column: 37, offset: 456 }..TextLocation { line: 14, column: 47, offset: 466 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid type nature for generic argument. DINT is no String.", range: [SourceLocation { span: Range(TextLocation { line: 14, column: 37, offset: 456 }..TextLocation { line: 14, column: 47, offset: 466 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid assignment: cannot assign 'TIME' to 'STRING'", range: [SourceLocation { span: Range(TextLocation { line: 14, column: 49, offset: 468 }..TextLocation { line: 14, column: 57, offset: 476 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid type nature for generic argument. TIME is no String.", range: [SourceLocation { span: Range(TextLocation { line: 14, column: 49, offset: 468 }..TextLocation { line: 14, column: 57, offset: 476 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid assignment: cannot assign 'BYTE' to 'STRING'", range: [SourceLocation { span: Range(TextLocation { line: 14, column: 59, offset: 478 }..TextLocation { line: 14, column: 67, offset: 486 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid type nature for generic argument. BYTE is no String.", range: [SourceLocation { span: Range(TextLocation { line: 14, column: 59, offset: 478 }..TextLocation { line: 14, column: 67, offset: 486 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid assignment: cannot assign 'CHAR' to 'STRING'", range: [SourceLocation { span: Range(TextLocation { line: 14, column: 78, offset: 497 }..TextLocation { line: 14, column: 86, offset: 505 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid type nature for generic argument. CHAR is no String.", range: [SourceLocation { span: Range(TextLocation { line: 14, column: 78, offset: 497 }..TextLocation { line: 14, column: 86, offset: 505 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid assignment: cannot assign 'DATE' to 'STRING'", range: [SourceLocation { span: Range(TextLocation { line: 14, column: 88, offset: 507 }..TextLocation { line: 14, column: 96, offset: 515 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid type nature for generic argument. DATE is no String.", range: [SourceLocation { span: Range(TextLocation { line: 14, column: 88, offset: 507 }..TextLocation { line: 14, column: 96, offset: 515 }) }], err_no: type__invalid_nature } +error: Invalid assignment: cannot assign 'REAL' to 'STRING' + ┌─ :15:14 + │ +15 │ func(var_real, var_unsigned, var_signed, var_time, var_byte, var_str, var_char, var_date); + │ ^^^^^^^^ Invalid assignment: cannot assign 'REAL' to 'STRING' + +error: Invalid type nature for generic argument. REAL is no String. + ┌─ :15:14 + │ +15 │ func(var_real, var_unsigned, var_signed, var_time, var_byte, var_str, var_char, var_date); + │ ^^^^^^^^ Invalid type nature for generic argument. REAL is no String. + +error: Invalid assignment: cannot assign 'UDINT' to 'STRING' + ┌─ :15:24 + │ +15 │ func(var_real, var_unsigned, var_signed, var_time, var_byte, var_str, var_char, var_date); + │ ^^^^^^^^^^^^ Invalid assignment: cannot assign 'UDINT' to 'STRING' + +error: Invalid type nature for generic argument. UDINT is no String. + ┌─ :15:24 + │ +15 │ func(var_real, var_unsigned, var_signed, var_time, var_byte, var_str, var_char, var_date); + │ ^^^^^^^^^^^^ Invalid type nature for generic argument. UDINT is no String. + +error: Invalid assignment: cannot assign 'DINT' to 'STRING' + ┌─ :15:38 + │ +15 │ func(var_real, var_unsigned, var_signed, var_time, var_byte, var_str, var_char, var_date); + │ ^^^^^^^^^^ Invalid assignment: cannot assign 'DINT' to 'STRING' + +error: Invalid type nature for generic argument. DINT is no String. + ┌─ :15:38 + │ +15 │ func(var_real, var_unsigned, var_signed, var_time, var_byte, var_str, var_char, var_date); + │ ^^^^^^^^^^ Invalid type nature for generic argument. DINT is no String. + +error: Invalid assignment: cannot assign 'TIME' to 'STRING' + ┌─ :15:50 + │ +15 │ func(var_real, var_unsigned, var_signed, var_time, var_byte, var_str, var_char, var_date); + │ ^^^^^^^^ Invalid assignment: cannot assign 'TIME' to 'STRING' + +error: Invalid type nature for generic argument. TIME is no String. + ┌─ :15:50 + │ +15 │ func(var_real, var_unsigned, var_signed, var_time, var_byte, var_str, var_char, var_date); + │ ^^^^^^^^ Invalid type nature for generic argument. TIME is no String. + +error: Invalid assignment: cannot assign 'BYTE' to 'STRING' + ┌─ :15:60 + │ +15 │ func(var_real, var_unsigned, var_signed, var_time, var_byte, var_str, var_char, var_date); + │ ^^^^^^^^ Invalid assignment: cannot assign 'BYTE' to 'STRING' + +error: Invalid type nature for generic argument. BYTE is no String. + ┌─ :15:60 + │ +15 │ func(var_real, var_unsigned, var_signed, var_time, var_byte, var_str, var_char, var_date); + │ ^^^^^^^^ Invalid type nature for generic argument. BYTE is no String. + +error: Invalid assignment: cannot assign 'CHAR' to 'STRING' + ┌─ :15:79 + │ +15 │ func(var_real, var_unsigned, var_signed, var_time, var_byte, var_str, var_char, var_date); + │ ^^^^^^^^ Invalid assignment: cannot assign 'CHAR' to 'STRING' + +error: Invalid type nature for generic argument. CHAR is no String. + ┌─ :15:79 + │ +15 │ func(var_real, var_unsigned, var_signed, var_time, var_byte, var_str, var_char, var_date); + │ ^^^^^^^^ Invalid type nature for generic argument. CHAR is no String. + +error: Invalid assignment: cannot assign 'DATE' to 'STRING' + ┌─ :15:89 + │ +15 │ func(var_real, var_unsigned, var_signed, var_time, var_byte, var_str, var_char, var_date); + │ ^^^^^^^^ Invalid assignment: cannot assign 'DATE' to 'STRING' + +error: Invalid type nature for generic argument. DATE is no String. + ┌─ :15:89 + │ +15 │ func(var_real, var_unsigned, var_signed, var_time, var_byte, var_str, var_char, var_date); + │ ^^^^^^^^ Invalid type nature for generic argument. DATE is no String. + diff --git a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_unsigned_does_not_allow_bits.snap b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_unsigned_does_not_allow_bits.snap index 91c3f3106f..5876d1cc1c 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_unsigned_does_not_allow_bits.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_unsigned_does_not_allow_bits.snap @@ -1,10 +1,35 @@ --- source: src/validation/tests/generic_validation_tests.rs -expression: res +expression: "&diagnostics" --- -SyntaxError { message: "Invalid type nature for generic argument. BOOL is no Unsigned.", range: [SourceLocation { span: Range(TextLocation { line: 2, column: 57, offset: 142 }..TextLocation { line: 2, column: 58, offset: 143 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid type nature for generic argument. BYTE is no Unsigned.", range: [SourceLocation { span: Range(TextLocation { line: 3, column: 57, offset: 216 }..TextLocation { line: 3, column: 58, offset: 217 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid type nature for generic argument. WORD is no Unsigned.", range: [SourceLocation { span: Range(TextLocation { line: 4, column: 57, offset: 290 }..TextLocation { line: 4, column: 58, offset: 291 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid type nature for generic argument. DWORD is no Unsigned.", range: [SourceLocation { span: Range(TextLocation { line: 5, column: 58, offset: 365 }..TextLocation { line: 5, column: 59, offset: 366 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid type nature for generic argument. LWORD is no Unsigned.", range: [SourceLocation { span: Range(TextLocation { line: 6, column: 58, offset: 440 }..TextLocation { line: 6, column: 59, offset: 441 }) }], err_no: type__invalid_nature } +error: Invalid type nature for generic argument. BOOL is no Unsigned. + ┌─ :3:58 + │ +3 │ FUNCTION func1 : INT VAR x : BOOL; END_VAR test(x); END_FUNCTION + │ ^ Invalid type nature for generic argument. BOOL is no Unsigned. + +error: Invalid type nature for generic argument. BYTE is no Unsigned. + ┌─ :4:58 + │ +4 │ FUNCTION func2 : INT VAR x : BYTE; END_VAR test(x); END_FUNCTION + │ ^ Invalid type nature for generic argument. BYTE is no Unsigned. + +error: Invalid type nature for generic argument. WORD is no Unsigned. + ┌─ :5:58 + │ +5 │ FUNCTION func3 : INT VAR x : WORD; END_VAR test(x); END_FUNCTION + │ ^ Invalid type nature for generic argument. WORD is no Unsigned. + +error: Invalid type nature for generic argument. DWORD is no Unsigned. + ┌─ :6:59 + │ +6 │ FUNCTION func4 : INT VAR x : DWORD; END_VAR test(x); END_FUNCTION + │ ^ Invalid type nature for generic argument. DWORD is no Unsigned. + +error: Invalid type nature for generic argument. LWORD is no Unsigned. + ┌─ :7:59 + │ +7 │ FUNCTION func5 : INT VAR x : LWORD; END_VAR test(x); END_FUNCTION + │ ^ Invalid type nature for generic argument. LWORD is no Unsigned. + diff --git a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_unsigned_does_not_allow_chars.snap b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_unsigned_does_not_allow_chars.snap index b16d084c82..e281997f84 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_unsigned_does_not_allow_chars.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_unsigned_does_not_allow_chars.snap @@ -1,9 +1,29 @@ --- source: src/validation/tests/generic_validation_tests.rs -expression: res +expression: "&diagnostics" --- -SyntaxError { message: "Invalid assignment: cannot assign 'CHAR' to 'USINT'", range: [SourceLocation { span: Range(TextLocation { line: 2, column: 57, offset: 142 }..TextLocation { line: 2, column: 58, offset: 143 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid type nature for generic argument. CHAR is no Unsigned.", range: [SourceLocation { span: Range(TextLocation { line: 2, column: 57, offset: 142 }..TextLocation { line: 2, column: 58, offset: 143 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid assignment: cannot assign 'WCHAR' to 'USINT'", range: [SourceLocation { span: Range(TextLocation { line: 3, column: 58, offset: 217 }..TextLocation { line: 3, column: 59, offset: 218 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid type nature for generic argument. WCHAR is no Unsigned.", range: [SourceLocation { span: Range(TextLocation { line: 3, column: 58, offset: 217 }..TextLocation { line: 3, column: 59, offset: 218 }) }], err_no: type__invalid_nature } +error: Invalid assignment: cannot assign 'CHAR' to 'USINT' + ┌─ :3:58 + │ +3 │ FUNCTION func1 : INT VAR x : CHAR; END_VAR test(x); END_FUNCTION + │ ^ Invalid assignment: cannot assign 'CHAR' to 'USINT' + +error: Invalid type nature for generic argument. CHAR is no Unsigned. + ┌─ :3:58 + │ +3 │ FUNCTION func1 : INT VAR x : CHAR; END_VAR test(x); END_FUNCTION + │ ^ Invalid type nature for generic argument. CHAR is no Unsigned. + +error: Invalid assignment: cannot assign 'WCHAR' to 'USINT' + ┌─ :4:59 + │ +4 │ FUNCTION func2 : INT VAR x : WCHAR; END_VAR test(x); END_FUNCTION + │ ^ Invalid assignment: cannot assign 'WCHAR' to 'USINT' + +error: Invalid type nature for generic argument. WCHAR is no Unsigned. + ┌─ :4:59 + │ +4 │ FUNCTION func2 : INT VAR x : WCHAR; END_VAR test(x); END_FUNCTION + │ ^ Invalid type nature for generic argument. WCHAR is no Unsigned. + diff --git a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_unsigned_does_not_allow_date.snap b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_unsigned_does_not_allow_date.snap index 379758d32c..d0abe53082 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_unsigned_does_not_allow_date.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_unsigned_does_not_allow_date.snap @@ -1,10 +1,35 @@ --- source: src/validation/tests/generic_validation_tests.rs -expression: res +expression: "&diagnostics" --- -SyntaxError { message: "Invalid type nature for generic argument. DATE_AND_TIME is no Unsigned.", range: [SourceLocation { span: Range(TextLocation { line: 2, column: 55, offset: 140 }..TextLocation { line: 2, column: 56, offset: 141 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid type nature for generic argument. DATE_AND_TIME is no Unsigned.", range: [SourceLocation { span: Range(TextLocation { line: 3, column: 56, offset: 213 }..TextLocation { line: 3, column: 57, offset: 214 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid type nature for generic argument. DATE is no Unsigned.", range: [SourceLocation { span: Range(TextLocation { line: 4, column: 57, offset: 287 }..TextLocation { line: 4, column: 58, offset: 288 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid type nature for generic argument. TIME_OF_DAY is no Unsigned.", range: [SourceLocation { span: Range(TextLocation { line: 5, column: 56, offset: 360 }..TextLocation { line: 5, column: 57, offset: 361 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid type nature for generic argument. TIME_OF_DAY is no Unsigned.", range: [SourceLocation { span: Range(TextLocation { line: 6, column: 57, offset: 434 }..TextLocation { line: 6, column: 58, offset: 435 }) }], err_no: type__invalid_nature } +error: Invalid type nature for generic argument. DATE_AND_TIME is no Unsigned. + ┌─ :3:56 + │ +3 │ FUNCTION func1 : INT VAR x : DT; END_VAR test(x); END_FUNCTION + │ ^ Invalid type nature for generic argument. DATE_AND_TIME is no Unsigned. + +error: Invalid type nature for generic argument. DATE_AND_TIME is no Unsigned. + ┌─ :4:57 + │ +4 │ FUNCTION func2 : INT VAR x : LDT; END_VAR test(x); END_FUNCTION + │ ^ Invalid type nature for generic argument. DATE_AND_TIME is no Unsigned. + +error: Invalid type nature for generic argument. DATE is no Unsigned. + ┌─ :5:58 + │ +5 │ FUNCTION func3 : INT VAR x : DATE; END_VAR test(x); END_FUNCTION + │ ^ Invalid type nature for generic argument. DATE is no Unsigned. + +error: Invalid type nature for generic argument. TIME_OF_DAY is no Unsigned. + ┌─ :6:57 + │ +6 │ FUNCTION func4 : INT VAR x : TOD; END_VAR test(x); END_FUNCTION + │ ^ Invalid type nature for generic argument. TIME_OF_DAY is no Unsigned. + +error: Invalid type nature for generic argument. TIME_OF_DAY is no Unsigned. + ┌─ :7:58 + │ +7 │ FUNCTION func5 : INT VAR x : LTOD; END_VAR test(x); END_FUNCTION + │ ^ Invalid type nature for generic argument. TIME_OF_DAY is no Unsigned. + diff --git a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_unsigned_does_not_allow_reals.snap b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_unsigned_does_not_allow_reals.snap index 0a10712372..3bcba293c9 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_unsigned_does_not_allow_reals.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_unsigned_does_not_allow_reals.snap @@ -1,7 +1,17 @@ --- source: src/validation/tests/generic_validation_tests.rs -expression: res +expression: "&diagnostics" --- -SyntaxError { message: "Invalid type nature for generic argument. REAL is no Unsigned.", range: [SourceLocation { span: Range(TextLocation { line: 2, column: 56, offset: 141 }..TextLocation { line: 2, column: 57, offset: 142 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid type nature for generic argument. LREAL is no Unsigned.", range: [SourceLocation { span: Range(TextLocation { line: 3, column: 58, offset: 216 }..TextLocation { line: 3, column: 59, offset: 217 }) }], err_no: type__invalid_nature } +error: Invalid type nature for generic argument. REAL is no Unsigned. + ┌─ :3:57 + │ +3 │ FUNCTION func : INT VAR x : REAL; END_VAR test(x); END_FUNCTION + │ ^ Invalid type nature for generic argument. REAL is no Unsigned. + +error: Invalid type nature for generic argument. LREAL is no Unsigned. + ┌─ :4:59 + │ +4 │ FUNCTION func1 : INT VAR x : LREAL; END_VAR test(x); END_FUNCTION + │ ^ Invalid type nature for generic argument. LREAL is no Unsigned. + diff --git a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_unsigned_does_not_allow_signed_ints.snap b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_unsigned_does_not_allow_signed_ints.snap index ed065d0218..36b40f22db 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_unsigned_does_not_allow_signed_ints.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_unsigned_does_not_allow_signed_ints.snap @@ -1,9 +1,29 @@ --- source: src/validation/tests/generic_validation_tests.rs -expression: res +expression: "&diagnostics" --- -SyntaxError { message: "Invalid type nature for generic argument. SINT is no Unsigned.", range: [SourceLocation { span: Range(TextLocation { line: 2, column: 57, offset: 142 }..TextLocation { line: 2, column: 58, offset: 143 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid type nature for generic argument. INT is no Unsigned.", range: [SourceLocation { span: Range(TextLocation { line: 3, column: 56, offset: 215 }..TextLocation { line: 3, column: 57, offset: 216 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid type nature for generic argument. DINT is no Unsigned.", range: [SourceLocation { span: Range(TextLocation { line: 4, column: 57, offset: 289 }..TextLocation { line: 4, column: 58, offset: 290 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid type nature for generic argument. LINT is no Unsigned.", range: [SourceLocation { span: Range(TextLocation { line: 5, column: 57, offset: 363 }..TextLocation { line: 5, column: 58, offset: 364 }) }], err_no: type__invalid_nature } +error: Invalid type nature for generic argument. SINT is no Unsigned. + ┌─ :3:58 + │ +3 │ FUNCTION func1 : INT VAR x : SINT; END_VAR test(x); END_FUNCTION + │ ^ Invalid type nature for generic argument. SINT is no Unsigned. + +error: Invalid type nature for generic argument. INT is no Unsigned. + ┌─ :4:57 + │ +4 │ FUNCTION func2 : INT VAR x : INT; END_VAR test(x); END_FUNCTION + │ ^ Invalid type nature for generic argument. INT is no Unsigned. + +error: Invalid type nature for generic argument. DINT is no Unsigned. + ┌─ :5:58 + │ +5 │ FUNCTION func3 : INT VAR x : DINT; END_VAR test(x); END_FUNCTION + │ ^ Invalid type nature for generic argument. DINT is no Unsigned. + +error: Invalid type nature for generic argument. LINT is no Unsigned. + ┌─ :6:58 + │ +6 │ FUNCTION func4 : INT VAR x : LINT; END_VAR test(x); END_FUNCTION + │ ^ Invalid type nature for generic argument. LINT is no Unsigned. + diff --git a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_unsigned_does_not_allow_string.snap b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_unsigned_does_not_allow_string.snap index 7332799f7e..c1bc15b379 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_unsigned_does_not_allow_string.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_unsigned_does_not_allow_string.snap @@ -1,9 +1,29 @@ --- source: src/validation/tests/generic_validation_tests.rs -expression: res +expression: "&diagnostics" --- -SyntaxError { message: "Invalid assignment: cannot assign 'STRING' to 'USINT'", range: [SourceLocation { span: Range(TextLocation { line: 2, column: 60, offset: 145 }..TextLocation { line: 2, column: 61, offset: 146 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid type nature for generic argument. STRING is no Unsigned.", range: [SourceLocation { span: Range(TextLocation { line: 2, column: 60, offset: 145 }..TextLocation { line: 2, column: 61, offset: 146 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid assignment: cannot assign 'WSTRING' to 'USINT'", range: [SourceLocation { span: Range(TextLocation { line: 3, column: 60, offset: 222 }..TextLocation { line: 3, column: 61, offset: 223 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid type nature for generic argument. WSTRING is no Unsigned.", range: [SourceLocation { span: Range(TextLocation { line: 3, column: 60, offset: 222 }..TextLocation { line: 3, column: 61, offset: 223 }) }], err_no: type__invalid_nature } +error: Invalid assignment: cannot assign 'STRING' to 'USINT' + ┌─ :3:61 + │ +3 │ FUNCTION func1 : INT VAR x : STRING; END_VAR test(x); END_FUNCTION + │ ^ Invalid assignment: cannot assign 'STRING' to 'USINT' + +error: Invalid type nature for generic argument. STRING is no Unsigned. + ┌─ :3:61 + │ +3 │ FUNCTION func1 : INT VAR x : STRING; END_VAR test(x); END_FUNCTION + │ ^ Invalid type nature for generic argument. STRING is no Unsigned. + +error: Invalid assignment: cannot assign 'WSTRING' to 'USINT' + ┌─ :4:61 + │ +4 │ FUNCTION func2 : INT VAR x : WSTRING; END_VAR test(x); END_FUNCTION + │ ^ Invalid assignment: cannot assign 'WSTRING' to 'USINT' + +error: Invalid type nature for generic argument. WSTRING is no Unsigned. + ┌─ :4:61 + │ +4 │ FUNCTION func2 : INT VAR x : WSTRING; END_VAR test(x); END_FUNCTION + │ ^ Invalid type nature for generic argument. WSTRING is no Unsigned. + diff --git a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_unsigned_does_not_allow_time.snap b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_unsigned_does_not_allow_time.snap index ccb44ea6a9..f47254d309 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_unsigned_does_not_allow_time.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_unsigned_does_not_allow_time.snap @@ -1,7 +1,17 @@ --- source: src/validation/tests/generic_validation_tests.rs -expression: res +expression: "&diagnostics" --- -SyntaxError { message: "Invalid type nature for generic argument. TIME is no Unsigned.", range: [SourceLocation { span: Range(TextLocation { line: 2, column: 57, offset: 142 }..TextLocation { line: 2, column: 58, offset: 143 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid type nature for generic argument. TIME is no Unsigned.", range: [SourceLocation { span: Range(TextLocation { line: 3, column: 58, offset: 217 }..TextLocation { line: 3, column: 59, offset: 218 }) }], err_no: type__invalid_nature } +error: Invalid type nature for generic argument. TIME is no Unsigned. + ┌─ :3:58 + │ +3 │ FUNCTION func1 : INT VAR x : TIME; END_VAR test(x); END_FUNCTION + │ ^ Invalid type nature for generic argument. TIME is no Unsigned. + +error: Invalid type nature for generic argument. TIME is no Unsigned. + ┌─ :4:59 + │ +4 │ FUNCTION func2 : INT VAR x : LTIME; END_VAR test(x); END_FUNCTION + │ ^ Invalid type nature for generic argument. TIME is no Unsigned. + diff --git a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_unsigned_multiple_parameters.snap b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_unsigned_multiple_parameters.snap index d4056c28e5..5b64fff636 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_unsigned_multiple_parameters.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_unsigned_multiple_parameters.snap @@ -1,14 +1,59 @@ --- source: src/validation/tests/generic_validation_tests.rs -expression: res +expression: "&diagnostics" --- -SyntaxError { message: "Invalid type nature for generic argument. REAL is no Unsigned.", range: [SourceLocation { span: Range(TextLocation { line: 14, column: 13, offset: 434 }..TextLocation { line: 14, column: 21, offset: 442 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid type nature for generic argument. DINT is no Unsigned.", range: [SourceLocation { span: Range(TextLocation { line: 14, column: 37, offset: 458 }..TextLocation { line: 14, column: 47, offset: 468 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid type nature for generic argument. TIME is no Unsigned.", range: [SourceLocation { span: Range(TextLocation { line: 14, column: 49, offset: 470 }..TextLocation { line: 14, column: 57, offset: 478 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid type nature for generic argument. BYTE is no Unsigned.", range: [SourceLocation { span: Range(TextLocation { line: 14, column: 59, offset: 480 }..TextLocation { line: 14, column: 67, offset: 488 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid assignment: cannot assign 'STRING' to 'UDINT'", range: [SourceLocation { span: Range(TextLocation { line: 14, column: 69, offset: 490 }..TextLocation { line: 14, column: 76, offset: 497 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid type nature for generic argument. STRING is no Unsigned.", range: [SourceLocation { span: Range(TextLocation { line: 14, column: 69, offset: 490 }..TextLocation { line: 14, column: 76, offset: 497 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid assignment: cannot assign 'CHAR' to 'UDINT'", range: [SourceLocation { span: Range(TextLocation { line: 14, column: 78, offset: 499 }..TextLocation { line: 14, column: 86, offset: 507 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid type nature for generic argument. CHAR is no Unsigned.", range: [SourceLocation { span: Range(TextLocation { line: 14, column: 78, offset: 499 }..TextLocation { line: 14, column: 86, offset: 507 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid type nature for generic argument. DATE is no Unsigned.", range: [SourceLocation { span: Range(TextLocation { line: 14, column: 88, offset: 509 }..TextLocation { line: 14, column: 96, offset: 517 }) }], err_no: type__invalid_nature } +error: Invalid type nature for generic argument. REAL is no Unsigned. + ┌─ :15:14 + │ +15 │ func(var_real, var_unsigned, var_signed, var_time, var_byte, var_str, var_char, var_date); + │ ^^^^^^^^ Invalid type nature for generic argument. REAL is no Unsigned. + +error: Invalid type nature for generic argument. DINT is no Unsigned. + ┌─ :15:38 + │ +15 │ func(var_real, var_unsigned, var_signed, var_time, var_byte, var_str, var_char, var_date); + │ ^^^^^^^^^^ Invalid type nature for generic argument. DINT is no Unsigned. + +error: Invalid type nature for generic argument. TIME is no Unsigned. + ┌─ :15:50 + │ +15 │ func(var_real, var_unsigned, var_signed, var_time, var_byte, var_str, var_char, var_date); + │ ^^^^^^^^ Invalid type nature for generic argument. TIME is no Unsigned. + +error: Invalid type nature for generic argument. BYTE is no Unsigned. + ┌─ :15:60 + │ +15 │ func(var_real, var_unsigned, var_signed, var_time, var_byte, var_str, var_char, var_date); + │ ^^^^^^^^ Invalid type nature for generic argument. BYTE is no Unsigned. + +error: Invalid assignment: cannot assign 'STRING' to 'UDINT' + ┌─ :15:70 + │ +15 │ func(var_real, var_unsigned, var_signed, var_time, var_byte, var_str, var_char, var_date); + │ ^^^^^^^ Invalid assignment: cannot assign 'STRING' to 'UDINT' + +error: Invalid type nature for generic argument. STRING is no Unsigned. + ┌─ :15:70 + │ +15 │ func(var_real, var_unsigned, var_signed, var_time, var_byte, var_str, var_char, var_date); + │ ^^^^^^^ Invalid type nature for generic argument. STRING is no Unsigned. + +error: Invalid assignment: cannot assign 'CHAR' to 'UDINT' + ┌─ :15:79 + │ +15 │ func(var_real, var_unsigned, var_signed, var_time, var_byte, var_str, var_char, var_date); + │ ^^^^^^^^ Invalid assignment: cannot assign 'CHAR' to 'UDINT' + +error: Invalid type nature for generic argument. CHAR is no Unsigned. + ┌─ :15:79 + │ +15 │ func(var_real, var_unsigned, var_signed, var_time, var_byte, var_str, var_char, var_date); + │ ^^^^^^^^ Invalid type nature for generic argument. CHAR is no Unsigned. + +error: Invalid type nature for generic argument. DATE is no Unsigned. + ┌─ :15:89 + │ +15 │ func(var_real, var_unsigned, var_signed, var_time, var_byte, var_str, var_char, var_date); + │ ^^^^^^^^ Invalid type nature for generic argument. DATE is no Unsigned. + diff --git a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__non_resolved_generics_reported.snap b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__non_resolved_generics_reported.snap index 809e301a76..24ac4b53e5 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__non_resolved_generics_reported.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__non_resolved_generics_reported.snap @@ -1,6 +1,11 @@ --- source: src/validation/tests/generic_validation_tests.rs -expression: res +expression: "&diagnostics" --- -SyntaxError { message: "Could not resolve generic type T with nature String", range: [SourceLocation { span: Range(TextLocation { line: 2, column: 30, offset: 86 }..TextLocation { line: 2, column: 37, offset: 93 }) }], err_no: type__unresolved_generic } +error: Could not resolve generic type T with nature String + ┌─ :3:31 + │ +3 │ FUNCTION func : INT test(); END_FUNCTION + │ ^^^^^^^ Could not resolve generic type T with nature String + diff --git a/src/validation/tests/snapshots/rusty__validation__tests__literals_validation_tests__bool_literal_casts_are_validated.snap b/src/validation/tests/snapshots/rusty__validation__tests__literals_validation_tests__bool_literal_casts_are_validated.snap index c64ab52a3e..10fa68c835 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__literals_validation_tests__bool_literal_casts_are_validated.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__literals_validation_tests__bool_literal_casts_are_validated.snap @@ -1,8 +1,23 @@ --- source: src/validation/tests/literals_validation_tests.rs -expression: res +expression: "&diagnostics" --- -SyntaxError { message: "Literal 2 out of range (BOOL)", range: [SourceLocation { span: Range(TextLocation { line: 6, column: 12, offset: 120 }..TextLocation { line: 6, column: 18, offset: 126 }) }], err_no: type__literal_out_of_range } -SyntaxError { message: "Literal 2.3 is not compatible to BOOL", range: [SourceLocation { span: Range(TextLocation { line: 7, column: 12, offset: 140 }..TextLocation { line: 7, column: 20, offset: 148 }) }], err_no: type__incompatible_literal_cast } -SyntaxError { message: "Literal 'abc' is not compatible to BOOL", range: [SourceLocation { span: Range(TextLocation { line: 8, column: 12, offset: 162 }..TextLocation { line: 8, column: 22, offset: 172 }) }], err_no: type__incompatible_literal_cast } +error: Literal 2 out of range (BOOL) + ┌─ :7:13 + │ +7 │ BOOL#2; + │ ^^^^^^ Literal 2 out of range (BOOL) + +error: Literal 2.3 is not compatible to BOOL + ┌─ :8:13 + │ +8 │ BOOL#2.3; + │ ^^^^^^^^ Literal 2.3 is not compatible to BOOL + +error: Literal 'abc' is not compatible to BOOL + ┌─ :9:13 + │ +9 │ BOOL#'abc'; + │ ^^^^^^^^^^ Literal 'abc' is not compatible to BOOL + diff --git a/src/validation/tests/snapshots/rusty__validation__tests__literals_validation_tests__char_cast_validate.snap b/src/validation/tests/snapshots/rusty__validation__tests__literals_validation_tests__char_cast_validate.snap index ce38ccf074..02de7a3fec 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__literals_validation_tests__char_cast_validate.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__literals_validation_tests__char_cast_validate.snap @@ -1,7 +1,17 @@ --- source: src/validation/tests/literals_validation_tests.rs -expression: res +expression: "&diagnostics" --- -SyntaxError { message: "Literal \"XY\" out of range (CHAR)", range: [SourceLocation { span: Range(TextLocation { line: 6, column: 12, offset: 80 }..TextLocation { line: 6, column: 21, offset: 89 }) }], err_no: type__literal_out_of_range } -SyntaxError { message: "Literal 'YZ' out of range (WCHAR)", range: [SourceLocation { span: Range(TextLocation { line: 7, column: 12, offset: 103 }..TextLocation { line: 7, column: 22, offset: 113 }) }], err_no: type__literal_out_of_range } +error: Literal "XY" out of range (CHAR) + ┌─ :7:13 + │ +7 │ CHAR#"XY"; + │ ^^^^^^^^^ Literal "XY" out of range (CHAR) + +error: Literal 'YZ' out of range (WCHAR) + ┌─ :8:13 + │ +8 │ WCHAR#'YZ'; + │ ^^^^^^^^^^ Literal 'YZ' out of range (WCHAR) + diff --git a/src/validation/tests/snapshots/rusty__validation__tests__literals_validation_tests__date_literal_casts_are_validated.snap b/src/validation/tests/snapshots/rusty__validation__tests__literals_validation_tests__date_literal_casts_are_validated.snap index 1403886fbc..b0d24a614e 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__literals_validation_tests__date_literal_casts_are_validated.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__literals_validation_tests__date_literal_casts_are_validated.snap @@ -1,17 +1,77 @@ --- source: src/validation/tests/literals_validation_tests.rs -expression: res +expression: "&diagnostics" --- -SyntaxError { message: "Literal DATE_AND_TIME is not compatible to LINT", range: [SourceLocation { span: Range(TextLocation { line: 2, column: 12, offset: 33 }..TextLocation { line: 2, column: 42, offset: 63 }) }], err_no: type__incompatible_literal_cast } -SyntaxError { message: "Literal TIME_OF_DAY is not compatible to LINT", range: [SourceLocation { span: Range(TextLocation { line: 3, column: 12, offset: 77 }..TextLocation { line: 3, column: 41, offset: 106 }) }], err_no: type__incompatible_literal_cast } -SyntaxError { message: "Literal TIME is not compatible to LINT", range: [SourceLocation { span: Range(TextLocation { line: 4, column: 12, offset: 120 }..TextLocation { line: 4, column: 28, offset: 136 }) }], err_no: type__incompatible_literal_cast } -SyntaxError { message: "Literal DATE is not compatible to LINT", range: [SourceLocation { span: Range(TextLocation { line: 5, column: 12, offset: 150 }..TextLocation { line: 5, column: 32, offset: 170 }) }], err_no: type__incompatible_literal_cast } -SyntaxError { message: "Literal DATE_AND_TIME is not compatible to ULINT", range: [SourceLocation { span: Range(TextLocation { line: 7, column: 12, offset: 185 }..TextLocation { line: 7, column: 43, offset: 216 }) }], err_no: type__incompatible_literal_cast } -SyntaxError { message: "Literal TIME_OF_DAY is not compatible to ULINT", range: [SourceLocation { span: Range(TextLocation { line: 8, column: 12, offset: 230 }..TextLocation { line: 8, column: 42, offset: 260 }) }], err_no: type__incompatible_literal_cast } -SyntaxError { message: "Literal TIME is not compatible to ULINT", range: [SourceLocation { span: Range(TextLocation { line: 9, column: 12, offset: 274 }..TextLocation { line: 9, column: 29, offset: 291 }) }], err_no: type__incompatible_literal_cast } -SyntaxError { message: "Literal DATE is not compatible to ULINT", range: [SourceLocation { span: Range(TextLocation { line: 10, column: 12, offset: 305 }..TextLocation { line: 10, column: 33, offset: 326 }) }], err_no: type__incompatible_literal_cast } -SyntaxError { message: "Literal DATE_AND_TIME is not compatible to INT", range: [SourceLocation { span: Range(TextLocation { line: 12, column: 12, offset: 341 }..TextLocation { line: 12, column: 41, offset: 370 }) }], err_no: type__incompatible_literal_cast } -SyntaxError { message: "Literal TIME_OF_DAY is not compatible to INT", range: [SourceLocation { span: Range(TextLocation { line: 13, column: 12, offset: 384 }..TextLocation { line: 13, column: 40, offset: 412 }) }], err_no: type__incompatible_literal_cast } -SyntaxError { message: "Literal TIME is not compatible to INT", range: [SourceLocation { span: Range(TextLocation { line: 14, column: 12, offset: 426 }..TextLocation { line: 14, column: 27, offset: 441 }) }], err_no: type__incompatible_literal_cast } -SyntaxError { message: "Literal DATE is not compatible to INT", range: [SourceLocation { span: Range(TextLocation { line: 15, column: 12, offset: 455 }..TextLocation { line: 15, column: 31, offset: 474 }) }], err_no: type__incompatible_literal_cast } +error: Literal DATE_AND_TIME is not compatible to LINT + ┌─ :3:13 + │ +3 │ LINT#DT#1989-06-15-13:56:14.77; + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Literal DATE_AND_TIME is not compatible to LINT + +error: Literal TIME_OF_DAY is not compatible to LINT + ┌─ :4:13 + │ +4 │ LINT#TIME_OF_DAY#15:36:30.123; + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Literal TIME_OF_DAY is not compatible to LINT + +error: Literal TIME is not compatible to LINT + ┌─ :5:13 + │ +5 │ LINT#T#12h34m15s; + │ ^^^^^^^^^^^^^^^^ Literal TIME is not compatible to LINT + +error: Literal DATE is not compatible to LINT + ┌─ :6:13 + │ +6 │ LINT#DATE#1996-05-06; + │ ^^^^^^^^^^^^^^^^^^^^ Literal DATE is not compatible to LINT + +error: Literal DATE_AND_TIME is not compatible to ULINT + ┌─ :8:13 + │ +8 │ ULINT#DT#1989-06-15-13:56:14.77; + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Literal DATE_AND_TIME is not compatible to ULINT + +error: Literal TIME_OF_DAY is not compatible to ULINT + ┌─ :9:13 + │ +9 │ ULINT#TIME_OF_DAY#15:36:30.123; + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Literal TIME_OF_DAY is not compatible to ULINT + +error: Literal TIME is not compatible to ULINT + ┌─ :10:13 + │ +10 │ ULINT#T#12h34m15s; + │ ^^^^^^^^^^^^^^^^^ Literal TIME is not compatible to ULINT + +error: Literal DATE is not compatible to ULINT + ┌─ :11:13 + │ +11 │ ULINT#DATE#1996-05-06; + │ ^^^^^^^^^^^^^^^^^^^^^ Literal DATE is not compatible to ULINT + +error: Literal DATE_AND_TIME is not compatible to INT + ┌─ :13:13 + │ +13 │ INT#DT#1989-06-15-13:56:14.77; + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Literal DATE_AND_TIME is not compatible to INT + +error: Literal TIME_OF_DAY is not compatible to INT + ┌─ :14:13 + │ +14 │ INT#TIME_OF_DAY#15:36:30.123; + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Literal TIME_OF_DAY is not compatible to INT + +error: Literal TIME is not compatible to INT + ┌─ :15:13 + │ +15 │ INT#T#12h34m15s; + │ ^^^^^^^^^^^^^^^ Literal TIME is not compatible to INT + +error: Literal DATE is not compatible to INT + ┌─ :16:13 + │ +16 │ INT#DATE#1996-05-06; + │ ^^^^^^^^^^^^^^^^^^^ Literal DATE is not compatible to INT + diff --git a/src/validation/tests/snapshots/rusty__validation__tests__literals_validation_tests__int_literal_casts_max_values_are_validated.snap b/src/validation/tests/snapshots/rusty__validation__tests__literals_validation_tests__int_literal_casts_max_values_are_validated.snap index 8c9e74b442..a013bd9d72 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__literals_validation_tests__int_literal_casts_max_values_are_validated.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__literals_validation_tests__int_literal_casts_max_values_are_validated.snap @@ -1,8 +1,23 @@ --- source: src/validation/tests/literals_validation_tests.rs -expression: res +expression: "&diagnostics" --- -SyntaxError { message: "Literal 256 out of range (BYTE)", range: [SourceLocation { span: Range(TextLocation { line: 3, column: 16, offset: 67 }..TextLocation { line: 3, column: 24, offset: 75 }) }], err_no: type__literal_out_of_range } -SyntaxError { message: "Literal 65536 out of range (UINT)", range: [SourceLocation { span: Range(TextLocation { line: 6, column: 16, offset: 123 }..TextLocation { line: 6, column: 27, offset: 134 }) }], err_no: type__literal_out_of_range } -SyntaxError { message: "Literal 4294967296 out of range (UDINT)", range: [SourceLocation { span: Range(TextLocation { line: 9, column: 16, offset: 190 }..TextLocation { line: 9, column: 35, offset: 209 }) }], err_no: type__literal_out_of_range } +error: Literal 256 out of range (BYTE) + ┌─ :4:17 + │ +4 │ BYTE#256; + │ ^^^^^^^^ Literal 256 out of range (BYTE) + +error: Literal 65536 out of range (UINT) + ┌─ :7:17 + │ +7 │ UINT#65_536; + │ ^^^^^^^^^^^ Literal 65536 out of range (UINT) + +error: Literal 4294967296 out of range (UDINT) + ┌─ :10:17 + │ +10 │ UDINT#4_294_967_296; + │ ^^^^^^^^^^^^^^^^^^^ Literal 4294967296 out of range (UDINT) + diff --git a/src/validation/tests/snapshots/rusty__validation__tests__literals_validation_tests__literal_cast_with_non_literal.snap b/src/validation/tests/snapshots/rusty__validation__tests__literals_validation_tests__literal_cast_with_non_literal.snap index 51a2732755..e731ba3200 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__literals_validation_tests__literal_cast_with_non_literal.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__literals_validation_tests__literal_cast_with_non_literal.snap @@ -1,6 +1,11 @@ --- source: src/validation/tests/literals_validation_tests.rs -expression: res +expression: "&diagnostics" --- -SyntaxError { message: "Expected literal", range: [SourceLocation { span: Range(TextLocation { line: 1, column: 12, offset: 24 }..TextLocation { line: 1, column: 19, offset: 31 }) }], err_no: type__expected_literal } +error: Expected literal + ┌─ :2:13 + │ +2 │ INT#[x]; + │ ^^^^^^^ Expected literal + diff --git a/src/validation/tests/snapshots/rusty__validation__tests__literals_validation_tests__real_literal_casts_are_validated.snap b/src/validation/tests/snapshots/rusty__validation__tests__literals_validation_tests__real_literal_casts_are_validated.snap index 18a43acb91..d657ddc51e 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__literals_validation_tests__real_literal_casts_are_validated.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__literals_validation_tests__real_literal_casts_are_validated.snap @@ -1,7 +1,17 @@ --- source: src/validation/tests/literals_validation_tests.rs -expression: res +expression: "&diagnostics" --- -SyntaxError { message: "Literal '3.14' is not compatible to REAL", range: [SourceLocation { span: Range(TextLocation { line: 10, column: 12, offset: 168 }..TextLocation { line: 10, column: 23, offset: 179 }) }], err_no: type__incompatible_literal_cast } -SyntaxError { message: "Literal \"3.14\" is not compatible to LREAL", range: [SourceLocation { span: Range(TextLocation { line: 14, column: 12, offset: 239 }..TextLocation { line: 14, column: 24, offset: 251 }) }], err_no: type__incompatible_literal_cast } +error: Literal '3.14' is not compatible to REAL + ┌─ :11:13 + │ +11 │ REAL#'3.14'; + │ ^^^^^^^^^^^ Literal '3.14' is not compatible to REAL + +error: Literal "3.14" is not compatible to LREAL + ┌─ :15:13 + │ +15 │ LREAL#"3.14"; + │ ^^^^^^^^^^^^ Literal "3.14" is not compatible to LREAL + diff --git a/src/validation/tests/snapshots/rusty__validation__tests__literals_validation_tests__string_literal_casts_are_validated.snap b/src/validation/tests/snapshots/rusty__validation__tests__literals_validation_tests__string_literal_casts_are_validated.snap index d25d3de01c..a94f510b9c 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__literals_validation_tests__string_literal_casts_are_validated.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__literals_validation_tests__string_literal_casts_are_validated.snap @@ -1,11 +1,41 @@ --- source: src/validation/tests/literals_validation_tests.rs -expression: res +expression: "&diagnostics" --- -SyntaxError { message: "Literal true is not compatible to STRING", range: [SourceLocation { span: Range(TextLocation { line: 6, column: 12, offset: 90 }..TextLocation { line: 6, column: 23, offset: 101 }) }], err_no: type__incompatible_literal_cast } -SyntaxError { message: "Literal false is not compatible to WSTRING", range: [SourceLocation { span: Range(TextLocation { line: 7, column: 12, offset: 115 }..TextLocation { line: 7, column: 25, offset: 128 }) }], err_no: type__incompatible_literal_cast } -SyntaxError { message: "Literal 22 is not compatible to STRING", range: [SourceLocation { span: Range(TextLocation { line: 9, column: 12, offset: 143 }..TextLocation { line: 9, column: 21, offset: 152 }) }], err_no: type__incompatible_literal_cast } -SyntaxError { message: "Literal 33 is not compatible to WSTRING", range: [SourceLocation { span: Range(TextLocation { line: 10, column: 12, offset: 166 }..TextLocation { line: 10, column: 22, offset: 176 }) }], err_no: type__incompatible_literal_cast } -SyntaxError { message: "Literal 3.14 is not compatible to STRING", range: [SourceLocation { span: Range(TextLocation { line: 12, column: 12, offset: 191 }..TextLocation { line: 12, column: 23, offset: 202 }) }], err_no: type__incompatible_literal_cast } -SyntaxError { message: "Literal 1.0 is not compatible to WSTRING", range: [SourceLocation { span: Range(TextLocation { line: 13, column: 12, offset: 216 }..TextLocation { line: 13, column: 23, offset: 227 }) }], err_no: type__incompatible_literal_cast } +error: Literal true is not compatible to STRING + ┌─ :7:13 + │ +7 │ STRING#TRUE; + │ ^^^^^^^^^^^ Literal true is not compatible to STRING + +error: Literal false is not compatible to WSTRING + ┌─ :8:13 + │ +8 │ WSTRING#FALSE; + │ ^^^^^^^^^^^^^ Literal false is not compatible to WSTRING + +error: Literal 22 is not compatible to STRING + ┌─ :10:13 + │ +10 │ STRING#22; + │ ^^^^^^^^^ Literal 22 is not compatible to STRING + +error: Literal 33 is not compatible to WSTRING + ┌─ :11:13 + │ +11 │ WSTRING#33; + │ ^^^^^^^^^^ Literal 33 is not compatible to WSTRING + +error: Literal 3.14 is not compatible to STRING + ┌─ :13:13 + │ +13 │ STRING#3.14; + │ ^^^^^^^^^^^ Literal 3.14 is not compatible to STRING + +error: Literal 1.0 is not compatible to WSTRING + ┌─ :14:13 + │ +14 │ WSTRING#1.0; + │ ^^^^^^^^^^^ Literal 1.0 is not compatible to WSTRING + diff --git a/src/validation/tests/snapshots/rusty__validation__tests__naming_validation_test__BOOL.snap b/src/validation/tests/snapshots/rusty__validation__tests__naming_validation_test__BOOL.snap index 46477b5c3b..6e2feacfac 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__naming_validation_test__BOOL.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__naming_validation_test__BOOL.snap @@ -1,7 +1,17 @@ --- source: src/validation/tests/naming_validation_test.rs -expression: res +expression: "&result" --- -SyntaxError { message: "BOOL can not be used as a name because it is a built-in datatype", range: [SourceLocation { span: Range(TextLocation { line: 0, column: 5, offset: 5 }..TextLocation { line: 0, column: 9, offset: 9 }) }], err_no: type__invalid_name } -SyntaxError { message: "BOOL: Ambiguous datatype.", range: [SourceLocation { span: Range(TextLocation { line: 0, column: 5, offset: 5 }..TextLocation { line: 0, column: 9, offset: 9 }) }, SourceLocation { span: None }], err_no: duplicate_symbol } +error: BOOL can not be used as a name because it is a built-in datatype + ┌─ :1:6 + │ +1 │ TYPE BOOL : STRUCT x : DINT; END_STRUCT END_TYPE + │ ^^^^ BOOL can not be used as a name because it is a built-in datatype + +error: BOOL: Ambiguous datatype. + ┌─ :1:6 + │ +1 │ TYPE BOOL : STRUCT x : DINT; END_STRUCT END_TYPE + │ ^^^^ BOOL: Ambiguous datatype. + diff --git a/src/validation/tests/snapshots/rusty__validation__tests__naming_validation_test__BYTE.snap b/src/validation/tests/snapshots/rusty__validation__tests__naming_validation_test__BYTE.snap index 46614f101f..c64f4d0724 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__naming_validation_test__BYTE.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__naming_validation_test__BYTE.snap @@ -1,7 +1,17 @@ --- source: src/validation/tests/naming_validation_test.rs -expression: res +expression: "&result" --- -SyntaxError { message: "BYTE can not be used as a name because it is a built-in datatype", range: [SourceLocation { span: Range(TextLocation { line: 0, column: 5, offset: 5 }..TextLocation { line: 0, column: 9, offset: 9 }) }], err_no: type__invalid_name } -SyntaxError { message: "BYTE: Ambiguous datatype.", range: [SourceLocation { span: Range(TextLocation { line: 0, column: 5, offset: 5 }..TextLocation { line: 0, column: 9, offset: 9 }) }, SourceLocation { span: None }], err_no: duplicate_symbol } +error: BYTE can not be used as a name because it is a built-in datatype + ┌─ :1:6 + │ +1 │ TYPE BYTE : STRUCT x : DINT; END_STRUCT END_TYPE + │ ^^^^ BYTE can not be used as a name because it is a built-in datatype + +error: BYTE: Ambiguous datatype. + ┌─ :1:6 + │ +1 │ TYPE BYTE : STRUCT x : DINT; END_STRUCT END_TYPE + │ ^^^^ BYTE: Ambiguous datatype. + diff --git a/src/validation/tests/snapshots/rusty__validation__tests__naming_validation_test__CHAR.snap b/src/validation/tests/snapshots/rusty__validation__tests__naming_validation_test__CHAR.snap index e61ba29977..7c3e934fbd 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__naming_validation_test__CHAR.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__naming_validation_test__CHAR.snap @@ -1,7 +1,17 @@ --- source: src/validation/tests/naming_validation_test.rs -expression: res +expression: "&result" --- -SyntaxError { message: "CHAR can not be used as a name because it is a built-in datatype", range: [SourceLocation { span: Range(TextLocation { line: 0, column: 5, offset: 5 }..TextLocation { line: 0, column: 9, offset: 9 }) }], err_no: type__invalid_name } -SyntaxError { message: "CHAR: Ambiguous datatype.", range: [SourceLocation { span: Range(TextLocation { line: 0, column: 5, offset: 5 }..TextLocation { line: 0, column: 9, offset: 9 }) }, SourceLocation { span: None }], err_no: duplicate_symbol } +error: CHAR can not be used as a name because it is a built-in datatype + ┌─ :1:6 + │ +1 │ TYPE CHAR : STRUCT x : DINT; END_STRUCT END_TYPE + │ ^^^^ CHAR can not be used as a name because it is a built-in datatype + +error: CHAR: Ambiguous datatype. + ┌─ :1:6 + │ +1 │ TYPE CHAR : STRUCT x : DINT; END_STRUCT END_TYPE + │ ^^^^ CHAR: Ambiguous datatype. + diff --git a/src/validation/tests/snapshots/rusty__validation__tests__naming_validation_test__D.snap b/src/validation/tests/snapshots/rusty__validation__tests__naming_validation_test__D.snap index a11eeb886d..2ca86e0dd7 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__naming_validation_test__D.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__naming_validation_test__D.snap @@ -1,7 +1,17 @@ --- source: src/validation/tests/naming_validation_test.rs -expression: res +expression: "&result" --- -SyntaxError { message: "D can not be used as a name because it is a built-in datatype", range: [SourceLocation { span: Range(TextLocation { line: 0, column: 5, offset: 5 }..TextLocation { line: 0, column: 6, offset: 6 }) }], err_no: type__invalid_name } -SyntaxError { message: "D: Ambiguous datatype.", range: [SourceLocation { span: Range(TextLocation { line: 0, column: 5, offset: 5 }..TextLocation { line: 0, column: 6, offset: 6 }) }, SourceLocation { span: None }], err_no: duplicate_symbol } +error: D can not be used as a name because it is a built-in datatype + ┌─ :1:6 + │ +1 │ TYPE D : STRUCT x : DINT; END_STRUCT END_TYPE + │ ^ D can not be used as a name because it is a built-in datatype + +error: D: Ambiguous datatype. + ┌─ :1:6 + │ +1 │ TYPE D : STRUCT x : DINT; END_STRUCT END_TYPE + │ ^ D: Ambiguous datatype. + diff --git a/src/validation/tests/snapshots/rusty__validation__tests__naming_validation_test__DATE.snap b/src/validation/tests/snapshots/rusty__validation__tests__naming_validation_test__DATE.snap index f47064f00b..dfc872b18e 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__naming_validation_test__DATE.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__naming_validation_test__DATE.snap @@ -1,7 +1,17 @@ --- source: src/validation/tests/naming_validation_test.rs -expression: res +expression: "&result" --- -SyntaxError { message: "DATE can not be used as a name because it is a built-in datatype", range: [SourceLocation { span: Range(TextLocation { line: 0, column: 5, offset: 5 }..TextLocation { line: 0, column: 9, offset: 9 }) }], err_no: type__invalid_name } -SyntaxError { message: "DATE: Ambiguous datatype.", range: [SourceLocation { span: Range(TextLocation { line: 0, column: 5, offset: 5 }..TextLocation { line: 0, column: 9, offset: 9 }) }, SourceLocation { span: None }], err_no: duplicate_symbol } +error: DATE can not be used as a name because it is a built-in datatype + ┌─ :1:6 + │ +1 │ TYPE DATE : STRUCT x : DINT; END_STRUCT END_TYPE + │ ^^^^ DATE can not be used as a name because it is a built-in datatype + +error: DATE: Ambiguous datatype. + ┌─ :1:6 + │ +1 │ TYPE DATE : STRUCT x : DINT; END_STRUCT END_TYPE + │ ^^^^ DATE: Ambiguous datatype. + diff --git a/src/validation/tests/snapshots/rusty__validation__tests__naming_validation_test__DATE_AND_TIME.snap b/src/validation/tests/snapshots/rusty__validation__tests__naming_validation_test__DATE_AND_TIME.snap index 45b8bd2140..897b10283a 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__naming_validation_test__DATE_AND_TIME.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__naming_validation_test__DATE_AND_TIME.snap @@ -1,7 +1,17 @@ --- source: src/validation/tests/naming_validation_test.rs -expression: res +expression: "&result" --- -SyntaxError { message: "DATE_AND_TIME can not be used as a name because it is a built-in datatype", range: [SourceLocation { span: Range(TextLocation { line: 0, column: 5, offset: 5 }..TextLocation { line: 0, column: 18, offset: 18 }) }], err_no: type__invalid_name } -SyntaxError { message: "DATE_AND_TIME: Ambiguous datatype.", range: [SourceLocation { span: Range(TextLocation { line: 0, column: 5, offset: 5 }..TextLocation { line: 0, column: 18, offset: 18 }) }, SourceLocation { span: None }], err_no: duplicate_symbol } +error: DATE_AND_TIME can not be used as a name because it is a built-in datatype + ┌─ :1:6 + │ +1 │ TYPE DATE_AND_TIME : STRUCT x : DINT; END_STRUCT END_TYPE + │ ^^^^^^^^^^^^^ DATE_AND_TIME can not be used as a name because it is a built-in datatype + +error: DATE_AND_TIME: Ambiguous datatype. + ┌─ :1:6 + │ +1 │ TYPE DATE_AND_TIME : STRUCT x : DINT; END_STRUCT END_TYPE + │ ^^^^^^^^^^^^^ DATE_AND_TIME: Ambiguous datatype. + diff --git a/src/validation/tests/snapshots/rusty__validation__tests__naming_validation_test__DINT.snap b/src/validation/tests/snapshots/rusty__validation__tests__naming_validation_test__DINT.snap index 4626b92f1e..ea73a56fd8 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__naming_validation_test__DINT.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__naming_validation_test__DINT.snap @@ -1,7 +1,17 @@ --- source: src/validation/tests/naming_validation_test.rs -expression: res +expression: "&result" --- -SyntaxError { message: "DINT can not be used as a name because it is a built-in datatype", range: [SourceLocation { span: Range(TextLocation { line: 0, column: 5, offset: 5 }..TextLocation { line: 0, column: 9, offset: 9 }) }], err_no: type__invalid_name } -SyntaxError { message: "DINT: Ambiguous datatype.", range: [SourceLocation { span: Range(TextLocation { line: 0, column: 5, offset: 5 }..TextLocation { line: 0, column: 9, offset: 9 }) }, SourceLocation { span: None }], err_no: duplicate_symbol } +error: DINT can not be used as a name because it is a built-in datatype + ┌─ :1:6 + │ +1 │ TYPE DINT : STRUCT x : DINT; END_STRUCT END_TYPE + │ ^^^^ DINT can not be used as a name because it is a built-in datatype + +error: DINT: Ambiguous datatype. + ┌─ :1:6 + │ +1 │ TYPE DINT : STRUCT x : DINT; END_STRUCT END_TYPE + │ ^^^^ DINT: Ambiguous datatype. + diff --git a/src/validation/tests/snapshots/rusty__validation__tests__naming_validation_test__DT.snap b/src/validation/tests/snapshots/rusty__validation__tests__naming_validation_test__DT.snap index 466d38e4b3..ea7ee26511 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__naming_validation_test__DT.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__naming_validation_test__DT.snap @@ -1,7 +1,17 @@ --- source: src/validation/tests/naming_validation_test.rs -expression: res +expression: "&result" --- -SyntaxError { message: "DT can not be used as a name because it is a built-in datatype", range: [SourceLocation { span: Range(TextLocation { line: 0, column: 5, offset: 5 }..TextLocation { line: 0, column: 7, offset: 7 }) }], err_no: type__invalid_name } -SyntaxError { message: "DT: Ambiguous datatype.", range: [SourceLocation { span: Range(TextLocation { line: 0, column: 5, offset: 5 }..TextLocation { line: 0, column: 7, offset: 7 }) }, SourceLocation { span: None }], err_no: duplicate_symbol } +error: DT can not be used as a name because it is a built-in datatype + ┌─ :1:6 + │ +1 │ TYPE DT : STRUCT x : DINT; END_STRUCT END_TYPE + │ ^^ DT can not be used as a name because it is a built-in datatype + +error: DT: Ambiguous datatype. + ┌─ :1:6 + │ +1 │ TYPE DT : STRUCT x : DINT; END_STRUCT END_TYPE + │ ^^ DT: Ambiguous datatype. + diff --git a/src/validation/tests/snapshots/rusty__validation__tests__naming_validation_test__DWORD.snap b/src/validation/tests/snapshots/rusty__validation__tests__naming_validation_test__DWORD.snap index 806c2bc180..e8ad3fa939 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__naming_validation_test__DWORD.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__naming_validation_test__DWORD.snap @@ -1,7 +1,17 @@ --- source: src/validation/tests/naming_validation_test.rs -expression: res +expression: "&result" --- -SyntaxError { message: "DWORD can not be used as a name because it is a built-in datatype", range: [SourceLocation { span: Range(TextLocation { line: 0, column: 5, offset: 5 }..TextLocation { line: 0, column: 10, offset: 10 }) }], err_no: type__invalid_name } -SyntaxError { message: "DWORD: Ambiguous datatype.", range: [SourceLocation { span: Range(TextLocation { line: 0, column: 5, offset: 5 }..TextLocation { line: 0, column: 10, offset: 10 }) }, SourceLocation { span: None }], err_no: duplicate_symbol } +error: DWORD can not be used as a name because it is a built-in datatype + ┌─ :1:6 + │ +1 │ TYPE DWORD : STRUCT x : DINT; END_STRUCT END_TYPE + │ ^^^^^ DWORD can not be used as a name because it is a built-in datatype + +error: DWORD: Ambiguous datatype. + ┌─ :1:6 + │ +1 │ TYPE DWORD : STRUCT x : DINT; END_STRUCT END_TYPE + │ ^^^^^ DWORD: Ambiguous datatype. + diff --git a/src/validation/tests/snapshots/rusty__validation__tests__naming_validation_test__INT.snap b/src/validation/tests/snapshots/rusty__validation__tests__naming_validation_test__INT.snap index d6ee9c13c4..8190e72c1e 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__naming_validation_test__INT.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__naming_validation_test__INT.snap @@ -1,7 +1,17 @@ --- source: src/validation/tests/naming_validation_test.rs -expression: res +expression: "&result" --- -SyntaxError { message: "INT can not be used as a name because it is a built-in datatype", range: [SourceLocation { span: Range(TextLocation { line: 0, column: 5, offset: 5 }..TextLocation { line: 0, column: 8, offset: 8 }) }], err_no: type__invalid_name } -SyntaxError { message: "INT: Ambiguous datatype.", range: [SourceLocation { span: Range(TextLocation { line: 0, column: 5, offset: 5 }..TextLocation { line: 0, column: 8, offset: 8 }) }, SourceLocation { span: None }], err_no: duplicate_symbol } +error: INT can not be used as a name because it is a built-in datatype + ┌─ :1:6 + │ +1 │ TYPE INT : STRUCT x : DINT; END_STRUCT END_TYPE + │ ^^^ INT can not be used as a name because it is a built-in datatype + +error: INT: Ambiguous datatype. + ┌─ :1:6 + │ +1 │ TYPE INT : STRUCT x : DINT; END_STRUCT END_TYPE + │ ^^^ INT: Ambiguous datatype. + diff --git a/src/validation/tests/snapshots/rusty__validation__tests__naming_validation_test__LD.snap b/src/validation/tests/snapshots/rusty__validation__tests__naming_validation_test__LD.snap index 958290ba53..f8f1e4a1f3 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__naming_validation_test__LD.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__naming_validation_test__LD.snap @@ -1,7 +1,17 @@ --- source: src/validation/tests/naming_validation_test.rs -expression: res +expression: "&result" --- -SyntaxError { message: "LD can not be used as a name because it is a built-in datatype", range: [SourceLocation { span: Range(TextLocation { line: 0, column: 5, offset: 5 }..TextLocation { line: 0, column: 7, offset: 7 }) }], err_no: type__invalid_name } -SyntaxError { message: "LD: Ambiguous datatype.", range: [SourceLocation { span: Range(TextLocation { line: 0, column: 5, offset: 5 }..TextLocation { line: 0, column: 7, offset: 7 }) }, SourceLocation { span: None }], err_no: duplicate_symbol } +error: LD can not be used as a name because it is a built-in datatype + ┌─ :1:6 + │ +1 │ TYPE LD : STRUCT x : DINT; END_STRUCT END_TYPE + │ ^^ LD can not be used as a name because it is a built-in datatype + +error: LD: Ambiguous datatype. + ┌─ :1:6 + │ +1 │ TYPE LD : STRUCT x : DINT; END_STRUCT END_TYPE + │ ^^ LD: Ambiguous datatype. + diff --git a/src/validation/tests/snapshots/rusty__validation__tests__naming_validation_test__LDATE.snap b/src/validation/tests/snapshots/rusty__validation__tests__naming_validation_test__LDATE.snap index fe67ea363c..5f1290e747 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__naming_validation_test__LDATE.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__naming_validation_test__LDATE.snap @@ -1,7 +1,17 @@ --- source: src/validation/tests/naming_validation_test.rs -expression: res +expression: "&result" --- -SyntaxError { message: "LDATE can not be used as a name because it is a built-in datatype", range: [SourceLocation { span: Range(TextLocation { line: 0, column: 5, offset: 5 }..TextLocation { line: 0, column: 10, offset: 10 }) }], err_no: type__invalid_name } -SyntaxError { message: "LDATE: Ambiguous datatype.", range: [SourceLocation { span: Range(TextLocation { line: 0, column: 5, offset: 5 }..TextLocation { line: 0, column: 10, offset: 10 }) }, SourceLocation { span: None }], err_no: duplicate_symbol } +error: LDATE can not be used as a name because it is a built-in datatype + ┌─ :1:6 + │ +1 │ TYPE LDATE : STRUCT x : DINT; END_STRUCT END_TYPE + │ ^^^^^ LDATE can not be used as a name because it is a built-in datatype + +error: LDATE: Ambiguous datatype. + ┌─ :1:6 + │ +1 │ TYPE LDATE : STRUCT x : DINT; END_STRUCT END_TYPE + │ ^^^^^ LDATE: Ambiguous datatype. + diff --git a/src/validation/tests/snapshots/rusty__validation__tests__naming_validation_test__LDATE_AND_TIME.snap b/src/validation/tests/snapshots/rusty__validation__tests__naming_validation_test__LDATE_AND_TIME.snap index a1f11915c8..4736d35571 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__naming_validation_test__LDATE_AND_TIME.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__naming_validation_test__LDATE_AND_TIME.snap @@ -1,7 +1,17 @@ --- source: src/validation/tests/naming_validation_test.rs -expression: res +expression: "&result" --- -SyntaxError { message: "LDATE_AND_TIME can not be used as a name because it is a built-in datatype", range: [SourceLocation { span: Range(TextLocation { line: 0, column: 5, offset: 5 }..TextLocation { line: 0, column: 19, offset: 19 }) }], err_no: type__invalid_name } -SyntaxError { message: "LDATE_AND_TIME: Ambiguous datatype.", range: [SourceLocation { span: Range(TextLocation { line: 0, column: 5, offset: 5 }..TextLocation { line: 0, column: 19, offset: 19 }) }, SourceLocation { span: None }], err_no: duplicate_symbol } +error: LDATE_AND_TIME can not be used as a name because it is a built-in datatype + ┌─ :1:6 + │ +1 │ TYPE LDATE_AND_TIME : STRUCT x : DINT; END_STRUCT END_TYPE + │ ^^^^^^^^^^^^^^ LDATE_AND_TIME can not be used as a name because it is a built-in datatype + +error: LDATE_AND_TIME: Ambiguous datatype. + ┌─ :1:6 + │ +1 │ TYPE LDATE_AND_TIME : STRUCT x : DINT; END_STRUCT END_TYPE + │ ^^^^^^^^^^^^^^ LDATE_AND_TIME: Ambiguous datatype. + diff --git a/src/validation/tests/snapshots/rusty__validation__tests__naming_validation_test__LDT.snap b/src/validation/tests/snapshots/rusty__validation__tests__naming_validation_test__LDT.snap index b50528c54f..6e1f52b494 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__naming_validation_test__LDT.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__naming_validation_test__LDT.snap @@ -1,7 +1,17 @@ --- source: src/validation/tests/naming_validation_test.rs -expression: res +expression: "&result" --- -SyntaxError { message: "LDT can not be used as a name because it is a built-in datatype", range: [SourceLocation { span: Range(TextLocation { line: 0, column: 5, offset: 5 }..TextLocation { line: 0, column: 8, offset: 8 }) }], err_no: type__invalid_name } -SyntaxError { message: "LDT: Ambiguous datatype.", range: [SourceLocation { span: Range(TextLocation { line: 0, column: 5, offset: 5 }..TextLocation { line: 0, column: 8, offset: 8 }) }, SourceLocation { span: None }], err_no: duplicate_symbol } +error: LDT can not be used as a name because it is a built-in datatype + ┌─ :1:6 + │ +1 │ TYPE LDT : STRUCT x : DINT; END_STRUCT END_TYPE + │ ^^^ LDT can not be used as a name because it is a built-in datatype + +error: LDT: Ambiguous datatype. + ┌─ :1:6 + │ +1 │ TYPE LDT : STRUCT x : DINT; END_STRUCT END_TYPE + │ ^^^ LDT: Ambiguous datatype. + diff --git a/src/validation/tests/snapshots/rusty__validation__tests__naming_validation_test__LINT.snap b/src/validation/tests/snapshots/rusty__validation__tests__naming_validation_test__LINT.snap index b596601daa..7f0ca0e1b0 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__naming_validation_test__LINT.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__naming_validation_test__LINT.snap @@ -1,7 +1,17 @@ --- source: src/validation/tests/naming_validation_test.rs -expression: res +expression: "&result" --- -SyntaxError { message: "LINT can not be used as a name because it is a built-in datatype", range: [SourceLocation { span: Range(TextLocation { line: 0, column: 5, offset: 5 }..TextLocation { line: 0, column: 9, offset: 9 }) }], err_no: type__invalid_name } -SyntaxError { message: "LINT: Ambiguous datatype.", range: [SourceLocation { span: Range(TextLocation { line: 0, column: 5, offset: 5 }..TextLocation { line: 0, column: 9, offset: 9 }) }, SourceLocation { span: None }], err_no: duplicate_symbol } +error: LINT can not be used as a name because it is a built-in datatype + ┌─ :1:6 + │ +1 │ TYPE LINT : STRUCT x : DINT; END_STRUCT END_TYPE + │ ^^^^ LINT can not be used as a name because it is a built-in datatype + +error: LINT: Ambiguous datatype. + ┌─ :1:6 + │ +1 │ TYPE LINT : STRUCT x : DINT; END_STRUCT END_TYPE + │ ^^^^ LINT: Ambiguous datatype. + diff --git a/src/validation/tests/snapshots/rusty__validation__tests__naming_validation_test__LREAL.snap b/src/validation/tests/snapshots/rusty__validation__tests__naming_validation_test__LREAL.snap index b7c7d12445..7d240628a5 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__naming_validation_test__LREAL.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__naming_validation_test__LREAL.snap @@ -1,7 +1,17 @@ --- source: src/validation/tests/naming_validation_test.rs -expression: res +expression: "&result" --- -SyntaxError { message: "LREAL can not be used as a name because it is a built-in datatype", range: [SourceLocation { span: Range(TextLocation { line: 0, column: 5, offset: 5 }..TextLocation { line: 0, column: 10, offset: 10 }) }], err_no: type__invalid_name } -SyntaxError { message: "LREAL: Ambiguous datatype.", range: [SourceLocation { span: Range(TextLocation { line: 0, column: 5, offset: 5 }..TextLocation { line: 0, column: 10, offset: 10 }) }, SourceLocation { span: None }], err_no: duplicate_symbol } +error: LREAL can not be used as a name because it is a built-in datatype + ┌─ :1:6 + │ +1 │ TYPE LREAL : STRUCT x : DINT; END_STRUCT END_TYPE + │ ^^^^^ LREAL can not be used as a name because it is a built-in datatype + +error: LREAL: Ambiguous datatype. + ┌─ :1:6 + │ +1 │ TYPE LREAL : STRUCT x : DINT; END_STRUCT END_TYPE + │ ^^^^^ LREAL: Ambiguous datatype. + diff --git a/src/validation/tests/snapshots/rusty__validation__tests__naming_validation_test__LT.snap b/src/validation/tests/snapshots/rusty__validation__tests__naming_validation_test__LT.snap index 2925a46907..fa111a1be1 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__naming_validation_test__LT.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__naming_validation_test__LT.snap @@ -1,7 +1,17 @@ --- source: src/validation/tests/naming_validation_test.rs -expression: res +expression: "&result" --- -SyntaxError { message: "LT can not be used as a name because it is a built-in datatype", range: [SourceLocation { span: Range(TextLocation { line: 0, column: 5, offset: 5 }..TextLocation { line: 0, column: 7, offset: 7 }) }], err_no: type__invalid_name } -SyntaxError { message: "LT: Ambiguous datatype.", range: [SourceLocation { span: Range(TextLocation { line: 0, column: 5, offset: 5 }..TextLocation { line: 0, column: 7, offset: 7 }) }, SourceLocation { span: None }], err_no: duplicate_symbol } +error: LT can not be used as a name because it is a built-in datatype + ┌─ :1:6 + │ +1 │ TYPE LT : STRUCT x : DINT; END_STRUCT END_TYPE + │ ^^ LT can not be used as a name because it is a built-in datatype + +error: LT: Ambiguous datatype. + ┌─ :1:6 + │ +1 │ TYPE LT : STRUCT x : DINT; END_STRUCT END_TYPE + │ ^^ LT: Ambiguous datatype. + diff --git a/src/validation/tests/snapshots/rusty__validation__tests__naming_validation_test__LTIME.snap b/src/validation/tests/snapshots/rusty__validation__tests__naming_validation_test__LTIME.snap index de619949f4..fa8328aa3d 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__naming_validation_test__LTIME.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__naming_validation_test__LTIME.snap @@ -1,7 +1,17 @@ --- source: src/validation/tests/naming_validation_test.rs -expression: res +expression: "&result" --- -SyntaxError { message: "LTIME can not be used as a name because it is a built-in datatype", range: [SourceLocation { span: Range(TextLocation { line: 0, column: 5, offset: 5 }..TextLocation { line: 0, column: 10, offset: 10 }) }], err_no: type__invalid_name } -SyntaxError { message: "LTIME: Ambiguous datatype.", range: [SourceLocation { span: Range(TextLocation { line: 0, column: 5, offset: 5 }..TextLocation { line: 0, column: 10, offset: 10 }) }, SourceLocation { span: None }], err_no: duplicate_symbol } +error: LTIME can not be used as a name because it is a built-in datatype + ┌─ :1:6 + │ +1 │ TYPE LTIME : STRUCT x : DINT; END_STRUCT END_TYPE + │ ^^^^^ LTIME can not be used as a name because it is a built-in datatype + +error: LTIME: Ambiguous datatype. + ┌─ :1:6 + │ +1 │ TYPE LTIME : STRUCT x : DINT; END_STRUCT END_TYPE + │ ^^^^^ LTIME: Ambiguous datatype. + diff --git a/src/validation/tests/snapshots/rusty__validation__tests__naming_validation_test__LTIME_OF_DAY.snap b/src/validation/tests/snapshots/rusty__validation__tests__naming_validation_test__LTIME_OF_DAY.snap index bcd62f4f79..19a640f9a2 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__naming_validation_test__LTIME_OF_DAY.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__naming_validation_test__LTIME_OF_DAY.snap @@ -1,7 +1,17 @@ --- source: src/validation/tests/naming_validation_test.rs -expression: res +expression: "&result" --- -SyntaxError { message: "LTIME_OF_DAY can not be used as a name because it is a built-in datatype", range: [SourceLocation { span: Range(TextLocation { line: 0, column: 5, offset: 5 }..TextLocation { line: 0, column: 17, offset: 17 }) }], err_no: type__invalid_name } -SyntaxError { message: "LTIME_OF_DAY: Ambiguous datatype.", range: [SourceLocation { span: Range(TextLocation { line: 0, column: 5, offset: 5 }..TextLocation { line: 0, column: 17, offset: 17 }) }, SourceLocation { span: None }], err_no: duplicate_symbol } +error: LTIME_OF_DAY can not be used as a name because it is a built-in datatype + ┌─ :1:6 + │ +1 │ TYPE LTIME_OF_DAY : STRUCT x : DINT; END_STRUCT END_TYPE + │ ^^^^^^^^^^^^ LTIME_OF_DAY can not be used as a name because it is a built-in datatype + +error: LTIME_OF_DAY: Ambiguous datatype. + ┌─ :1:6 + │ +1 │ TYPE LTIME_OF_DAY : STRUCT x : DINT; END_STRUCT END_TYPE + │ ^^^^^^^^^^^^ LTIME_OF_DAY: Ambiguous datatype. + diff --git a/src/validation/tests/snapshots/rusty__validation__tests__naming_validation_test__LTOD.snap b/src/validation/tests/snapshots/rusty__validation__tests__naming_validation_test__LTOD.snap index 77634f6bad..5cd69d13a0 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__naming_validation_test__LTOD.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__naming_validation_test__LTOD.snap @@ -1,7 +1,17 @@ --- source: src/validation/tests/naming_validation_test.rs -expression: res +expression: "&result" --- -SyntaxError { message: "LTOD can not be used as a name because it is a built-in datatype", range: [SourceLocation { span: Range(TextLocation { line: 0, column: 5, offset: 5 }..TextLocation { line: 0, column: 9, offset: 9 }) }], err_no: type__invalid_name } -SyntaxError { message: "LTOD: Ambiguous datatype.", range: [SourceLocation { span: Range(TextLocation { line: 0, column: 5, offset: 5 }..TextLocation { line: 0, column: 9, offset: 9 }) }, SourceLocation { span: None }], err_no: duplicate_symbol } +error: LTOD can not be used as a name because it is a built-in datatype + ┌─ :1:6 + │ +1 │ TYPE LTOD : STRUCT x : DINT; END_STRUCT END_TYPE + │ ^^^^ LTOD can not be used as a name because it is a built-in datatype + +error: LTOD: Ambiguous datatype. + ┌─ :1:6 + │ +1 │ TYPE LTOD : STRUCT x : DINT; END_STRUCT END_TYPE + │ ^^^^ LTOD: Ambiguous datatype. + diff --git a/src/validation/tests/snapshots/rusty__validation__tests__naming_validation_test__LWORD.snap b/src/validation/tests/snapshots/rusty__validation__tests__naming_validation_test__LWORD.snap index 826467b914..f509262d78 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__naming_validation_test__LWORD.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__naming_validation_test__LWORD.snap @@ -1,7 +1,17 @@ --- source: src/validation/tests/naming_validation_test.rs -expression: res +expression: "&result" --- -SyntaxError { message: "LWORD can not be used as a name because it is a built-in datatype", range: [SourceLocation { span: Range(TextLocation { line: 0, column: 5, offset: 5 }..TextLocation { line: 0, column: 10, offset: 10 }) }], err_no: type__invalid_name } -SyntaxError { message: "LWORD: Ambiguous datatype.", range: [SourceLocation { span: Range(TextLocation { line: 0, column: 5, offset: 5 }..TextLocation { line: 0, column: 10, offset: 10 }) }, SourceLocation { span: None }], err_no: duplicate_symbol } +error: LWORD can not be used as a name because it is a built-in datatype + ┌─ :1:6 + │ +1 │ TYPE LWORD : STRUCT x : DINT; END_STRUCT END_TYPE + │ ^^^^^ LWORD can not be used as a name because it is a built-in datatype + +error: LWORD: Ambiguous datatype. + ┌─ :1:6 + │ +1 │ TYPE LWORD : STRUCT x : DINT; END_STRUCT END_TYPE + │ ^^^^^ LWORD: Ambiguous datatype. + diff --git a/src/validation/tests/snapshots/rusty__validation__tests__naming_validation_test__REAL.snap b/src/validation/tests/snapshots/rusty__validation__tests__naming_validation_test__REAL.snap index c3b229f341..3d829cb3c4 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__naming_validation_test__REAL.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__naming_validation_test__REAL.snap @@ -1,7 +1,17 @@ --- source: src/validation/tests/naming_validation_test.rs -expression: res +expression: "&result" --- -SyntaxError { message: "REAL can not be used as a name because it is a built-in datatype", range: [SourceLocation { span: Range(TextLocation { line: 0, column: 5, offset: 5 }..TextLocation { line: 0, column: 9, offset: 9 }) }], err_no: type__invalid_name } -SyntaxError { message: "REAL: Ambiguous datatype.", range: [SourceLocation { span: Range(TextLocation { line: 0, column: 5, offset: 5 }..TextLocation { line: 0, column: 9, offset: 9 }) }, SourceLocation { span: None }], err_no: duplicate_symbol } +error: REAL can not be used as a name because it is a built-in datatype + ┌─ :1:6 + │ +1 │ TYPE REAL : STRUCT x : DINT; END_STRUCT END_TYPE + │ ^^^^ REAL can not be used as a name because it is a built-in datatype + +error: REAL: Ambiguous datatype. + ┌─ :1:6 + │ +1 │ TYPE REAL : STRUCT x : DINT; END_STRUCT END_TYPE + │ ^^^^ REAL: Ambiguous datatype. + diff --git a/src/validation/tests/snapshots/rusty__validation__tests__naming_validation_test__SINT.snap b/src/validation/tests/snapshots/rusty__validation__tests__naming_validation_test__SINT.snap index 585e524100..ade231dbad 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__naming_validation_test__SINT.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__naming_validation_test__SINT.snap @@ -1,7 +1,17 @@ --- source: src/validation/tests/naming_validation_test.rs -expression: res +expression: "&result" --- -SyntaxError { message: "SINT can not be used as a name because it is a built-in datatype", range: [SourceLocation { span: Range(TextLocation { line: 0, column: 5, offset: 5 }..TextLocation { line: 0, column: 9, offset: 9 }) }], err_no: type__invalid_name } -SyntaxError { message: "SINT: Ambiguous datatype.", range: [SourceLocation { span: Range(TextLocation { line: 0, column: 5, offset: 5 }..TextLocation { line: 0, column: 9, offset: 9 }) }, SourceLocation { span: None }], err_no: duplicate_symbol } +error: SINT can not be used as a name because it is a built-in datatype + ┌─ :1:6 + │ +1 │ TYPE SINT : STRUCT x : DINT; END_STRUCT END_TYPE + │ ^^^^ SINT can not be used as a name because it is a built-in datatype + +error: SINT: Ambiguous datatype. + ┌─ :1:6 + │ +1 │ TYPE SINT : STRUCT x : DINT; END_STRUCT END_TYPE + │ ^^^^ SINT: Ambiguous datatype. + diff --git a/src/validation/tests/snapshots/rusty__validation__tests__naming_validation_test__STRING.snap b/src/validation/tests/snapshots/rusty__validation__tests__naming_validation_test__STRING.snap index 377a6dae88..ee358452c3 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__naming_validation_test__STRING.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__naming_validation_test__STRING.snap @@ -1,7 +1,17 @@ --- source: src/validation/tests/naming_validation_test.rs -expression: res +expression: "&result" --- -SyntaxError { message: "STRING can not be used as a name because it is a built-in datatype", range: [SourceLocation { span: Range(TextLocation { line: 0, column: 5, offset: 5 }..TextLocation { line: 0, column: 11, offset: 11 }) }], err_no: type__invalid_name } -SyntaxError { message: "STRING: Ambiguous datatype.", range: [SourceLocation { span: Range(TextLocation { line: 0, column: 5, offset: 5 }..TextLocation { line: 0, column: 11, offset: 11 }) }, SourceLocation { span: None }], err_no: duplicate_symbol } +error: STRING can not be used as a name because it is a built-in datatype + ┌─ :1:6 + │ +1 │ TYPE STRING : STRUCT x : DINT; END_STRUCT END_TYPE + │ ^^^^^^ STRING can not be used as a name because it is a built-in datatype + +error: STRING: Ambiguous datatype. + ┌─ :1:6 + │ +1 │ TYPE STRING : STRUCT x : DINT; END_STRUCT END_TYPE + │ ^^^^^^ STRING: Ambiguous datatype. + diff --git a/src/validation/tests/snapshots/rusty__validation__tests__naming_validation_test__T.snap b/src/validation/tests/snapshots/rusty__validation__tests__naming_validation_test__T.snap index e24b4bdc0c..16a427a025 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__naming_validation_test__T.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__naming_validation_test__T.snap @@ -1,7 +1,17 @@ --- source: src/validation/tests/naming_validation_test.rs -expression: res +expression: "&result" --- -SyntaxError { message: "T can not be used as a name because it is a built-in datatype", range: [SourceLocation { span: Range(TextLocation { line: 0, column: 5, offset: 5 }..TextLocation { line: 0, column: 6, offset: 6 }) }], err_no: type__invalid_name } -SyntaxError { message: "T: Ambiguous datatype.", range: [SourceLocation { span: Range(TextLocation { line: 0, column: 5, offset: 5 }..TextLocation { line: 0, column: 6, offset: 6 }) }, SourceLocation { span: None }], err_no: duplicate_symbol } +error: T can not be used as a name because it is a built-in datatype + ┌─ :1:6 + │ +1 │ TYPE T : STRUCT x : DINT; END_STRUCT END_TYPE + │ ^ T can not be used as a name because it is a built-in datatype + +error: T: Ambiguous datatype. + ┌─ :1:6 + │ +1 │ TYPE T : STRUCT x : DINT; END_STRUCT END_TYPE + │ ^ T: Ambiguous datatype. + diff --git a/src/validation/tests/snapshots/rusty__validation__tests__naming_validation_test__TIME.snap b/src/validation/tests/snapshots/rusty__validation__tests__naming_validation_test__TIME.snap index 9e5f6ec7da..dc6c765b49 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__naming_validation_test__TIME.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__naming_validation_test__TIME.snap @@ -1,7 +1,17 @@ --- source: src/validation/tests/naming_validation_test.rs -expression: res +expression: "&result" --- -SyntaxError { message: "TIME can not be used as a name because it is a built-in datatype", range: [SourceLocation { span: Range(TextLocation { line: 0, column: 5, offset: 5 }..TextLocation { line: 0, column: 9, offset: 9 }) }], err_no: type__invalid_name } -SyntaxError { message: "TIME: Ambiguous datatype.", range: [SourceLocation { span: Range(TextLocation { line: 0, column: 5, offset: 5 }..TextLocation { line: 0, column: 9, offset: 9 }) }, SourceLocation { span: None }], err_no: duplicate_symbol } +error: TIME can not be used as a name because it is a built-in datatype + ┌─ :1:6 + │ +1 │ TYPE TIME : STRUCT x : DINT; END_STRUCT END_TYPE + │ ^^^^ TIME can not be used as a name because it is a built-in datatype + +error: TIME: Ambiguous datatype. + ┌─ :1:6 + │ +1 │ TYPE TIME : STRUCT x : DINT; END_STRUCT END_TYPE + │ ^^^^ TIME: Ambiguous datatype. + diff --git a/src/validation/tests/snapshots/rusty__validation__tests__naming_validation_test__TIME_OF_DAY.snap b/src/validation/tests/snapshots/rusty__validation__tests__naming_validation_test__TIME_OF_DAY.snap index 62b697861a..b3367cbc89 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__naming_validation_test__TIME_OF_DAY.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__naming_validation_test__TIME_OF_DAY.snap @@ -1,7 +1,17 @@ --- source: src/validation/tests/naming_validation_test.rs -expression: res +expression: "&result" --- -SyntaxError { message: "TIME_OF_DAY can not be used as a name because it is a built-in datatype", range: [SourceLocation { span: Range(TextLocation { line: 0, column: 5, offset: 5 }..TextLocation { line: 0, column: 16, offset: 16 }) }], err_no: type__invalid_name } -SyntaxError { message: "TIME_OF_DAY: Ambiguous datatype.", range: [SourceLocation { span: Range(TextLocation { line: 0, column: 5, offset: 5 }..TextLocation { line: 0, column: 16, offset: 16 }) }, SourceLocation { span: None }], err_no: duplicate_symbol } +error: TIME_OF_DAY can not be used as a name because it is a built-in datatype + ┌─ :1:6 + │ +1 │ TYPE TIME_OF_DAY : STRUCT x : DINT; END_STRUCT END_TYPE + │ ^^^^^^^^^^^ TIME_OF_DAY can not be used as a name because it is a built-in datatype + +error: TIME_OF_DAY: Ambiguous datatype. + ┌─ :1:6 + │ +1 │ TYPE TIME_OF_DAY : STRUCT x : DINT; END_STRUCT END_TYPE + │ ^^^^^^^^^^^ TIME_OF_DAY: Ambiguous datatype. + diff --git a/src/validation/tests/snapshots/rusty__validation__tests__naming_validation_test__TOD.snap b/src/validation/tests/snapshots/rusty__validation__tests__naming_validation_test__TOD.snap index dd76b1abb1..3dd0974f02 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__naming_validation_test__TOD.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__naming_validation_test__TOD.snap @@ -1,7 +1,17 @@ --- source: src/validation/tests/naming_validation_test.rs -expression: res +expression: "&result" --- -SyntaxError { message: "TOD can not be used as a name because it is a built-in datatype", range: [SourceLocation { span: Range(TextLocation { line: 0, column: 5, offset: 5 }..TextLocation { line: 0, column: 8, offset: 8 }) }], err_no: type__invalid_name } -SyntaxError { message: "TOD: Ambiguous datatype.", range: [SourceLocation { span: Range(TextLocation { line: 0, column: 5, offset: 5 }..TextLocation { line: 0, column: 8, offset: 8 }) }, SourceLocation { span: None }], err_no: duplicate_symbol } +error: TOD can not be used as a name because it is a built-in datatype + ┌─ :1:6 + │ +1 │ TYPE TOD : STRUCT x : DINT; END_STRUCT END_TYPE + │ ^^^ TOD can not be used as a name because it is a built-in datatype + +error: TOD: Ambiguous datatype. + ┌─ :1:6 + │ +1 │ TYPE TOD : STRUCT x : DINT; END_STRUCT END_TYPE + │ ^^^ TOD: Ambiguous datatype. + diff --git a/src/validation/tests/snapshots/rusty__validation__tests__naming_validation_test__UDINT.snap b/src/validation/tests/snapshots/rusty__validation__tests__naming_validation_test__UDINT.snap index 105df49ce3..879942270e 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__naming_validation_test__UDINT.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__naming_validation_test__UDINT.snap @@ -1,7 +1,17 @@ --- source: src/validation/tests/naming_validation_test.rs -expression: res +expression: "&result" --- -SyntaxError { message: "UDINT can not be used as a name because it is a built-in datatype", range: [SourceLocation { span: Range(TextLocation { line: 0, column: 5, offset: 5 }..TextLocation { line: 0, column: 10, offset: 10 }) }], err_no: type__invalid_name } -SyntaxError { message: "UDINT: Ambiguous datatype.", range: [SourceLocation { span: Range(TextLocation { line: 0, column: 5, offset: 5 }..TextLocation { line: 0, column: 10, offset: 10 }) }, SourceLocation { span: None }], err_no: duplicate_symbol } +error: UDINT can not be used as a name because it is a built-in datatype + ┌─ :1:6 + │ +1 │ TYPE UDINT : STRUCT x : DINT; END_STRUCT END_TYPE + │ ^^^^^ UDINT can not be used as a name because it is a built-in datatype + +error: UDINT: Ambiguous datatype. + ┌─ :1:6 + │ +1 │ TYPE UDINT : STRUCT x : DINT; END_STRUCT END_TYPE + │ ^^^^^ UDINT: Ambiguous datatype. + diff --git a/src/validation/tests/snapshots/rusty__validation__tests__naming_validation_test__UINT.snap b/src/validation/tests/snapshots/rusty__validation__tests__naming_validation_test__UINT.snap index 5fa390e443..e63138fa1f 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__naming_validation_test__UINT.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__naming_validation_test__UINT.snap @@ -1,7 +1,17 @@ --- source: src/validation/tests/naming_validation_test.rs -expression: res +expression: "&result" --- -SyntaxError { message: "UINT can not be used as a name because it is a built-in datatype", range: [SourceLocation { span: Range(TextLocation { line: 0, column: 5, offset: 5 }..TextLocation { line: 0, column: 9, offset: 9 }) }], err_no: type__invalid_name } -SyntaxError { message: "UINT: Ambiguous datatype.", range: [SourceLocation { span: Range(TextLocation { line: 0, column: 5, offset: 5 }..TextLocation { line: 0, column: 9, offset: 9 }) }, SourceLocation { span: None }], err_no: duplicate_symbol } +error: UINT can not be used as a name because it is a built-in datatype + ┌─ :1:6 + │ +1 │ TYPE UINT : STRUCT x : DINT; END_STRUCT END_TYPE + │ ^^^^ UINT can not be used as a name because it is a built-in datatype + +error: UINT: Ambiguous datatype. + ┌─ :1:6 + │ +1 │ TYPE UINT : STRUCT x : DINT; END_STRUCT END_TYPE + │ ^^^^ UINT: Ambiguous datatype. + diff --git a/src/validation/tests/snapshots/rusty__validation__tests__naming_validation_test__ULINT.snap b/src/validation/tests/snapshots/rusty__validation__tests__naming_validation_test__ULINT.snap index 26a60695a5..b3b6e74aab 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__naming_validation_test__ULINT.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__naming_validation_test__ULINT.snap @@ -1,7 +1,17 @@ --- source: src/validation/tests/naming_validation_test.rs -expression: res +expression: "&result" --- -SyntaxError { message: "ULINT can not be used as a name because it is a built-in datatype", range: [SourceLocation { span: Range(TextLocation { line: 0, column: 5, offset: 5 }..TextLocation { line: 0, column: 10, offset: 10 }) }], err_no: type__invalid_name } -SyntaxError { message: "ULINT: Ambiguous datatype.", range: [SourceLocation { span: Range(TextLocation { line: 0, column: 5, offset: 5 }..TextLocation { line: 0, column: 10, offset: 10 }) }, SourceLocation { span: None }], err_no: duplicate_symbol } +error: ULINT can not be used as a name because it is a built-in datatype + ┌─ :1:6 + │ +1 │ TYPE ULINT : STRUCT x : DINT; END_STRUCT END_TYPE + │ ^^^^^ ULINT can not be used as a name because it is a built-in datatype + +error: ULINT: Ambiguous datatype. + ┌─ :1:6 + │ +1 │ TYPE ULINT : STRUCT x : DINT; END_STRUCT END_TYPE + │ ^^^^^ ULINT: Ambiguous datatype. + diff --git a/src/validation/tests/snapshots/rusty__validation__tests__naming_validation_test__USINT.snap b/src/validation/tests/snapshots/rusty__validation__tests__naming_validation_test__USINT.snap index 17c39f093a..c658653fd6 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__naming_validation_test__USINT.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__naming_validation_test__USINT.snap @@ -1,7 +1,17 @@ --- source: src/validation/tests/naming_validation_test.rs -expression: res +expression: "&result" --- -SyntaxError { message: "USINT can not be used as a name because it is a built-in datatype", range: [SourceLocation { span: Range(TextLocation { line: 0, column: 5, offset: 5 }..TextLocation { line: 0, column: 10, offset: 10 }) }], err_no: type__invalid_name } -SyntaxError { message: "USINT: Ambiguous datatype.", range: [SourceLocation { span: Range(TextLocation { line: 0, column: 5, offset: 5 }..TextLocation { line: 0, column: 10, offset: 10 }) }, SourceLocation { span: None }], err_no: duplicate_symbol } +error: USINT can not be used as a name because it is a built-in datatype + ┌─ :1:6 + │ +1 │ TYPE USINT : STRUCT x : DINT; END_STRUCT END_TYPE + │ ^^^^^ USINT can not be used as a name because it is a built-in datatype + +error: USINT: Ambiguous datatype. + ┌─ :1:6 + │ +1 │ TYPE USINT : STRUCT x : DINT; END_STRUCT END_TYPE + │ ^^^^^ USINT: Ambiguous datatype. + diff --git a/src/validation/tests/snapshots/rusty__validation__tests__naming_validation_test__WCHAR.snap b/src/validation/tests/snapshots/rusty__validation__tests__naming_validation_test__WCHAR.snap index 98b843f922..204b071d06 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__naming_validation_test__WCHAR.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__naming_validation_test__WCHAR.snap @@ -1,7 +1,17 @@ --- source: src/validation/tests/naming_validation_test.rs -expression: res +expression: "&result" --- -SyntaxError { message: "WCHAR can not be used as a name because it is a built-in datatype", range: [SourceLocation { span: Range(TextLocation { line: 0, column: 5, offset: 5 }..TextLocation { line: 0, column: 10, offset: 10 }) }], err_no: type__invalid_name } -SyntaxError { message: "WCHAR: Ambiguous datatype.", range: [SourceLocation { span: Range(TextLocation { line: 0, column: 5, offset: 5 }..TextLocation { line: 0, column: 10, offset: 10 }) }, SourceLocation { span: None }], err_no: duplicate_symbol } +error: WCHAR can not be used as a name because it is a built-in datatype + ┌─ :1:6 + │ +1 │ TYPE WCHAR : STRUCT x : DINT; END_STRUCT END_TYPE + │ ^^^^^ WCHAR can not be used as a name because it is a built-in datatype + +error: WCHAR: Ambiguous datatype. + ┌─ :1:6 + │ +1 │ TYPE WCHAR : STRUCT x : DINT; END_STRUCT END_TYPE + │ ^^^^^ WCHAR: Ambiguous datatype. + diff --git a/src/validation/tests/snapshots/rusty__validation__tests__naming_validation_test__WORD.snap b/src/validation/tests/snapshots/rusty__validation__tests__naming_validation_test__WORD.snap index 6bf73fa139..33d376e944 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__naming_validation_test__WORD.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__naming_validation_test__WORD.snap @@ -1,7 +1,17 @@ --- source: src/validation/tests/naming_validation_test.rs -expression: res +expression: "&result" --- -SyntaxError { message: "WORD can not be used as a name because it is a built-in datatype", range: [SourceLocation { span: Range(TextLocation { line: 0, column: 5, offset: 5 }..TextLocation { line: 0, column: 9, offset: 9 }) }], err_no: type__invalid_name } -SyntaxError { message: "WORD: Ambiguous datatype.", range: [SourceLocation { span: Range(TextLocation { line: 0, column: 5, offset: 5 }..TextLocation { line: 0, column: 9, offset: 9 }) }, SourceLocation { span: None }], err_no: duplicate_symbol } +error: WORD can not be used as a name because it is a built-in datatype + ┌─ :1:6 + │ +1 │ TYPE WORD : STRUCT x : DINT; END_STRUCT END_TYPE + │ ^^^^ WORD can not be used as a name because it is a built-in datatype + +error: WORD: Ambiguous datatype. + ┌─ :1:6 + │ +1 │ TYPE WORD : STRUCT x : DINT; END_STRUCT END_TYPE + │ ^^^^ WORD: Ambiguous datatype. + diff --git a/src/validation/tests/snapshots/rusty__validation__tests__naming_validation_test__WSTRING.snap b/src/validation/tests/snapshots/rusty__validation__tests__naming_validation_test__WSTRING.snap index e3fb21d7b7..b504862fa0 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__naming_validation_test__WSTRING.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__naming_validation_test__WSTRING.snap @@ -1,7 +1,17 @@ --- source: src/validation/tests/naming_validation_test.rs -expression: res +expression: "&result" --- -SyntaxError { message: "WSTRING can not be used as a name because it is a built-in datatype", range: [SourceLocation { span: Range(TextLocation { line: 0, column: 5, offset: 5 }..TextLocation { line: 0, column: 12, offset: 12 }) }], err_no: type__invalid_name } -SyntaxError { message: "WSTRING: Ambiguous datatype.", range: [SourceLocation { span: Range(TextLocation { line: 0, column: 5, offset: 5 }..TextLocation { line: 0, column: 12, offset: 12 }) }, SourceLocation { span: None }], err_no: duplicate_symbol } +error: WSTRING can not be used as a name because it is a built-in datatype + ┌─ :1:6 + │ +1 │ TYPE WSTRING : STRUCT x : DINT; END_STRUCT END_TYPE + │ ^^^^^^^ WSTRING can not be used as a name because it is a built-in datatype + +error: WSTRING: Ambiguous datatype. + ┌─ :1:6 + │ +1 │ TYPE WSTRING : STRUCT x : DINT; END_STRUCT END_TYPE + │ ^^^^^^^ WSTRING: Ambiguous datatype. + diff --git a/src/validation/tests/snapshots/rusty__validation__tests__naming_validation_test____U1.snap b/src/validation/tests/snapshots/rusty__validation__tests__naming_validation_test____U1.snap index 30b7d6250b..1dee331e23 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__naming_validation_test____U1.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__naming_validation_test____U1.snap @@ -1,7 +1,17 @@ --- source: src/validation/tests/naming_validation_test.rs -expression: res +expression: "&result" --- -SyntaxError { message: "__U1 can not be used as a name because it is a built-in datatype", range: [SourceLocation { span: Range(TextLocation { line: 0, column: 5, offset: 5 }..TextLocation { line: 0, column: 9, offset: 9 }) }], err_no: type__invalid_name } -SyntaxError { message: "__U1: Ambiguous datatype.", range: [SourceLocation { span: Range(TextLocation { line: 0, column: 5, offset: 5 }..TextLocation { line: 0, column: 9, offset: 9 }) }, SourceLocation { span: None }], err_no: duplicate_symbol } +error: __U1 can not be used as a name because it is a built-in datatype + ┌─ :1:6 + │ +1 │ TYPE __U1 : STRUCT x : DINT; END_STRUCT END_TYPE + │ ^^^^ __U1 can not be used as a name because it is a built-in datatype + +error: __U1: Ambiguous datatype. + ┌─ :1:6 + │ +1 │ TYPE __U1 : STRUCT x : DINT; END_STRUCT END_TYPE + │ ^^^^ __U1: Ambiguous datatype. + diff --git a/src/validation/tests/snapshots/rusty__validation__tests__pou_validation_tests__actions_container_no_name.snap b/src/validation/tests/snapshots/rusty__validation__tests__pou_validation_tests__actions_container_no_name.snap index 153809b6a2..f1e2af92b6 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__pou_validation_tests__actions_container_no_name.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__pou_validation_tests__actions_container_no_name.snap @@ -1,6 +1,11 @@ --- source: src/validation/tests/pou_validation_tests.rs -expression: res +expression: "&diagnostics" --- -ImprovementSuggestion { message: "Missing Actions Container Name", range: [SourceLocation { span: Range(TextLocation { line: 0, column: 24, offset: 24 }..TextLocation { line: 0, column: 34, offset: 34 }) }] } +warning: Missing Actions Container Name + ┌─ :1:25 + │ +1 │ ACTIONS ACTION myAction END_ACTION END_ACTIONS + │ ^^^^^^^^^^ Missing Actions Container Name + diff --git a/src/validation/tests/snapshots/rusty__validation__tests__pou_validation_tests__class_has_implementation.snap b/src/validation/tests/snapshots/rusty__validation__tests__pou_validation_tests__class_has_implementation.snap index d9b8128c21..c98c260d76 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__pou_validation_tests__class_has_implementation.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__pou_validation_tests__class_has_implementation.snap @@ -1,6 +1,12 @@ --- source: src/validation/tests/pou_validation_tests.rs -expression: res +expression: "&diagnostics" --- -SyntaxError { message: "A class cannot have an implementation", range: [SourceLocation { span: Range(TextLocation { line: 5, column: 12, offset: 88 }..TextLocation { line: 6, column: 17, offset: 120 }) }], err_no: syntax__generic_error } +error: A class cannot have an implementation + ┌─ :6:13 + │ +6 │ ╭ LIGHT := TRUE; +7 │ │ END_CLASS + │ ╰─────────────────^ A class cannot have an implementation + diff --git a/src/validation/tests/snapshots/rusty__validation__tests__pou_validation_tests__class_with_return_type.snap b/src/validation/tests/snapshots/rusty__validation__tests__pou_validation_tests__class_with_return_type.snap index cfabf3fd5e..64ead19a63 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__pou_validation_tests__class_with_return_type.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__pou_validation_tests__class_with_return_type.snap @@ -1,7 +1,17 @@ --- source: src/validation/tests/pou_validation_tests.rs -expression: res +expression: "&diagnostics" --- -SyntaxError { message: "POU Type Class does not support a return type. Did you mean Function?", range: [SourceLocation { span: Range(TextLocation { line: 1, column: 18, offset: 19 }..TextLocation { line: 1, column: 23, offset: 24 }) }], err_no: pou__unexpected_return_type } -SyntaxError { message: "A class cannot have a return type", range: [SourceLocation { span: Range(TextLocation { line: 1, column: 14, offset: 15 }..TextLocation { line: 1, column: 17, offset: 18 }) }], err_no: syntax__generic_error } +error: POU Type Class does not support a return type. Did you mean Function? + ┌─ :2:19 + │ +2 │ CLASS cls : INT + │ ^^^^^ POU Type Class does not support a return type. Did you mean Function? + +error: A class cannot have a return type + ┌─ :2:15 + │ +2 │ CLASS cls : INT + │ ^^^ A class cannot have a return type + diff --git a/src/validation/tests/snapshots/rusty__validation__tests__pou_validation_tests__function_has_super_class.snap b/src/validation/tests/snapshots/rusty__validation__tests__pou_validation_tests__function_has_super_class.snap index 914bd198c2..29e436404b 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__pou_validation_tests__function_has_super_class.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__pou_validation_tests__function_has_super_class.snap @@ -1,7 +1,17 @@ --- source: src/validation/tests/pou_validation_tests.rs -expression: res +expression: "&diagnostics" --- -SyntaxError { message: "A function cannot use EXTEND", range: [SourceLocation { span: Range(TextLocation { line: 4, column: 17, offset: 55 }..TextLocation { line: 4, column: 21, offset: 59 }) }], err_no: syntax__generic_error } -SyntaxError { message: "Function Return type missing", range: [SourceLocation { span: Range(TextLocation { line: 4, column: 17, offset: 55 }..TextLocation { line: 4, column: 21, offset: 59 }) }], err_no: pou__missing_return_type } +error: A function cannot use EXTEND + ┌─ :5:18 + │ +5 │ FUNCTION func EXTENDS cls + │ ^^^^ A function cannot use EXTEND + +error: Function Return type missing + ┌─ :5:18 + │ +5 │ FUNCTION func EXTENDS cls + │ ^^^^ Function Return type missing + diff --git a/src/validation/tests/snapshots/rusty__validation__tests__pou_validation_tests__function_no_return_unsupported.snap b/src/validation/tests/snapshots/rusty__validation__tests__pou_validation_tests__function_no_return_unsupported.snap index 94b44161c8..ab99c70493 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__pou_validation_tests__function_no_return_unsupported.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__pou_validation_tests__function_no_return_unsupported.snap @@ -1,6 +1,11 @@ --- source: src/validation/tests/pou_validation_tests.rs -expression: res +expression: "&diagnostics" --- -SyntaxError { message: "Function Return type missing", range: [SourceLocation { span: Range(TextLocation { line: 0, column: 9, offset: 9 }..TextLocation { line: 0, column: 12, offset: 12 }) }], err_no: pou__missing_return_type } +error: Function Return type missing + ┌─ :1:10 + │ +1 │ FUNCTION foo VAR_INPUT END_VAR END_FUNCTION + │ ^^^ Function Return type missing + diff --git a/src/validation/tests/snapshots/rusty__validation__tests__pou_validation_tests__in_out_variable_not_allowed_in_class.snap b/src/validation/tests/snapshots/rusty__validation__tests__pou_validation_tests__in_out_variable_not_allowed_in_class.snap index 3dc3341bbf..65896ca4c3 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__pou_validation_tests__in_out_variable_not_allowed_in_class.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__pou_validation_tests__in_out_variable_not_allowed_in_class.snap @@ -1,6 +1,11 @@ --- source: src/validation/tests/pou_validation_tests.rs -expression: res +expression: "&diagnostics" --- -SyntaxError { message: "A class cannot have a var in/out/inout blocks", range: [SourceLocation { span: Range(TextLocation { line: 1, column: 14, offset: 15 }..TextLocation { line: 1, column: 17, offset: 18 }) }], err_no: syntax__generic_error } +error: A class cannot have a var in/out/inout blocks + ┌─ :2:15 + │ +2 │ CLASS cls + │ ^^^ A class cannot have a var in/out/inout blocks + diff --git a/src/validation/tests/snapshots/rusty__validation__tests__pou_validation_tests__in_out_variable_out_of_order.snap b/src/validation/tests/snapshots/rusty__validation__tests__pou_validation_tests__in_out_variable_out_of_order.snap index cded1c4176..50ab58d4f5 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__pou_validation_tests__in_out_variable_out_of_order.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__pou_validation_tests__in_out_variable_out_of_order.snap @@ -1,8 +1,23 @@ --- source: src/validation/tests/pou_validation_tests.rs -expression: res +expression: diagnostics --- -SyntaxError { message: "Missing inout parameter: myOtherInOut", range: [SourceLocation { span: Range(TextLocation { line: 8, column: 8, offset: 218 }..TextLocation { line: 8, column: 10, offset: 220 }) }], err_no: pou__missing_action_container } -SyntaxError { message: "Expected a reference for parameter myInOut because their type is InOut", range: [SourceLocation { span: Range(TextLocation { line: 9, column: 14, offset: 286 }..TextLocation { line: 9, column: 18, offset: 290 }) }], err_no: call__invalid_parameter_type } -SyntaxError { message: "Missing inout parameter: myOtherInOut", range: [SourceLocation { span: Range(TextLocation { line: 9, column: 8, offset: 280 }..TextLocation { line: 9, column: 10, offset: 282 }) }], err_no: pou__missing_action_container } +error: Missing inout parameter: myOtherInOut + ┌─ :9:9 + │ +9 │ fb(myInOut := out2); // invalid: missing in-out param + │ ^^ Missing inout parameter: myOtherInOut + +error: Expected a reference for parameter myInOut because their type is InOut + ┌─ :10:15 + │ +10 │ fb(0, TRUE); // invalid: one in-out is a literal, the other is missing + │ ^^^^ Expected a reference for parameter myInOut because their type is InOut + +error: Missing inout parameter: myOtherInOut + ┌─ :10:9 + │ +10 │ fb(0, TRUE); // invalid: one in-out is a literal, the other is missing + │ ^^ Missing inout parameter: myOtherInOut + diff --git a/src/validation/tests/snapshots/rusty__validation__tests__pou_validation_tests__input_variable_not_allowed_in_class.snap b/src/validation/tests/snapshots/rusty__validation__tests__pou_validation_tests__input_variable_not_allowed_in_class.snap index 3dc3341bbf..65896ca4c3 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__pou_validation_tests__input_variable_not_allowed_in_class.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__pou_validation_tests__input_variable_not_allowed_in_class.snap @@ -1,6 +1,11 @@ --- source: src/validation/tests/pou_validation_tests.rs -expression: res +expression: "&diagnostics" --- -SyntaxError { message: "A class cannot have a var in/out/inout blocks", range: [SourceLocation { span: Range(TextLocation { line: 1, column: 14, offset: 15 }..TextLocation { line: 1, column: 17, offset: 18 }) }], err_no: syntax__generic_error } +error: A class cannot have a var in/out/inout blocks + ┌─ :2:15 + │ +2 │ CLASS cls + │ ^^^ A class cannot have a var in/out/inout blocks + diff --git a/src/validation/tests/snapshots/rusty__validation__tests__pou_validation_tests__output_variable_not_allowed_in_class.snap b/src/validation/tests/snapshots/rusty__validation__tests__pou_validation_tests__output_variable_not_allowed_in_class.snap index 3dc3341bbf..65896ca4c3 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__pou_validation_tests__output_variable_not_allowed_in_class.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__pou_validation_tests__output_variable_not_allowed_in_class.snap @@ -1,6 +1,11 @@ --- source: src/validation/tests/pou_validation_tests.rs -expression: res +expression: "&diagnostics" --- -SyntaxError { message: "A class cannot have a var in/out/inout blocks", range: [SourceLocation { span: Range(TextLocation { line: 1, column: 14, offset: 15 }..TextLocation { line: 1, column: 17, offset: 18 }) }], err_no: syntax__generic_error } +error: A class cannot have a var in/out/inout blocks + ┌─ :2:15 + │ +2 │ CLASS cls + │ ^^^ A class cannot have a var in/out/inout blocks + diff --git a/src/validation/tests/snapshots/rusty__validation__tests__pou_validation_tests__program_has_super_class.snap b/src/validation/tests/snapshots/rusty__validation__tests__pou_validation_tests__program_has_super_class.snap index dfcdf622dd..2ed1b32923 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__pou_validation_tests__program_has_super_class.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__pou_validation_tests__program_has_super_class.snap @@ -1,6 +1,11 @@ --- source: src/validation/tests/pou_validation_tests.rs -expression: res +expression: "&diagnostics" --- -SyntaxError { message: "A program cannot use EXTEND", range: [SourceLocation { span: Range(TextLocation { line: 4, column: 16, offset: 54 }..TextLocation { line: 4, column: 20, offset: 58 }) }], err_no: syntax__generic_error } +error: A program cannot use EXTEND + ┌─ :5:17 + │ +5 │ PROGRAM prog EXTENDS cls + │ ^^^^ A program cannot use EXTEND + diff --git a/src/validation/tests/snapshots/rusty__validation__tests__recursive_validation_tests__arrays__one_cycle_aba_input.snap b/src/validation/tests/snapshots/rusty__validation__tests__recursive_validation_tests__arrays__one_cycle_aba_input.snap index 7733bab663..8cc8e82837 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__recursive_validation_tests__arrays__one_cycle_aba_input.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__recursive_validation_tests__arrays__one_cycle_aba_input.snap @@ -1,6 +1,14 @@ --- source: src/validation/tests/recursive_validation_tests.rs -expression: res +expression: "&diagnostics" --- -SemanticError { message: "Recursive data structure `A -> B -> A` has infinite size", range: [SourceLocation { span: Range(TextLocation { line: 1, column: 17, offset: 18 }..TextLocation { line: 1, column: 18, offset: 19 }) }, SourceLocation { span: Range(TextLocation { line: 5, column: 27, offset: 128 }..TextLocation { line: 5, column: 28, offset: 129 }) }], err_no: pou__recursive_data_structure } +error: Recursive data structure `A -> B -> A` has infinite size + ┌─ :2:18 + │ +2 │ TYPE A : STRUCT + │ ^ Recursive data structure `A -> B -> A` has infinite size + · +6 │ FUNCTION_BLOCK B + │ - see also + diff --git a/src/validation/tests/snapshots/rusty__validation__tests__recursive_validation_tests__arrays__one_cycle_aba_output.snap b/src/validation/tests/snapshots/rusty__validation__tests__recursive_validation_tests__arrays__one_cycle_aba_output.snap index 7733bab663..8cc8e82837 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__recursive_validation_tests__arrays__one_cycle_aba_output.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__recursive_validation_tests__arrays__one_cycle_aba_output.snap @@ -1,6 +1,14 @@ --- source: src/validation/tests/recursive_validation_tests.rs -expression: res +expression: "&diagnostics" --- -SemanticError { message: "Recursive data structure `A -> B -> A` has infinite size", range: [SourceLocation { span: Range(TextLocation { line: 1, column: 17, offset: 18 }..TextLocation { line: 1, column: 18, offset: 19 }) }, SourceLocation { span: Range(TextLocation { line: 5, column: 27, offset: 128 }..TextLocation { line: 5, column: 28, offset: 129 }) }], err_no: pou__recursive_data_structure } +error: Recursive data structure `A -> B -> A` has infinite size + ┌─ :2:18 + │ +2 │ TYPE A : STRUCT + │ ^ Recursive data structure `A -> B -> A` has infinite size + · +6 │ FUNCTION_BLOCK B + │ - see also + diff --git a/src/validation/tests/snapshots/rusty__validation__tests__recursive_validation_tests__arrays__one_cycle_bcb.snap b/src/validation/tests/snapshots/rusty__validation__tests__recursive_validation_tests__arrays__one_cycle_bcb.snap index 3529627da3..fa8fe2a89b 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__recursive_validation_tests__arrays__one_cycle_bcb.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__recursive_validation_tests__arrays__one_cycle_bcb.snap @@ -1,6 +1,14 @@ --- source: src/validation/tests/recursive_validation_tests.rs -expression: res +expression: "&diagnostics" --- -SemanticError { message: "Recursive data structure `B -> C -> B` has infinite size", range: [SourceLocation { span: Range(TextLocation { line: 5, column: 17, offset: 117 }..TextLocation { line: 5, column: 18, offset: 118 }) }, SourceLocation { span: Range(TextLocation { line: 9, column: 17, offset: 216 }..TextLocation { line: 9, column: 18, offset: 217 }) }], err_no: pou__recursive_data_structure } +error: Recursive data structure `B -> C -> B` has infinite size + ┌─ :6:18 + │ + 6 │ TYPE B : STRUCT + │ ^ Recursive data structure `B -> C -> B` has infinite size + · +10 │ TYPE C : STRUCT + │ - see also + diff --git a/src/validation/tests/snapshots/rusty__validation__tests__recursive_validation_tests__arrays__one_cycle_with_multiple_identical_members_aba.snap b/src/validation/tests/snapshots/rusty__validation__tests__recursive_validation_tests__arrays__one_cycle_with_multiple_identical_members_aba.snap index 3c359549d5..09cc059a87 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__recursive_validation_tests__arrays__one_cycle_with_multiple_identical_members_aba.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__recursive_validation_tests__arrays__one_cycle_with_multiple_identical_members_aba.snap @@ -1,6 +1,14 @@ --- source: src/validation/tests/recursive_validation_tests.rs -expression: res +expression: "&diagnostics" --- -SemanticError { message: "Recursive data structure `A -> B -> A` has infinite size", range: [SourceLocation { span: Range(TextLocation { line: 1, column: 17, offset: 18 }..TextLocation { line: 1, column: 18, offset: 19 }) }, SourceLocation { span: Range(TextLocation { line: 7, column: 17, offset: 196 }..TextLocation { line: 7, column: 18, offset: 197 }) }], err_no: pou__recursive_data_structure } +error: Recursive data structure `A -> B -> A` has infinite size + ┌─ :2:18 + │ +2 │ TYPE A : STRUCT + │ ^ Recursive data structure `A -> B -> A` has infinite size + · +8 │ TYPE B : STRUCT + │ - see also + diff --git a/src/validation/tests/snapshots/rusty__validation__tests__recursive_validation_tests__arrays__two_cycles_aa_and_aba.snap b/src/validation/tests/snapshots/rusty__validation__tests__recursive_validation_tests__arrays__two_cycles_aa_and_aba.snap index 28beaa22eb..27960e1961 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__recursive_validation_tests__arrays__two_cycles_aa_and_aba.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__recursive_validation_tests__arrays__two_cycles_aa_and_aba.snap @@ -1,7 +1,20 @@ --- source: src/validation/tests/recursive_validation_tests.rs -expression: res +expression: "&diagnostics" --- -SemanticError { message: "Recursive data structure `A -> A` has infinite size", range: [SourceLocation { span: Range(TextLocation { line: 1, column: 17, offset: 18 }..TextLocation { line: 1, column: 18, offset: 19 }) }], err_no: pou__recursive_data_structure } -SemanticError { message: "Recursive data structure `A -> B -> A` has infinite size", range: [SourceLocation { span: Range(TextLocation { line: 1, column: 17, offset: 18 }..TextLocation { line: 1, column: 18, offset: 19 }) }, SourceLocation { span: Range(TextLocation { line: 6, column: 17, offset: 155 }..TextLocation { line: 6, column: 18, offset: 156 }) }], err_no: pou__recursive_data_structure } +error: Recursive data structure `A -> A` has infinite size + ┌─ :2:18 + │ +2 │ TYPE A : STRUCT + │ ^ Recursive data structure `A -> A` has infinite size + +error: Recursive data structure `A -> B -> A` has infinite size + ┌─ :2:18 + │ +2 │ TYPE A : STRUCT + │ ^ Recursive data structure `A -> B -> A` has infinite size + · +7 │ TYPE B : STRUCT + │ - see also + diff --git a/src/validation/tests/snapshots/rusty__validation__tests__recursive_validation_tests__arrays__two_cycles_with_branch_input.snap b/src/validation/tests/snapshots/rusty__validation__tests__recursive_validation_tests__arrays__two_cycles_with_branch_input.snap index 5278172cbb..9b1d70c775 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__recursive_validation_tests__arrays__two_cycles_with_branch_input.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__recursive_validation_tests__arrays__two_cycles_with_branch_input.snap @@ -1,7 +1,35 @@ --- source: src/validation/tests/recursive_validation_tests.rs -expression: res +expression: "&diagnostics" --- -SemanticError { message: "Recursive data structure `F -> G -> H -> I -> F` has infinite size", range: [SourceLocation { span: Range(TextLocation { line: 21, column: 27, offset: 488 }..TextLocation { line: 21, column: 28, offset: 489 }) }, SourceLocation { span: Range(TextLocation { line: 28, column: 17, offset: 643 }..TextLocation { line: 28, column: 18, offset: 644 }) }, SourceLocation { span: Range(TextLocation { line: 32, column: 27, offset: 737 }..TextLocation { line: 32, column: 28, offset: 738 }) }, SourceLocation { span: Range(TextLocation { line: 38, column: 17, offset: 865 }..TextLocation { line: 38, column: 18, offset: 866 }) }], err_no: pou__recursive_data_structure } -SemanticError { message: "Recursive data structure `B -> C -> E -> F -> B` has infinite size", range: [SourceLocation { span: Range(TextLocation { line: 7, column: 17, offset: 156 }..TextLocation { line: 7, column: 18, offset: 157 }) }, SourceLocation { span: Range(TextLocation { line: 11, column: 27, offset: 250 }..TextLocation { line: 11, column: 28, offset: 251 }) }, SourceLocation { span: Range(TextLocation { line: 17, column: 17, offset: 378 }..TextLocation { line: 17, column: 18, offset: 379 }) }, SourceLocation { span: Range(TextLocation { line: 21, column: 27, offset: 488 }..TextLocation { line: 21, column: 28, offset: 489 }) }], err_no: pou__recursive_data_structure } +error: Recursive data structure `F -> G -> H -> I -> F` has infinite size + ┌─ :22:28 + │ +22 │ FUNCTION_BLOCK F + │ ^ Recursive data structure `F -> G -> H -> I -> F` has infinite size + · +29 │ TYPE G : STRUCT + │ - see also + · +33 │ FUNCTION_BLOCK H + │ - see also + · +39 │ TYPE I : STRUCT + │ - see also + +error: Recursive data structure `B -> C -> E -> F -> B` has infinite size + ┌─ :8:18 + │ + 8 │ TYPE B : STRUCT + │ ^ Recursive data structure `B -> C -> E -> F -> B` has infinite size + · +12 │ FUNCTION_BLOCK C + │ - see also + · +18 │ TYPE E : STRUCT + │ - see also + · +22 │ FUNCTION_BLOCK F + │ - see also + diff --git a/src/validation/tests/snapshots/rusty__validation__tests__recursive_validation_tests__functionblocks__one_cycle_aba_input.snap b/src/validation/tests/snapshots/rusty__validation__tests__recursive_validation_tests__functionblocks__one_cycle_aba_input.snap index 171a7141aa..92e6b08c0d 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__recursive_validation_tests__functionblocks__one_cycle_aba_input.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__recursive_validation_tests__functionblocks__one_cycle_aba_input.snap @@ -1,6 +1,14 @@ --- source: src/validation/tests/recursive_validation_tests.rs -expression: res +expression: "&diagnostics" --- -SemanticError { message: "Recursive data structure `A -> B -> A` has infinite size", range: [SourceLocation { span: Range(TextLocation { line: 1, column: 27, offset: 28 }..TextLocation { line: 1, column: 28, offset: 29 }) }, SourceLocation { span: Range(TextLocation { line: 8, column: 27, offset: 167 }..TextLocation { line: 8, column: 28, offset: 168 }) }], err_no: pou__recursive_data_structure } +error: Recursive data structure `A -> B -> A` has infinite size + ┌─ :2:28 + │ +2 │ FUNCTION_BLOCK A + │ ^ Recursive data structure `A -> B -> A` has infinite size + · +9 │ FUNCTION_BLOCK B + │ - see also + diff --git a/src/validation/tests/snapshots/rusty__validation__tests__recursive_validation_tests__functionblocks__one_cycle_aba_output.snap b/src/validation/tests/snapshots/rusty__validation__tests__recursive_validation_tests__functionblocks__one_cycle_aba_output.snap index 4ae0396f58..92e6b08c0d 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__recursive_validation_tests__functionblocks__one_cycle_aba_output.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__recursive_validation_tests__functionblocks__one_cycle_aba_output.snap @@ -1,6 +1,14 @@ --- source: src/validation/tests/recursive_validation_tests.rs -expression: res +expression: "&diagnostics" --- -SemanticError { message: "Recursive data structure `A -> B -> A` has infinite size", range: [SourceLocation { span: Range(TextLocation { line: 1, column: 27, offset: 28 }..TextLocation { line: 1, column: 28, offset: 29 }) }, SourceLocation { span: Range(TextLocation { line: 8, column: 27, offset: 168 }..TextLocation { line: 8, column: 28, offset: 169 }) }], err_no: pou__recursive_data_structure } +error: Recursive data structure `A -> B -> A` has infinite size + ┌─ :2:28 + │ +2 │ FUNCTION_BLOCK A + │ ^ Recursive data structure `A -> B -> A` has infinite size + · +9 │ FUNCTION_BLOCK B + │ - see also + diff --git a/src/validation/tests/snapshots/rusty__validation__tests__recursive_validation_tests__functionblocks__one_cycle_aba_var.snap b/src/validation/tests/snapshots/rusty__validation__tests__recursive_validation_tests__functionblocks__one_cycle_aba_var.snap index ee769ad2aa..92e6b08c0d 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__recursive_validation_tests__functionblocks__one_cycle_aba_var.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__recursive_validation_tests__functionblocks__one_cycle_aba_var.snap @@ -1,6 +1,14 @@ --- source: src/validation/tests/recursive_validation_tests.rs -expression: res +expression: "&diagnostics" --- -SemanticError { message: "Recursive data structure `A -> B -> A` has infinite size", range: [SourceLocation { span: Range(TextLocation { line: 1, column: 27, offset: 28 }..TextLocation { line: 1, column: 28, offset: 29 }) }, SourceLocation { span: Range(TextLocation { line: 8, column: 27, offset: 161 }..TextLocation { line: 8, column: 28, offset: 162 }) }], err_no: pou__recursive_data_structure } +error: Recursive data structure `A -> B -> A` has infinite size + ┌─ :2:28 + │ +2 │ FUNCTION_BLOCK A + │ ^ Recursive data structure `A -> B -> A` has infinite size + · +9 │ FUNCTION_BLOCK B + │ - see also + diff --git a/src/validation/tests/snapshots/rusty__validation__tests__recursive_validation_tests__functionblocks__two_cycles_with_branch_input.snap b/src/validation/tests/snapshots/rusty__validation__tests__recursive_validation_tests__functionblocks__two_cycles_with_branch_input.snap index d44e0ed07f..3d405ada9e 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__recursive_validation_tests__functionblocks__two_cycles_with_branch_input.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__recursive_validation_tests__functionblocks__two_cycles_with_branch_input.snap @@ -1,7 +1,35 @@ --- source: src/validation/tests/recursive_validation_tests.rs -expression: res +expression: "&diagnostics" --- -SemanticError { message: "Recursive data structure `F -> G -> H -> I -> F` has infinite size", range: [SourceLocation { span: Range(TextLocation { line: 25, column: 27, offset: 580 }..TextLocation { line: 25, column: 28, offset: 581 }) }, SourceLocation { span: Range(TextLocation { line: 32, column: 27, offset: 745 }..TextLocation { line: 32, column: 28, offset: 746 }) }, SourceLocation { span: Range(TextLocation { line: 38, column: 27, offset: 883 }..TextLocation { line: 38, column: 28, offset: 884 }) }, SourceLocation { span: Range(TextLocation { line: 44, column: 27, offset: 1021 }..TextLocation { line: 44, column: 28, offset: 1022 }) }], err_no: pou__recursive_data_structure } -SemanticError { message: "Recursive data structure `B -> C -> E -> F -> B` has infinite size", range: [SourceLocation { span: Range(TextLocation { line: 7, column: 27, offset: 166 }..TextLocation { line: 7, column: 28, offset: 167 }) }, SourceLocation { span: Range(TextLocation { line: 13, column: 27, offset: 304 }..TextLocation { line: 13, column: 28, offset: 305 }) }, SourceLocation { span: Range(TextLocation { line: 19, column: 27, offset: 442 }..TextLocation { line: 19, column: 28, offset: 443 }) }, SourceLocation { span: Range(TextLocation { line: 25, column: 27, offset: 580 }..TextLocation { line: 25, column: 28, offset: 581 }) }], err_no: pou__recursive_data_structure } +error: Recursive data structure `F -> G -> H -> I -> F` has infinite size + ┌─ :26:28 + │ +26 │ FUNCTION_BLOCK F + │ ^ Recursive data structure `F -> G -> H -> I -> F` has infinite size + · +33 │ FUNCTION_BLOCK G + │ - see also + · +39 │ FUNCTION_BLOCK H + │ - see also + · +45 │ FUNCTION_BLOCK I + │ - see also + +error: Recursive data structure `B -> C -> E -> F -> B` has infinite size + ┌─ :8:28 + │ + 8 │ FUNCTION_BLOCK B + │ ^ Recursive data structure `B -> C -> E -> F -> B` has infinite size + · +14 │ FUNCTION_BLOCK C + │ - see also + · +20 │ FUNCTION_BLOCK E + │ - see also + · +26 │ FUNCTION_BLOCK F + │ - see also + diff --git a/src/validation/tests/snapshots/rusty__validation__tests__recursive_validation_tests__mixed_structs_and_functionblocks__one_cycle_aba_input.snap b/src/validation/tests/snapshots/rusty__validation__tests__recursive_validation_tests__mixed_structs_and_functionblocks__one_cycle_aba_input.snap index 1db683e81d..8cc8e82837 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__recursive_validation_tests__mixed_structs_and_functionblocks__one_cycle_aba_input.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__recursive_validation_tests__mixed_structs_and_functionblocks__one_cycle_aba_input.snap @@ -1,6 +1,14 @@ --- source: src/validation/tests/recursive_validation_tests.rs -expression: res +expression: "&diagnostics" --- -SemanticError { message: "Recursive data structure `A -> B -> A` has infinite size", range: [SourceLocation { span: Range(TextLocation { line: 1, column: 17, offset: 18 }..TextLocation { line: 1, column: 18, offset: 19 }) }, SourceLocation { span: Range(TextLocation { line: 5, column: 27, offset: 112 }..TextLocation { line: 5, column: 28, offset: 113 }) }], err_no: pou__recursive_data_structure } +error: Recursive data structure `A -> B -> A` has infinite size + ┌─ :2:18 + │ +2 │ TYPE A : STRUCT + │ ^ Recursive data structure `A -> B -> A` has infinite size + · +6 │ FUNCTION_BLOCK B + │ - see also + diff --git a/src/validation/tests/snapshots/rusty__validation__tests__recursive_validation_tests__mixed_structs_and_functionblocks__one_cycle_aba_output.snap b/src/validation/tests/snapshots/rusty__validation__tests__recursive_validation_tests__mixed_structs_and_functionblocks__one_cycle_aba_output.snap index 1db683e81d..8cc8e82837 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__recursive_validation_tests__mixed_structs_and_functionblocks__one_cycle_aba_output.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__recursive_validation_tests__mixed_structs_and_functionblocks__one_cycle_aba_output.snap @@ -1,6 +1,14 @@ --- source: src/validation/tests/recursive_validation_tests.rs -expression: res +expression: "&diagnostics" --- -SemanticError { message: "Recursive data structure `A -> B -> A` has infinite size", range: [SourceLocation { span: Range(TextLocation { line: 1, column: 17, offset: 18 }..TextLocation { line: 1, column: 18, offset: 19 }) }, SourceLocation { span: Range(TextLocation { line: 5, column: 27, offset: 112 }..TextLocation { line: 5, column: 28, offset: 113 }) }], err_no: pou__recursive_data_structure } +error: Recursive data structure `A -> B -> A` has infinite size + ┌─ :2:18 + │ +2 │ TYPE A : STRUCT + │ ^ Recursive data structure `A -> B -> A` has infinite size + · +6 │ FUNCTION_BLOCK B + │ - see also + diff --git a/src/validation/tests/snapshots/rusty__validation__tests__recursive_validation_tests__mixed_structs_and_functionblocks__two_cycles_with_branch_input.snap b/src/validation/tests/snapshots/rusty__validation__tests__recursive_validation_tests__mixed_structs_and_functionblocks__two_cycles_with_branch_input.snap index 1e2734e00f..9b1d70c775 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__recursive_validation_tests__mixed_structs_and_functionblocks__two_cycles_with_branch_input.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__recursive_validation_tests__mixed_structs_and_functionblocks__two_cycles_with_branch_input.snap @@ -1,7 +1,35 @@ --- source: src/validation/tests/recursive_validation_tests.rs -expression: res +expression: "&diagnostics" --- -SemanticError { message: "Recursive data structure `F -> G -> H -> I -> F` has infinite size", range: [SourceLocation { span: Range(TextLocation { line: 21, column: 27, offset: 472 }..TextLocation { line: 21, column: 28, offset: 473 }) }, SourceLocation { span: Range(TextLocation { line: 28, column: 17, offset: 627 }..TextLocation { line: 28, column: 18, offset: 628 }) }, SourceLocation { span: Range(TextLocation { line: 32, column: 27, offset: 721 }..TextLocation { line: 32, column: 28, offset: 722 }) }, SourceLocation { span: Range(TextLocation { line: 38, column: 17, offset: 849 }..TextLocation { line: 38, column: 18, offset: 850 }) }], err_no: pou__recursive_data_structure } -SemanticError { message: "Recursive data structure `B -> C -> E -> F -> B` has infinite size", range: [SourceLocation { span: Range(TextLocation { line: 7, column: 17, offset: 156 }..TextLocation { line: 7, column: 18, offset: 157 }) }, SourceLocation { span: Range(TextLocation { line: 11, column: 27, offset: 250 }..TextLocation { line: 11, column: 28, offset: 251 }) }, SourceLocation { span: Range(TextLocation { line: 17, column: 17, offset: 378 }..TextLocation { line: 17, column: 18, offset: 379 }) }, SourceLocation { span: Range(TextLocation { line: 21, column: 27, offset: 472 }..TextLocation { line: 21, column: 28, offset: 473 }) }], err_no: pou__recursive_data_structure } +error: Recursive data structure `F -> G -> H -> I -> F` has infinite size + ┌─ :22:28 + │ +22 │ FUNCTION_BLOCK F + │ ^ Recursive data structure `F -> G -> H -> I -> F` has infinite size + · +29 │ TYPE G : STRUCT + │ - see also + · +33 │ FUNCTION_BLOCK H + │ - see also + · +39 │ TYPE I : STRUCT + │ - see also + +error: Recursive data structure `B -> C -> E -> F -> B` has infinite size + ┌─ :8:18 + │ + 8 │ TYPE B : STRUCT + │ ^ Recursive data structure `B -> C -> E -> F -> B` has infinite size + · +12 │ FUNCTION_BLOCK C + │ - see also + · +18 │ TYPE E : STRUCT + │ - see also + · +22 │ FUNCTION_BLOCK F + │ - see also + diff --git a/src/validation/tests/snapshots/rusty__validation__tests__recursive_validation_tests__structs__one_cycle_aba.snap b/src/validation/tests/snapshots/rusty__validation__tests__recursive_validation_tests__structs__one_cycle_aba.snap index 7909063805..e51c1a8270 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__recursive_validation_tests__structs__one_cycle_aba.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__recursive_validation_tests__structs__one_cycle_aba.snap @@ -1,6 +1,14 @@ --- source: src/validation/tests/recursive_validation_tests.rs -expression: res +expression: "&diagnostics" --- -SemanticError { message: "Recursive data structure `A -> B -> A` has infinite size", range: [SourceLocation { span: Range(TextLocation { line: 1, column: 17, offset: 18 }..TextLocation { line: 1, column: 18, offset: 19 }) }, SourceLocation { span: Range(TextLocation { line: 5, column: 17, offset: 102 }..TextLocation { line: 5, column: 18, offset: 103 }) }], err_no: pou__recursive_data_structure } +error: Recursive data structure `A -> B -> A` has infinite size + ┌─ :2:18 + │ +2 │ TYPE A : STRUCT + │ ^ Recursive data structure `A -> B -> A` has infinite size + · +6 │ TYPE B : STRUCT + │ - see also + diff --git a/src/validation/tests/snapshots/rusty__validation__tests__recursive_validation_tests__structs__one_cycle_abca.snap b/src/validation/tests/snapshots/rusty__validation__tests__recursive_validation_tests__structs__one_cycle_abca.snap index c60b7ed3cb..f76b47c047 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__recursive_validation_tests__structs__one_cycle_abca.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__recursive_validation_tests__structs__one_cycle_abca.snap @@ -1,6 +1,17 @@ --- source: src/validation/tests/recursive_validation_tests.rs -expression: res +expression: "&diagnostics" --- -SemanticError { message: "Recursive data structure `A -> B -> C -> A` has infinite size", range: [SourceLocation { span: Range(TextLocation { line: 1, column: 17, offset: 18 }..TextLocation { line: 1, column: 18, offset: 19 }) }, SourceLocation { span: Range(TextLocation { line: 5, column: 17, offset: 102 }..TextLocation { line: 5, column: 18, offset: 103 }) }, SourceLocation { span: Range(TextLocation { line: 9, column: 17, offset: 186 }..TextLocation { line: 9, column: 18, offset: 187 }) }], err_no: pou__recursive_data_structure } +error: Recursive data structure `A -> B -> C -> A` has infinite size + ┌─ :2:18 + │ + 2 │ TYPE A : STRUCT + │ ^ Recursive data structure `A -> B -> C -> A` has infinite size + · + 6 │ TYPE B : STRUCT + │ - see also + · +10 │ TYPE C : STRUCT + │ - see also + diff --git a/src/validation/tests/snapshots/rusty__validation__tests__recursive_validation_tests__structs__one_cycle_bcb.snap b/src/validation/tests/snapshots/rusty__validation__tests__recursive_validation_tests__structs__one_cycle_bcb.snap index 2fa7035880..fa8fe2a89b 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__recursive_validation_tests__structs__one_cycle_bcb.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__recursive_validation_tests__structs__one_cycle_bcb.snap @@ -1,6 +1,14 @@ --- source: src/validation/tests/recursive_validation_tests.rs -expression: res +expression: "&diagnostics" --- -SemanticError { message: "Recursive data structure `B -> C -> B` has infinite size", range: [SourceLocation { span: Range(TextLocation { line: 5, column: 17, offset: 102 }..TextLocation { line: 5, column: 18, offset: 103 }) }, SourceLocation { span: Range(TextLocation { line: 9, column: 17, offset: 186 }..TextLocation { line: 9, column: 18, offset: 187 }) }], err_no: pou__recursive_data_structure } +error: Recursive data structure `B -> C -> B` has infinite size + ┌─ :6:18 + │ + 6 │ TYPE B : STRUCT + │ ^ Recursive data structure `B -> C -> B` has infinite size + · +10 │ TYPE C : STRUCT + │ - see also + diff --git a/src/validation/tests/snapshots/rusty__validation__tests__recursive_validation_tests__structs__one_cycle_multiple_self_a.snap b/src/validation/tests/snapshots/rusty__validation__tests__recursive_validation_tests__structs__one_cycle_multiple_self_a.snap index 2abd637a8b..dfb2d325ea 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__recursive_validation_tests__structs__one_cycle_multiple_self_a.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__recursive_validation_tests__structs__one_cycle_multiple_self_a.snap @@ -1,6 +1,11 @@ --- source: src/validation/tests/recursive_validation_tests.rs -expression: res +expression: "&diagnostics" --- -SemanticError { message: "Recursive data structure `A -> A` has infinite size", range: [SourceLocation { span: Range(TextLocation { line: 1, column: 17, offset: 18 }..TextLocation { line: 1, column: 18, offset: 19 }) }], err_no: pou__recursive_data_structure } +error: Recursive data structure `A -> A` has infinite size + ┌─ :2:18 + │ +2 │ TYPE A : STRUCT + │ ^ Recursive data structure `A -> A` has infinite size + diff --git a/src/validation/tests/snapshots/rusty__validation__tests__recursive_validation_tests__structs__one_cycle_self_a.snap b/src/validation/tests/snapshots/rusty__validation__tests__recursive_validation_tests__structs__one_cycle_self_a.snap index 2abd637a8b..dfb2d325ea 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__recursive_validation_tests__structs__one_cycle_self_a.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__recursive_validation_tests__structs__one_cycle_self_a.snap @@ -1,6 +1,11 @@ --- source: src/validation/tests/recursive_validation_tests.rs -expression: res +expression: "&diagnostics" --- -SemanticError { message: "Recursive data structure `A -> A` has infinite size", range: [SourceLocation { span: Range(TextLocation { line: 1, column: 17, offset: 18 }..TextLocation { line: 1, column: 18, offset: 19 }) }], err_no: pou__recursive_data_structure } +error: Recursive data structure `A -> A` has infinite size + ┌─ :2:18 + │ +2 │ TYPE A : STRUCT + │ ^ Recursive data structure `A -> A` has infinite size + diff --git a/src/validation/tests/snapshots/rusty__validation__tests__recursive_validation_tests__structs__one_cycle_with_multiple_identical_members_aba.snap b/src/validation/tests/snapshots/rusty__validation__tests__recursive_validation_tests__structs__one_cycle_with_multiple_identical_members_aba.snap index 108c58431d..09cc059a87 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__recursive_validation_tests__structs__one_cycle_with_multiple_identical_members_aba.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__recursive_validation_tests__structs__one_cycle_with_multiple_identical_members_aba.snap @@ -1,6 +1,14 @@ --- source: src/validation/tests/recursive_validation_tests.rs -expression: res +expression: "&diagnostics" --- -SemanticError { message: "Recursive data structure `A -> B -> A` has infinite size", range: [SourceLocation { span: Range(TextLocation { line: 1, column: 17, offset: 18 }..TextLocation { line: 1, column: 18, offset: 19 }) }, SourceLocation { span: Range(TextLocation { line: 7, column: 17, offset: 151 }..TextLocation { line: 7, column: 18, offset: 152 }) }], err_no: pou__recursive_data_structure } +error: Recursive data structure `A -> B -> A` has infinite size + ┌─ :2:18 + │ +2 │ TYPE A : STRUCT + │ ^ Recursive data structure `A -> B -> A` has infinite size + · +8 │ TYPE B : STRUCT + │ - see also + diff --git a/src/validation/tests/snapshots/rusty__validation__tests__recursive_validation_tests__structs__two_cycles_aa_and_aba.snap b/src/validation/tests/snapshots/rusty__validation__tests__recursive_validation_tests__structs__two_cycles_aa_and_aba.snap index 58ea13a545..27960e1961 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__recursive_validation_tests__structs__two_cycles_aa_and_aba.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__recursive_validation_tests__structs__two_cycles_aa_and_aba.snap @@ -1,7 +1,20 @@ --- source: src/validation/tests/recursive_validation_tests.rs -expression: res +expression: "&diagnostics" --- -SemanticError { message: "Recursive data structure `A -> A` has infinite size", range: [SourceLocation { span: Range(TextLocation { line: 1, column: 17, offset: 18 }..TextLocation { line: 1, column: 18, offset: 19 }) }], err_no: pou__recursive_data_structure } -SemanticError { message: "Recursive data structure `A -> B -> A` has infinite size", range: [SourceLocation { span: Range(TextLocation { line: 1, column: 17, offset: 18 }..TextLocation { line: 1, column: 18, offset: 19 }) }, SourceLocation { span: Range(TextLocation { line: 6, column: 17, offset: 125 }..TextLocation { line: 6, column: 18, offset: 126 }) }], err_no: pou__recursive_data_structure } +error: Recursive data structure `A -> A` has infinite size + ┌─ :2:18 + │ +2 │ TYPE A : STRUCT + │ ^ Recursive data structure `A -> A` has infinite size + +error: Recursive data structure `A -> B -> A` has infinite size + ┌─ :2:18 + │ +2 │ TYPE A : STRUCT + │ ^ Recursive data structure `A -> B -> A` has infinite size + · +7 │ TYPE B : STRUCT + │ - see also + diff --git a/src/validation/tests/snapshots/rusty__validation__tests__recursive_validation_tests__structs__two_cycles_branch_cc_and_cec.snap b/src/validation/tests/snapshots/rusty__validation__tests__recursive_validation_tests__structs__two_cycles_branch_cc_and_cec.snap index c8a751145d..7df694da3b 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__recursive_validation_tests__structs__two_cycles_branch_cc_and_cec.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__recursive_validation_tests__structs__two_cycles_branch_cc_and_cec.snap @@ -1,7 +1,20 @@ --- source: src/validation/tests/recursive_validation_tests.rs -expression: res +expression: "&diagnostics" --- -SemanticError { message: "Recursive data structure `C -> C` has infinite size", range: [SourceLocation { span: Range(TextLocation { line: 9, column: 17, offset: 186 }..TextLocation { line: 9, column: 18, offset: 187 }) }], err_no: pou__recursive_data_structure } -SemanticError { message: "Recursive data structure `C -> E -> C` has infinite size", range: [SourceLocation { span: Range(TextLocation { line: 9, column: 17, offset: 186 }..TextLocation { line: 9, column: 18, offset: 187 }) }, SourceLocation { span: Range(TextLocation { line: 14, column: 17, offset: 293 }..TextLocation { line: 14, column: 18, offset: 294 }) }], err_no: pou__recursive_data_structure } +error: Recursive data structure `C -> C` has infinite size + ┌─ :10:18 + │ +10 │ TYPE C : STRUCT + │ ^ Recursive data structure `C -> C` has infinite size + +error: Recursive data structure `C -> E -> C` has infinite size + ┌─ :10:18 + │ +10 │ TYPE C : STRUCT + │ ^ Recursive data structure `C -> E -> C` has infinite size + · +15 │ TYPE E : STRUCT + │ - see also + diff --git a/src/validation/tests/snapshots/rusty__validation__tests__recursive_validation_tests__structs__two_cycles_with_branch.snap b/src/validation/tests/snapshots/rusty__validation__tests__recursive_validation_tests__structs__two_cycles_with_branch.snap index f82f01d7bd..b91f2d2f8e 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__recursive_validation_tests__structs__two_cycles_with_branch.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__recursive_validation_tests__structs__two_cycles_with_branch.snap @@ -1,7 +1,35 @@ --- source: src/validation/tests/recursive_validation_tests.rs -expression: res +expression: "&diagnostics" --- -SemanticError { message: "Recursive data structure `F -> G -> H -> I -> F` has infinite size", range: [SourceLocation { span: Range(TextLocation { line: 17, column: 17, offset: 354 }..TextLocation { line: 17, column: 18, offset: 355 }) }, SourceLocation { span: Range(TextLocation { line: 22, column: 17, offset: 461 }..TextLocation { line: 22, column: 18, offset: 462 }) }, SourceLocation { span: Range(TextLocation { line: 26, column: 17, offset: 545 }..TextLocation { line: 26, column: 18, offset: 546 }) }, SourceLocation { span: Range(TextLocation { line: 30, column: 17, offset: 629 }..TextLocation { line: 30, column: 18, offset: 630 }) }], err_no: pou__recursive_data_structure } -SemanticError { message: "Recursive data structure `B -> C -> E -> F -> B` has infinite size", range: [SourceLocation { span: Range(TextLocation { line: 5, column: 17, offset: 102 }..TextLocation { line: 5, column: 18, offset: 103 }) }, SourceLocation { span: Range(TextLocation { line: 9, column: 17, offset: 186 }..TextLocation { line: 9, column: 18, offset: 187 }) }, SourceLocation { span: Range(TextLocation { line: 13, column: 17, offset: 270 }..TextLocation { line: 13, column: 18, offset: 271 }) }, SourceLocation { span: Range(TextLocation { line: 17, column: 17, offset: 354 }..TextLocation { line: 17, column: 18, offset: 355 }) }], err_no: pou__recursive_data_structure } +error: Recursive data structure `F -> G -> H -> I -> F` has infinite size + ┌─ :18:18 + │ +18 │ TYPE F : STRUCT + │ ^ Recursive data structure `F -> G -> H -> I -> F` has infinite size + · +23 │ TYPE G : STRUCT + │ - see also + · +27 │ TYPE H : STRUCT + │ - see also + · +31 │ TYPE I : STRUCT + │ - see also + +error: Recursive data structure `B -> C -> E -> F -> B` has infinite size + ┌─ :6:18 + │ + 6 │ TYPE B : STRUCT + │ ^ Recursive data structure `B -> C -> E -> F -> B` has infinite size + · +10 │ TYPE C : STRUCT + │ - see also + · +14 │ TYPE E : STRUCT + │ - see also + · +18 │ TYPE F : STRUCT + │ - see also + diff --git a/src/validation/tests/snapshots/rusty__validation__tests__reference_resolve_tests__reference_to_private_variable_in_intermediate_fb.snap b/src/validation/tests/snapshots/rusty__validation__tests__reference_resolve_tests__reference_to_private_variable_in_intermediate_fb.snap index 157f75e045..c497c678b7 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__reference_resolve_tests__reference_to_private_variable_in_intermediate_fb.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__reference_resolve_tests__reference_to_private_variable_in_intermediate_fb.snap @@ -1,6 +1,11 @@ --- source: src/validation/tests/reference_resolve_tests.rs -expression: res +expression: "&diagnostics" --- -SyntaxError { message: "Illegal access to private member fb1.f", range: [SourceLocation { span: Range(TextLocation { line: 18, column: 18, offset: 393 }..TextLocation { line: 18, column: 19, offset: 394 }) }], err_no: reference__illegal_access } +error: Illegal access to private member fb1.f + ┌─ :19:19 + │ +19 │ a.f.x := 7; + │ ^ Illegal access to private member fb1.f + diff --git a/src/validation/tests/snapshots/rusty__validation__tests__reference_resolve_tests__reference_to_private_variable_is_illegal.snap b/src/validation/tests/snapshots/rusty__validation__tests__reference_resolve_tests__reference_to_private_variable_is_illegal.snap index 7fb1b20c72..9dbbebe722 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__reference_resolve_tests__reference_to_private_variable_is_illegal.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__reference_resolve_tests__reference_to_private_variable_is_illegal.snap @@ -1,6 +1,11 @@ --- source: src/validation/tests/reference_resolve_tests.rs -expression: res +expression: "&diagnostics" --- -SyntaxError { message: "Illegal access to private member prg.s", range: [SourceLocation { span: Range(TextLocation { line: 8, column: 20, offset: 174 }..TextLocation { line: 8, column: 21, offset: 175 }) }], err_no: reference__illegal_access } +error: Illegal access to private member prg.s + ┌─ :9:21 + │ +9 │ prg.s := 7; + │ ^ Illegal access to private member prg.s + diff --git a/src/validation/tests/snapshots/rusty__validation__tests__reference_resolve_tests__resole_struct_member_access.snap b/src/validation/tests/snapshots/rusty__validation__tests__reference_resolve_tests__resole_struct_member_access.snap index f3548e849f..97d9b260ef 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__reference_resolve_tests__resole_struct_member_access.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__reference_resolve_tests__resole_struct_member_access.snap @@ -1,11 +1,41 @@ --- source: src/validation/tests/reference_resolve_tests.rs -expression: res +expression: "&diagnostics" --- -SyntaxError { message: "Could not resolve reference to field10", range: [SourceLocation { span: Range(TextLocation { line: 27, column: 18, offset: 691 }..TextLocation { line: 27, column: 25, offset: 698 }) }], err_no: reference__unresolved } -SyntaxError { message: "Could not resolve reference to field20", range: [SourceLocation { span: Range(TextLocation { line: 28, column: 18, offset: 718 }..TextLocation { line: 28, column: 25, offset: 725 }) }], err_no: reference__unresolved } -SyntaxError { message: "Could not resolve reference to field30", range: [SourceLocation { span: Range(TextLocation { line: 29, column: 18, offset: 745 }..TextLocation { line: 29, column: 25, offset: 752 }) }], err_no: reference__unresolved } -SyntaxError { message: "Could not resolve reference to subfield10", range: [SourceLocation { span: Range(TextLocation { line: 37, column: 22, offset: 951 }..TextLocation { line: 37, column: 32, offset: 961 }) }], err_no: reference__unresolved } -SyntaxError { message: "Could not resolve reference to subfield20", range: [SourceLocation { span: Range(TextLocation { line: 38, column: 22, offset: 985 }..TextLocation { line: 38, column: 32, offset: 995 }) }], err_no: reference__unresolved } -SyntaxError { message: "Could not resolve reference to subfield30", range: [SourceLocation { span: Range(TextLocation { line: 39, column: 22, offset: 1019 }..TextLocation { line: 39, column: 32, offset: 1029 }) }], err_no: reference__unresolved } +error: Could not resolve reference to field10 + ┌─ :28:19 + │ +28 │ s.field10; + │ ^^^^^^^ Could not resolve reference to field10 + +error: Could not resolve reference to field20 + ┌─ :29:19 + │ +29 │ s.field20; + │ ^^^^^^^ Could not resolve reference to field20 + +error: Could not resolve reference to field30 + ┌─ :30:19 + │ +30 │ s.field30; + │ ^^^^^^^ Could not resolve reference to field30 + +error: Could not resolve reference to subfield10 + ┌─ :38:23 + │ +38 │ s.sub.subfield10; + │ ^^^^^^^^^^ Could not resolve reference to subfield10 + +error: Could not resolve reference to subfield20 + ┌─ :39:23 + │ +39 │ s.sub.subfield20; + │ ^^^^^^^^^^ Could not resolve reference to subfield20 + +error: Could not resolve reference to subfield30 + ┌─ :40:23 + │ +40 │ s.sub.subfield30; + │ ^^^^^^^^^^ Could not resolve reference to subfield30 + diff --git a/src/validation/tests/snapshots/rusty__validation__tests__reference_resolve_tests__resolve_function_block_calls_in_structs_and_field_access.snap b/src/validation/tests/snapshots/rusty__validation__tests__reference_resolve_tests__resolve_function_block_calls_in_structs_and_field_access.snap index fe9ebe56b9..1831afcebb 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__reference_resolve_tests__resolve_function_block_calls_in_structs_and_field_access.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__reference_resolve_tests__resolve_function_block_calls_in_structs_and_field_access.snap @@ -1,11 +1,41 @@ --- source: src/validation/tests/reference_resolve_tests.rs -expression: res +expression: "&diagnostics" --- -SyntaxError { message: "Could not resolve reference to fb3", range: [SourceLocation { span: Range(TextLocation { line: 24, column: 29, offset: 648 }..TextLocation { line: 24, column: 32, offset: 651 }) }], err_no: reference__unresolved } -SyntaxError { message: "Could not resolve reference to a", range: [SourceLocation { span: Range(TextLocation { line: 24, column: 33, offset: 652 }..TextLocation { line: 24, column: 34, offset: 653 }) }], err_no: reference__unresolved } -SyntaxError { message: "Could not resolve reference to fb3", range: [SourceLocation { span: Range(TextLocation { line: 24, column: 43, offset: 662 }..TextLocation { line: 24, column: 46, offset: 665 }) }], err_no: reference__unresolved } -SyntaxError { message: "Could not resolve reference to b", range: [SourceLocation { span: Range(TextLocation { line: 24, column: 47, offset: 666 }..TextLocation { line: 24, column: 48, offset: 667 }) }], err_no: reference__unresolved } -SyntaxError { message: "Could not resolve reference to fb3", range: [SourceLocation { span: Range(TextLocation { line: 24, column: 57, offset: 676 }..TextLocation { line: 24, column: 60, offset: 679 }) }], err_no: reference__unresolved } -SyntaxError { message: "Could not resolve reference to c", range: [SourceLocation { span: Range(TextLocation { line: 24, column: 61, offset: 680 }..TextLocation { line: 24, column: 62, offset: 681 }) }], err_no: reference__unresolved } +error: Could not resolve reference to fb3 + ┌─ :25:30 + │ +25 │ s.fb1(a := s.fb3.a, b := s.fb3.b, c := s.fb3.c); + │ ^^^ Could not resolve reference to fb3 + +error: Could not resolve reference to a + ┌─ :25:34 + │ +25 │ s.fb1(a := s.fb3.a, b := s.fb3.b, c := s.fb3.c); + │ ^ Could not resolve reference to a + +error: Could not resolve reference to fb3 + ┌─ :25:44 + │ +25 │ s.fb1(a := s.fb3.a, b := s.fb3.b, c := s.fb3.c); + │ ^^^ Could not resolve reference to fb3 + +error: Could not resolve reference to b + ┌─ :25:48 + │ +25 │ s.fb1(a := s.fb3.a, b := s.fb3.b, c := s.fb3.c); + │ ^ Could not resolve reference to b + +error: Could not resolve reference to fb3 + ┌─ :25:58 + │ +25 │ s.fb1(a := s.fb3.a, b := s.fb3.b, c := s.fb3.c); + │ ^^^ Could not resolve reference to fb3 + +error: Could not resolve reference to c + ┌─ :25:62 + │ +25 │ s.fb1(a := s.fb3.a, b := s.fb3.b, c := s.fb3.c); + │ ^ Could not resolve reference to c + diff --git a/src/validation/tests/snapshots/rusty__validation__tests__reference_resolve_tests__resolve_function_calls_and_parameters.snap b/src/validation/tests/snapshots/rusty__validation__tests__reference_resolve_tests__resolve_function_calls_and_parameters.snap index f9579a562e..98d0bc9eb2 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__reference_resolve_tests__resolve_function_calls_and_parameters.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__reference_resolve_tests__resolve_function_calls_and_parameters.snap @@ -1,9 +1,29 @@ --- source: src/validation/tests/reference_resolve_tests.rs -expression: res +expression: "&diagnostics" --- -SyntaxError { message: "Could not resolve reference to boo", range: [SourceLocation { span: Range(TextLocation { line: 4, column: 16, offset: 101 }..TextLocation { line: 4, column: 19, offset: 104 }) }], err_no: reference__unresolved } -SyntaxError { message: "Could not resolve reference to c", range: [SourceLocation { span: Range(TextLocation { line: 4, column: 20, offset: 105 }..TextLocation { line: 4, column: 21, offset: 106 }) }], err_no: reference__unresolved } -SyntaxError { message: "Could not resolve reference to c", range: [SourceLocation { span: Range(TextLocation { line: 6, column: 25, offset: 163 }..TextLocation { line: 6, column: 26, offset: 164 }) }], err_no: reference__unresolved } -SyntaxError { message: "Could not resolve reference to y", range: [SourceLocation { span: Range(TextLocation { line: 7, column: 20, offset: 187 }..TextLocation { line: 7, column: 21, offset: 188 }) }], err_no: reference__unresolved } +error: Could not resolve reference to boo + ┌─ :5:17 + │ +5 │ boo(c); + │ ^^^ Could not resolve reference to boo + +error: Could not resolve reference to c + ┌─ :5:21 + │ +5 │ boo(c); + │ ^ Could not resolve reference to c + +error: Could not resolve reference to c + ┌─ :7:26 + │ +7 │ foo(x := c); + │ ^ Could not resolve reference to c + +error: Could not resolve reference to y + ┌─ :8:21 + │ +8 │ foo(y := a); + │ ^ Could not resolve reference to y + diff --git a/src/validation/tests/snapshots/rusty__validation__tests__reference_resolve_tests__resolve_function_members_via_qualifier.snap b/src/validation/tests/snapshots/rusty__validation__tests__reference_resolve_tests__resolve_function_members_via_qualifier.snap index 6d0af40985..97d7171d3e 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__reference_resolve_tests__resolve_function_members_via_qualifier.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__reference_resolve_tests__resolve_function_members_via_qualifier.snap @@ -1,8 +1,23 @@ --- source: src/validation/tests/reference_resolve_tests.rs -expression: res +expression: "&diagnostics" --- -SyntaxError { message: "Could not resolve reference to a", range: [SourceLocation { span: Range(TextLocation { line: 6, column: 20, offset: 180 }..TextLocation { line: 6, column: 21, offset: 181 }) }], err_no: reference__unresolved } -SyntaxError { message: "Could not resolve reference to b", range: [SourceLocation { span: Range(TextLocation { line: 7, column: 20, offset: 216 }..TextLocation { line: 7, column: 21, offset: 217 }) }], err_no: reference__unresolved } -SyntaxError { message: "Could not resolve reference to c", range: [SourceLocation { span: Range(TextLocation { line: 8, column: 20, offset: 252 }..TextLocation { line: 8, column: 21, offset: 253 }) }], err_no: reference__unresolved } +error: Could not resolve reference to a + ┌─ :7:21 + │ +7 │ foo.a; (* not ok *) + │ ^ Could not resolve reference to a + +error: Could not resolve reference to b + ┌─ :8:21 + │ +8 │ foo.b; (* not ok *) + │ ^ Could not resolve reference to b + +error: Could not resolve reference to c + ┌─ :9:21 + │ +9 │ foo.c; (* not ok *) + │ ^ Could not resolve reference to c + diff --git a/src/validation/tests/snapshots/rusty__validation__tests__reference_resolve_tests__resolve_simple_variable_references.snap b/src/validation/tests/snapshots/rusty__validation__tests__reference_resolve_tests__resolve_simple_variable_references.snap index 583f1f4bce..3c99cd0e66 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__reference_resolve_tests__resolve_simple_variable_references.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__reference_resolve_tests__resolve_simple_variable_references.snap @@ -1,7 +1,17 @@ --- source: src/validation/tests/reference_resolve_tests.rs -expression: res +expression: diagnostics --- -SyntaxError { message: "Could not resolve reference to b", range: [SourceLocation { span: Range(TextLocation { line: 9, column: 16, offset: 168 }..TextLocation { line: 9, column: 17, offset: 169 }) }], err_no: reference__unresolved } -SyntaxError { message: "Could not resolve reference to gb", range: [SourceLocation { span: Range(TextLocation { line: 11, column: 16, offset: 207 }..TextLocation { line: 11, column: 18, offset: 209 }) }], err_no: reference__unresolved } +error: Could not resolve reference to b + ┌─ :10:17 + │ +10 │ b; + │ ^ Could not resolve reference to b + +error: Could not resolve reference to gb + ┌─ :12:17 + │ +12 │ gb; + │ ^^ Could not resolve reference to gb + diff --git a/src/validation/tests/snapshots/rusty__validation__tests__statement_validation_tests__action_implicit_downcast.snap b/src/validation/tests/snapshots/rusty__validation__tests__statement_validation_tests__action_implicit_downcast.snap index 172cbf754d..1a5617f051 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__statement_validation_tests__action_implicit_downcast.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__statement_validation_tests__action_implicit_downcast.snap @@ -1,7 +1,17 @@ --- source: src/validation/tests/statement_validation_tests.rs -expression: res +expression: "&diagnostics" --- -SyntaxError { message: "Invalid assignment: cannot assign 'WSTRING' to 'STRING'", range: [SourceLocation { span: Range(TextLocation { line: 8, column: 29, offset: 213 }..TextLocation { line: 8, column: 37, offset: 221 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid assignment: cannot assign 'ARRAY[1..3] OF LINT' to 'STRING'", range: [SourceLocation { span: Range(TextLocation { line: 9, column: 31, offset: 276 }..TextLocation { line: 9, column: 38, offset: 283 }) }], err_no: var__invalid_assignment } +error: Invalid assignment: cannot assign 'WSTRING' to 'STRING' + ┌─ :9:30 + │ +9 │ fb.foo(var_lint, var_wstr); // downcast, invalid + │ ^^^^^^^^ Invalid assignment: cannot assign 'WSTRING' to 'STRING' + +error: Invalid assignment: cannot assign 'ARRAY[1..3] OF LINT' to 'STRING' + ┌─ :10:32 + │ +10 │ prog.bar(var_lint, var_arr); // downcast, invalid + │ ^^^^^^^ Invalid assignment: cannot assign 'ARRAY[1..3] OF LINT' to 'STRING' + diff --git a/src/validation/tests/snapshots/rusty__validation__tests__statement_validation_tests__assign_pointer_to_too_small_type_result_in_an_error.snap b/src/validation/tests/snapshots/rusty__validation__tests__statement_validation_tests__assign_pointer_to_too_small_type_result_in_an_error.snap index a6c8a6c9a0..666573de90 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__statement_validation_tests__assign_pointer_to_too_small_type_result_in_an_error.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__statement_validation_tests__assign_pointer_to_too_small_type_result_in_an_error.snap @@ -1,7 +1,17 @@ --- source: src/validation/tests/statement_validation_tests.rs -expression: res +expression: "&diagnostics" --- -SyntaxError { message: "The type DWORD 32 is too small to hold a Pointer", range: [SourceLocation { span: Range(TextLocation { line: 8, column: 12, offset: 174 }..TextLocation { line: 8, column: 26, offset: 188 }) }], err_no: type__incompatible_size } -SyntaxError { message: "Invalid assignment: cannot assign 'REF_TO INT' to 'DWORD'", range: [SourceLocation { span: Range(TextLocation { line: 8, column: 12, offset: 174 }..TextLocation { line: 8, column: 26, offset: 188 }) }], err_no: var__invalid_assignment } +error: The type DWORD 32 is too small to hold a Pointer + ┌─ :9:13 + │ +9 │ address := ptr; //should throw error as address is too small to store full pointer + │ ^^^^^^^^^^^^^^ The type DWORD 32 is too small to hold a Pointer + +error: Invalid assignment: cannot assign 'REF_TO INT' to 'DWORD' + ┌─ :9:13 + │ +9 │ address := ptr; //should throw error as address is too small to store full pointer + │ ^^^^^^^^^^^^^^ Invalid assignment: cannot assign 'REF_TO INT' to 'DWORD' + diff --git a/src/validation/tests/snapshots/rusty__validation__tests__statement_validation_tests__assign_too_small_type_to_pointer_result_in_an_error.snap b/src/validation/tests/snapshots/rusty__validation__tests__statement_validation_tests__assign_too_small_type_to_pointer_result_in_an_error.snap index 6028b9bbed..f26f8d7f18 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__statement_validation_tests__assign_too_small_type_to_pointer_result_in_an_error.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__statement_validation_tests__assign_too_small_type_to_pointer_result_in_an_error.snap @@ -1,7 +1,17 @@ --- source: src/validation/tests/statement_validation_tests.rs -expression: res +expression: "&diagnostics" --- -SyntaxError { message: "The type DWORD 32 is too small to to be stored in a Pointer", range: [SourceLocation { span: Range(TextLocation { line: 8, column: 12, offset: 174 }..TextLocation { line: 8, column: 26, offset: 188 }) }], err_no: type__incompatible_size } -SyntaxError { message: "Invalid assignment: cannot assign 'DWORD' to 'REF_TO INT'", range: [SourceLocation { span: Range(TextLocation { line: 8, column: 12, offset: 174 }..TextLocation { line: 8, column: 26, offset: 188 }) }], err_no: var__invalid_assignment } +error: The type DWORD 32 is too small to to be stored in a Pointer + ┌─ :9:13 + │ +9 │ ptr := address; //should throw error as address is too small to store full pointer + │ ^^^^^^^^^^^^^^ The type DWORD 32 is too small to to be stored in a Pointer + +error: Invalid assignment: cannot assign 'DWORD' to 'REF_TO INT' + ┌─ :9:13 + │ +9 │ ptr := address; //should throw error as address is too small to store full pointer + │ ^^^^^^^^^^^^^^ Invalid assignment: cannot assign 'DWORD' to 'REF_TO INT' + diff --git a/src/validation/tests/snapshots/rusty__validation__tests__statement_validation_tests__assigning_to_rvalue.snap b/src/validation/tests/snapshots/rusty__validation__tests__statement_validation_tests__assigning_to_rvalue.snap index 76ca073189..142d61482d 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__statement_validation_tests__assigning_to_rvalue.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__statement_validation_tests__assigning_to_rvalue.snap @@ -1,8 +1,23 @@ --- source: src/validation/tests/statement_validation_tests.rs -expression: res +expression: "&diagnostics" --- -SyntaxError { message: "Expression is not assignable", range: [SourceLocation { span: Range(TextLocation { line: 11, column: 12, offset: 189 }..TextLocation { line: 11, column: 13, offset: 190 }) }], err_no: reference__expected } -SyntaxError { message: "Expression is not assignable", range: [SourceLocation { span: Range(TextLocation { line: 12, column: 12, offset: 209 }..TextLocation { line: 12, column: 13, offset: 210 }) }], err_no: reference__expected } -SyntaxError { message: "Expression is not assignable", range: [SourceLocation { span: Range(TextLocation { line: 13, column: 17, offset: 234 }..TextLocation { line: 13, column: 18, offset: 235 }) }], err_no: reference__expected } +error: Expression is not assignable + ┌─ :12:13 + │ +12 │ 1 := 1; + │ ^ Expression is not assignable + +error: Expression is not assignable + ┌─ :13:13 + │ +13 │ 1 := i; + │ ^ Expression is not assignable + +error: Expression is not assignable + ┌─ :14:18 + │ +14 │ func(1 := 1); + │ ^ Expression is not assignable + diff --git a/src/validation/tests/snapshots/rusty__validation__tests__statement_validation_tests__assignment_to_constants_result_in_an_error.snap b/src/validation/tests/snapshots/rusty__validation__tests__statement_validation_tests__assignment_to_constants_result_in_an_error.snap index 3928377ffe..a4143a01fe 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__statement_validation_tests__assignment_to_constants_result_in_an_error.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__statement_validation_tests__assignment_to_constants_result_in_an_error.snap @@ -1,7 +1,17 @@ --- source: src/validation/tests/statement_validation_tests.rs -expression: res +expression: "&diagnostics" --- -SyntaxError { message: "Cannot assign to CONSTANT 'prg.cl'", range: [SourceLocation { span: Range(TextLocation { line: 19, column: 12, offset: 327 }..TextLocation { line: 19, column: 14, offset: 329 }) }], err_no: var__cannot_assign_to_const } -SyntaxError { message: "Cannot assign to CONSTANT 'ci'", range: [SourceLocation { span: Range(TextLocation { line: 21, column: 12, offset: 371 }..TextLocation { line: 21, column: 14, offset: 373 }) }], err_no: var__cannot_assign_to_const } +error: Cannot assign to CONSTANT 'prg.cl' + ┌─ :20:13 + │ +20 │ cl := 4; + │ ^^ Cannot assign to CONSTANT 'prg.cl' + +error: Cannot assign to CONSTANT 'ci' + ┌─ :22:13 + │ +22 │ ci := 4; + │ ^^ Cannot assign to CONSTANT 'ci' + diff --git a/src/validation/tests/snapshots/rusty__validation__tests__statement_validation_tests__assignment_to_enum_literals_results_in_error.snap b/src/validation/tests/snapshots/rusty__validation__tests__statement_validation_tests__assignment_to_enum_literals_results_in_error.snap index 44b88d5242..3c559ac10e 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__statement_validation_tests__assignment_to_enum_literals_results_in_error.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__statement_validation_tests__assignment_to_enum_literals_results_in_error.snap @@ -1,8 +1,23 @@ --- source: src/validation/tests/statement_validation_tests.rs -expression: res +expression: "&diagnostics" --- -SyntaxError { message: "Cannot assign to CONSTANT '__prg_state.OPEN'", range: [SourceLocation { span: Range(TextLocation { line: 12, column: 12, offset: 228 }..TextLocation { line: 12, column: 16, offset: 232 }) }], err_no: var__cannot_assign_to_const } -SyntaxError { message: "Cannot assign to CONSTANT '__global_g_enum.B'", range: [SourceLocation { span: Range(TextLocation { line: 13, column: 12, offset: 251 }..TextLocation { line: 13, column: 13, offset: 252 }) }], err_no: var__cannot_assign_to_const } -SyntaxError { message: "Cannot assign to CONSTANT 'Color.red'", range: [SourceLocation { span: Range(TextLocation { line: 14, column: 12, offset: 271 }..TextLocation { line: 14, column: 15, offset: 274 }) }], err_no: var__cannot_assign_to_const } +error: Cannot assign to CONSTANT '__prg_state.OPEN' + ┌─ :13:13 + │ +13 │ OPEN := 3; + │ ^^^^ Cannot assign to CONSTANT '__prg_state.OPEN' + +error: Cannot assign to CONSTANT '__global_g_enum.B' + ┌─ :14:13 + │ +14 │ B := A; + │ ^ Cannot assign to CONSTANT '__global_g_enum.B' + +error: Cannot assign to CONSTANT 'Color.red' + ┌─ :15:13 + │ +15 │ red := green; + │ ^^^ Cannot assign to CONSTANT 'Color.red' + diff --git a/src/validation/tests/snapshots/rusty__validation__tests__statement_validation_tests__bit_access_with_incorrect_operator_causes_warning.snap b/src/validation/tests/snapshots/rusty__validation__tests__statement_validation_tests__bit_access_with_incorrect_operator_causes_warning.snap index 3b9df72e26..a5a87489cc 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__statement_validation_tests__bit_access_with_incorrect_operator_causes_warning.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__statement_validation_tests__bit_access_with_incorrect_operator_causes_warning.snap @@ -1,7 +1,17 @@ --- source: src/validation/tests/statement_validation_tests.rs -expression: res +expression: diagnostics --- -SyntaxError { message: "Could not resolve reference to n1", range: [SourceLocation { span: Range(TextLocation { line: 11, column: 24, offset: 287 }..TextLocation { line: 11, column: 26, offset: 289 }) }], err_no: reference__unresolved } -ImprovementSuggestion { message: "If you meant to directly access a bit/byte/word/.., use %X/%B/%Wn1 instead.", range: [SourceLocation { span: Range(TextLocation { line: 11, column: 24, offset: 287 }..TextLocation { line: 11, column: 26, offset: 289 }) }] } +error: Could not resolve reference to n1 + ┌─ :12:25 + │ +12 │ Output.var1.n1 := Input.var1; // bitaccess without %X -> Warning + │ ^^ Could not resolve reference to n1 + +warning: If you meant to directly access a bit/byte/word/.., use %X/%B/%Wn1 instead. + ┌─ :12:25 + │ +12 │ Output.var1.n1 := Input.var1; // bitaccess without %X -> Warning + │ ^^ If you meant to directly access a bit/byte/word/.., use %X/%B/%Wn1 instead. + diff --git a/src/validation/tests/snapshots/rusty__validation__tests__statement_validation_tests__case_condition_used_outside_case_statement.snap b/src/validation/tests/snapshots/rusty__validation__tests__statement_validation_tests__case_condition_used_outside_case_statement.snap index 2acaacb3ae..91af0a0db1 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__statement_validation_tests__case_condition_used_outside_case_statement.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__statement_validation_tests__case_condition_used_outside_case_statement.snap @@ -1,7 +1,17 @@ --- source: src/validation/tests/statement_validation_tests.rs -expression: res +expression: "&diagnostics" --- -SyntaxError { message: "Case condition used outside of case statement! Did you mean to use ';'?", range: [SourceLocation { span: Range(TextLocation { line: 5, column: 12, offset: 86 }..TextLocation { line: 5, column: 32, offset: 106 }) }], err_no: case__case_condition_outside_case_statement } -SyntaxError { message: "Case condition used outside of case statement! Did you mean to use ';'?", range: [SourceLocation { span: Range(TextLocation { line: 6, column: 12, offset: 124 }..TextLocation { line: 6, column: 14, offset: 126 }) }], err_no: case__case_condition_outside_case_statement } +error: Case condition used outside of case statement! Did you mean to use ';'? + ┌─ :6:13 + │ +6 │ var1 := TOD#20:15:30:123; + │ ^^^^^^^^^^^^^^^^^^^^ Case condition used outside of case statement! Did you mean to use ';'? + +error: Case condition used outside of case statement! Did you mean to use ';'? + ┌─ :7:13 + │ +7 │ 23: + │ ^^ Case condition used outside of case statement! Did you mean to use ';'? + diff --git a/src/validation/tests/snapshots/rusty__validation__tests__statement_validation_tests__function_block_implicit_downcast.snap b/src/validation/tests/snapshots/rusty__validation__tests__statement_validation_tests__function_block_implicit_downcast.snap index 69c15e4026..fa87259698 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__statement_validation_tests__function_block_implicit_downcast.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__statement_validation_tests__function_block_implicit_downcast.snap @@ -1,6 +1,11 @@ --- source: src/validation/tests/statement_validation_tests.rs -expression: res +expression: "&diagnostics" --- -SyntaxError { message: "Invalid assignment: cannot assign 'WSTRING' to 'STRING'", range: [SourceLocation { span: Range(TextLocation { line: 15, column: 16, offset: 464 }..TextLocation { line: 15, column: 24, offset: 472 }) }], err_no: var__invalid_assignment } +error: Invalid assignment: cannot assign 'WSTRING' to 'STRING' + ┌─ :16:17 + │ +16 │ var_wstr, // invalid + │ ^^^^^^^^ Invalid assignment: cannot assign 'WSTRING' to 'STRING' + diff --git a/src/validation/tests/snapshots/rusty__validation__tests__statement_validation_tests__function_call_parameter_validation.snap b/src/validation/tests/snapshots/rusty__validation__tests__statement_validation_tests__function_call_parameter_validation.snap index b7fc7df26c..ed77d8abec 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__statement_validation_tests__function_call_parameter_validation.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__statement_validation_tests__function_call_parameter_validation.snap @@ -1,13 +1,53 @@ --- source: src/validation/tests/statement_validation_tests.rs -expression: res +expression: "&diagnostics" --- -SyntaxError { message: "Cannot mix implicit and explicit call parameters!", range: [SourceLocation { span: Range(TextLocation { line: 22, column: 33, offset: 507 }..TextLocation { line: 22, column: 37, offset: 511 }) }], err_no: call__invalid_parameter_type } -SyntaxError { message: "Cannot mix implicit and explicit call parameters!", range: [SourceLocation { span: Range(TextLocation { line: 22, column: 39, offset: 513 }..TextLocation { line: 22, column: 43, offset: 517 }) }], err_no: call__invalid_parameter_type } -SyntaxError { message: "Invalid assignment: cannot assign 'STRING' to 'DINT'", range: [SourceLocation { span: Range(TextLocation { line: 24, column: 16, offset: 581 }..TextLocation { line: 24, column: 30, offset: 595 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "The type DINT 32 is too small to hold a Pointer", range: [SourceLocation { span: Range(TextLocation { line: 24, column: 32, offset: 597 }..TextLocation { line: 24, column: 46, offset: 611 }) }], err_no: type__incompatible_size } -SyntaxError { message: "Invalid assignment: cannot assign 'REF_TO WSTRING' to 'DINT'", range: [SourceLocation { span: Range(TextLocation { line: 24, column: 32, offset: 597 }..TextLocation { line: 24, column: 46, offset: 611 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid assignment: cannot assign 'STRING' to 'DINT'", range: [SourceLocation { span: Range(TextLocation { line: 26, column: 16, offset: 770 }..TextLocation { line: 26, column: 20, offset: 774 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "The type DINT 32 is too small to hold a Pointer", range: [SourceLocation { span: Range(TextLocation { line: 26, column: 22, offset: 776 }..TextLocation { line: 26, column: 26, offset: 780 }) }], err_no: type__incompatible_size } -SyntaxError { message: "Invalid assignment: cannot assign 'REF_TO WSTRING' to 'DINT'", range: [SourceLocation { span: Range(TextLocation { line: 26, column: 22, offset: 776 }..TextLocation { line: 26, column: 26, offset: 780 }) }], err_no: var__invalid_assignment } +error: Cannot mix implicit and explicit call parameters! + ┌─ :23:34 + │ +23 │ foo(output1 => var1, var1, var1); // invalid cannot mix explicit and implicit + │ ^^^^ Cannot mix implicit and explicit call parameters! + +error: Cannot mix implicit and explicit call parameters! + ┌─ :23:40 + │ +23 │ foo(output1 => var1, var1, var1); // invalid cannot mix explicit and implicit + │ ^^^^ Cannot mix implicit and explicit call parameters! + +error: Invalid assignment: cannot assign 'STRING' to 'DINT' + ┌─ :25:17 + │ +25 │ foo(input1 := var2, inout1 := var3, output1 => var4); // invalid types assigned + │ ^^^^^^^^^^^^^^ Invalid assignment: cannot assign 'STRING' to 'DINT' + +error: The type DINT 32 is too small to hold a Pointer + ┌─ :25:33 + │ +25 │ foo(input1 := var2, inout1 := var3, output1 => var4); // invalid types assigned + │ ^^^^^^^^^^^^^^ The type DINT 32 is too small to hold a Pointer + +error: Invalid assignment: cannot assign 'REF_TO WSTRING' to 'DINT' + ┌─ :25:33 + │ +25 │ foo(input1 := var2, inout1 := var3, output1 => var4); // invalid types assigned + │ ^^^^^^^^^^^^^^ Invalid assignment: cannot assign 'REF_TO WSTRING' to 'DINT' + +error: Invalid assignment: cannot assign 'STRING' to 'DINT' + ┌─ :27:17 + │ +27 │ foo(var2, var3, var4); // invalid types assigned + │ ^^^^ Invalid assignment: cannot assign 'STRING' to 'DINT' + +error: The type DINT 32 is too small to hold a Pointer + ┌─ :27:23 + │ +27 │ foo(var2, var3, var4); // invalid types assigned + │ ^^^^ The type DINT 32 is too small to hold a Pointer + +error: Invalid assignment: cannot assign 'REF_TO WSTRING' to 'DINT' + ┌─ :27:23 + │ +27 │ foo(var2, var3, var4); // invalid types assigned + │ ^^^^ Invalid assignment: cannot assign 'REF_TO WSTRING' to 'DINT' + diff --git a/src/validation/tests/snapshots/rusty__validation__tests__statement_validation_tests__implicit_param_downcast_in_function_call.snap b/src/validation/tests/snapshots/rusty__validation__tests__statement_validation_tests__implicit_param_downcast_in_function_call.snap index 0458857b49..4b40189b26 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__statement_validation_tests__implicit_param_downcast_in_function_call.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__statement_validation_tests__implicit_param_downcast_in_function_call.snap @@ -1,6 +1,11 @@ --- source: src/validation/tests/statement_validation_tests.rs -expression: res +expression: "&diagnostics" --- -SyntaxError { message: "Invalid assignment: cannot assign 'WSTRING' to 'STRING'", range: [SourceLocation { span: Range(TextLocation { line: 16, column: 16, offset: 633 }..TextLocation { line: 16, column: 31, offset: 648 }) }], err_no: var__invalid_assignment } +error: Invalid assignment: cannot assign 'WSTRING' to 'STRING' + ┌─ :17:17 + │ +17 │ var_in_out_wstr, // invalid + │ ^^^^^^^^^^^^^^^ Invalid assignment: cannot assign 'WSTRING' to 'STRING' + diff --git a/src/validation/tests/snapshots/rusty__validation__tests__statement_validation_tests__invalid_cast_statement_causes_error.snap b/src/validation/tests/snapshots/rusty__validation__tests__statement_validation_tests__invalid_cast_statement_causes_error.snap index d8b080053a..4ff58a75db 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__statement_validation_tests__invalid_cast_statement_causes_error.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__statement_validation_tests__invalid_cast_statement_causes_error.snap @@ -1,6 +1,11 @@ --- source: src/validation/tests/statement_validation_tests.rs -expression: res +expression: diagnostics --- -SyntaxError { message: "Could not resolve reference to var1", range: [SourceLocation { span: Range(TextLocation { line: 6, column: 27, offset: 141 }..TextLocation { line: 6, column: 31, offset: 145 }) }], err_no: reference__unresolved } +error: Could not resolve reference to var1 + ┌─ :7:28 + │ +7 │ i := INT#s.var1; // illegal, var1 cannot be found in INT + │ ^^^^ Could not resolve reference to var1 + diff --git a/src/validation/tests/snapshots/rusty__validation__tests__statement_validation_tests__invalid_char_assignments.snap b/src/validation/tests/snapshots/rusty__validation__tests__statement_validation_tests__invalid_char_assignments.snap index 871ec1d945..f67255c813 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__statement_validation_tests__invalid_char_assignments.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__statement_validation_tests__invalid_char_assignments.snap @@ -1,17 +1,77 @@ --- source: src/validation/tests/statement_validation_tests.rs -expression: res +expression: "&diagnostics" --- -SyntaxError { message: "Value: 'AJK%&/231' exceeds length for type: CHAR", range: [SourceLocation { span: Range(TextLocation { line: 10, column: 12, offset: 205 }..TextLocation { line: 10, column: 28, offset: 221 }) }], err_no: syntax__generic_error } -SyntaxError { message: "Invalid assignment: cannot assign 'STRING' to 'CHAR'", range: [SourceLocation { span: Range(TextLocation { line: 10, column: 12, offset: 205 }..TextLocation { line: 10, column: 28, offset: 221 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Value: '898JKAN' exceeds length for type: WCHAR", range: [SourceLocation { span: Range(TextLocation { line: 11, column: 12, offset: 246 }..TextLocation { line: 11, column: 27, offset: 261 }) }], err_no: syntax__generic_error } -SyntaxError { message: "Invalid assignment: cannot assign 'WSTRING' to 'WCHAR'", range: [SourceLocation { span: Range(TextLocation { line: 11, column: 12, offset: 246 }..TextLocation { line: 11, column: 27, offset: 261 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid assignment: cannot assign 'WCHAR' to 'CHAR'", range: [SourceLocation { span: Range(TextLocation { line: 13, column: 12, offset: 287 }..TextLocation { line: 13, column: 19, offset: 294 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid assignment: cannot assign 'CHAR' to 'WCHAR'", range: [SourceLocation { span: Range(TextLocation { line: 14, column: 12, offset: 319 }..TextLocation { line: 14, column: 19, offset: 326 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid assignment: cannot assign 'INT' to 'CHAR'", range: [SourceLocation { span: Range(TextLocation { line: 17, column: 12, offset: 373 }..TextLocation { line: 17, column: 18, offset: 379 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid assignment: cannot assign 'DINT' to 'CHAR'", range: [SourceLocation { span: Range(TextLocation { line: 18, column: 12, offset: 404 }..TextLocation { line: 18, column: 19, offset: 411 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid assignment: cannot assign 'STRING' to 'CHAR'", range: [SourceLocation { span: Range(TextLocation { line: 21, column: 12, offset: 461 }..TextLocation { line: 21, column: 18, offset: 467 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid assignment: cannot assign 'STRING' to 'WCHAR'", range: [SourceLocation { span: Range(TextLocation { line: 22, column: 12, offset: 492 }..TextLocation { line: 22, column: 19, offset: 499 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid assignment: cannot assign 'CHAR' to 'INT'", range: [SourceLocation { span: Range(TextLocation { line: 24, column: 12, offset: 525 }..TextLocation { line: 24, column: 18, offset: 531 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid assignment: cannot assign 'CHAR' to 'STRING'", range: [SourceLocation { span: Range(TextLocation { line: 25, column: 12, offset: 556 }..TextLocation { line: 25, column: 18, offset: 562 }) }], err_no: var__invalid_assignment } +error: Value: 'AJK%&/231' exceeds length for type: CHAR + ┌─ :11:13 + │ +11 │ c := 'AJK%&/231'; // invalid + │ ^^^^^^^^^^^^^^^^ Value: 'AJK%&/231' exceeds length for type: CHAR + +error: Invalid assignment: cannot assign 'STRING' to 'CHAR' + ┌─ :11:13 + │ +11 │ c := 'AJK%&/231'; // invalid + │ ^^^^^^^^^^^^^^^^ Invalid assignment: cannot assign 'STRING' to 'CHAR' + +error: Value: '898JKAN' exceeds length for type: WCHAR + ┌─ :12:13 + │ +12 │ wc := "898JKAN"; // invalid + │ ^^^^^^^^^^^^^^^ Value: '898JKAN' exceeds length for type: WCHAR + +error: Invalid assignment: cannot assign 'WSTRING' to 'WCHAR' + ┌─ :12:13 + │ +12 │ wc := "898JKAN"; // invalid + │ ^^^^^^^^^^^^^^^ Invalid assignment: cannot assign 'WSTRING' to 'WCHAR' + +error: Invalid assignment: cannot assign 'WCHAR' to 'CHAR' + ┌─ :14:13 + │ +14 │ c := wc; // invalid + │ ^^^^^^^ Invalid assignment: cannot assign 'WCHAR' to 'CHAR' + +error: Invalid assignment: cannot assign 'CHAR' to 'WCHAR' + ┌─ :15:13 + │ +15 │ wc := c; // invalid + │ ^^^^^^^ Invalid assignment: cannot assign 'CHAR' to 'WCHAR' + +error: Invalid assignment: cannot assign 'INT' to 'CHAR' + ┌─ :18:13 + │ +18 │ c := i; // invalid + │ ^^^^^^ Invalid assignment: cannot assign 'INT' to 'CHAR' + +error: Invalid assignment: cannot assign 'DINT' to 'CHAR' + ┌─ :19:13 + │ +19 │ c := 42; // invalid + │ ^^^^^^^ Invalid assignment: cannot assign 'DINT' to 'CHAR' + +error: Invalid assignment: cannot assign 'STRING' to 'CHAR' + ┌─ :22:13 + │ +22 │ c := s; // invalid + │ ^^^^^^ Invalid assignment: cannot assign 'STRING' to 'CHAR' + +error: Invalid assignment: cannot assign 'STRING' to 'WCHAR' + ┌─ :23:13 + │ +23 │ wc := s; // invalid + │ ^^^^^^^ Invalid assignment: cannot assign 'STRING' to 'WCHAR' + +error: Invalid assignment: cannot assign 'CHAR' to 'INT' + ┌─ :25:13 + │ +25 │ i := c; // invalid + │ ^^^^^^ Invalid assignment: cannot assign 'CHAR' to 'INT' + +error: Invalid assignment: cannot assign 'CHAR' to 'STRING' + ┌─ :26:13 + │ +26 │ s := c; // invalid + │ ^^^^^^ Invalid assignment: cannot assign 'CHAR' to 'STRING' + diff --git a/src/validation/tests/snapshots/rusty__validation__tests__statement_validation_tests__method_implicit_downcast.snap b/src/validation/tests/snapshots/rusty__validation__tests__statement_validation_tests__method_implicit_downcast.snap index 738b575116..6452c5e854 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__statement_validation_tests__method_implicit_downcast.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__statement_validation_tests__method_implicit_downcast.snap @@ -1,6 +1,11 @@ --- source: src/validation/tests/statement_validation_tests.rs -expression: res +expression: "&diagnostics" --- -SyntaxError { message: "Invalid assignment: cannot assign 'ARRAY[1..3] OF DINT' to 'ARRAY[1..3] OF SINT'", range: [SourceLocation { span: Range(TextLocation { line: 7, column: 32, offset: 156 }..TextLocation { line: 7, column: 39, offset: 163 }) }], err_no: var__invalid_assignment } +error: Invalid assignment: cannot assign 'ARRAY[1..3] OF DINT' to 'ARRAY[1..3] OF SINT' + ┌─ :8:33 + │ +8 │ cl.testMethod(var_lint, var_arr, ADR(var_arr)); // downcast, invalid, ok + │ ^^^^^^^ Invalid assignment: cannot assign 'ARRAY[1..3] OF DINT' to 'ARRAY[1..3] OF SINT' + diff --git a/src/validation/tests/snapshots/rusty__validation__tests__statement_validation_tests__missing_string_compare_function_causes_error.snap b/src/validation/tests/snapshots/rusty__validation__tests__statement_validation_tests__missing_string_compare_function_causes_error.snap index 9781755843..e54b6795f0 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__statement_validation_tests__missing_string_compare_function_causes_error.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__statement_validation_tests__missing_string_compare_function_causes_error.snap @@ -1,13 +1,53 @@ --- source: src/validation/tests/statement_validation_tests.rs -expression: res +expression: "&diagnostics" --- -SyntaxError { message: "Missing compare function 'FUNCTION STRING_EQUAL : BOOL VAR_INPUT a,b : STRING; END_VAR ...'.", range: [SourceLocation { span: Range(TextLocation { line: 2, column: 12, offset: 33 }..TextLocation { line: 2, column: 22, offset: 43 }) }], err_no: codegen__missing_compare_function } -SyntaxError { message: "Missing compare function 'FUNCTION STRING_EQUAL : BOOL VAR_INPUT a,b : STRING; END_VAR ...'.", range: [SourceLocation { span: Range(TextLocation { line: 3, column: 12, offset: 89 }..TextLocation { line: 3, column: 22, offset: 99 }) }], err_no: codegen__missing_compare_function } -SyntaxError { message: "Missing compare function 'FUNCTION STRING_LESS : BOOL VAR_INPUT a,b : STRING; END_VAR ...'.", range: [SourceLocation { span: Range(TextLocation { line: 4, column: 12, offset: 145 }..TextLocation { line: 4, column: 22, offset: 155 }) }], err_no: codegen__missing_compare_function } -SyntaxError { message: "Missing compare function 'FUNCTION STRING_GREATER : BOOL VAR_INPUT a,b : STRING; END_VAR ...'.", range: [SourceLocation { span: Range(TextLocation { line: 5, column: 12, offset: 201 }..TextLocation { line: 5, column: 22, offset: 211 }) }], err_no: codegen__missing_compare_function } -SyntaxError { message: "Missing compare function 'FUNCTION STRING_LESS : BOOL VAR_INPUT a,b : STRING; END_VAR ...'.", range: [SourceLocation { span: Range(TextLocation { line: 6, column: 12, offset: 257 }..TextLocation { line: 6, column: 22, offset: 267 }) }], err_no: codegen__missing_compare_function } -SyntaxError { message: "Missing compare function 'FUNCTION STRING_EQUAL : BOOL VAR_INPUT a,b : STRING; END_VAR ...'.", range: [SourceLocation { span: Range(TextLocation { line: 6, column: 12, offset: 257 }..TextLocation { line: 6, column: 22, offset: 267 }) }], err_no: codegen__missing_compare_function } -SyntaxError { message: "Missing compare function 'FUNCTION STRING_GREATER : BOOL VAR_INPUT a,b : STRING; END_VAR ...'.", range: [SourceLocation { span: Range(TextLocation { line: 7, column: 12, offset: 313 }..TextLocation { line: 7, column: 22, offset: 323 }) }], err_no: codegen__missing_compare_function } -SyntaxError { message: "Missing compare function 'FUNCTION STRING_EQUAL : BOOL VAR_INPUT a,b : STRING; END_VAR ...'.", range: [SourceLocation { span: Range(TextLocation { line: 7, column: 12, offset: 313 }..TextLocation { line: 7, column: 22, offset: 323 }) }], err_no: codegen__missing_compare_function } +error: Missing compare function 'FUNCTION STRING_EQUAL : BOOL VAR_INPUT a,b : STRING; END_VAR ...'. + ┌─ :3:13 + │ +3 │ 'a' = 'b'; // missing compare function :-( + │ ^^^^^^^^^^ Missing compare function 'FUNCTION STRING_EQUAL : BOOL VAR_INPUT a,b : STRING; END_VAR ...'. + +error: Missing compare function 'FUNCTION STRING_EQUAL : BOOL VAR_INPUT a,b : STRING; END_VAR ...'. + ┌─ :4:13 + │ +4 │ 'a' <> 'b'; // missing compare function :-( + │ ^^^^^^^^^^ Missing compare function 'FUNCTION STRING_EQUAL : BOOL VAR_INPUT a,b : STRING; END_VAR ...'. + +error: Missing compare function 'FUNCTION STRING_LESS : BOOL VAR_INPUT a,b : STRING; END_VAR ...'. + ┌─ :5:13 + │ +5 │ 'a' < 'b'; // missing compare function :-( + │ ^^^^^^^^^^ Missing compare function 'FUNCTION STRING_LESS : BOOL VAR_INPUT a,b : STRING; END_VAR ...'. + +error: Missing compare function 'FUNCTION STRING_GREATER : BOOL VAR_INPUT a,b : STRING; END_VAR ...'. + ┌─ :6:13 + │ +6 │ 'a' > 'b'; // missing compare function :-( + │ ^^^^^^^^^^ Missing compare function 'FUNCTION STRING_GREATER : BOOL VAR_INPUT a,b : STRING; END_VAR ...'. + +error: Missing compare function 'FUNCTION STRING_LESS : BOOL VAR_INPUT a,b : STRING; END_VAR ...'. + ┌─ :7:13 + │ +7 │ 'a' <= 'b'; // missing compare function :-( + │ ^^^^^^^^^^ Missing compare function 'FUNCTION STRING_LESS : BOOL VAR_INPUT a,b : STRING; END_VAR ...'. + +error: Missing compare function 'FUNCTION STRING_EQUAL : BOOL VAR_INPUT a,b : STRING; END_VAR ...'. + ┌─ :7:13 + │ +7 │ 'a' <= 'b'; // missing compare function :-( + │ ^^^^^^^^^^ Missing compare function 'FUNCTION STRING_EQUAL : BOOL VAR_INPUT a,b : STRING; END_VAR ...'. + +error: Missing compare function 'FUNCTION STRING_GREATER : BOOL VAR_INPUT a,b : STRING; END_VAR ...'. + ┌─ :8:13 + │ +8 │ 'a' >= 'b'; // missing compare function :-( + │ ^^^^^^^^^^ Missing compare function 'FUNCTION STRING_GREATER : BOOL VAR_INPUT a,b : STRING; END_VAR ...'. + +error: Missing compare function 'FUNCTION STRING_EQUAL : BOOL VAR_INPUT a,b : STRING; END_VAR ...'. + ┌─ :8:13 + │ +8 │ 'a' >= 'b'; // missing compare function :-( + │ ^^^^^^^^^^ Missing compare function 'FUNCTION STRING_EQUAL : BOOL VAR_INPUT a,b : STRING; END_VAR ...'. + diff --git a/src/validation/tests/snapshots/rusty__validation__tests__statement_validation_tests__missing_wstring_compare_function_causes_error.snap b/src/validation/tests/snapshots/rusty__validation__tests__statement_validation_tests__missing_wstring_compare_function_causes_error.snap index 0e4894de07..87e3c235b7 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__statement_validation_tests__missing_wstring_compare_function_causes_error.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__statement_validation_tests__missing_wstring_compare_function_causes_error.snap @@ -1,13 +1,53 @@ --- source: src/validation/tests/statement_validation_tests.rs -expression: res +expression: "&diagnostics" --- -SyntaxError { message: "Missing compare function 'FUNCTION WSTRING_EQUAL : BOOL VAR_INPUT a,b : WSTRING; END_VAR ...'.", range: [SourceLocation { span: Range(TextLocation { line: 2, column: 12, offset: 33 }..TextLocation { line: 2, column: 22, offset: 43 }) }], err_no: codegen__missing_compare_function } -SyntaxError { message: "Missing compare function 'FUNCTION WSTRING_EQUAL : BOOL VAR_INPUT a,b : WSTRING; END_VAR ...'.", range: [SourceLocation { span: Range(TextLocation { line: 3, column: 12, offset: 89 }..TextLocation { line: 3, column: 22, offset: 99 }) }], err_no: codegen__missing_compare_function } -SyntaxError { message: "Missing compare function 'FUNCTION WSTRING_LESS : BOOL VAR_INPUT a,b : WSTRING; END_VAR ...'.", range: [SourceLocation { span: Range(TextLocation { line: 4, column: 12, offset: 145 }..TextLocation { line: 4, column: 22, offset: 155 }) }], err_no: codegen__missing_compare_function } -SyntaxError { message: "Missing compare function 'FUNCTION WSTRING_GREATER : BOOL VAR_INPUT a,b : WSTRING; END_VAR ...'.", range: [SourceLocation { span: Range(TextLocation { line: 5, column: 12, offset: 201 }..TextLocation { line: 5, column: 22, offset: 211 }) }], err_no: codegen__missing_compare_function } -SyntaxError { message: "Missing compare function 'FUNCTION WSTRING_LESS : BOOL VAR_INPUT a,b : WSTRING; END_VAR ...'.", range: [SourceLocation { span: Range(TextLocation { line: 6, column: 12, offset: 257 }..TextLocation { line: 6, column: 22, offset: 267 }) }], err_no: codegen__missing_compare_function } -SyntaxError { message: "Missing compare function 'FUNCTION WSTRING_EQUAL : BOOL VAR_INPUT a,b : WSTRING; END_VAR ...'.", range: [SourceLocation { span: Range(TextLocation { line: 6, column: 12, offset: 257 }..TextLocation { line: 6, column: 22, offset: 267 }) }], err_no: codegen__missing_compare_function } -SyntaxError { message: "Missing compare function 'FUNCTION WSTRING_GREATER : BOOL VAR_INPUT a,b : WSTRING; END_VAR ...'.", range: [SourceLocation { span: Range(TextLocation { line: 7, column: 12, offset: 313 }..TextLocation { line: 7, column: 22, offset: 323 }) }], err_no: codegen__missing_compare_function } -SyntaxError { message: "Missing compare function 'FUNCTION WSTRING_EQUAL : BOOL VAR_INPUT a,b : WSTRING; END_VAR ...'.", range: [SourceLocation { span: Range(TextLocation { line: 7, column: 12, offset: 313 }..TextLocation { line: 7, column: 22, offset: 323 }) }], err_no: codegen__missing_compare_function } +error: Missing compare function 'FUNCTION WSTRING_EQUAL : BOOL VAR_INPUT a,b : WSTRING; END_VAR ...'. + ┌─ :3:13 + │ +3 │ "a" = "b"; // missing compare function :-( + │ ^^^^^^^^^^ Missing compare function 'FUNCTION WSTRING_EQUAL : BOOL VAR_INPUT a,b : WSTRING; END_VAR ...'. + +error: Missing compare function 'FUNCTION WSTRING_EQUAL : BOOL VAR_INPUT a,b : WSTRING; END_VAR ...'. + ┌─ :4:13 + │ +4 │ "a" <> "b"; // missing compare function :-( + │ ^^^^^^^^^^ Missing compare function 'FUNCTION WSTRING_EQUAL : BOOL VAR_INPUT a,b : WSTRING; END_VAR ...'. + +error: Missing compare function 'FUNCTION WSTRING_LESS : BOOL VAR_INPUT a,b : WSTRING; END_VAR ...'. + ┌─ :5:13 + │ +5 │ "a" < "b"; // missing compare function :-( + │ ^^^^^^^^^^ Missing compare function 'FUNCTION WSTRING_LESS : BOOL VAR_INPUT a,b : WSTRING; END_VAR ...'. + +error: Missing compare function 'FUNCTION WSTRING_GREATER : BOOL VAR_INPUT a,b : WSTRING; END_VAR ...'. + ┌─ :6:13 + │ +6 │ "a" > "b"; // missing compare function :-( + │ ^^^^^^^^^^ Missing compare function 'FUNCTION WSTRING_GREATER : BOOL VAR_INPUT a,b : WSTRING; END_VAR ...'. + +error: Missing compare function 'FUNCTION WSTRING_LESS : BOOL VAR_INPUT a,b : WSTRING; END_VAR ...'. + ┌─ :7:13 + │ +7 │ "a" <= "b"; // missing compare function :-( + │ ^^^^^^^^^^ Missing compare function 'FUNCTION WSTRING_LESS : BOOL VAR_INPUT a,b : WSTRING; END_VAR ...'. + +error: Missing compare function 'FUNCTION WSTRING_EQUAL : BOOL VAR_INPUT a,b : WSTRING; END_VAR ...'. + ┌─ :7:13 + │ +7 │ "a" <= "b"; // missing compare function :-( + │ ^^^^^^^^^^ Missing compare function 'FUNCTION WSTRING_EQUAL : BOOL VAR_INPUT a,b : WSTRING; END_VAR ...'. + +error: Missing compare function 'FUNCTION WSTRING_GREATER : BOOL VAR_INPUT a,b : WSTRING; END_VAR ...'. + ┌─ :8:13 + │ +8 │ "a" >= "b"; // missing compare function :-( + │ ^^^^^^^^^^ Missing compare function 'FUNCTION WSTRING_GREATER : BOOL VAR_INPUT a,b : WSTRING; END_VAR ...'. + +error: Missing compare function 'FUNCTION WSTRING_EQUAL : BOOL VAR_INPUT a,b : WSTRING; END_VAR ...'. + ┌─ :8:13 + │ +8 │ "a" >= "b"; // missing compare function :-( + │ ^^^^^^^^^^ Missing compare function 'FUNCTION WSTRING_EQUAL : BOOL VAR_INPUT a,b : WSTRING; END_VAR ...'. + diff --git a/src/validation/tests/snapshots/rusty__validation__tests__statement_validation_tests__program_call_parameter_validation.snap b/src/validation/tests/snapshots/rusty__validation__tests__statement_validation_tests__program_call_parameter_validation.snap index 910492da3e..fb8cd0ca90 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__statement_validation_tests__program_call_parameter_validation.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__statement_validation_tests__program_call_parameter_validation.snap @@ -1,13 +1,53 @@ --- source: src/validation/tests/statement_validation_tests.rs -expression: res +expression: "&diagnostics" --- -SyntaxError { message: "Cannot mix implicit and explicit call parameters!", range: [SourceLocation { span: Range(TextLocation { line: 22, column: 34, offset: 501 }..TextLocation { line: 22, column: 38, offset: 505 }) }], err_no: call__invalid_parameter_type } -SyntaxError { message: "Cannot mix implicit and explicit call parameters!", range: [SourceLocation { span: Range(TextLocation { line: 22, column: 40, offset: 507 }..TextLocation { line: 22, column: 44, offset: 511 }) }], err_no: call__invalid_parameter_type } -SyntaxError { message: "Invalid assignment: cannot assign 'STRING' to 'DINT'", range: [SourceLocation { span: Range(TextLocation { line: 24, column: 17, offset: 576 }..TextLocation { line: 24, column: 31, offset: 590 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "The type DINT 32 is too small to hold a Pointer", range: [SourceLocation { span: Range(TextLocation { line: 24, column: 33, offset: 592 }..TextLocation { line: 24, column: 47, offset: 606 }) }], err_no: type__incompatible_size } -SyntaxError { message: "Invalid assignment: cannot assign 'REF_TO WSTRING' to 'DINT'", range: [SourceLocation { span: Range(TextLocation { line: 24, column: 33, offset: 592 }..TextLocation { line: 24, column: 47, offset: 606 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid assignment: cannot assign 'STRING' to 'DINT'", range: [SourceLocation { span: Range(TextLocation { line: 26, column: 17, offset: 767 }..TextLocation { line: 26, column: 21, offset: 771 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "The type DINT 32 is too small to hold a Pointer", range: [SourceLocation { span: Range(TextLocation { line: 26, column: 23, offset: 773 }..TextLocation { line: 26, column: 27, offset: 777 }) }], err_no: type__incompatible_size } -SyntaxError { message: "Invalid assignment: cannot assign 'REF_TO WSTRING' to 'DINT'", range: [SourceLocation { span: Range(TextLocation { line: 26, column: 23, offset: 773 }..TextLocation { line: 26, column: 27, offset: 777 }) }], err_no: var__invalid_assignment } +error: Cannot mix implicit and explicit call parameters! + ┌─ :23:35 + │ +23 │ prog(output1 => var1, var1, var1); // invalid cannot mix explicit and implicit + │ ^^^^ Cannot mix implicit and explicit call parameters! + +error: Cannot mix implicit and explicit call parameters! + ┌─ :23:41 + │ +23 │ prog(output1 => var1, var1, var1); // invalid cannot mix explicit and implicit + │ ^^^^ Cannot mix implicit and explicit call parameters! + +error: Invalid assignment: cannot assign 'STRING' to 'DINT' + ┌─ :25:18 + │ +25 │ prog(input1 := var2, inout1 := var3, output1 => var4); // invalid types assigned + │ ^^^^^^^^^^^^^^ Invalid assignment: cannot assign 'STRING' to 'DINT' + +error: The type DINT 32 is too small to hold a Pointer + ┌─ :25:34 + │ +25 │ prog(input1 := var2, inout1 := var3, output1 => var4); // invalid types assigned + │ ^^^^^^^^^^^^^^ The type DINT 32 is too small to hold a Pointer + +error: Invalid assignment: cannot assign 'REF_TO WSTRING' to 'DINT' + ┌─ :25:34 + │ +25 │ prog(input1 := var2, inout1 := var3, output1 => var4); // invalid types assigned + │ ^^^^^^^^^^^^^^ Invalid assignment: cannot assign 'REF_TO WSTRING' to 'DINT' + +error: Invalid assignment: cannot assign 'STRING' to 'DINT' + ┌─ :27:18 + │ +27 │ prog(var2, var3, var4); // invalid types assigned + │ ^^^^ Invalid assignment: cannot assign 'STRING' to 'DINT' + +error: The type DINT 32 is too small to hold a Pointer + ┌─ :27:24 + │ +27 │ prog(var2, var3, var4); // invalid types assigned + │ ^^^^ The type DINT 32 is too small to hold a Pointer + +error: Invalid assignment: cannot assign 'REF_TO WSTRING' to 'DINT' + ┌─ :27:24 + │ +27 │ prog(var2, var3, var4); // invalid types assigned + │ ^^^^ Invalid assignment: cannot assign 'REF_TO WSTRING' to 'DINT' + diff --git a/src/validation/tests/snapshots/rusty__validation__tests__statement_validation_tests__program_implicit_downcast.snap b/src/validation/tests/snapshots/rusty__validation__tests__statement_validation_tests__program_implicit_downcast.snap index fc5661d64a..fa87259698 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__statement_validation_tests__program_implicit_downcast.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__statement_validation_tests__program_implicit_downcast.snap @@ -1,6 +1,11 @@ --- source: src/validation/tests/statement_validation_tests.rs -expression: res +expression: "&diagnostics" --- -SyntaxError { message: "Invalid assignment: cannot assign 'WSTRING' to 'STRING'", range: [SourceLocation { span: Range(TextLocation { line: 15, column: 16, offset: 466 }..TextLocation { line: 15, column: 24, offset: 474 }) }], err_no: var__invalid_assignment } +error: Invalid assignment: cannot assign 'WSTRING' to 'STRING' + ┌─ :16:17 + │ +16 │ var_wstr, // invalid + │ ^^^^^^^^ Invalid assignment: cannot assign 'WSTRING' to 'STRING' + diff --git a/src/validation/tests/snapshots/rusty__validation__tests__statement_validation_tests__program_missing_inout_assignment.snap b/src/validation/tests/snapshots/rusty__validation__tests__statement_validation_tests__program_missing_inout_assignment.snap index fb6ad8e4bc..7a56bc9171 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__statement_validation_tests__program_missing_inout_assignment.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__statement_validation_tests__program_missing_inout_assignment.snap @@ -1,9 +1,29 @@ --- source: src/validation/tests/statement_validation_tests.rs -expression: res +expression: "&diagnostics" --- -SyntaxError { message: "Missing inout parameter: inout1", range: [SourceLocation { span: Range(TextLocation { line: 17, column: 12, offset: 327 }..TextLocation { line: 17, column: 16, offset: 331 }) }], err_no: pou__missing_action_container } -SyntaxError { message: "Missing inout parameter: inout1", range: [SourceLocation { span: Range(TextLocation { line: 18, column: 12, offset: 378 }..TextLocation { line: 18, column: 16, offset: 382 }) }], err_no: pou__missing_action_container } -SyntaxError { message: "Missing inout parameter: inout1", range: [SourceLocation { span: Range(TextLocation { line: 19, column: 12, offset: 408 }..TextLocation { line: 19, column: 16, offset: 412 }) }], err_no: pou__missing_action_container } -SyntaxError { message: "Missing inout parameter: inout1", range: [SourceLocation { span: Range(TextLocation { line: 20, column: 12, offset: 432 }..TextLocation { line: 20, column: 16, offset: 436 }) }], err_no: pou__missing_action_container } +error: Missing inout parameter: inout1 + ┌─ :18:13 + │ +18 │ prog(input1 := var1, output1 => var2); + │ ^^^^ Missing inout parameter: inout1 + +error: Missing inout parameter: inout1 + ┌─ :19:13 + │ +19 │ prog(var1, var2); + │ ^^^^ Missing inout parameter: inout1 + +error: Missing inout parameter: inout1 + ┌─ :20:13 + │ +20 │ prog(var1); + │ ^^^^ Missing inout parameter: inout1 + +error: Missing inout parameter: inout1 + ┌─ :21:13 + │ +21 │ prog(); + │ ^^^^ Missing inout parameter: inout1 + diff --git a/src/validation/tests/snapshots/rusty__validation__tests__statement_validation_tests__ref_builtin_function_reports_invalid_param_count.snap b/src/validation/tests/snapshots/rusty__validation__tests__statement_validation_tests__ref_builtin_function_reports_invalid_param_count.snap index d3c13c2ad3..a0a7bf6a56 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__statement_validation_tests__ref_builtin_function_reports_invalid_param_count.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__statement_validation_tests__ref_builtin_function_reports_invalid_param_count.snap @@ -1,7 +1,17 @@ --- source: src/validation/tests/statement_validation_tests.rs -expression: res +expression: diagnostics --- -SyntaxError { message: "Invalid parameter count. Received 0 parameters while 1 parameters were expected.", range: [SourceLocation { span: Range(TextLocation { line: 6, column: 12, offset: 134 }..TextLocation { line: 6, column: 15, offset: 137 }) }], err_no: call__invalid_parameter_count } -SyntaxError { message: "Invalid parameter count. Received 4 parameters while 1 parameters were expected.", range: [SourceLocation { span: Range(TextLocation { line: 7, column: 12, offset: 153 }..TextLocation { line: 7, column: 15, offset: 156 }) }], err_no: call__invalid_parameter_count } +error: Invalid parameter count. Received 0 parameters while 1 parameters were expected. + ┌─ :7:13 + │ +7 │ REF(); + │ ^^^ Invalid parameter count. Received 0 parameters while 1 parameters were expected. + +error: Invalid parameter count. Received 4 parameters while 1 parameters were expected. + ┌─ :8:13 + │ +8 │ REF(x, 1, 2, 'abc'); + │ ^^^ Invalid parameter count. Received 4 parameters while 1 parameters were expected. + diff --git a/src/validation/tests/snapshots/rusty__validation__tests__statement_validation_tests__reference_to_reference_assignments_in_function_arguments.snap b/src/validation/tests/snapshots/rusty__validation__tests__statement_validation_tests__reference_to_reference_assignments_in_function_arguments.snap index 45b1cc0b55..02f721f482 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__statement_validation_tests__reference_to_reference_assignments_in_function_arguments.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__statement_validation_tests__reference_to_reference_assignments_in_function_arguments.snap @@ -1,11 +1,41 @@ --- source: src/validation/tests/statement_validation_tests.rs -expression: res +expression: "&diagnostics" --- -SyntaxError { message: "Invalid assignment: cannot assign '__POINTER_TO_INT' to 'REF_TO STRUCT_params'", range: [SourceLocation { span: Range(TextLocation { line: 46, column: 12, offset: 1286 }..TextLocation { line: 46, column: 34, offset: 1308 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid assignment: cannot assign '__POINTER_TO_REAL' to 'REF_TO STRUCT_params'", range: [SourceLocation { span: Range(TextLocation { line: 47, column: 12, offset: 1322 }..TextLocation { line: 47, column: 34, offset: 1344 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid assignment: cannot assign '__POINTER_TO_STRING' to 'REF_TO STRUCT_params'", range: [SourceLocation { span: Range(TextLocation { line: 48, column: 12, offset: 1358 }..TextLocation { line: 48, column: 34, offset: 1380 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid assignment: cannot assign '__POINTER_TO_INT' to 'REF_TO STRUCT_params'", range: [SourceLocation { span: Range(TextLocation { line: 54, column: 12, offset: 1588 }..TextLocation { line: 54, column: 32, offset: 1608 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid assignment: cannot assign '__POINTER_TO_REAL' to 'REF_TO STRUCT_params'", range: [SourceLocation { span: Range(TextLocation { line: 55, column: 12, offset: 1622 }..TextLocation { line: 55, column: 32, offset: 1642 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid assignment: cannot assign '__POINTER_TO___global_global6' to 'REF_TO STRUCT_params'", range: [SourceLocation { span: Range(TextLocation { line: 56, column: 12, offset: 1656 }..TextLocation { line: 56, column: 32, offset: 1676 }) }], err_no: var__invalid_assignment } +error: Invalid assignment: cannot assign '__POINTER_TO_INT' to 'REF_TO STRUCT_params' + ┌─ :47:13 + │ +47 │ input1 := REF(global4), + │ ^^^^^^^^^^^^^^^^^^^^^^ Invalid assignment: cannot assign '__POINTER_TO_INT' to 'REF_TO STRUCT_params' + +error: Invalid assignment: cannot assign '__POINTER_TO_REAL' to 'REF_TO STRUCT_params' + ┌─ :48:13 + │ +48 │ input2 := REF(global5), + │ ^^^^^^^^^^^^^^^^^^^^^^ Invalid assignment: cannot assign '__POINTER_TO_REAL' to 'REF_TO STRUCT_params' + +error: Invalid assignment: cannot assign '__POINTER_TO_STRING' to 'REF_TO STRUCT_params' + ┌─ :49:13 + │ +49 │ input3 := REF(global6), + │ ^^^^^^^^^^^^^^^^^^^^^^ Invalid assignment: cannot assign '__POINTER_TO_STRING' to 'REF_TO STRUCT_params' + +error: Invalid assignment: cannot assign '__POINTER_TO_INT' to 'REF_TO STRUCT_params' + ┌─ :55:13 + │ +55 │ input1 := &(global4), + │ ^^^^^^^^^^^^^^^^^^^^ Invalid assignment: cannot assign '__POINTER_TO_INT' to 'REF_TO STRUCT_params' + +error: Invalid assignment: cannot assign '__POINTER_TO_REAL' to 'REF_TO STRUCT_params' + ┌─ :56:13 + │ +56 │ input2 := &(global5), + │ ^^^^^^^^^^^^^^^^^^^^ Invalid assignment: cannot assign '__POINTER_TO_REAL' to 'REF_TO STRUCT_params' + +error: Invalid assignment: cannot assign '__POINTER_TO___global_global6' to 'REF_TO STRUCT_params' + ┌─ :57:13 + │ +57 │ input3 := &(global6), + │ ^^^^^^^^^^^^^^^^^^^^ Invalid assignment: cannot assign '__POINTER_TO___global_global6' to 'REF_TO STRUCT_params' + diff --git a/src/validation/tests/snapshots/rusty__validation__tests__statement_validation_tests__string_compare_function_with_wrong_signature_causes_error.snap b/src/validation/tests/snapshots/rusty__validation__tests__statement_validation_tests__string_compare_function_with_wrong_signature_causes_error.snap index 09db28f874..99aacf8c7e 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__statement_validation_tests__string_compare_function_with_wrong_signature_causes_error.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__statement_validation_tests__string_compare_function_with_wrong_signature_causes_error.snap @@ -1,6 +1,11 @@ --- source: src/validation/tests/statement_validation_tests.rs -expression: res +expression: "&diagnostics" --- -SyntaxError { message: "Missing compare function 'FUNCTION STRING_EQUAL : BOOL VAR_INPUT a,b : STRING; END_VAR ...'.", range: [SourceLocation { span: Range(TextLocation { line: 4, column: 12, offset: 114 }..TextLocation { line: 4, column: 22, offset: 124 }) }], err_no: codegen__missing_compare_function } +error: Missing compare function 'FUNCTION STRING_EQUAL : BOOL VAR_INPUT a,b : STRING; END_VAR ...'. + ┌─ :5:13 + │ +5 │ 'a' = 'b'; // missing compare function :-( + │ ^^^^^^^^^^ Missing compare function 'FUNCTION STRING_EQUAL : BOOL VAR_INPUT a,b : STRING; END_VAR ...'. + diff --git a/src/validation/tests/snapshots/rusty__validation__tests__statement_validation_tests__switch_case_duplicate_integer.snap b/src/validation/tests/snapshots/rusty__validation__tests__statement_validation_tests__switch_case_duplicate_integer.snap index 59b954d7c1..93951eeeb2 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__statement_validation_tests__switch_case_duplicate_integer.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__statement_validation_tests__switch_case_duplicate_integer.snap @@ -1,9 +1,29 @@ --- source: src/validation/tests/statement_validation_tests.rs -expression: res +expression: "&diagnostics" --- -SyntaxError { message: "Duplicate condition value: 4. Occurred more than once!", range: [SourceLocation { span: Range(TextLocation { line: 15, column: 16, offset: 332 }..TextLocation { line: 15, column: 22, offset: 338 }) }], err_no: case__duplicate_condition } -SyntaxError { message: "Duplicate condition value: 4. Occurred more than once!", range: [SourceLocation { span: Range(TextLocation { line: 17, column: 16, offset: 386 }..TextLocation { line: 17, column: 25, offset: 395 }) }], err_no: case__duplicate_condition } -SyntaxError { message: "Duplicate condition value: 4. Occurred more than once!", range: [SourceLocation { span: Range(TextLocation { line: 19, column: 16, offset: 443 }..TextLocation { line: 19, column: 24, offset: 451 }) }], err_no: case__duplicate_condition } -SyntaxError { message: "Duplicate condition value: 4. Occurred more than once!", range: [SourceLocation { span: Range(TextLocation { line: 21, column: 16, offset: 499 }..TextLocation { line: 21, column: 19, offset: 502 }) }], err_no: case__duplicate_condition } +error: Duplicate condition value: 4. Occurred more than once! + ┌─ :16:17 + │ +16 │ BASE*2: + │ ^^^^^^ Duplicate condition value: 4. Occurred more than once! + +error: Duplicate condition value: 4. Occurred more than once! + ┌─ :18:17 + │ +18 │ BASE+GLOB: + │ ^^^^^^^^^ Duplicate condition value: 4. Occurred more than once! + +error: Duplicate condition value: 4. Occurred more than once! + ┌─ :20:17 + │ +20 │ MYTYPE_A: + │ ^^^^^^^^ Duplicate condition value: 4. Occurred more than once! + +error: Duplicate condition value: 4. Occurred more than once! + ┌─ :22:17 + │ +22 │ 2+2: + │ ^^^ Duplicate condition value: 4. Occurred more than once! + diff --git a/src/validation/tests/snapshots/rusty__validation__tests__statement_validation_tests__switch_case_duplicate_integer_non_const_var_reference.snap b/src/validation/tests/snapshots/rusty__validation__tests__statement_validation_tests__switch_case_duplicate_integer_non_const_var_reference.snap index 1ea41bc5ba..8df7a6e3df 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__statement_validation_tests__switch_case_duplicate_integer_non_const_var_reference.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__statement_validation_tests__switch_case_duplicate_integer_non_const_var_reference.snap @@ -1,9 +1,29 @@ --- source: src/validation/tests/statement_validation_tests.rs -expression: res +expression: "&diagnostics" --- -SyntaxError { message: "'x' is no const reference. Non constant variables are not supported in case conditions", range: [SourceLocation { span: Range(TextLocation { line: 13, column: 16, offset: 246 }..TextLocation { line: 13, column: 17, offset: 247 }) }], err_no: type__invalid_type } -SyntaxError { message: "'y' is no const reference. Non constant variables are not supported in case conditions", range: [SourceLocation { span: Range(TextLocation { line: 15, column: 16, offset: 324 }..TextLocation { line: 15, column: 17, offset: 325 }) }], err_no: type__invalid_type } -SyntaxError { message: "'x' is no const reference. Non constant variables are not supported in case conditions", range: [SourceLocation { span: Range(TextLocation { line: 17, column: 16, offset: 402 }..TextLocation { line: 17, column: 19, offset: 405 }) }], err_no: type__invalid_type } -SyntaxError { message: "'x' is no const reference. Non constant variables are not supported in case conditions", range: [SourceLocation { span: Range(TextLocation { line: 21, column: 16, offset: 535 }..TextLocation { line: 21, column: 23, offset: 542 }) }], err_no: type__invalid_type } +error: 'x' is no const reference. Non constant variables are not supported in case conditions + ┌─ :14:17 + │ +14 │ x: // x is no constant => error + │ ^ 'x' is no const reference. Non constant variables are not supported in case conditions + +error: 'y' is no const reference. Non constant variables are not supported in case conditions + ┌─ :16:17 + │ +16 │ y: // y is no constant => error + │ ^ 'y' is no const reference. Non constant variables are not supported in case conditions + +error: 'x' is no const reference. Non constant variables are not supported in case conditions + ┌─ :18:17 + │ +18 │ 2+x: // x is no constant => error + │ ^^^ 'x' is no const reference. Non constant variables are not supported in case conditions + +error: 'x' is no const reference. Non constant variables are not supported in case conditions + ┌─ :22:17 + │ +22 │ CONST+x: // x is no constant => error + │ ^^^^^^^ 'x' is no const reference. Non constant variables are not supported in case conditions + diff --git a/src/validation/tests/snapshots/rusty__validation__tests__statement_validation_tests__switch_case_invalid_case_conditions.snap b/src/validation/tests/snapshots/rusty__validation__tests__statement_validation_tests__switch_case_invalid_case_conditions.snap index 9d1f809b86..aa0039c7b3 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__statement_validation_tests__switch_case_invalid_case_conditions.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__statement_validation_tests__switch_case_invalid_case_conditions.snap @@ -1,8 +1,43 @@ --- source: src/validation/tests/statement_validation_tests.rs -expression: res +expression: "&diagnostics" --- -SyntaxError { message: "Invalid case condition!", range: [SourceLocation { span: Range(TextLocation { line: 10, column: 16, offset: 174 }..TextLocation { line: 10, column: 22, offset: 180 }) }], err_no: case__case_condition_outside_case_statement } -SyntaxError { message: "Cannot resolve constant: CallStatement {\n operator: ReferenceExpr {\n kind: Member(\n Identifier {\n name: \"foo\",\n },\n ),\n base: None,\n },\n parameters: None,\n}. Non constant variables are not supported in case conditions", range: [SourceLocation { span: Range(TextLocation { line: 10, column: 16, offset: 174 }..TextLocation { line: 10, column: 22, offset: 180 }) }], err_no: type__invalid_type } -SyntaxError { message: "Invalid case condition!", range: [SourceLocation { span: Range(TextLocation { line: 12, column: 16, offset: 227 }..TextLocation { line: 12, column: 24, offset: 235 }) }], err_no: case__case_condition_outside_case_statement } +error: Invalid case condition! + ┌─ :11:17 + │ +11 │ foo(): + │ ^^^^^^ Invalid case condition! + +error: Cannot resolve constant: CallStatement { + operator: ReferenceExpr { + kind: Member( + Identifier { + name: "foo", + }, + ), + base: None, + }, + parameters: None, +}. Non constant variables are not supported in case conditions + ┌─ :11:17 + │ +11 │ foo(): + │ ^^^^^^ Cannot resolve constant: CallStatement { + operator: ReferenceExpr { + kind: Member( + Identifier { + name: "foo", + }, + ), + base: None, + }, + parameters: None, +}. Non constant variables are not supported in case conditions + +error: Invalid case condition! + ┌─ :13:17 + │ +13 │ res := 2: + │ ^^^^^^^^ Invalid case condition! + diff --git a/src/validation/tests/snapshots/rusty__validation__tests__statement_validation_tests__validate_array_elements_passed_to_functions_by_ref.snap b/src/validation/tests/snapshots/rusty__validation__tests__statement_validation_tests__validate_array_elements_passed_to_functions_by_ref.snap index 0f4d381118..bcb8532680 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__statement_validation_tests__validate_array_elements_passed_to_functions_by_ref.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__statement_validation_tests__validate_array_elements_passed_to_functions_by_ref.snap @@ -1,7 +1,17 @@ --- source: src/validation/tests/statement_validation_tests.rs -expression: res +expression: "&diagnostics" --- -SyntaxError { message: "Invalid assignment: cannot assign 'ARRAY[0..1] OF INT' to 'INT'", range: [SourceLocation { span: Range(TextLocation { line: 16, column: 17, offset: 323 }..TextLocation { line: 16, column: 18, offset: 324 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid assignment: cannot assign 'ARRAY[0..1] OF INT' to 'INT'", range: [SourceLocation { span: Range(TextLocation { line: 16, column: 20, offset: 326 }..TextLocation { line: 16, column: 21, offset: 327 }) }], err_no: var__invalid_assignment } +error: Invalid assignment: cannot assign 'ARRAY[0..1] OF INT' to 'INT' + ┌─ :17:18 + │ +17 │ func(x, x); // Invalid because we pass a whole array + │ ^ Invalid assignment: cannot assign 'ARRAY[0..1] OF INT' to 'INT' + +error: Invalid assignment: cannot assign 'ARRAY[0..1] OF INT' to 'INT' + ┌─ :17:21 + │ +17 │ func(x, x); // Invalid because we pass a whole array + │ ^ Invalid assignment: cannot assign 'ARRAY[0..1] OF INT' to 'INT' + diff --git a/src/validation/tests/snapshots/rusty__validation__tests__statement_validation_tests__validate_arrays_passed_to_functions.snap b/src/validation/tests/snapshots/rusty__validation__tests__statement_validation_tests__validate_arrays_passed_to_functions.snap index f05608379a..73f53eccc2 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__statement_validation_tests__validate_arrays_passed_to_functions.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__statement_validation_tests__validate_arrays_passed_to_functions.snap @@ -1,13 +1,53 @@ --- source: src/validation/tests/statement_validation_tests.rs -expression: res +expression: "&diagnostics" --- -SyntaxError { message: "Invalid assignment: cannot assign 'ARRAY[0..1] OF SINT' to 'ARRAY[0..1] OF DINT'", range: [SourceLocation { span: Range(TextLocation { line: 25, column: 17, offset: 959 }..TextLocation { line: 25, column: 25, offset: 967 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid assignment: cannot assign 'ARRAY[0..1] OF INT' to 'ARRAY[0..1] OF DINT'", range: [SourceLocation { span: Range(TextLocation { line: 26, column: 17, offset: 987 }..TextLocation { line: 26, column: 24, offset: 994 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid assignment: cannot assign 'ARRAY[0..1] OF LINT' to 'ARRAY[0..1] OF DINT'", range: [SourceLocation { span: Range(TextLocation { line: 28, column: 17, offset: 1042 }..TextLocation { line: 28, column: 25, offset: 1050 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid assignment: cannot assign 'ARRAY[0..1] OF REAL' to 'ARRAY[0..1] OF DINT'", range: [SourceLocation { span: Range(TextLocation { line: 29, column: 17, offset: 1070 }..TextLocation { line: 29, column: 25, offset: 1078 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid assignment: cannot assign 'ARRAY[0..1] OF LREAL' to 'ARRAY[0..1] OF DINT'", range: [SourceLocation { span: Range(TextLocation { line: 30, column: 17, offset: 1098 }..TextLocation { line: 30, column: 26, offset: 1107 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid assignment: cannot assign 'ARRAY[1..10] OF DINT' to 'ARRAY[0..1] OF DINT'", range: [SourceLocation { span: Range(TextLocation { line: 35, column: 17, offset: 1300 }..TextLocation { line: 35, column: 30, offset: 1313 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid assignment: cannot assign 'ARRAY[10..100] OF DINT' to 'ARRAY[0..1] OF DINT'", range: [SourceLocation { span: Range(TextLocation { line: 36, column: 17, offset: 1333 }..TextLocation { line: 36, column: 32, offset: 1348 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid assignment: cannot assign 'ARRAY[0..1] OF ARRAY[0..1] OF DINT' to 'ARRAY[0..1] OF DINT'", range: [SourceLocation { span: Range(TextLocation { line: 39, column: 17, offset: 1425 }..TextLocation { line: 39, column: 28, offset: 1436 }) }], err_no: var__invalid_assignment } +error: Invalid assignment: cannot assign 'ARRAY[0..1] OF SINT' to 'ARRAY[0..1] OF DINT' + ┌─ :26:18 + │ +26 │ func(arr_sint); + │ ^^^^^^^^ Invalid assignment: cannot assign 'ARRAY[0..1] OF SINT' to 'ARRAY[0..1] OF DINT' + +error: Invalid assignment: cannot assign 'ARRAY[0..1] OF INT' to 'ARRAY[0..1] OF DINT' + ┌─ :27:18 + │ +27 │ func(arr_int); + │ ^^^^^^^ Invalid assignment: cannot assign 'ARRAY[0..1] OF INT' to 'ARRAY[0..1] OF DINT' + +error: Invalid assignment: cannot assign 'ARRAY[0..1] OF LINT' to 'ARRAY[0..1] OF DINT' + ┌─ :29:18 + │ +29 │ func(arr_lint); + │ ^^^^^^^^ Invalid assignment: cannot assign 'ARRAY[0..1] OF LINT' to 'ARRAY[0..1] OF DINT' + +error: Invalid assignment: cannot assign 'ARRAY[0..1] OF REAL' to 'ARRAY[0..1] OF DINT' + ┌─ :30:18 + │ +30 │ func(arr_real); + │ ^^^^^^^^ Invalid assignment: cannot assign 'ARRAY[0..1] OF REAL' to 'ARRAY[0..1] OF DINT' + +error: Invalid assignment: cannot assign 'ARRAY[0..1] OF LREAL' to 'ARRAY[0..1] OF DINT' + ┌─ :31:18 + │ +31 │ func(arr_lreal); + │ ^^^^^^^^^ Invalid assignment: cannot assign 'ARRAY[0..1] OF LREAL' to 'ARRAY[0..1] OF DINT' + +error: Invalid assignment: cannot assign 'ARRAY[1..10] OF DINT' to 'ARRAY[0..1] OF DINT' + ┌─ :36:18 + │ +36 │ func(arr_dint_1_10); + │ ^^^^^^^^^^^^^ Invalid assignment: cannot assign 'ARRAY[1..10] OF DINT' to 'ARRAY[0..1] OF DINT' + +error: Invalid assignment: cannot assign 'ARRAY[10..100] OF DINT' to 'ARRAY[0..1] OF DINT' + ┌─ :37:18 + │ +37 │ func(arr_dint_10_100); + │ ^^^^^^^^^^^^^^^ Invalid assignment: cannot assign 'ARRAY[10..100] OF DINT' to 'ARRAY[0..1] OF DINT' + +error: Invalid assignment: cannot assign 'ARRAY[0..1] OF ARRAY[0..1] OF DINT' to 'ARRAY[0..1] OF DINT' + ┌─ :40:18 + │ +40 │ func(arr_dint_2d); + │ ^^^^^^^^^^^ Invalid assignment: cannot assign 'ARRAY[0..1] OF ARRAY[0..1] OF DINT' to 'ARRAY[0..1] OF DINT' + diff --git a/src/validation/tests/snapshots/rusty__validation__tests__statement_validation_tests__validate_call_by_ref.snap b/src/validation/tests/snapshots/rusty__validation__tests__statement_validation_tests__validate_call_by_ref.snap index 9cdfa1bffc..7f8e09746b 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__statement_validation_tests__validate_call_by_ref.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__statement_validation_tests__validate_call_by_ref.snap @@ -1,13 +1,53 @@ --- source: src/validation/tests/statement_validation_tests.rs -expression: res +expression: "&diagnostics" --- -SyntaxError { message: "Expected a reference for parameter byRefInOut because their type is InOut", range: [SourceLocation { span: Range(TextLocation { line: 22, column: 20, offset: 561 }..TextLocation { line: 22, column: 21, offset: 562 }) }], err_no: call__invalid_parameter_type } -SyntaxError { message: "Expected a reference for parameter byRefOutput because their type is Output", range: [SourceLocation { span: Range(TextLocation { line: 22, column: 23, offset: 564 }..TextLocation { line: 22, column: 24, offset: 565 }) }], err_no: call__invalid_parameter_type } -SyntaxError { message: "Expected a reference for parameter byRefInOut because their type is InOut", range: [SourceLocation { span: Range(TextLocation { line: 23, column: 20, offset: 588 }..TextLocation { line: 23, column: 21, offset: 589 }) }], err_no: call__invalid_parameter_type } -SyntaxError { message: "Expected a reference for parameter byRefOutput because their type is Output", range: [SourceLocation { span: Range(TextLocation { line: 24, column: 23, offset: 618 }..TextLocation { line: 24, column: 24, offset: 619 }) }], err_no: call__invalid_parameter_type } -SyntaxError { message: "Expected a reference for parameter byRefInOut because their type is InOut", range: [SourceLocation { span: Range(TextLocation { line: 26, column: 20, offset: 678 }..TextLocation { line: 26, column: 21, offset: 679 }) }], err_no: call__invalid_parameter_type } -SyntaxError { message: "Expected a reference for parameter byRefOutput because their type is Output", range: [SourceLocation { span: Range(TextLocation { line: 26, column: 23, offset: 681 }..TextLocation { line: 26, column: 24, offset: 682 }) }], err_no: call__invalid_parameter_type } -SyntaxError { message: "Expected a reference for parameter byRefInOut because their type is InOut", range: [SourceLocation { span: Range(TextLocation { line: 27, column: 20, offset: 705 }..TextLocation { line: 27, column: 21, offset: 706 }) }], err_no: call__invalid_parameter_type } -SyntaxError { message: "Expected a reference for parameter byRefOutput because their type is Output", range: [SourceLocation { span: Range(TextLocation { line: 28, column: 23, offset: 735 }..TextLocation { line: 28, column: 24, offset: 736 }) }], err_no: call__invalid_parameter_type } +error: Expected a reference for parameter byRefInOut because their type is InOut + ┌─ :23:21 + │ +23 │ func(1, 2, 3); + │ ^ Expected a reference for parameter byRefInOut because their type is InOut + +error: Expected a reference for parameter byRefOutput because their type is Output + ┌─ :23:24 + │ +23 │ func(1, 2, 3); + │ ^ Expected a reference for parameter byRefOutput because their type is Output + +error: Expected a reference for parameter byRefInOut because their type is InOut + ┌─ :24:21 + │ +24 │ func(1, 2, x); + │ ^ Expected a reference for parameter byRefInOut because their type is InOut + +error: Expected a reference for parameter byRefOutput because their type is Output + ┌─ :25:24 + │ +25 │ func(1, x, 3); + │ ^ Expected a reference for parameter byRefOutput because their type is Output + +error: Expected a reference for parameter byRefInOut because their type is InOut + ┌─ :27:21 + │ +27 │ func(x, 2, 3); + │ ^ Expected a reference for parameter byRefInOut because their type is InOut + +error: Expected a reference for parameter byRefOutput because their type is Output + ┌─ :27:24 + │ +27 │ func(x, 2, 3); + │ ^ Expected a reference for parameter byRefOutput because their type is Output + +error: Expected a reference for parameter byRefInOut because their type is InOut + ┌─ :28:21 + │ +28 │ func(x, 2, x); + │ ^ Expected a reference for parameter byRefInOut because their type is InOut + +error: Expected a reference for parameter byRefOutput because their type is Output + ┌─ :29:24 + │ +29 │ func(x, x, 3); + │ ^ Expected a reference for parameter byRefOutput because their type is Output + diff --git a/src/validation/tests/snapshots/rusty__validation__tests__statement_validation_tests__validate_call_by_ref_explicit.snap b/src/validation/tests/snapshots/rusty__validation__tests__statement_validation_tests__validate_call_by_ref_explicit.snap index 7c26fd053e..6f0e4acafc 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__statement_validation_tests__validate_call_by_ref_explicit.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__statement_validation_tests__validate_call_by_ref_explicit.snap @@ -1,10 +1,35 @@ --- source: src/validation/tests/statement_validation_tests.rs -expression: res +expression: "&diagnostics" --- -SyntaxError { message: "Expected a reference for parameter byRefInOut because their type is InOut", range: [SourceLocation { span: Range(TextLocation { line: 22, column: 48, offset: 589 }..TextLocation { line: 22, column: 49, offset: 590 }) }], err_no: call__invalid_parameter_type } -SyntaxError { message: "Expected a reference for parameter byRefInOut because their type is InOut", range: [SourceLocation { span: Range(TextLocation { line: 24, column: 48, offset: 772 }..TextLocation { line: 24, column: 49, offset: 773 }) }], err_no: call__invalid_parameter_type } -SyntaxError { message: "Expected a reference for parameter byRefOutput because their type is Output", range: [SourceLocation { span: Range(TextLocation { line: 24, column: 66, offset: 790 }..TextLocation { line: 24, column: 67, offset: 791 }) }], err_no: call__invalid_parameter_type } -SyntaxError { message: "Expected a reference for parameter byRefInOut because their type is InOut", range: [SourceLocation { span: Range(TextLocation { line: 25, column: 48, offset: 842 }..TextLocation { line: 25, column: 49, offset: 843 }) }], err_no: call__invalid_parameter_type } -SyntaxError { message: "Expected a reference for parameter byRefOutput because their type is Output", range: [SourceLocation { span: Range(TextLocation { line: 26, column: 66, offset: 930 }..TextLocation { line: 26, column: 67, offset: 931 }) }], err_no: call__invalid_parameter_type } +error: Expected a reference for parameter byRefInOut because their type is InOut + ┌─ :23:49 + │ +23 │ func(byValInput := 1, byRefInOut := 2, byRefOutput => ); + │ ^ Expected a reference for parameter byRefInOut because their type is InOut + +error: Expected a reference for parameter byRefInOut because their type is InOut + ┌─ :25:49 + │ +25 │ func(byValInput := 1, byRefInOut := 2, byRefOutput => 3); + │ ^ Expected a reference for parameter byRefInOut because their type is InOut + +error: Expected a reference for parameter byRefOutput because their type is Output + ┌─ :25:67 + │ +25 │ func(byValInput := 1, byRefInOut := 2, byRefOutput => 3); + │ ^ Expected a reference for parameter byRefOutput because their type is Output + +error: Expected a reference for parameter byRefInOut because their type is InOut + ┌─ :26:49 + │ +26 │ func(byValInput := 1, byRefInOut := 2, byRefOutput => x); + │ ^ Expected a reference for parameter byRefInOut because their type is InOut + +error: Expected a reference for parameter byRefOutput because their type is Output + ┌─ :27:67 + │ +27 │ func(byValInput := 1, byRefInOut := x, byRefOutput => 3); + │ ^ Expected a reference for parameter byRefOutput because their type is Output + diff --git a/src/validation/tests/snapshots/rusty__validation__tests__variable_length_array_test__access__variable_length_array_access.snap b/src/validation/tests/snapshots/rusty__validation__tests__variable_length_array_test__access__variable_length_array_access.snap index 99ef91d8b6..1da6db57f6 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__variable_length_array_test__access__variable_length_array_access.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__variable_length_array_test__access__variable_length_array_access.snap @@ -1,7 +1,17 @@ --- source: src/validation/tests/variable_length_array_test.rs -expression: res +expression: diagnostics --- -SemanticError { message: "Expected array access with 1 dimensions, found 2", range: [SourceLocation { span: Range(TextLocation { line: 7, column: 20, offset: 187 }..TextLocation { line: 7, column: 24, offset: 191 }) }], err_no: vla__invalid_array_access } -SyntaxError { message: "Invalid assignment: cannot assign 'ARRAY[0..5, 5..10] OF DINT' to 'ARRAY[*] OF DINT'", range: [SourceLocation { span: Range(TextLocation { line: 17, column: 19, offset: 514 }..TextLocation { line: 17, column: 26, offset: 521 }) }], err_no: var__invalid_assignment } +error: Expected array access with 1 dimensions, found 2 + ┌─ :8:21 + │ +8 │ arr[0, 0] := 1; // This should fail (arr is defined as a 1D array) + │ ^^^^ Expected array access with 1 dimensions, found 2 + +error: Invalid assignment: cannot assign 'ARRAY[0..5, 5..10] OF DINT' to 'ARRAY[*] OF DINT' + ┌─ :18:20 + │ +18 │ fn(local_b); // This call should fail, because we expect a 1D array + │ ^^^^^^^ Invalid assignment: cannot assign 'ARRAY[0..5, 5..10] OF DINT' to 'ARRAY[*] OF DINT' + diff --git a/src/validation/tests/snapshots/rusty__validation__tests__variable_length_array_test__access__variable_length_array_incompatible_datatypes.snap b/src/validation/tests/snapshots/rusty__validation__tests__variable_length_array_test__access__variable_length_array_incompatible_datatypes.snap index 16d09d6de1..5b550e9b96 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__variable_length_array_test__access__variable_length_array_incompatible_datatypes.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__variable_length_array_test__access__variable_length_array_incompatible_datatypes.snap @@ -1,8 +1,23 @@ --- source: src/validation/tests/variable_length_array_test.rs -expression: res +expression: diagnostics --- -SyntaxError { message: "Invalid assignment: cannot assign 'ARRAY[0..10] OF INT' to 'ARRAY[*] OF DINT'", range: [SourceLocation { span: Range(TextLocation { line: 14, column: 19, offset: 436 }..TextLocation { line: 14, column: 28, offset: 445 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid assignment: cannot assign 'ARRAY[0..10] OF REAL' to 'ARRAY[*] OF DINT'", range: [SourceLocation { span: Range(TextLocation { line: 15, column: 19, offset: 467 }..TextLocation { line: 15, column: 30, offset: 478 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid assignment: cannot assign 'ARRAY[0..10] OF STRING' to 'ARRAY[*] OF DINT'", range: [SourceLocation { span: Range(TextLocation { line: 16, column: 19, offset: 500 }..TextLocation { line: 16, column: 31, offset: 512 }) }], err_no: var__invalid_assignment } +error: Invalid assignment: cannot assign 'ARRAY[0..10] OF INT' to 'ARRAY[*] OF DINT' + ┌─ :15:20 + │ +15 │ fn(local_int); + │ ^^^^^^^^^ Invalid assignment: cannot assign 'ARRAY[0..10] OF INT' to 'ARRAY[*] OF DINT' + +error: Invalid assignment: cannot assign 'ARRAY[0..10] OF REAL' to 'ARRAY[*] OF DINT' + ┌─ :16:20 + │ +16 │ fn(local_float); + │ ^^^^^^^^^^^ Invalid assignment: cannot assign 'ARRAY[0..10] OF REAL' to 'ARRAY[*] OF DINT' + +error: Invalid assignment: cannot assign 'ARRAY[0..10] OF STRING' to 'ARRAY[*] OF DINT' + ┌─ :17:20 + │ +17 │ fn(local_string); + │ ^^^^^^^^^^^^ Invalid assignment: cannot assign 'ARRAY[0..10] OF STRING' to 'ARRAY[*] OF DINT' + diff --git a/src/validation/tests/snapshots/rusty__validation__tests__variable_length_array_test__assignment__function_calls.snap b/src/validation/tests/snapshots/rusty__validation__tests__variable_length_array_test__assignment__function_calls.snap index 6635324a26..42fc8669a0 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__variable_length_array_test__assignment__function_calls.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__variable_length_array_test__assignment__function_calls.snap @@ -1,7 +1,17 @@ --- source: src/validation/tests/variable_length_array_test.rs -expression: res +expression: diagnostics --- -SyntaxError { message: "Invalid assignment: cannot assign 'ARRAY[*] OF DINT' to 'ARRAY[0..10] OF DINT'", range: [SourceLocation { span: Range(TextLocation { line: 11, column: 16, offset: 267 }..TextLocation { line: 11, column: 26, offset: 277 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid assignment: cannot assign 'ARRAY[0..10] OF DINT' to 'ARRAY[*] OF DINT'", range: [SourceLocation { span: Range(TextLocation { line: 12, column: 16, offset: 295 }..TextLocation { line: 12, column: 24, offset: 303 }) }], err_no: var__invalid_assignment } +error: Invalid assignment: cannot assign 'ARRAY[*] OF DINT' to 'ARRAY[0..10] OF DINT' + ┌─ :12:17 + │ +12 │ a := vla; + │ ^^^^^^^^^^ Invalid assignment: cannot assign 'ARRAY[*] OF DINT' to 'ARRAY[0..10] OF DINT' + +error: Invalid assignment: cannot assign 'ARRAY[0..10] OF DINT' to 'ARRAY[*] OF DINT' + ┌─ :13:17 + │ +13 │ vla := a; + │ ^^^^^^^^ Invalid assignment: cannot assign 'ARRAY[0..10] OF DINT' to 'ARRAY[*] OF DINT' + diff --git a/src/validation/tests/snapshots/rusty__validation__tests__variable_length_array_test__builtins__builtins_called_with_invalid_index.snap b/src/validation/tests/snapshots/rusty__validation__tests__variable_length_array_test__builtins__builtins_called_with_invalid_index.snap index 9c07df33c6..612d36a31c 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__variable_length_array_test__builtins__builtins_called_with_invalid_index.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__variable_length_array_test__builtins__builtins_called_with_invalid_index.snap @@ -1,11 +1,41 @@ --- source: src/validation/tests/variable_length_array_test.rs -expression: res +expression: diagnostics --- -SyntaxError { message: "Invalid type nature for generic argument. REAL is no Int.", range: [SourceLocation { span: Range(TextLocation { line: 17, column: 29, offset: 361 }..TextLocation { line: 17, column: 35, offset: 367 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid type nature for generic argument. TIME is no Int.", range: [SourceLocation { span: Range(TextLocation { line: 18, column: 29, offset: 410 }..TextLocation { line: 18, column: 36, offset: 417 }) }], err_no: type__invalid_nature } -SemanticError { message: "Index out of bounds.", range: [SourceLocation { span: Range(TextLocation { line: 19, column: 12, offset: 443 }..TextLocation { line: 19, column: 23, offset: 454 }) }], err_no: vla__dimension_idx_out_of_bounds } -SyntaxError { message: "Invalid type nature for generic argument. REAL is no Int.", range: [SourceLocation { span: Range(TextLocation { line: 21, column: 29, offset: 517 }..TextLocation { line: 21, column: 35, offset: 523 }) }], err_no: type__invalid_nature } -SyntaxError { message: "Invalid type nature for generic argument. TIME is no Int.", range: [SourceLocation { span: Range(TextLocation { line: 22, column: 29, offset: 566 }..TextLocation { line: 22, column: 36, offset: 573 }) }], err_no: type__invalid_nature } -SemanticError { message: "Index out of bounds.", range: [SourceLocation { span: Range(TextLocation { line: 23, column: 12, offset: 599 }..TextLocation { line: 23, column: 23, offset: 610 }) }], err_no: vla__dimension_idx_out_of_bounds } +error: Invalid type nature for generic argument. REAL is no Int. + ┌─ :18:30 + │ +18 │ LOWER_BOUND(vla, 3.1415); // invalid + │ ^^^^^^ Invalid type nature for generic argument. REAL is no Int. + +error: Invalid type nature for generic argument. TIME is no Int. + ┌─ :19:30 + │ +19 │ LOWER_BOUND(vla, TIME#3s); // invalid + │ ^^^^^^^ Invalid type nature for generic argument. TIME is no Int. + +error: Index out of bounds. + ┌─ :20:13 + │ +20 │ LOWER_BOUND(vla, 0); // index out of bounds + │ ^^^^^^^^^^^ Index out of bounds. + +error: Invalid type nature for generic argument. REAL is no Int. + ┌─ :22:30 + │ +22 │ UPPER_BOUND(vla, 3.1415); // invalid + │ ^^^^^^ Invalid type nature for generic argument. REAL is no Int. + +error: Invalid type nature for generic argument. TIME is no Int. + ┌─ :23:30 + │ +23 │ UPPER_BOUND(vla, TIME#3s); // invalid + │ ^^^^^^^ Invalid type nature for generic argument. TIME is no Int. + +error: Index out of bounds. + ┌─ :24:13 + │ +24 │ UPPER_BOUND(vla, 0); // index out of bounds + │ ^^^^^^^^^^^ Index out of bounds. + diff --git a/src/validation/tests/snapshots/rusty__validation__tests__variable_length_array_test__builtins__builtins_called_with_invalid_number_of_params.snap b/src/validation/tests/snapshots/rusty__validation__tests__variable_length_array_test__builtins__builtins_called_with_invalid_number_of_params.snap index 08dd9eecc4..5f984fc46a 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__variable_length_array_test__builtins__builtins_called_with_invalid_number_of_params.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__variable_length_array_test__builtins__builtins_called_with_invalid_number_of_params.snap @@ -1,17 +1,77 @@ --- source: src/validation/tests/variable_length_array_test.rs -expression: res +expression: diagnostics --- -SyntaxError { message: "Invalid parameter count. Received 0 parameters while 2 parameters were expected.", range: [SourceLocation { span: Range(TextLocation { line: 12, column: 12, offset: 251 }..TextLocation { line: 12, column: 23, offset: 262 }) }], err_no: call__invalid_parameter_count } -SyntaxError { message: "Invalid parameter count. Received 1 parameters while 2 parameters were expected.", range: [SourceLocation { span: Range(TextLocation { line: 13, column: 12, offset: 278 }..TextLocation { line: 13, column: 23, offset: 289 }) }], err_no: call__invalid_parameter_count } -SyntaxError { message: "Invalid parameter count. Received 1 parameters while 2 parameters were expected.", range: [SourceLocation { span: Range(TextLocation { line: 14, column: 12, offset: 308 }..TextLocation { line: 14, column: 23, offset: 319 }) }], err_no: call__invalid_parameter_count } -SyntaxError { message: "Expected a reference for parameter arr because their type is InOut", range: [SourceLocation { span: Range(TextLocation { line: 14, column: 24, offset: 320 }..TextLocation { line: 14, column: 25, offset: 321 }) }], err_no: call__invalid_parameter_type } -SyntaxError { message: "Invalid assignment: cannot assign 'DINT' to 'VARIABLE LENGTH ARRAY'", range: [SourceLocation { span: Range(TextLocation { line: 14, column: 24, offset: 320 }..TextLocation { line: 14, column: 25, offset: 321 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid parameter count. Received 4 parameters while 2 parameters were expected.", range: [SourceLocation { span: Range(TextLocation { line: 15, column: 12, offset: 336 }..TextLocation { line: 15, column: 23, offset: 347 }) }], err_no: call__invalid_parameter_count } -SyntaxError { message: "Invalid parameter count. Received 0 parameters while 2 parameters were expected.", range: [SourceLocation { span: Range(TextLocation { line: 17, column: 12, offset: 376 }..TextLocation { line: 17, column: 23, offset: 387 }) }], err_no: call__invalid_parameter_count } -SyntaxError { message: "Invalid parameter count. Received 1 parameters while 2 parameters were expected.", range: [SourceLocation { span: Range(TextLocation { line: 18, column: 12, offset: 403 }..TextLocation { line: 18, column: 23, offset: 414 }) }], err_no: call__invalid_parameter_count } -SyntaxError { message: "Invalid parameter count. Received 1 parameters while 2 parameters were expected.", range: [SourceLocation { span: Range(TextLocation { line: 19, column: 12, offset: 433 }..TextLocation { line: 19, column: 23, offset: 444 }) }], err_no: call__invalid_parameter_count } -SyntaxError { message: "Expected a reference for parameter arr because their type is InOut", range: [SourceLocation { span: Range(TextLocation { line: 19, column: 24, offset: 445 }..TextLocation { line: 19, column: 25, offset: 446 }) }], err_no: call__invalid_parameter_type } -SyntaxError { message: "Invalid assignment: cannot assign 'DINT' to 'VARIABLE LENGTH ARRAY'", range: [SourceLocation { span: Range(TextLocation { line: 19, column: 24, offset: 445 }..TextLocation { line: 19, column: 25, offset: 446 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid parameter count. Received 4 parameters while 2 parameters were expected.", range: [SourceLocation { span: Range(TextLocation { line: 20, column: 12, offset: 461 }..TextLocation { line: 20, column: 23, offset: 472 }) }], err_no: call__invalid_parameter_count } +error: Invalid parameter count. Received 0 parameters while 2 parameters were expected. + ┌─ :13:13 + │ +13 │ LOWER_BOUND(); + │ ^^^^^^^^^^^ Invalid parameter count. Received 0 parameters while 2 parameters were expected. + +error: Invalid parameter count. Received 1 parameters while 2 parameters were expected. + ┌─ :14:13 + │ +14 │ LOWER_BOUND(vla); + │ ^^^^^^^^^^^ Invalid parameter count. Received 1 parameters while 2 parameters were expected. + +error: Invalid parameter count. Received 1 parameters while 2 parameters were expected. + ┌─ :15:13 + │ +15 │ LOWER_BOUND(1); + │ ^^^^^^^^^^^ Invalid parameter count. Received 1 parameters while 2 parameters were expected. + +error: Expected a reference for parameter arr because their type is InOut + ┌─ :15:25 + │ +15 │ LOWER_BOUND(1); + │ ^ Expected a reference for parameter arr because their type is InOut + +error: Invalid assignment: cannot assign 'DINT' to 'VARIABLE LENGTH ARRAY' + ┌─ :15:25 + │ +15 │ LOWER_BOUND(1); + │ ^ Invalid assignment: cannot assign 'DINT' to 'VARIABLE LENGTH ARRAY' + +error: Invalid parameter count. Received 4 parameters while 2 parameters were expected. + ┌─ :16:13 + │ +16 │ LOWER_BOUND(vla, 1, 2, 3); + │ ^^^^^^^^^^^ Invalid parameter count. Received 4 parameters while 2 parameters were expected. + +error: Invalid parameter count. Received 0 parameters while 2 parameters were expected. + ┌─ :18:13 + │ +18 │ UPPER_BOUND(); + │ ^^^^^^^^^^^ Invalid parameter count. Received 0 parameters while 2 parameters were expected. + +error: Invalid parameter count. Received 1 parameters while 2 parameters were expected. + ┌─ :19:13 + │ +19 │ UPPER_BOUND(vla); + │ ^^^^^^^^^^^ Invalid parameter count. Received 1 parameters while 2 parameters were expected. + +error: Invalid parameter count. Received 1 parameters while 2 parameters were expected. + ┌─ :20:13 + │ +20 │ UPPER_BOUND(1); + │ ^^^^^^^^^^^ Invalid parameter count. Received 1 parameters while 2 parameters were expected. + +error: Expected a reference for parameter arr because their type is InOut + ┌─ :20:25 + │ +20 │ UPPER_BOUND(1); + │ ^ Expected a reference for parameter arr because their type is InOut + +error: Invalid assignment: cannot assign 'DINT' to 'VARIABLE LENGTH ARRAY' + ┌─ :20:25 + │ +20 │ UPPER_BOUND(1); + │ ^ Invalid assignment: cannot assign 'DINT' to 'VARIABLE LENGTH ARRAY' + +error: Invalid parameter count. Received 4 parameters while 2 parameters were expected. + ┌─ :21:13 + │ +21 │ UPPER_BOUND(vla, 1, 2, 3); + │ ^^^^^^^^^^^ Invalid parameter count. Received 4 parameters while 2 parameters were expected. + diff --git a/src/validation/tests/snapshots/rusty__validation__tests__variable_length_array_test__builtins__builtins_called_with_invalid_type.snap b/src/validation/tests/snapshots/rusty__validation__tests__variable_length_array_test__builtins__builtins_called_with_invalid_type.snap index b1cabf23fc..b4e8617331 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__variable_length_array_test__builtins__builtins_called_with_invalid_type.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__variable_length_array_test__builtins__builtins_called_with_invalid_type.snap @@ -1,13 +1,53 @@ --- source: src/validation/tests/variable_length_array_test.rs -expression: res +expression: diagnostics --- -SyntaxError { message: "Invalid assignment: cannot assign 'ARRAY[0..1] OF DINT' to 'VARIABLE LENGTH ARRAY'", range: [SourceLocation { span: Range(TextLocation { line: 9, column: 24, offset: 221 }..TextLocation { line: 9, column: 27, offset: 224 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid assignment: cannot assign 'TIME' to 'VARIABLE LENGTH ARRAY'", range: [SourceLocation { span: Range(TextLocation { line: 10, column: 24, offset: 265 }..TextLocation { line: 10, column: 32, offset: 273 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Expected a reference for parameter arr because their type is InOut", range: [SourceLocation { span: Range(TextLocation { line: 11, column: 24, offset: 303 }..TextLocation { line: 11, column: 39, offset: 318 }) }], err_no: call__invalid_parameter_type } -SyntaxError { message: "Invalid assignment: cannot assign 'STRING' to 'VARIABLE LENGTH ARRAY'", range: [SourceLocation { span: Range(TextLocation { line: 11, column: 24, offset: 303 }..TextLocation { line: 11, column: 39, offset: 318 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid assignment: cannot assign 'ARRAY[0..1] OF DINT' to 'VARIABLE LENGTH ARRAY'", range: [SourceLocation { span: Range(TextLocation { line: 13, column: 24, offset: 349 }..TextLocation { line: 13, column: 27, offset: 352 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Invalid assignment: cannot assign 'TIME' to 'VARIABLE LENGTH ARRAY'", range: [SourceLocation { span: Range(TextLocation { line: 14, column: 24, offset: 393 }..TextLocation { line: 14, column: 32, offset: 401 }) }], err_no: var__invalid_assignment } -SyntaxError { message: "Expected a reference for parameter arr because their type is InOut", range: [SourceLocation { span: Range(TextLocation { line: 15, column: 24, offset: 431 }..TextLocation { line: 15, column: 39, offset: 446 }) }], err_no: call__invalid_parameter_type } -SyntaxError { message: "Invalid assignment: cannot assign 'STRING' to 'VARIABLE LENGTH ARRAY'", range: [SourceLocation { span: Range(TextLocation { line: 15, column: 24, offset: 431 }..TextLocation { line: 15, column: 39, offset: 446 }) }], err_no: var__invalid_assignment } +error: Invalid assignment: cannot assign 'ARRAY[0..1] OF DINT' to 'VARIABLE LENGTH ARRAY' + ┌─ :10:25 + │ +10 │ LOWER_BOUND(arr, MY_CONST + 1); + │ ^^^ Invalid assignment: cannot assign 'ARRAY[0..1] OF DINT' to 'VARIABLE LENGTH ARRAY' + +error: Invalid assignment: cannot assign 'TIME' to 'VARIABLE LENGTH ARRAY' + ┌─ :11:25 + │ +11 │ LOWER_BOUND(duration, 1); + │ ^^^^^^^^ Invalid assignment: cannot assign 'TIME' to 'VARIABLE LENGTH ARRAY' + +error: Expected a reference for parameter arr because their type is InOut + ┌─ :12:25 + │ +12 │ LOWER_BOUND('i am a string', 1); + │ ^^^^^^^^^^^^^^^ Expected a reference for parameter arr because their type is InOut + +error: Invalid assignment: cannot assign 'STRING' to 'VARIABLE LENGTH ARRAY' + ┌─ :12:25 + │ +12 │ LOWER_BOUND('i am a string', 1); + │ ^^^^^^^^^^^^^^^ Invalid assignment: cannot assign 'STRING' to 'VARIABLE LENGTH ARRAY' + +error: Invalid assignment: cannot assign 'ARRAY[0..1] OF DINT' to 'VARIABLE LENGTH ARRAY' + ┌─ :14:25 + │ +14 │ UPPER_BOUND(arr, MY_CONST + 1); + │ ^^^ Invalid assignment: cannot assign 'ARRAY[0..1] OF DINT' to 'VARIABLE LENGTH ARRAY' + +error: Invalid assignment: cannot assign 'TIME' to 'VARIABLE LENGTH ARRAY' + ┌─ :15:25 + │ +15 │ UPPER_BOUND(duration, 1); + │ ^^^^^^^^ Invalid assignment: cannot assign 'TIME' to 'VARIABLE LENGTH ARRAY' + +error: Expected a reference for parameter arr because their type is InOut + ┌─ :16:25 + │ +16 │ UPPER_BOUND('i am a string', 1); + │ ^^^^^^^^^^^^^^^ Expected a reference for parameter arr because their type is InOut + +error: Invalid assignment: cannot assign 'STRING' to 'VARIABLE LENGTH ARRAY' + ┌─ :16:25 + │ +16 │ UPPER_BOUND('i am a string', 1); + │ ^^^^^^^^^^^^^^^ Invalid assignment: cannot assign 'STRING' to 'VARIABLE LENGTH ARRAY' + diff --git a/src/validation/tests/snapshots/rusty__validation__tests__variable_length_array_test__functions__variable_length_array_function_input.snap b/src/validation/tests/snapshots/rusty__validation__tests__variable_length_array_test__functions__variable_length_array_function_input.snap index d9fb5bd88a..5b451a2e83 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__variable_length_array_test__functions__variable_length_array_function_input.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__variable_length_array_test__functions__variable_length_array_function_input.snap @@ -1,6 +1,11 @@ --- source: src/validation/tests/variable_length_array_test.rs -expression: res +expression: "parse_and_validate_buffered(&function.replace(\"\", \"INPUT\"))" --- -ImprovementSuggestion { message: "Variable Length Arrays are always by-ref, even when declared in a by-value block", range: [SourceLocation { span: Range(TextLocation { line: 3, column: 12, offset: 54 }..TextLocation { line: 3, column: 15, offset: 57 }) }] } +warning: Variable Length Arrays are always by-ref, even when declared in a by-value block + ┌─ :4:13 + │ +4 │ arr : ARRAY[*] OF DINT; + │ ^^^ Variable Length Arrays are always by-ref, even when declared in a by-value block + diff --git a/src/validation/tests/snapshots/rusty__validation__tests__variable_length_array_test__naming__global_vla_does_not_cause_name_conflict.snap b/src/validation/tests/snapshots/rusty__validation__tests__variable_length_array_test__naming__global_vla_does_not_cause_name_conflict.snap index d32c04e418..628abf8acb 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__variable_length_array_test__naming__global_vla_does_not_cause_name_conflict.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__variable_length_array_test__naming__global_vla_does_not_cause_name_conflict.snap @@ -1,6 +1,11 @@ --- source: src/validation/tests/variable_length_array_test.rs -expression: res +expression: diag --- -SemanticError { message: "VLAs can not be defined as global variables", range: [SourceLocation { span: Range(TextLocation { line: 2, column: 12, offset: 32 }..TextLocation { line: 2, column: 15, offset: 35 }) }], err_no: vla__invalid_container } +error: VLAs can not be defined as global variables + ┌─ :3:13 + │ +3 │ vla : ARRAY[*, *] OF DINT; + │ ^^^ VLAs can not be defined as global variables + diff --git a/src/validation/tests/snapshots/rusty__validation__tests__variable_length_array_test__program__variable_length_array_program_inout.snap b/src/validation/tests/snapshots/rusty__validation__tests__variable_length_array_test__program__variable_length_array_program_inout.snap index 32b5d3acf7..9bd258d08f 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__variable_length_array_test__program__variable_length_array_program_inout.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__variable_length_array_test__program__variable_length_array_program_inout.snap @@ -1,7 +1,17 @@ --- source: src/validation/tests/variable_length_array_test.rs -expression: res +expression: program_inout --- -SyntaxError { message: "POU Type Program does not support a return type. Did you mean Function?", range: [SourceLocation { span: Range(TextLocation { line: 1, column: 15, offset: 16 }..TextLocation { line: 1, column: 21, offset: 22 }) }], err_no: pou__unexpected_return_type } -SemanticError { message: "Variable Length Arrays are not allowed to be defined inside a Program", range: [SourceLocation { span: Range(TextLocation { line: 3, column: 12, offset: 54 }..TextLocation { line: 3, column: 15, offset: 57 }) }], err_no: vla__invalid_container } +error: POU Type Program does not support a return type. Did you mean Function? + ┌─ :2:16 + │ +2 │ PROGRAM fn : DINT + │ ^^^^^^ POU Type Program does not support a return type. Did you mean Function? + +error: Variable Length Arrays are not allowed to be defined inside a Program + ┌─ :4:13 + │ +4 │ arr : ARRAY[*] OF DINT; + │ ^^^ Variable Length Arrays are not allowed to be defined inside a Program + diff --git a/src/validation/tests/snapshots/rusty__validation__tests__variable_length_array_test__program__variable_length_array_program_input.snap b/src/validation/tests/snapshots/rusty__validation__tests__variable_length_array_test__program__variable_length_array_program_input.snap index 8cbec4d213..f75d5342c1 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__variable_length_array_test__program__variable_length_array_program_input.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__variable_length_array_test__program__variable_length_array_program_input.snap @@ -1,7 +1,17 @@ --- source: src/validation/tests/variable_length_array_test.rs -expression: res +expression: program_input --- -SyntaxError { message: "POU Type Program does not support a return type. Did you mean Function?", range: [SourceLocation { span: Range(TextLocation { line: 1, column: 15, offset: 16 }..TextLocation { line: 1, column: 21, offset: 22 }) }], err_no: pou__unexpected_return_type } -SemanticError { message: "Variable Length Arrays are not allowed to be defined inside a Program", range: [SourceLocation { span: Range(TextLocation { line: 3, column: 12, offset: 53 }..TextLocation { line: 3, column: 15, offset: 56 }) }], err_no: vla__invalid_container } +error: POU Type Program does not support a return type. Did you mean Function? + ┌─ :2:16 + │ +2 │ PROGRAM fn : DINT + │ ^^^^^^ POU Type Program does not support a return type. Did you mean Function? + +error: Variable Length Arrays are not allowed to be defined inside a Program + ┌─ :4:13 + │ +4 │ arr : ARRAY[*] OF DINT; + │ ^^^ Variable Length Arrays are not allowed to be defined inside a Program + diff --git a/src/validation/tests/snapshots/rusty__validation__tests__variable_length_array_test__program__variable_length_array_program_input_ref.snap b/src/validation/tests/snapshots/rusty__validation__tests__variable_length_array_test__program__variable_length_array_program_input_ref.snap index aab2d14936..f75d5342c1 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__variable_length_array_test__program__variable_length_array_program_input_ref.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__variable_length_array_test__program__variable_length_array_program_input_ref.snap @@ -1,7 +1,17 @@ --- source: src/validation/tests/variable_length_array_test.rs -expression: res +expression: program_input --- -SyntaxError { message: "POU Type Program does not support a return type. Did you mean Function?", range: [SourceLocation { span: Range(TextLocation { line: 1, column: 15, offset: 16 }..TextLocation { line: 1, column: 21, offset: 22 }) }], err_no: pou__unexpected_return_type } -SemanticError { message: "Variable Length Arrays are not allowed to be defined inside a Program", range: [SourceLocation { span: Range(TextLocation { line: 3, column: 12, offset: 59 }..TextLocation { line: 3, column: 15, offset: 62 }) }], err_no: vla__invalid_container } +error: POU Type Program does not support a return type. Did you mean Function? + ┌─ :2:16 + │ +2 │ PROGRAM fn : DINT + │ ^^^^^^ POU Type Program does not support a return type. Did you mean Function? + +error: Variable Length Arrays are not allowed to be defined inside a Program + ┌─ :4:13 + │ +4 │ arr : ARRAY[*] OF DINT; + │ ^^^ Variable Length Arrays are not allowed to be defined inside a Program + diff --git a/src/validation/tests/snapshots/rusty__validation__tests__variable_length_array_test__program__variable_length_array_program_output.snap b/src/validation/tests/snapshots/rusty__validation__tests__variable_length_array_test__program__variable_length_array_program_output.snap index 32b5d3acf7..1dbca1d309 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__variable_length_array_test__program__variable_length_array_program_output.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__variable_length_array_test__program__variable_length_array_program_output.snap @@ -1,7 +1,17 @@ --- source: src/validation/tests/variable_length_array_test.rs -expression: res +expression: program_output --- -SyntaxError { message: "POU Type Program does not support a return type. Did you mean Function?", range: [SourceLocation { span: Range(TextLocation { line: 1, column: 15, offset: 16 }..TextLocation { line: 1, column: 21, offset: 22 }) }], err_no: pou__unexpected_return_type } -SemanticError { message: "Variable Length Arrays are not allowed to be defined inside a Program", range: [SourceLocation { span: Range(TextLocation { line: 3, column: 12, offset: 54 }..TextLocation { line: 3, column: 15, offset: 57 }) }], err_no: vla__invalid_container } +error: POU Type Program does not support a return type. Did you mean Function? + ┌─ :2:16 + │ +2 │ PROGRAM fn : DINT + │ ^^^^^^ POU Type Program does not support a return type. Did you mean Function? + +error: Variable Length Arrays are not allowed to be defined inside a Program + ┌─ :4:13 + │ +4 │ arr : ARRAY[*] OF DINT; + │ ^^^ Variable Length Arrays are not allowed to be defined inside a Program + diff --git a/src/validation/tests/snapshots/rusty__validation__tests__variable_length_array_test__variable_length_array_defined_as_a_global_variable.snap b/src/validation/tests/snapshots/rusty__validation__tests__variable_length_array_test__variable_length_array_defined_as_a_global_variable.snap index d32c04e418..0c773fa5a6 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__variable_length_array_test__variable_length_array_defined_as_a_global_variable.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__variable_length_array_test__variable_length_array_defined_as_a_global_variable.snap @@ -1,6 +1,11 @@ --- source: src/validation/tests/variable_length_array_test.rs -expression: res +expression: parse_and_validate_buffered(src) --- -SemanticError { message: "VLAs can not be defined as global variables", range: [SourceLocation { span: Range(TextLocation { line: 2, column: 12, offset: 32 }..TextLocation { line: 2, column: 15, offset: 35 }) }], err_no: vla__invalid_container } +error: VLAs can not be defined as global variables + ┌─ :3:13 + │ +3 │ arr : ARRAY[*] OF DINT; + │ ^^^ VLAs can not be defined as global variables + diff --git a/src/validation/tests/snapshots/rusty__validation__tests__variable_validation_tests__constant_fb_instances_are_illegal.snap b/src/validation/tests/snapshots/rusty__validation__tests__variable_validation_tests__constant_fb_instances_are_illegal.snap index 711eb41551..1226c5e237 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__variable_validation_tests__constant_fb_instances_are_illegal.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__variable_validation_tests__constant_fb_instances_are_illegal.snap @@ -1,7 +1,17 @@ --- source: src/validation/tests/variable_validation_tests.rs -expression: res +expression: "&diagnostics" --- -SyntaxError { message: "Invalid constant y - Functionblock- and Class-instances cannot be delcared constant", range: [SourceLocation { span: Range(TextLocation { line: 14, column: 12, offset: 319 }..TextLocation { line: 14, column: 13, offset: 320 }) }], err_no: var__invalid_constant } -SyntaxError { message: "Invalid constant z - Functionblock- and Class-instances cannot be delcared constant", range: [SourceLocation { span: Range(TextLocation { line: 15, column: 12, offset: 341 }..TextLocation { line: 15, column: 13, offset: 342 }) }], err_no: var__invalid_constant } +error: Invalid constant y - Functionblock- and Class-instances cannot be delcared constant + ┌─ :15:13 + │ +15 │ y : MyFb; + │ ^ Invalid constant y - Functionblock- and Class-instances cannot be delcared constant + +error: Invalid constant z - Functionblock- and Class-instances cannot be delcared constant + ┌─ :16:13 + │ +16 │ z : cls; + │ ^ Invalid constant z - Functionblock- and Class-instances cannot be delcared constant + diff --git a/src/validation/tests/snapshots/rusty__validation__tests__variable_validation_tests__constant_on_illegal_var_blocks_cause_validation_issue.snap b/src/validation/tests/snapshots/rusty__validation__tests__variable_validation_tests__constant_on_illegal_var_blocks_cause_validation_issue.snap index 18984668ed..7fd5852236 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__variable_validation_tests__constant_on_illegal_var_blocks_cause_validation_issue.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__variable_validation_tests__constant_on_illegal_var_blocks_cause_validation_issue.snap @@ -1,11 +1,41 @@ --- source: src/validation/tests/variable_validation_tests.rs -expression: res +expression: "&diagnostics" --- -SyntaxError { message: "This variable block does not support the CONSTANT modifier", range: [SourceLocation { span: Range(TextLocation { line: 5, column: 12, offset: 83 }..TextLocation { line: 5, column: 21, offset: 92 }) }], err_no: var__invalid_constant_block } -SyntaxError { message: "This variable block does not support the CONSTANT modifier", range: [SourceLocation { span: Range(TextLocation { line: 8, column: 12, offset: 145 }..TextLocation { line: 8, column: 22, offset: 155 }) }], err_no: var__invalid_constant_block } -SyntaxError { message: "This variable block does not support the CONSTANT modifier", range: [SourceLocation { span: Range(TextLocation { line: 11, column: 12, offset: 208 }..TextLocation { line: 11, column: 22, offset: 218 }) }], err_no: var__invalid_constant_block } -SyntaxError { message: "This variable block does not support the CONSTANT modifier", range: [SourceLocation { span: Range(TextLocation { line: 24, column: 16, offset: 447 }..TextLocation { line: 24, column: 25, offset: 456 }) }], err_no: var__invalid_constant_block } -SyntaxError { message: "This variable block does not support the CONSTANT modifier", range: [SourceLocation { span: Range(TextLocation { line: 27, column: 16, offset: 517 }..TextLocation { line: 27, column: 26, offset: 527 }) }], err_no: var__invalid_constant_block } -SyntaxError { message: "This variable block does not support the CONSTANT modifier", range: [SourceLocation { span: Range(TextLocation { line: 30, column: 16, offset: 588 }..TextLocation { line: 30, column: 26, offset: 598 }) }], err_no: var__invalid_constant_block } +error: This variable block does not support the CONSTANT modifier + ┌─ :6:13 + │ +6 │ VAR_INPUT CONSTANT //illegal + │ ^^^^^^^^^ This variable block does not support the CONSTANT modifier + +error: This variable block does not support the CONSTANT modifier + ┌─ :9:13 + │ +9 │ VAR_OUTPUT CONSTANT //illegal + │ ^^^^^^^^^^ This variable block does not support the CONSTANT modifier + +error: This variable block does not support the CONSTANT modifier + ┌─ :12:13 + │ +12 │ VAR_IN_OUT CONSTANT //illegal + │ ^^^^^^^^^^ This variable block does not support the CONSTANT modifier + +error: This variable block does not support the CONSTANT modifier + ┌─ :25:17 + │ +25 │ VAR_INPUT CONSTANT //illegal + │ ^^^^^^^^^ This variable block does not support the CONSTANT modifier + +error: This variable block does not support the CONSTANT modifier + ┌─ :28:17 + │ +28 │ VAR_OUTPUT CONSTANT //illegal + │ ^^^^^^^^^^ This variable block does not support the CONSTANT modifier + +error: This variable block does not support the CONSTANT modifier + ┌─ :31:17 + │ +31 │ VAR_IN_OUT CONSTANT //illegal + │ ^^^^^^^^^^ This variable block does not support the CONSTANT modifier + diff --git a/src/validation/tests/snapshots/rusty__validation__tests__variable_validation_tests__overflows__overflows_with_aliases.snap b/src/validation/tests/snapshots/rusty__validation__tests__variable_validation_tests__overflows__overflows_with_aliases.snap index 7178e99097..ff7e700c1a 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__variable_validation_tests__overflows__overflows_with_aliases.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__variable_validation_tests__overflows__overflows_with_aliases.snap @@ -1,8 +1,23 @@ --- source: src/validation/tests/variable_validation_tests.rs -expression: res +expression: diagnostics --- -SemanticError { message: "This will overflow for type INT", range: [SourceLocation { span: Range(TextLocation { line: 1, column: 35, offset: 36 }..TextLocation { line: 1, column: 40, offset: 41 }) }], err_no: var__overflow } -SemanticError { message: "This will overflow for type REAL", range: [SourceLocation { span: Range(TextLocation { line: 2, column: 35, offset: 87 }..TextLocation { line: 2, column: 49, offset: 101 }) }], err_no: var__overflow } -SemanticError { message: "This will overflow for type LREAL", range: [SourceLocation { span: Range(TextLocation { line: 3, column: 35, offset: 147 }..TextLocation { line: 3, column: 58, offset: 170 }) }], err_no: var__overflow } +error: This will overflow for type INT + ┌─ :2:36 + │ +2 │ TYPE MyINT : INT := 60000; END_TYPE + │ ^^^^^ This will overflow for type INT + +error: This will overflow for type REAL + ┌─ :3:36 + │ +3 │ TYPE MyREAL : REAL := 3.50282347E+38; END_TYPE + │ ^^^^^^^^^^^^^^ This will overflow for type REAL + +error: This will overflow for type LREAL + ┌─ :4:36 + │ +4 │ TYPE MyLREAL : LREAL := 1.8076931348623157E+308; END_TYPE + │ ^^^^^^^^^^^^^^^^^^^^^^^ This will overflow for type LREAL + diff --git a/src/validation/tests/snapshots/rusty__validation__tests__variable_validation_tests__overflows__overflows_with_array_initializer.snap b/src/validation/tests/snapshots/rusty__validation__tests__variable_validation_tests__overflows__overflows_with_array_initializer.snap index a3379fb0a5..c8bf4d92c2 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__variable_validation_tests__overflows__overflows_with_array_initializer.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__variable_validation_tests__overflows__overflows_with_array_initializer.snap @@ -1,6 +1,11 @@ --- source: src/validation/tests/variable_validation_tests.rs -expression: res +expression: diagnostics --- -SemanticError { message: "This will overflow for type UINT", range: [SourceLocation { span: Range(TextLocation { line: 2, column: 45, offset: 65 }..TextLocation { line: 2, column: 47, offset: 67 }) }], err_no: var__overflow } +error: This will overflow for type UINT + ┌─ :3:46 + │ +3 │ arr : ARRAY[0..5] OF UINT := [0, -1, -2, -3, -4, -5]; + │ ^^ This will overflow for type UINT + diff --git a/src/validation/tests/snapshots/rusty__validation__tests__variable_validation_tests__overflows__overflows_with_constants.snap b/src/validation/tests/snapshots/rusty__validation__tests__variable_validation_tests__overflows__overflows_with_constants.snap index 0ec46ac78b..5bf1340851 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__variable_validation_tests__overflows__overflows_with_constants.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__variable_validation_tests__overflows__overflows_with_constants.snap @@ -1,6 +1,13 @@ --- source: src/validation/tests/variable_validation_tests.rs -expression: res +expression: diagnostics --- -SemanticError { message: "This will overflow for type INT", range: [SourceLocation { span: Range(TextLocation { line: 2, column: 23, offset: 52 }..TextLocation { line: 3, column: 28, offset: 93 }) }], err_no: var__overflow } +error: This will overflow for type INT + ┌─ :3:24 + │ +3 │ a : INT := 16384; // OK + │ ╭────────────────────────^ +4 │ │ b : INT := 16384; // OK + │ ╰────────────────────────────^ This will overflow for type INT + diff --git a/src/validation/tests/snapshots/rusty__validation__tests__variable_validation_tests__overflows__overflows_with_expressions.snap b/src/validation/tests/snapshots/rusty__validation__tests__variable_validation_tests__overflows__overflows_with_expressions.snap index 48a96000eb..1e07e18ae3 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__variable_validation_tests__overflows__overflows_with_expressions.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__variable_validation_tests__overflows__overflows_with_expressions.snap @@ -1,25 +1,125 @@ --- source: src/validation/tests/variable_validation_tests.rs -expression: res +expression: diagnostics --- -SemanticError { message: "This will overflow for type SINT", range: [SourceLocation { span: Range(TextLocation { line: 4, column: 41, offset: 108 }..TextLocation { line: 4, column: 54, offset: 121 }) }], err_no: var__overflow } -SemanticError { message: "This will overflow for type SINT", range: [SourceLocation { span: Range(TextLocation { line: 5, column: 42, offset: 177 }..TextLocation { line: 5, column: 54, offset: 189 }) }], err_no: var__overflow } -SemanticError { message: "This will overflow for type USINT", range: [SourceLocation { span: Range(TextLocation { line: 6, column: 42, offset: 245 }..TextLocation { line: 6, column: 53, offset: 256 }) }], err_no: var__overflow } -SemanticError { message: "This will overflow for type USINT", range: [SourceLocation { span: Range(TextLocation { line: 7, column: 42, offset: 310 }..TextLocation { line: 7, column: 54, offset: 322 }) }], err_no: var__overflow } -SemanticError { message: "This will overflow for type INT", range: [SourceLocation { span: Range(TextLocation { line: 10, column: 40, offset: 398 }..TextLocation { line: 10, column: 56, offset: 414 }) }], err_no: var__overflow } -SemanticError { message: "This will overflow for type INT", range: [SourceLocation { span: Range(TextLocation { line: 11, column: 41, offset: 470 }..TextLocation { line: 11, column: 56, offset: 485 }) }], err_no: var__overflow } -SemanticError { message: "This will overflow for type UINT", range: [SourceLocation { span: Range(TextLocation { line: 12, column: 41, offset: 541 }..TextLocation { line: 12, column: 52, offset: 552 }) }], err_no: var__overflow } -SemanticError { message: "This will overflow for type UINT", range: [SourceLocation { span: Range(TextLocation { line: 13, column: 41, offset: 606 }..TextLocation { line: 13, column: 56, offset: 621 }) }], err_no: var__overflow } -SemanticError { message: "This will overflow for type DINT", range: [SourceLocation { span: Range(TextLocation { line: 16, column: 41, offset: 698 }..TextLocation { line: 16, column: 64, offset: 721 }) }], err_no: var__overflow } -SemanticError { message: "This will overflow for type DINT", range: [SourceLocation { span: Range(TextLocation { line: 17, column: 42, offset: 785 }..TextLocation { line: 17, column: 64, offset: 807 }) }], err_no: var__overflow } -SemanticError { message: "This will overflow for type UDINT", range: [SourceLocation { span: Range(TextLocation { line: 18, column: 42, offset: 871 }..TextLocation { line: 18, column: 53, offset: 882 }) }], err_no: var__overflow } -SemanticError { message: "This will overflow for type UDINT", range: [SourceLocation { span: Range(TextLocation { line: 19, column: 42, offset: 944 }..TextLocation { line: 19, column: 64, offset: 966 }) }], err_no: var__overflow } -SemanticError { message: "This will overflow for type LINT", range: [SourceLocation { span: Range(TextLocation { line: 22, column: 41, offset: 1051 }..TextLocation { line: 22, column: 76, offset: 1086 }) }], err_no: var__overflow } -SemanticError { message: "This will overflow for type LINT", range: [SourceLocation { span: Range(TextLocation { line: 23, column: 42, offset: 1162 }..TextLocation { line: 23, column: 76, offset: 1196 }) }], err_no: var__overflow } -SemanticError { message: "This will overflow for type ULINT", range: [SourceLocation { span: Range(TextLocation { line: 24, column: 42, offset: 1272 }..TextLocation { line: 24, column: 53, offset: 1283 }) }], err_no: var__overflow } -SemanticError { message: "This will overflow for type ULINT", range: [SourceLocation { span: Range(TextLocation { line: 25, column: 42, offset: 1357 }..TextLocation { line: 25, column: 77, offset: 1392 }) }], err_no: var__overflow } -SemanticError { message: "This will overflow for type REAL", range: [SourceLocation { span: Range(TextLocation { line: 28, column: 38, offset: 1487 }..TextLocation { line: 28, column: 61, offset: 1510 }) }], err_no: var__overflow } -SemanticError { message: "This will overflow for type REAL", range: [SourceLocation { span: Range(TextLocation { line: 29, column: 38, offset: 1570 }..TextLocation { line: 29, column: 61, offset: 1593 }) }], err_no: var__overflow } -SemanticError { message: "This will overflow for type LREAL", range: [SourceLocation { span: Range(TextLocation { line: 32, column: 40, offset: 1679 }..TextLocation { line: 32, column: 72, offset: 1711 }) }], err_no: var__overflow } -SemanticError { message: "This will overflow for type LREAL", range: [SourceLocation { span: Range(TextLocation { line: 33, column: 40, offset: 1782 }..TextLocation { line: 33, column: 72, offset: 1814 }) }], err_no: var__overflow } +error: This will overflow for type SINT + ┌─ :5:42 + │ +5 │ min_sint : SINT := ((-128 * 1) * 2); // -128 + │ ^^^^^^^^^^^^^ This will overflow for type SINT + +error: This will overflow for type SINT + ┌─ :6:43 + │ +6 │ max_sint : SINT := ((127 * 1) * 2); // 127 + │ ^^^^^^^^^^^^ This will overflow for type SINT + +error: This will overflow for type USINT + ┌─ :7:43 + │ +7 │ min_usint : USINT := ((1 * 1) * -2); // 0 + │ ^^^^^^^^^^^ This will overflow for type USINT + +error: This will overflow for type USINT + ┌─ :8:43 + │ +8 │ max_usint : USINT := ((256 * 1) * 2); // 256 + │ ^^^^^^^^^^^^ This will overflow for type USINT + +error: This will overflow for type INT + ┌─ :11:41 + │ +11 │ min_int : INT := ((-32_768 * 1) * 2); // -32768 + │ ^^^^^^^^^^^^^^^^ This will overflow for type INT + +error: This will overflow for type INT + ┌─ :12:42 + │ +12 │ max_int : INT := ((32_767 * 1) * 2); // 32767 + │ ^^^^^^^^^^^^^^^ This will overflow for type INT + +error: This will overflow for type UINT + ┌─ :13:42 + │ +13 │ min_uint : UINT := ((1 * 1) * -2); // 0 + │ ^^^^^^^^^^^ This will overflow for type UINT + +error: This will overflow for type UINT + ┌─ :14:42 + │ +14 │ max_uint : UINT := ((65_536 * 1) * 2); // 65536 + │ ^^^^^^^^^^^^^^^ This will overflow for type UINT + +error: This will overflow for type DINT + ┌─ :17:42 + │ +17 │ min_dint : DINT := ((-2_147_483_649 * 1) * 2); // -2_147_483_648 + │ ^^^^^^^^^^^^^^^^^^^^^^^ This will overflow for type DINT + +error: This will overflow for type DINT + ┌─ :18:43 + │ +18 │ max_dint : DINT := (( 2_147_483_648 * 1) * 2); // 2_147_483_647 + │ ^^^^^^^^^^^^^^^^^^^^^^ This will overflow for type DINT + +error: This will overflow for type UDINT + ┌─ :19:43 + │ +19 │ min_udint : UDINT := ((1 * 1) * -2); // 0 + │ ^^^^^^^^^^^ This will overflow for type UDINT + +error: This will overflow for type UDINT + ┌─ :20:43 + │ +20 │ max_udint : UDINT := ((4_294_967_296 * 1) * 2); // 4_294_967_296 + │ ^^^^^^^^^^^^^^^^^^^^^^ This will overflow for type UDINT + +error: This will overflow for type LINT + ┌─ :23:42 + │ +23 │ min_lint : LINT := ((-9_223_372_036_854_775_808 * 1) * 2); // -9_223_372_036_854_775_808 + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ This will overflow for type LINT + +error: This will overflow for type LINT + ┌─ :24:43 + │ +24 │ max_lint : LINT := (( 9_223_372_036_854_775_807 * 1) * 2); // 9_223_372_036_854_775_807 + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ This will overflow for type LINT + +error: This will overflow for type ULINT + ┌─ :25:43 + │ +25 │ min_ulint : ULINT := ((1 * 1) * -2); // 0 + │ ^^^^^^^^^^^ This will overflow for type ULINT + +error: This will overflow for type ULINT + ┌─ :26:43 + │ +26 │ max_ulint : ULINT := ((18_446_744_073_709_551_615 * 1) * 2); // 18_446_744_073_709_551_615 + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ This will overflow for type ULINT + +error: This will overflow for type REAL + ┌─ :29:39 + │ +29 │ min_real : REAL := ((-3.40282347E+38 * 1) * 2); // -3.40282347E+38 + │ ^^^^^^^^^^^^^^^^^^^^^^^ This will overflow for type REAL + +error: This will overflow for type REAL + ┌─ :30:39 + │ +30 │ max_real : REAL := (( 3.40282347E+38 * 1) * 2); // 3.40282347E+38 + │ ^^^^^^^^^^^^^^^^^^^^^^^ This will overflow for type REAL + +error: This will overflow for type LREAL + ┌─ :33:41 + │ +33 │ min_lreal : LREAL := ((-1.7976931348623157E+308 * 1) * 2); // -1.7976931348623157E+308 + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ This will overflow for type LREAL + +error: This will overflow for type LREAL + ┌─ :34:41 + │ +34 │ max_lreal : LREAL := (( 1.7976931348623157E+308 * 1) * 2); // 1.7976931348623157E+308 + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ This will overflow for type LREAL + diff --git a/src/validation/tests/snapshots/rusty__validation__tests__variable_validation_tests__overflows__overflows_with_globals.snap b/src/validation/tests/snapshots/rusty__validation__tests__variable_validation_tests__overflows__overflows_with_globals.snap index 81e1d19278..016a72b4bd 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__variable_validation_tests__overflows__overflows_with_globals.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__variable_validation_tests__overflows__overflows_with_globals.snap @@ -1,7 +1,17 @@ --- source: src/validation/tests/variable_validation_tests.rs -expression: res +expression: diagnostics --- -SemanticError { message: "This will overflow for type INT", range: [SourceLocation { span: Range(TextLocation { line: 2, column: 23, offset: 43 }..TextLocation { line: 2, column: 28, offset: 48 }) }], err_no: var__overflow } -SemanticError { message: "This will overflow for type INT", range: [SourceLocation { span: Range(TextLocation { line: 3, column: 23, offset: 73 }..TextLocation { line: 3, column: 32, offset: 82 }) }], err_no: var__overflow } +error: This will overflow for type INT + ┌─ :3:24 + │ +3 │ a : INT := 32768; + │ ^^^^^ This will overflow for type INT + +error: This will overflow for type INT + ┌─ :4:24 + │ +4 │ b : INT := 32767 + 1; + │ ^^^^^^^^^ This will overflow for type INT + diff --git a/src/validation/tests/snapshots/rusty__validation__tests__variable_validation_tests__overflows__overflows_with_hex.snap b/src/validation/tests/snapshots/rusty__validation__tests__variable_validation_tests__overflows__overflows_with_hex.snap index ffef944530..050a07db6d 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__variable_validation_tests__overflows__overflows_with_hex.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__variable_validation_tests__overflows__overflows_with_hex.snap @@ -1,7 +1,17 @@ --- source: src/validation/tests/variable_validation_tests.rs -expression: res +expression: diagnostics --- -SemanticError { message: "This will overflow for type WORD", range: [SourceLocation { span: Range(TextLocation { line: 3, column: 29, offset: 95 }..TextLocation { line: 3, column: 37, offset: 103 }) }], err_no: var__overflow } -SyntaxError { message: "Literal 1048575 out of range (WORD)", range: [SourceLocation { span: Range(TextLocation { line: 3, column: 24, offset: 90 }..TextLocation { line: 3, column: 37, offset: 103 }) }], err_no: type__literal_out_of_range } +error: This will overflow for type WORD + ┌─ :4:30 + │ +4 │ y : UINT := WORD#16#fffff; // Not OK, should have been `ffff` not `ffff_f_` + │ ^^^^^^^^ This will overflow for type WORD + +error: Literal 1048575 out of range (WORD) + ┌─ :4:25 + │ +4 │ y : UINT := WORD#16#fffff; // Not OK, should have been `ffff` not `ffff_f_` + │ ^^^^^^^^^^^^^ Literal 1048575 out of range (WORD) + diff --git a/src/validation/tests/snapshots/rusty__validation__tests__variable_validation_tests__overflows__overflows_with_literals.snap b/src/validation/tests/snapshots/rusty__validation__tests__variable_validation_tests__overflows__overflows_with_literals.snap index eb61df054a..66e6072599 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__variable_validation_tests__overflows__overflows_with_literals.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__variable_validation_tests__overflows__overflows_with_literals.snap @@ -1,25 +1,125 @@ --- source: src/validation/tests/variable_validation_tests.rs -expression: res +expression: diagnostics --- -SemanticError { message: "This will overflow for type SINT", range: [SourceLocation { span: Range(TextLocation { line: 4, column: 39, offset: 106 }..TextLocation { line: 4, column: 43, offset: 110 }) }], err_no: var__overflow } -SemanticError { message: "This will overflow for type SINT", range: [SourceLocation { span: Range(TextLocation { line: 5, column: 40, offset: 163 }..TextLocation { line: 5, column: 43, offset: 166 }) }], err_no: var__overflow } -SemanticError { message: "This will overflow for type USINT", range: [SourceLocation { span: Range(TextLocation { line: 6, column: 40, offset: 219 }..TextLocation { line: 6, column: 42, offset: 221 }) }], err_no: var__overflow } -SemanticError { message: "This will overflow for type USINT", range: [SourceLocation { span: Range(TextLocation { line: 7, column: 40, offset: 272 }..TextLocation { line: 7, column: 43, offset: 275 }) }], err_no: var__overflow } -SemanticError { message: "This will overflow for type INT", range: [SourceLocation { span: Range(TextLocation { line: 10, column: 38, offset: 348 }..TextLocation { line: 10, column: 45, offset: 355 }) }], err_no: var__overflow } -SemanticError { message: "This will overflow for type INT", range: [SourceLocation { span: Range(TextLocation { line: 11, column: 38, offset: 406 }..TextLocation { line: 11, column: 44, offset: 412 }) }], err_no: var__overflow } -SemanticError { message: "This will overflow for type UINT", range: [SourceLocation { span: Range(TextLocation { line: 12, column: 39, offset: 465 }..TextLocation { line: 12, column: 41, offset: 467 }) }], err_no: var__overflow } -SemanticError { message: "This will overflow for type UINT", range: [SourceLocation { span: Range(TextLocation { line: 13, column: 39, offset: 518 }..TextLocation { line: 13, column: 45, offset: 524 }) }], err_no: var__overflow } -SemanticError { message: "This will overflow for type DINT", range: [SourceLocation { span: Range(TextLocation { line: 16, column: 39, offset: 598 }..TextLocation { line: 16, column: 53, offset: 612 }) }], err_no: var__overflow } -SemanticError { message: "This will overflow for type DINT", range: [SourceLocation { span: Range(TextLocation { line: 17, column: 40, offset: 673 }..TextLocation { line: 17, column: 53, offset: 686 }) }], err_no: var__overflow } -SemanticError { message: "This will overflow for type UDINT", range: [SourceLocation { span: Range(TextLocation { line: 18, column: 40, offset: 747 }..TextLocation { line: 18, column: 42, offset: 749 }) }], err_no: var__overflow } -SemanticError { message: "This will overflow for type UDINT", range: [SourceLocation { span: Range(TextLocation { line: 19, column: 40, offset: 808 }..TextLocation { line: 19, column: 53, offset: 821 }) }], err_no: var__overflow } -SemanticError { message: "This will overflow for type LINT", range: [SourceLocation { span: Range(TextLocation { line: 22, column: 39, offset: 903 }..TextLocation { line: 22, column: 65, offset: 929 }) }], err_no: var__overflow } -SemanticError { message: "This will overflow for type LINT", range: [SourceLocation { span: Range(TextLocation { line: 23, column: 40, offset: 1002 }..TextLocation { line: 23, column: 65, offset: 1027 }) }], err_no: var__overflow } -SemanticError { message: "This will overflow for type ULINT", range: [SourceLocation { span: Range(TextLocation { line: 24, column: 40, offset: 1100 }..TextLocation { line: 24, column: 42, offset: 1102 }) }], err_no: var__overflow } -SemanticError { message: "This will overflow for type ULINT", range: [SourceLocation { span: Range(TextLocation { line: 25, column: 40, offset: 1173 }..TextLocation { line: 25, column: 66, offset: 1199 }) }], err_no: var__overflow } -SemanticError { message: "This will overflow for type REAL", range: [SourceLocation { span: Range(TextLocation { line: 28, column: 36, offset: 1291 }..TextLocation { line: 28, column: 50, offset: 1305 }) }], err_no: var__overflow } -SemanticError { message: "This will overflow for type REAL", range: [SourceLocation { span: Range(TextLocation { line: 29, column: 36, offset: 1362 }..TextLocation { line: 29, column: 50, offset: 1376 }) }], err_no: var__overflow } -SemanticError { message: "This will overflow for type LREAL", range: [SourceLocation { span: Range(TextLocation { line: 32, column: 38, offset: 1459 }..TextLocation { line: 32, column: 61, offset: 1482 }) }], err_no: var__overflow } -SemanticError { message: "This will overflow for type LREAL", range: [SourceLocation { span: Range(TextLocation { line: 33, column: 38, offset: 1550 }..TextLocation { line: 33, column: 61, offset: 1573 }) }], err_no: var__overflow } +error: This will overflow for type SINT + ┌─ :5:40 + │ +5 │ min_sint : SINT := -129; // -128 + │ ^^^^ This will overflow for type SINT + +error: This will overflow for type SINT + ┌─ :6:41 + │ +6 │ max_sint : SINT := 128; // 127 + │ ^^^ This will overflow for type SINT + +error: This will overflow for type USINT + ┌─ :7:41 + │ +7 │ min_usint : USINT := -1; // 0 + │ ^^ This will overflow for type USINT + +error: This will overflow for type USINT + ┌─ :8:41 + │ +8 │ max_usint : USINT := 257; // 256 + │ ^^^ This will overflow for type USINT + +error: This will overflow for type INT + ┌─ :11:39 + │ +11 │ min_int : INT := -32_769; // -32768 + │ ^^^^^^^ This will overflow for type INT + +error: This will overflow for type INT + ┌─ :12:39 + │ +12 │ max_int : INT := 32_768; // 32767 + │ ^^^^^^ This will overflow for type INT + +error: This will overflow for type UINT + ┌─ :13:40 + │ +13 │ min_uint : UINT := -1; // 0 + │ ^^ This will overflow for type UINT + +error: This will overflow for type UINT + ┌─ :14:40 + │ +14 │ max_uint : UINT := 65_537; // 65536 + │ ^^^^^^ This will overflow for type UINT + +error: This will overflow for type DINT + ┌─ :17:40 + │ +17 │ min_dint : DINT := -2_147_483_649; // -2_147_483_648 + │ ^^^^^^^^^^^^^^ This will overflow for type DINT + +error: This will overflow for type DINT + ┌─ :18:41 + │ +18 │ max_dint : DINT := 2_147_483_648; // 2_147_483_647 + │ ^^^^^^^^^^^^^ This will overflow for type DINT + +error: This will overflow for type UDINT + ┌─ :19:41 + │ +19 │ min_udint : UDINT := -1; // 0 + │ ^^ This will overflow for type UDINT + +error: This will overflow for type UDINT + ┌─ :20:41 + │ +20 │ max_udint : UDINT := 4_294_967_296; // 4_294_967_296 + │ ^^^^^^^^^^^^^ This will overflow for type UDINT + +error: This will overflow for type LINT + ┌─ :23:40 + │ +23 │ min_lint : LINT := -9_223_372_036_854_775_809; // -9_223_372_036_854_775_808 + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^ This will overflow for type LINT + +error: This will overflow for type LINT + ┌─ :24:41 + │ +24 │ max_lint : LINT := 9_223_372_036_854_775_808; // 9_223_372_036_854_775_807 + │ ^^^^^^^^^^^^^^^^^^^^^^^^^ This will overflow for type LINT + +error: This will overflow for type ULINT + ┌─ :25:41 + │ +25 │ min_ulint : ULINT := -1; // 0 + │ ^^ This will overflow for type ULINT + +error: This will overflow for type ULINT + ┌─ :26:41 + │ +26 │ max_ulint : ULINT := 18_446_744_073_709_551_616; // 18_446_744_073_709_551_615 + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^ This will overflow for type ULINT + +error: This will overflow for type REAL + ┌─ :29:37 + │ +29 │ min_real : REAL := -3.50282347E+38; // -3.40282347E+38 + │ ^^^^^^^^^^^^^^ This will overflow for type REAL + +error: This will overflow for type REAL + ┌─ :30:37 + │ +30 │ max_real : REAL := 3.50282347E+38; // 3.40282347E+38 + │ ^^^^^^^^^^^^^^ This will overflow for type REAL + +error: This will overflow for type LREAL + ┌─ :33:39 + │ +33 │ min_lreal : LREAL := -1.8076931348623157E+308; // -1.7976931348623157E+308 + │ ^^^^^^^^^^^^^^^^^^^^^^^ This will overflow for type LREAL + +error: This will overflow for type LREAL + ┌─ :34:39 + │ +34 │ max_lreal : LREAL := 1.8076931348623157E+308; // 1.7976931348623157E+308 + │ ^^^^^^^^^^^^^^^^^^^^^^^ This will overflow for type LREAL + diff --git a/src/validation/tests/snapshots/rusty__validation__tests__variable_validation_tests__overflows__overflows_with_non_global_constants.snap b/src/validation/tests/snapshots/rusty__validation__tests__variable_validation_tests__overflows__overflows_with_non_global_constants.snap new file mode 100644 index 0000000000..a3aaa4c797 --- /dev/null +++ b/src/validation/tests/snapshots/rusty__validation__tests__variable_validation_tests__overflows__overflows_with_non_global_constants.snap @@ -0,0 +1,11 @@ +--- +source: src/validation/tests/variable_validation_tests.rs +expression: diagnostics +--- +error: Unresolved constant 'c' variable: 'a' is no const reference + ┌─ :5:24 + │ +5 │ c : INT := a + b; // Will overflow + │ ^^^^^ Unresolved constant 'c' variable: 'a' is no const reference + + diff --git a/src/validation/tests/snapshots/rusty__validation__tests__variable_validation_tests__overflows__overflows_with_not.snap b/src/validation/tests/snapshots/rusty__validation__tests__variable_validation_tests__overflows__overflows_with_not.snap index 7c9f6231f3..b90dff4b55 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__variable_validation_tests__overflows__overflows_with_not.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__variable_validation_tests__overflows__overflows_with_not.snap @@ -1,6 +1,11 @@ --- source: src/validation/tests/variable_validation_tests.rs -expression: res +expression: diagnostics --- -SemanticError { message: "This will overflow for type UINT", range: [SourceLocation { span: Range(TextLocation { line: 3, column: 24, offset: 86 }..TextLocation { line: 3, column: 33, offset: 95 }) }], err_no: var__overflow } +error: This will overflow for type UINT + ┌─ :4:25 + │ +4 │ y : UINT := NOT -1234; // Not OK (because of -1234) + │ ^^^^^^^^^ This will overflow for type UINT + diff --git a/src/validation/tests/snapshots/rusty__validation__tests__variable_validation_tests__sized_varargs_require_type.snap b/src/validation/tests/snapshots/rusty__validation__tests__variable_validation_tests__sized_varargs_require_type.snap index 0cbc76d71b..b67da5750b 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__variable_validation_tests__sized_varargs_require_type.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__variable_validation_tests__sized_varargs_require_type.snap @@ -1,6 +1,11 @@ --- source: src/validation/tests/variable_validation_tests.rs -expression: res +expression: "&diagnostics" --- -SyntaxError { message: "Missing datatype : Sized Variadics require a known datatype.", range: [SourceLocation { span: Range(TextLocation { line: 4, column: 26, offset: 103 }..TextLocation { line: 4, column: 29, offset: 106 }) }], err_no: var__missing_type } +error: Missing datatype : Sized Variadics require a known datatype. + ┌─ :5:27 + │ +5 │ args : {sized}...; + │ ^^^ Missing datatype : Sized Variadics require a known datatype. + diff --git a/src/validation/tests/snapshots/rusty__validation__tests__variable_validation_tests__unresolvable_variables_are_reported.snap b/src/validation/tests/snapshots/rusty__validation__tests__variable_validation_tests__unresolvable_variables_are_reported.snap index 7ecc904113..eb5d88255b 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__variable_validation_tests__unresolvable_variables_are_reported.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__variable_validation_tests__unresolvable_variables_are_reported.snap @@ -1,8 +1,23 @@ --- source: src/validation/tests/variable_validation_tests.rs -expression: res +expression: "&diagnostics" --- -SyntaxError { message: "Unresolved constant 'cx' variable", range: [SourceLocation { span: Range(TextLocation { line: 18, column: 28, offset: 372 }..TextLocation { line: 18, column: 30, offset: 374 }) }], err_no: var__unresolved_constant } -SyntaxError { message: "Could not resolve reference to a", range: [SourceLocation { span: Range(TextLocation { line: 20, column: 29, offset: 453 }..TextLocation { line: 20, column: 30, offset: 454 }) }], err_no: reference__unresolved } -SyntaxError { message: "Unresolved constant 'cai' variable", range: [SourceLocation { span: Range(TextLocation { line: 20, column: 29, offset: 453 }..TextLocation { line: 20, column: 30, offset: 454 }) }], err_no: var__unresolved_constant } +error: Unresolved constant 'cx' variable + ┌─ :19:29 + │ +19 │ cx : INT := cx; //unresolvable + │ ^^ Unresolved constant 'cx' variable + +error: Could not resolve reference to a + ┌─ :21:30 + │ +21 │ cai : INT := a; //unresolvable + │ ^ Could not resolve reference to a + +error: Unresolved constant 'cai' variable + ┌─ :21:30 + │ +21 │ cai : INT := a; //unresolvable + │ ^ Unresolved constant 'cai' variable + diff --git a/src/validation/tests/statement_validation_tests.rs b/src/validation/tests/statement_validation_tests.rs index 92c16e3226..5b908ae3e7 100644 --- a/src/validation/tests/statement_validation_tests.rs +++ b/src/validation/tests/statement_validation_tests.rs @@ -1,14 +1,12 @@ use insta::assert_snapshot; -use plc_diagnostics::diagnostics::Diagnostic; -use crate::assert_validation_snapshot; -use crate::test_utils::tests::{parse_and_validate, parse_and_validate_buffered}; +use crate::test_utils::tests::parse_and_validate_buffered; #[test] fn assign_pointer_to_too_small_type_result_in_an_error() { //GIVEN assignment statements to DWORD //WHEN it is validated - let diagnostics: Vec = parse_and_validate( + let diagnostics = parse_and_validate_buffered( " PROGRAM FOO VAR @@ -23,14 +21,14 @@ fn assign_pointer_to_too_small_type_result_in_an_error() { ); //THEN assignment with different type sizes are reported - assert_validation_snapshot!(&diagnostics); + assert_snapshot!(&diagnostics); } #[test] fn assign_too_small_type_to_pointer_result_in_an_error() { //GIVEN assignment statements to pointer //WHEN it is validated - let diagnostics: Vec = parse_and_validate( + let diagnostics = parse_and_validate_buffered( " PROGRAM FOO VAR @@ -45,14 +43,14 @@ fn assign_too_small_type_to_pointer_result_in_an_error() { ); //THEN assignment with different type sizes are reported - assert_validation_snapshot!(&diagnostics); + assert_snapshot!(&diagnostics); } #[test] fn assign_pointer_to_lword() { //GIVEN assignment statements to lword //WHEN it is validated - let diagnostics: Vec = parse_and_validate( + let diagnostics = parse_and_validate_buffered( " PROGRAM FOO VAR @@ -67,14 +65,14 @@ fn assign_pointer_to_lword() { ); //THEN every assignment is valid - assert_eq!(diagnostics, vec![]); + assert!(diagnostics.is_empty()); } #[test] fn assignment_to_constants_result_in_an_error() { // GIVEN assignment statements to constants, some to writable variables // WHEN it is validated - let diagnostics = parse_and_validate( + let diagnostics = parse_and_validate_buffered( " VAR_GLOBAL CONSTANT ci: INT := 1; @@ -102,14 +100,14 @@ fn assignment_to_constants_result_in_an_error() { ); // THEN everything but VAR and VAR_GLOBALS are reported - assert_validation_snapshot!(&diagnostics); + assert_snapshot!(&diagnostics); } #[test] fn assignment_to_enum_literals_results_in_error() { // GIVEN assignment statements to constants, some to writable variables // WHEN it is validated - let diagnostics = parse_and_validate( + let diagnostics = parse_and_validate_buffered( " TYPE Color: (red, yellow, green); END_TYPE @@ -130,14 +128,14 @@ fn assignment_to_enum_literals_results_in_error() { ); // THEN everything but VAR and VAR_GLOBALS are reported - assert_validation_snapshot!(&diagnostics); + assert_snapshot!(&diagnostics); } #[test] fn invalid_char_assignments() { // GIVEN invalid assignments to CHAR/WCHAR // WHEN it is validated - let diagnostics = parse_and_validate( + let diagnostics = parse_and_validate_buffered( r#" PROGRAM mainProg VAR @@ -176,14 +174,14 @@ fn invalid_char_assignments() { ); // THEN every assignment should be reported - assert_validation_snapshot!(&diagnostics); + assert_snapshot!(&diagnostics); } #[test] fn missing_string_compare_function_causes_error() { // GIVEN assignment statements to constants, some to writable variables // WHEN it is validated - let diagnostics = parse_and_validate( + let diagnostics = parse_and_validate_buffered( " PROGRAM prg 'a' = 'b'; // missing compare function :-( @@ -197,14 +195,14 @@ fn missing_string_compare_function_causes_error() { ); // THEN everything but VAR and VAR_GLOBALS are reported - assert_validation_snapshot!(&diagnostics); + assert_snapshot!(&diagnostics); } #[test] fn string_compare_function_cause_no_error_if_functions_exist() { // GIVEN assignment statements to constants, some to writable variables // WHEN it is validated - let diagnostics = parse_and_validate( + let diagnostics = parse_and_validate_buffered( " FUNCTION STRING_EQUAL : BOOL VAR_INPUT a,b : STRING; END_VAR END_FUNCTION FUNCTION STRING_GREATER : BOOL VAR_INPUT a,b : STRING; END_VAR END_FUNCTION @@ -222,14 +220,14 @@ fn string_compare_function_cause_no_error_if_functions_exist() { ); // THEN everything but VAR and VAR_GLOBALS are reported - assert_eq!(diagnostics, vec![]); + assert!(diagnostics.is_empty()); } #[test] fn string_compare_function_with_wrong_signature_causes_error() { // GIVEN assignment statements to constants, some to writable variables // WHEN it is validated - let diagnostics = parse_and_validate( + let diagnostics = parse_and_validate_buffered( " FUNCTION STRING_EQUAL : BOOL VAR_INPUT a : STRING; END_VAR END_FUNCTION @@ -240,14 +238,14 @@ fn string_compare_function_with_wrong_signature_causes_error() { ); // THEN everything but VAR and VAR_GLOBALS are reported - assert_validation_snapshot!(&diagnostics); + assert_snapshot!(&diagnostics); } #[test] fn missing_wstring_compare_function_causes_error() { // GIVEN assignment statements to constants, some to writable variables // WHEN it is validated - let diagnostics = parse_and_validate( + let diagnostics = parse_and_validate_buffered( r#" PROGRAM prg "a" = "b"; // missing compare function :-( @@ -261,14 +259,14 @@ fn missing_wstring_compare_function_causes_error() { ); // THEN everything but VAR and VAR_GLOBALS are reported - assert_validation_snapshot!(&diagnostics); + assert_snapshot!(&diagnostics); } #[test] fn wstring_compare_function_cause_no_error_if_functions_exist() { // GIVEN assignment statements to constants, some to writable variables // WHEN it is validated - let diagnostics = parse_and_validate( + let diagnostics = parse_and_validate_buffered( r#" FUNCTION WSTRING_EQUAL : BOOL VAR_INPUT a,b : WSTRING; END_VAR END_FUNCTION FUNCTION WSTRING_GREATER : BOOL VAR_INPUT a,b : WSTRING; END_VAR END_FUNCTION @@ -286,14 +284,14 @@ fn wstring_compare_function_cause_no_error_if_functions_exist() { ); // THEN everything but VAR and VAR_GLOBALS are reported - assert_eq!(diagnostics, vec![]); + assert!(diagnostics.is_empty()); } #[test] fn switch_case() { // GIVEN switch case statement // WHEN it is validated - let diagnostics = parse_and_validate( + let diagnostics = parse_and_validate_buffered( r#" VAR_GLOBAL CONSTANT BASE : DINT := 1; @@ -325,14 +323,14 @@ fn switch_case() { ); // THEN no errors should occure - assert_eq!(diagnostics, vec![]); + assert!(diagnostics.is_empty()); } #[test] fn switch_case_duplicate_integer_non_const_var_reference() { // GIVEN switch case with non constant variables // WHEN it is validated - let diagnostics = parse_and_validate( + let diagnostics = parse_and_validate_buffered( r#" VAR_GLOBAL CONSTANT CONST : DINT := 8; @@ -362,14 +360,14 @@ fn switch_case_duplicate_integer_non_const_var_reference() { ); // THEN the non constant variables are reported - assert_validation_snapshot!(&diagnostics); + assert_snapshot!(&diagnostics); } #[test] fn switch_case_duplicate_integer() { // GIVEN switch case with duplicate constant conditions // WHEN it is validated - let diagnostics = parse_and_validate( + let diagnostics = parse_and_validate_buffered( r#" VAR_GLOBAL CONSTANT BASE : DINT := 2; @@ -399,14 +397,14 @@ fn switch_case_duplicate_integer() { ); // THEN the non constant variables are reported - assert_validation_snapshot!(&diagnostics); + assert_snapshot!(&diagnostics); } #[test] fn switch_case_invalid_case_conditions() { // GIVEN switch case statement // WHEN it is validated - let diagnostics = parse_and_validate( + let diagnostics = parse_and_validate_buffered( r#" FUNCTION foo : DINT END_FUNCTION @@ -427,14 +425,14 @@ fn switch_case_invalid_case_conditions() { ); // THEN - assert_validation_snapshot!(&diagnostics); + assert_snapshot!(&diagnostics); } #[test] fn case_condition_used_outside_case_statement() { // GIVEN switch case statement // WHEN it is validated - let diagnostics = parse_and_validate( + let diagnostics = parse_and_validate_buffered( r#" PROGRAM main VAR @@ -448,14 +446,14 @@ fn case_condition_used_outside_case_statement() { ); // THEN - assert_validation_snapshot!(&diagnostics); + assert_snapshot!(&diagnostics); } #[test] fn subrange_compare_function_causes_no_error() { // GIVEN comparison of subranges // WHEN it is validated - let diagnostics = parse_and_validate( + let diagnostics = parse_and_validate_buffered( r#" PROGRAM main VAR @@ -475,14 +473,14 @@ fn subrange_compare_function_causes_no_error() { ); // THEN the validator does not throw an error - assert_eq!(diagnostics, vec![]); + assert!(diagnostics.is_empty()); } #[test] fn aliased_subrange_compare_function_causes_no_error() { // GIVEN comparison of aliased subranges // WHEN it is validated - let diagnostics = parse_and_validate( + let diagnostics = parse_and_validate_buffered( r#" TYPE MyInt: INT(0..500); END_TYPE PROGRAM main @@ -503,14 +501,14 @@ fn aliased_subrange_compare_function_causes_no_error() { ); // THEN the validator does not throw an error - assert_eq!(diagnostics, vec![]); + assert!(diagnostics.is_empty()); } #[test] fn aliased_int_compare_function_causes_no_error() { // GIVEN comparison of aliased integers // WHEN it is validated - let diagnostics = parse_and_validate( + let diagnostics = parse_and_validate_buffered( r#" TYPE MyInt: INT; END_TYPE PROGRAM main @@ -531,13 +529,13 @@ fn aliased_int_compare_function_causes_no_error() { ); // THEN the validator does not throw an error - assert_eq!(diagnostics, vec![]); + assert!(diagnostics.is_empty()); } #[test] fn program_missing_inout_assignment() { // GIVEN - let diagnostics = parse_and_validate( + let diagnostics = parse_and_validate_buffered( " PROGRAM prog VAR_INPUT @@ -563,14 +561,14 @@ fn program_missing_inout_assignment() { ", ); // THEN - assert_validation_snapshot!(&diagnostics); + assert_snapshot!(&diagnostics); } #[test] fn function_call_parameter_validation() { // GIVEN // WHEN - let diagnostics = parse_and_validate( + let diagnostics = parse_and_validate_buffered( r#" FUNCTION foo : DINT VAR_INPUT @@ -604,14 +602,14 @@ fn function_call_parameter_validation() { ); // THEN - assert_validation_snapshot!(&diagnostics); + assert_snapshot!(&diagnostics); } #[test] fn program_call_parameter_validation() { // GIVEN // WHEN - let diagnostics = parse_and_validate( + let diagnostics = parse_and_validate_buffered( r#" PROGRAM prog VAR_INPUT @@ -645,12 +643,12 @@ fn program_call_parameter_validation() { ); // THEN - assert_validation_snapshot!(&diagnostics); + assert_snapshot!(&diagnostics); } #[test] fn reference_to_reference_assignments_in_function_arguments() { - let diagnostics: Vec = parse_and_validate( + let diagnostics = parse_and_validate_buffered( r#" VAR_GLOBAL global1 : STRUCT_params; @@ -713,12 +711,12 @@ fn reference_to_reference_assignments_in_function_arguments() { "#, ); - assert_validation_snapshot!(&diagnostics); + assert_snapshot!(&diagnostics); } #[test] fn ref_builtin_function_reports_invalid_param_count() { - let diagnostics = parse_and_validate( + let diagnostics = parse_and_validate_buffered( " FUNCTION main : DINT VAR @@ -731,7 +729,7 @@ fn ref_builtin_function_reports_invalid_param_count() { ", ); - assert_validation_snapshot!(diagnostics); + assert_snapshot!(diagnostics); } #[test] @@ -773,7 +771,7 @@ fn address_of_operations() { #[test] fn validate_call_by_ref() { - let diagnostics: Vec = parse_and_validate( + let diagnostics = parse_and_validate_buffered( " FUNCTION func : DINT VAR_INPUT @@ -808,12 +806,12 @@ fn validate_call_by_ref() { ", ); - assert_validation_snapshot!(&diagnostics); + assert_snapshot!(&diagnostics); } #[test] fn validate_call_by_ref_explicit() { - let diagnostics: Vec = parse_and_validate( + let diagnostics = parse_and_validate_buffered( " FUNCTION func : DINT VAR_INPUT @@ -846,12 +844,12 @@ fn validate_call_by_ref_explicit() { ", ); - assert_validation_snapshot!(&diagnostics); + assert_snapshot!(&diagnostics); } #[test] fn implicit_param_downcast_in_function_call() { - let diagnostics: Vec = parse_and_validate( + let diagnostics = parse_and_validate_buffered( " PROGRAM main VAR @@ -893,12 +891,12 @@ fn implicit_param_downcast_in_function_call() { ", ); - assert_validation_snapshot!(&diagnostics); + assert_snapshot!(&diagnostics); } #[test] fn function_block_implicit_downcast() { - let diagnostics = parse_and_validate( + let diagnostics = parse_and_validate_buffered( r#" PROGRAM main VAR @@ -939,12 +937,12 @@ fn function_block_implicit_downcast() { "#, ); - assert_validation_snapshot!(&diagnostics); + assert_snapshot!(&diagnostics); } #[test] fn program_implicit_downcast() { - let diagnostics = parse_and_validate( + let diagnostics = parse_and_validate_buffered( r#" PROGRAM main VAR @@ -985,12 +983,12 @@ fn program_implicit_downcast() { "#, ); - assert_validation_snapshot!(&diagnostics); + assert_snapshot!(&diagnostics); } #[test] fn action_implicit_downcast() { - let diagnostics = parse_and_validate( + let diagnostics = parse_and_validate_buffered( r#" PROGRAM main VAR @@ -1029,12 +1027,12 @@ fn action_implicit_downcast() { "#, ); - assert_validation_snapshot!(&diagnostics); + assert_snapshot!(&diagnostics); } #[test] fn method_implicit_downcast() { - let diagnostics = parse_and_validate( + let diagnostics = parse_and_validate_buffered( r#" PROGRAM main VAR @@ -1061,12 +1059,12 @@ fn method_implicit_downcast() { "#, ); - assert_validation_snapshot!(&diagnostics); + assert_snapshot!(&diagnostics); } #[test] fn validate_array_elements_passed_to_functions_by_ref() { - let diagnostics: Vec = parse_and_validate( + let diagnostics = parse_and_validate_buffered( " FUNCTION func : DINT VAR_IN_OUT @@ -1090,12 +1088,12 @@ fn validate_array_elements_passed_to_functions_by_ref() { ", ); - assert_validation_snapshot!(&diagnostics); + assert_snapshot!(&diagnostics); } #[test] fn validate_arrays_passed_to_functions() { - let diagnostics: Vec = parse_and_validate( + let diagnostics = parse_and_validate_buffered( " FUNCTION func : DINT VAR_INPUT @@ -1140,12 +1138,12 @@ fn validate_arrays_passed_to_functions() { ", ); - assert_validation_snapshot!(&diagnostics); + assert_snapshot!(&diagnostics); } #[test] fn assigning_to_rvalue() { - let diagnostics = parse_and_validate( + let diagnostics = parse_and_validate_buffered( r#" FUNCTION func : DINT VAR_INPUT @@ -1164,12 +1162,12 @@ fn assigning_to_rvalue() { "#, ); - assert_validation_snapshot!(&diagnostics); + assert_snapshot!(&diagnostics); } #[test] fn assigning_to_qualified_references_allowed() { - let diagnostics = parse_and_validate( + let diagnostics = parse_and_validate_buffered( r#" PROGRAM prg VAR_INPUT @@ -1183,12 +1181,12 @@ fn assigning_to_qualified_references_allowed() { "#, ); - assert_eq!(diagnostics.len(), 0); + assert!(diagnostics.is_empty()); } #[test] fn assigning_to_rvalue_allowed_for_directaccess() { - let diagnostics = parse_and_validate( + let diagnostics = parse_and_validate_buffered( r#" PROGRAM main VAR @@ -1201,12 +1199,12 @@ fn assigning_to_rvalue_allowed_for_directaccess() { "#, ); - assert_eq!(diagnostics.len(), 0); + assert!(diagnostics.is_empty()); } #[test] fn allowed_assignable_types() { - let diagnostics = parse_and_validate( + let diagnostics = parse_and_validate_buffered( r#" PROGRAM main VAR @@ -1225,7 +1223,7 @@ fn allowed_assignable_types() { "#, ); - assert_eq!(diagnostics.len(), 0); + assert!(diagnostics.is_empty()); } #[test] @@ -1250,7 +1248,7 @@ fn assignment_of_incompatible_types_is_reported() { #[test] fn passing_compatible_numeric_types_to_functions_is_allowed() { - let diagnostics = parse_and_validate( + let diagnostics = parse_and_validate_buffered( r#" PROGRAM prog VAR @@ -1271,12 +1269,12 @@ fn passing_compatible_numeric_types_to_functions_is_allowed() { "#, ); - assert_eq!(diagnostics, vec![]); + assert!(diagnostics.is_empty()); } #[test] fn bit_access_with_incorrect_operator_causes_warning() { - let diagnostics = parse_and_validate( + let diagnostics = parse_and_validate_buffered( "PROGRAM mainProg VAR_INPUT Input : STRUCT1; @@ -1311,12 +1309,12 @@ fn bit_access_with_incorrect_operator_causes_warning() { END_TYPE", ); - assert_validation_snapshot!(diagnostics); + assert_snapshot!(diagnostics); } #[test] fn invalid_cast_statement_causes_error() { - let diagnostics = parse_and_validate( + let diagnostics = parse_and_validate_buffered( "PROGRAM mainProg VAR_INPUT s : STRUCT1; @@ -1336,5 +1334,5 @@ fn invalid_cast_statement_causes_error() { ", ); - assert_validation_snapshot!(diagnostics); + assert_snapshot!(diagnostics); } diff --git a/src/validation/tests/variable_length_array_test.rs b/src/validation/tests/variable_length_array_test.rs index 998555c2de..e916a141d4 100644 --- a/src/validation/tests/variable_length_array_test.rs +++ b/src/validation/tests/variable_length_array_test.rs @@ -1,4 +1,5 @@ -use crate::{assert_validation_snapshot, test_utils::tests::parse_and_validate}; +use crate::test_utils::tests::parse_and_validate_buffered; +use insta::assert_snapshot; static SOURCE: &str = " fn : DINT @@ -24,71 +25,71 @@ fn variable_length_array_defined_as_a_global_variable() { END_VAR "; - assert_validation_snapshot!(parse_and_validate(src)); + assert_snapshot!(parse_and_validate_buffered(src)); } mod functions { - use crate::{ - assert_validation_snapshot, test_utils::tests::parse_and_validate, - validation::tests::variable_length_array_test::SOURCE, - }; + use crate::test_utils::tests::parse_and_validate_buffered; + use crate::validation::tests::variable_length_array_test::SOURCE; + use insta::assert_snapshot; #[test] fn variable_length_array_function_with_input_output_and_inout() { let function = SOURCE.replace("", "FUNCTION"); - assert!(parse_and_validate(&function.replace("", "INPUT {ref}")).is_empty()); - assert!(parse_and_validate(&function.replace("", "OUTPUT")).is_empty()); - assert!(parse_and_validate(&function.replace("", "IN_OUT")).is_empty()); + assert!(parse_and_validate_buffered(&function.replace("", "INPUT {ref}")).is_empty()); + assert!(parse_and_validate_buffered(&function.replace("", "OUTPUT")).is_empty()); + assert!(parse_and_validate_buffered(&function.replace("", "IN_OUT")).is_empty()); } #[test] fn variable_length_array_function_input() { let function = SOURCE.replace("", "FUNCTION"); - assert_validation_snapshot!(parse_and_validate(&function.replace("", "INPUT"))); + assert_snapshot!(parse_and_validate_buffered(&function.replace("", "INPUT"))); } } mod program { use crate::{ - assert_validation_snapshot, test_utils::tests::parse_and_validate, - validation::tests::variable_length_array_test::SOURCE, + test_utils::tests::parse_and_validate_buffered, validation::tests::variable_length_array_test::SOURCE, }; + use insta::assert_snapshot; #[test] fn variable_length_array_program_input() { let program = SOURCE.replace("", "PROGRAM"); - let program_input = parse_and_validate(&program.replace("", "INPUT")); - assert_validation_snapshot!(program_input); + let program_input = parse_and_validate_buffered(&program.replace("", "INPUT")); + assert_snapshot!(program_input); } #[test] fn variable_length_array_program_input_ref() { let program = SOURCE.replace("", "PROGRAM"); - let program_input = parse_and_validate(&program.replace("", "INPUT {ref}")); - assert_validation_snapshot!(program_input); + let program_input = parse_and_validate_buffered(&program.replace("", "INPUT {ref}")); + assert_snapshot!(program_input); } #[test] fn variable_length_array_program_output() { let program = SOURCE.replace("", "PROGRAM"); - let program_output = parse_and_validate(&program.replace("", "OUTPUT")); - assert_validation_snapshot!(program_output); + let program_output = parse_and_validate_buffered(&program.replace("", "OUTPUT")); + assert_snapshot!(program_output); } #[test] fn variable_length_array_program_inout() { let program = SOURCE.replace("", "PROGRAM"); - let program_inout = parse_and_validate(&program.replace("", "IN_OUT")); - assert_validation_snapshot!(program_inout); + let program_inout = parse_and_validate_buffered(&program.replace("", "IN_OUT")); + assert_snapshot!(program_inout); } } mod access { - use crate::{assert_validation_snapshot, test_utils::tests::parse_and_validate}; + use crate::test_utils::tests::parse_and_validate_buffered; + use insta::assert_snapshot; #[test] fn variable_length_array_access() { - let diagnostics = parse_and_validate( + let diagnostics = parse_and_validate_buffered( " FUNCTION fn : DINT VAR_INPUT {ref} @@ -111,12 +112,12 @@ mod access { ", ); - assert_validation_snapshot!(diagnostics); + assert_snapshot!(diagnostics); } #[test] fn variable_length_array_incompatible_datatypes() { - let diagnostics = parse_and_validate( + let diagnostics = parse_and_validate_buffered( " FUNCTION fn : DINT VAR_INPUT {ref} @@ -138,16 +139,17 @@ mod access { ", ); - assert_validation_snapshot!(diagnostics); + assert_snapshot!(diagnostics); } } mod assignment { - use crate::{assert_validation_snapshot, test_utils::tests::parse_and_validate}; + use crate::test_utils::tests::parse_and_validate_buffered; + use insta::assert_snapshot; #[test] fn function_calls() { - let diagnostics = parse_and_validate( + let diagnostics = parse_and_validate_buffered( " FUNCTION fn : DINT VAR_TEMP @@ -174,15 +176,17 @@ mod assignment { ", ); - assert_validation_snapshot!(diagnostics); + assert_snapshot!(diagnostics); } } mod naming { - use crate::{assert_validation_snapshot, test_utils::tests::parse_and_validate}; + use crate::test_utils::tests::parse_and_validate_buffered; + use insta::assert_snapshot; + #[test] fn two_identical_vlas_in_same_pou_arent_duplicated_in_symbol_map() { - let diag = parse_and_validate( + let diag = parse_and_validate_buffered( r#" FUNCTION foo : INT VAR_INPUT{ref} @@ -206,7 +210,7 @@ mod naming { #[test] fn global_vla_does_not_cause_name_conflict() { - let diag = parse_and_validate( + let diag = parse_and_validate_buffered( r#" VAR_GLOBAL vla : ARRAY[*, *] OF DINT; @@ -219,16 +223,17 @@ mod naming { END_FUNCTION "#, ); - assert_validation_snapshot!(diag); + assert_snapshot!(diag); } } mod builtins { - use crate::{assert_validation_snapshot, test_utils::tests::parse_and_validate}; + use crate::test_utils::tests::parse_and_validate_buffered; + use insta::assert_snapshot; #[test] fn builtins_called_with_invalid_type() { - let diagnostics = parse_and_validate( + let diagnostics = parse_and_validate_buffered( " FUNCTION main : DINT VAR CONSTANT @@ -249,12 +254,12 @@ mod builtins { ", ); - assert_validation_snapshot!(diagnostics); + assert_snapshot!(diagnostics); } #[test] fn builtins_called_with_invalid_index() { - let diagnostics = parse_and_validate( + let diagnostics = parse_and_validate_buffered( " FUNCTION main : DINT VAR @@ -285,12 +290,12 @@ mod builtins { ", ); - assert_validation_snapshot!(diagnostics); + assert_snapshot!(diagnostics); } #[test] fn builtins_called_with_aliased_type() { - let diagnostics = parse_and_validate( + let diagnostics = parse_and_validate_buffered( " FUNCTION main : DINT VAR @@ -315,12 +320,12 @@ mod builtins { ", ); - assert_validation_snapshot!(diagnostics); + assert_snapshot!(diagnostics); } #[test] fn builtins_called_with_invalid_number_of_params() { - let diagnostics = parse_and_validate( + let diagnostics = parse_and_validate_buffered( " FUNCTION main : DINT VAR @@ -346,6 +351,6 @@ mod builtins { ", ); - assert_validation_snapshot!(diagnostics); + assert_snapshot!(diagnostics); } } diff --git a/src/validation/tests/variable_validation_tests.rs b/src/validation/tests/variable_validation_tests.rs index 1ac87a2004..777c2b8fa5 100644 --- a/src/validation/tests/variable_validation_tests.rs +++ b/src/validation/tests/variable_validation_tests.rs @@ -1,10 +1,9 @@ use crate::test_utils::tests::parse_and_validate_buffered; -use crate::{assert_validation_snapshot, test_utils::tests::parse_and_validate}; use insta::assert_snapshot; #[test] fn uninitialized_constants_fall_back_to_the_default() { - let diagnostics = parse_and_validate( + let diagnostics = parse_and_validate_buffered( " VAR_GLOBAL gX : INT; @@ -30,12 +29,12 @@ fn uninitialized_constants_fall_back_to_the_default() { ", ); - assert_eq!(diagnostics, vec![]); + assert!(diagnostics.is_empty()); } #[test] fn unresolvable_variables_are_reported() { - let diagnostics = parse_and_validate( + let diagnostics = parse_and_validate_buffered( " VAR_GLOBAL gX : INT := 7 + cgX; @@ -62,14 +61,14 @@ fn unresolvable_variables_are_reported() { ", ); - assert_validation_snapshot!(&diagnostics); + assert_snapshot!(&diagnostics); } #[test] fn constant_on_illegal_var_blocks_cause_validation_issue() { // GIVEN different variable block types with the CONSTANT modifier // WHEN it is validated - let diagnostics = parse_and_validate( + let diagnostics = parse_and_validate_buffered( " VAR_GLOBAL CONSTANT //OK END_VAR @@ -111,14 +110,14 @@ fn constant_on_illegal_var_blocks_cause_validation_issue() { ); // THEN everything but VAR and VAR_GLOBALS are reported - assert_validation_snapshot!(&diagnostics); + assert_snapshot!(&diagnostics); } #[test] fn constant_fb_instances_are_illegal() { // GIVEN a couple of constants, including FB instances and class-instances // WHEN it is validated - let diagnostics = parse_and_validate( + let diagnostics = parse_and_validate_buffered( " FUNCTION_BLOCK MyFb ; @@ -140,14 +139,14 @@ fn constant_fb_instances_are_illegal() { ); // THEN everything but VAR and VAR_GLOBALS are reported - assert_validation_snapshot!(&diagnostics); + assert_snapshot!(&diagnostics); } #[test] fn sized_varargs_require_type() { // GIVEN a function with a untyped sized variadic argument // WHEN it is validated - let diagnostics = parse_and_validate( + let diagnostics = parse_and_validate_buffered( " FUNCTION f_with_var : INT VAR_INPUT @@ -158,15 +157,16 @@ fn sized_varargs_require_type() { ", ); - assert_validation_snapshot!(&diagnostics); + assert_snapshot!(&diagnostics); } mod overflows { - use crate::{assert_validation_snapshot, test_utils::tests::parse_and_validate}; + use crate::test_utils::tests::parse_and_validate_buffered; + use insta::assert_snapshot; #[test] fn overflows_with_literals() { - let diagnostics = parse_and_validate( + let diagnostics = parse_and_validate_buffered( " FUNCTION main : DINT VAR @@ -206,12 +206,12 @@ mod overflows { ", ); - assert_validation_snapshot!(diagnostics); + assert_snapshot!(diagnostics); } #[test] fn overflows_with_expressions() { - let diagnostics = parse_and_validate( + let diagnostics = parse_and_validate_buffered( " FUNCTION main : DINT VAR @@ -251,12 +251,12 @@ mod overflows { ", ); - assert_validation_snapshot!(diagnostics); + assert_snapshot!(diagnostics); } #[test] fn overflows_with_globals() { - let diagnostics = parse_and_validate( + let diagnostics = parse_and_validate_buffered( " VAR_GLOBAL a : INT := 32768; @@ -265,12 +265,12 @@ mod overflows { ", ); - assert_validation_snapshot!(diagnostics); + assert_snapshot!(diagnostics); } #[test] fn overflows_with_aliases() { - let diagnostics = parse_and_validate( + let diagnostics = parse_and_validate_buffered( " TYPE MyINT : INT := 60000; END_TYPE TYPE MyREAL : REAL := 3.50282347E+38; END_TYPE @@ -278,12 +278,12 @@ mod overflows { ", ); - assert_validation_snapshot!(diagnostics); + assert_snapshot!(diagnostics); } #[test] fn overflows_with_constants() { - let diagnostics = parse_and_validate( + let diagnostics = parse_and_validate_buffered( " VAR_GLOBAL CONSTANT a : INT := 16384; // OK @@ -293,12 +293,12 @@ mod overflows { ", ); - assert_validation_snapshot!(diagnostics); + assert_snapshot!(diagnostics); } #[test] fn overflows_with_non_global_constants() { - let diagnostics = parse_and_validate( + let diagnostics = parse_and_validate_buffered( " VAR_GLOBAL a : INT := 16384; // OK @@ -311,11 +311,7 @@ mod overflows { // As of now we do not evaluate `c` because the variable block isn't defined to be constant. // If at some point we support evaluation such cases, this test should fail. See also: // https://github.com/PLC-lang/rusty/issues/847 - assert_eq!(diagnostics.len(), 1); - assert_eq!( - diagnostics[0].get_message(), - "Unresolved constant 'c' variable: 'a' is no const reference" - ); + assert_snapshot!(diagnostics) } #[test] @@ -323,7 +319,7 @@ mod overflows { // TODO(volsa): We currently only detect the first overflow value inside an array-initalizer because // the `evaluate_with_target_hint` method will return an error after it first detected such a value (i.e. // after `-1`). - let diagnostics = parse_and_validate( + let diagnostics = parse_and_validate_buffered( " VAR_GLOBAL arr : ARRAY[0..5] OF UINT := [0, -1, -2, -3, -4, -5]; @@ -331,12 +327,12 @@ mod overflows { ", ); - assert_validation_snapshot!(diagnostics) + assert_snapshot!(diagnostics) } #[test] fn overflows_with_not() { - let diagnostics = parse_and_validate( + let diagnostics = parse_and_validate_buffered( " VAR_GLOBAL x : UINT := 1234; // OK @@ -345,12 +341,12 @@ mod overflows { ", ); - assert_validation_snapshot!(diagnostics); + assert_snapshot!(diagnostics); } #[test] fn overflows_with_hex() { - let diagnostics = parse_and_validate( + let diagnostics = parse_and_validate_buffered( " VAR_GLOBAL x : UINT := WORD#16#ffff; // OK @@ -359,7 +355,7 @@ mod overflows { ", ); - assert_validation_snapshot!(diagnostics); + assert_snapshot!(diagnostics); } } From 0ae481175d285c1881b0bbcdbbb4000a1d22b4e8 Mon Sep 17 00:00:00 2001 From: Ghaith Hachem Date: Tue, 30 Jan 2024 10:29:06 +0100 Subject: [PATCH 26/33] feat(diagnostics): refactor the diagnostics to be more consistant (#1063) * feat(#826): refactor the diagnostics to be more consistant Diagnostics are now created using builder methods, and are no longer enums. A severity field now indicates the default severity of a diagnostic. This can be overridden in a diagnostian. This is yet to be implemented. We now use Anyhow to report some errors to simplify conversions between our Diagnostic type and some rust types. * feat: rework the errors and diagnostics Errors / Diagnostics are now of a single type and can be constructed using a builder pattern. The error codes are now a string value instead of an enum, each error can now have a description. At a later stage the descriptions would be accessible from the command line and the book, for now they do nothing. This now allows the option make erros configurable using the Diagnostician so that the user can ignore certain warnings or upgrade a warning to an error. With this commit all erros will now break compilation. This has not yet been tested with existing code but I assume in the current state we will have issues. We should test this with oscat and internal projects before commiting to decide if the severity we set as default is OK. * Convert pointer error to warning, fix a false positive * fix: array bounds are dint not int The location problems in the validation snap are still open. * Make sure snapshots are still valid The snapshots were re-applied after we switched them to buffered diagnostics. Some issues were fixed as a result --- .vscode/launch.json | 4 +- Cargo.lock | 5 + Cargo.toml | 5 +- compiler/plc_ast/src/ast.rs | 39 +- compiler/plc_diagnostics/Cargo.toml | 2 + compiler/plc_diagnostics/src/diagnostician.rs | 34 +- compiler/plc_diagnostics/src/diagnostics.rs | 1117 ++++++----------- compiler/plc_diagnostics/src/errno.rs | 116 -- .../plc_diagnostics/src/error_codes/E001.md | 4 + .../plc_diagnostics/src/error_codes/E002.md | 4 + .../plc_diagnostics/src/error_codes/E003.md | 3 + .../plc_diagnostics/src/error_codes/E004.md | 3 + .../plc_diagnostics/src/error_codes/E005.md | 5 + .../plc_diagnostics/src/error_codes/E006.md | 19 + .../plc_diagnostics/src/error_codes/E007.md | 3 + .../plc_diagnostics/src/error_codes/E008.md | 1 + .../plc_diagnostics/src/error_codes/E009.md | 1 + .../plc_diagnostics/src/error_codes/E010.md | 1 + .../plc_diagnostics/src/error_codes/E011.md | 1 + .../plc_diagnostics/src/error_codes/E012.md | 1 + .../plc_diagnostics/src/error_codes/E013.md | 1 + .../plc_diagnostics/src/error_codes/E014.md | 1 + .../plc_diagnostics/src/error_codes/E015.md | 1 + .../plc_diagnostics/src/error_codes/E016.md | 1 + .../plc_diagnostics/src/error_codes/E017.md | 1 + .../plc_diagnostics/src/error_codes/E018.md | 1 + .../plc_diagnostics/src/error_codes/E019.md | 1 + .../plc_diagnostics/src/error_codes/E020.md | 1 + .../plc_diagnostics/src/error_codes/E021.md | 1 + .../plc_diagnostics/src/error_codes/E022.md | 1 + .../plc_diagnostics/src/error_codes/E023.md | 1 + .../plc_diagnostics/src/error_codes/E024.md | 1 + .../plc_diagnostics/src/error_codes/E025.md | 1 + .../plc_diagnostics/src/error_codes/E026.md | 1 + .../plc_diagnostics/src/error_codes/E027.md | 1 + .../plc_diagnostics/src/error_codes/E028.md | 1 + .../plc_diagnostics/src/error_codes/E029.md | 1 + .../plc_diagnostics/src/error_codes/E030.md | 1 + .../plc_diagnostics/src/error_codes/E031.md | 1 + .../plc_diagnostics/src/error_codes/E032.md | 1 + .../plc_diagnostics/src/error_codes/E033.md | 1 + .../plc_diagnostics/src/error_codes/E034.md | 1 + .../plc_diagnostics/src/error_codes/E035.md | 1 + .../plc_diagnostics/src/error_codes/E036.md | 1 + .../plc_diagnostics/src/error_codes/E037.md | 1 + .../plc_diagnostics/src/error_codes/E038.md | 1 + .../plc_diagnostics/src/error_codes/E039.md | 1 + .../plc_diagnostics/src/error_codes/E040.md | 1 + .../plc_diagnostics/src/error_codes/E041.md | 1 + .../plc_diagnostics/src/error_codes/E042.md | 1 + .../plc_diagnostics/src/error_codes/E043.md | 1 + .../plc_diagnostics/src/error_codes/E044.md | 1 + .../plc_diagnostics/src/error_codes/E045.md | 1 + .../plc_diagnostics/src/error_codes/E046.md | 1 + .../plc_diagnostics/src/error_codes/E047.md | 1 + .../plc_diagnostics/src/error_codes/E048.md | 1 + .../plc_diagnostics/src/error_codes/E049.md | 1 + .../plc_diagnostics/src/error_codes/E050.md | 1 + .../plc_diagnostics/src/error_codes/E051.md | 1 + .../plc_diagnostics/src/error_codes/E052.md | 1 + .../plc_diagnostics/src/error_codes/E053.md | 1 + .../plc_diagnostics/src/error_codes/E054.md | 1 + .../plc_diagnostics/src/error_codes/E055.md | 1 + .../plc_diagnostics/src/error_codes/E056.md | 1 + .../plc_diagnostics/src/error_codes/E057.md | 1 + .../plc_diagnostics/src/error_codes/E058.md | 1 + .../plc_diagnostics/src/error_codes/E059.md | 1 + .../plc_diagnostics/src/error_codes/E060.md | 1 + .../plc_diagnostics/src/error_codes/E061.md | 1 + .../plc_diagnostics/src/error_codes/E062.md | 1 + .../plc_diagnostics/src/error_codes/E063.md | 1 + .../plc_diagnostics/src/error_codes/E064.md | 1 + .../plc_diagnostics/src/error_codes/E065.md | 1 + .../plc_diagnostics/src/error_codes/E066.md | 1 + .../plc_diagnostics/src/error_codes/E067.md | 1 + .../plc_diagnostics/src/error_codes/E068.md | 1 + .../plc_diagnostics/src/error_codes/E069.md | 1 + .../plc_diagnostics/src/error_codes/E070.md | 1 + .../plc_diagnostics/src/error_codes/E071.md | 1 + .../plc_diagnostics/src/error_codes/E072.md | 1 + .../plc_diagnostics/src/error_codes/E073.md | 1 + .../plc_diagnostics/src/error_codes/E074.md | 1 + .../plc_diagnostics/src/error_codes/E075.md | 1 + .../plc_diagnostics/src/error_codes/E076.md | 1 + .../plc_diagnostics/src/error_codes/E077.md | 1 + .../plc_diagnostics/src/error_codes/E078.md | 1 + .../plc_diagnostics/src/error_codes/E079.md | 1 + .../plc_diagnostics/src/error_codes/E080.md | 1 + .../plc_diagnostics/src/error_codes/E081.md | 1 + .../plc_diagnostics/src/error_codes/E082.md | 1 + .../plc_diagnostics/src/error_codes/E083.md | 1 + .../plc_diagnostics/src/error_codes/E084.md | 1 + .../plc_diagnostics/src/error_codes/E085.md | 1 + .../plc_diagnostics/src/error_codes/E086.md | 1 + .../plc_diagnostics/src/error_codes/E087.md | 1 + .../plc_diagnostics/src/error_codes/E088.md | 1 + .../plc_diagnostics/src/error_codes/E089.md | 1 + .../plc_diagnostics/src/error_codes/E090.md | 1 + compiler/plc_diagnostics/src/lib.rs | 1 - compiler/plc_diagnostics/src/reporter.rs | 2 +- .../plc_diagnostics/src/reporter/clang.rs | 2 +- .../plc_diagnostics/src/reporter/codespan.rs | 4 +- compiler/plc_driver/Cargo.toml | 1 + compiler/plc_driver/src/lib.rs | 20 +- compiler/plc_driver/src/main.rs | 8 +- compiler/plc_driver/src/pipelines.rs | 24 +- .../plc_driver/src/tests/external_files.rs | 12 +- ...thout_including_file_results_in_error.snap | 5 + compiler/plc_index/src/lib.rs | 18 +- compiler/plc_project/Cargo.toml | 1 + compiler/plc_project/src/build_config.rs | 29 +- compiler/plc_project/src/project.rs | 13 +- ...onal_fields_reports_unexpected_fields.snap | 2 +- ..._with_empty_files_array_reports_error.snap | 2 +- ...h_invalid_enum_variants_reports_error.snap | 2 +- ...g_required_properties_reports_error-2.snap | 2 +- ...ing_required_properties_reports_error.snap | 2 +- compiler/plc_xml/src/model/fbd.rs | 21 +- ..._sink_source_connections_are_an_error.snap | 66 +- ...ed_sink_removed_from_model_with_error.snap | 22 +- ...sts__unconnected_source_has_no_effect.snap | 22 +- compiler/plc_xml/src/xml_parser/control.rs | 10 +- ...d_jump_generated_as_empty_statement-2.snap | 26 +- ...r__control__tests__unnamed_controls-2.snap | 52 +- ...chained_to_another_conditional_return.snap | 86 +- ...conditional_return_without_connection.snap | 30 +- ...recursion_does_not_overflow_the_stack.snap | 84 +- ...rser__tests__unassociated_connections.snap | 28 +- ...arser__tests__unconnected_connections.snap | 28 +- libs/stdlib/iec61131-st/string_conversion.st | 24 +- libs/stdlib/src/string_conversion.rs | 46 + libs/stdlib/tests/common/mod.rs | 4 + src/builtins.rs | 28 +- src/codegen.rs | 32 +- src/codegen/debug.rs | 7 +- src/codegen/generators/data_type_generator.rs | 21 +- .../generators/expression_generator.rs | 40 +- src/codegen/generators/llvm.rs | 4 +- src/codegen/generators/pou_generator.rs | 8 +- src/codegen/generators/statement_generator.rs | 18 +- src/codegen/generators/variable_generator.rs | 9 +- src/codegen/tests/switch_case_tests.rs | 12 +- src/hardware_binding.rs | 14 +- src/index/visitor.rs | 4 +- src/lexer.rs | 12 +- src/lexer/tests/lexer_tests.rs | 4 +- src/linker.rs | 11 +- src/parser.rs | 86 +- src/parser/control_parser.rs | 9 +- src/parser/expressions_parser.rs | 44 +- ...function_return_type_with_initializer.snap | 4 +- ...tring_with_round_parens_can_be_parsed.snap | 4 +- ...inter_type_with_wrong_keyword_to_test.snap | 4 +- ...s_tests__pointer_type_without_to_test.snap | 4 +- ...ser_tests__actions_with_invalid_token.snap | 36 +- ...nction_inline_enum_return_unsupported.snap | 4 +- ...tion_inline_struct_return_unsupported.snap | 4 +- ...r_tests__global_pointer_declaration-3.snap | 4 +- src/resolver/const_evaluator.rs | 2 +- src/resolver/tests/const_resolver_tests.rs | 6 +- src/resolver/tests/resolve_literals_tests.rs | 6 +- src/typesystem.rs | 4 + src/validation.rs | 4 +- src/validation/array.rs | 26 +- src/validation/global.rs | 37 +- src/validation/pou.rs | 72 +- src/validation/recursive.rs | 19 +- src/validation/statement.rs | 455 ++++--- ..._tests__pointer_assignment_validation.snap | 8 +- ...n_tests__struct_assignment_validation.snap | 24 +- ...validation_test__bitaccess_range_test.snap | 16 +- ...alidation_test__byteaccess_range_test.snap | 12 +- ...lidation_test__dwordaccess_range_test.snap | 4 +- ...alidation_test__wordaccess_range_test.snap | 8 +- ...ltins_called_with_invalid_param_count.snap | 4 +- ...n_tests__any_bit_does_not_allow_chars.snap | 8 +- ...on_tests__any_bit_does_not_allow_date.snap | 20 +- ...on_tests__any_bit_does_not_allow_ints.snap | 32 +- ...n_tests__any_bit_does_not_allow_reals.snap | 8 +- ..._tests__any_bit_does_not_allow_string.snap | 8 +- ...on_tests__any_bit_does_not_allow_time.snap | 8 +- ...on_tests__any_bit_multiple_parameters.snap | 28 +- ...n_tests__any_char_does_not_allow_bits.snap | 20 +- ...n_tests__any_char_does_not_allow_date.snap | 20 +- ...n_tests__any_char_does_not_allow_ints.snap | 32 +- ..._tests__any_char_does_not_allow_reals.snap | 8 +- ...tests__any_char_does_not_allow_string.snap | 8 +- ...n_tests__any_char_does_not_allow_time.snap | 8 +- ...n_tests__any_char_multiple_parameters.snap | 28 +- ..._tests__any_chars_does_not_allow_bits.snap | 20 +- ..._tests__any_chars_does_not_allow_date.snap | 20 +- ..._tests__any_chars_does_not_allow_ints.snap | 32 +- ...tests__any_chars_does_not_allow_reals.snap | 8 +- ..._tests__any_chars_does_not_allow_time.snap | 8 +- ..._tests__any_chars_multiple_parameters.snap | 24 +- ...n_tests__any_date_does_not_allow_bits.snap | 20 +- ..._tests__any_date_does_not_allow_chars.snap | 8 +- ...n_tests__any_date_does_not_allow_ints.snap | 32 +- ..._tests__any_date_does_not_allow_reals.snap | 8 +- ...tests__any_date_does_not_allow_string.snap | 8 +- ...n_tests__any_date_does_not_allow_time.snap | 8 +- ...n_tests__any_date_multiple_parameters.snap | 28 +- ...sts__any_duration_does_not_allow_bits.snap | 20 +- ...ts__any_duration_does_not_allow_chars.snap | 8 +- ...sts__any_duration_does_not_allow_date.snap | 20 +- ...sts__any_duration_does_not_allow_ints.snap | 32 +- ...ts__any_duration_does_not_allow_reals.snap | 8 +- ...s__any_duration_does_not_allow_string.snap | 8 +- ...sts__any_duration_multiple_parameters.snap | 28 +- ...on_tests__any_int_does_not_allow_bits.snap | 20 +- ...n_tests__any_int_does_not_allow_chars.snap | 8 +- ...on_tests__any_int_does_not_allow_date.snap | 20 +- ...n_tests__any_int_does_not_allow_reals.snap | 8 +- ..._tests__any_int_does_not_allow_string.snap | 8 +- ...on_tests__any_int_does_not_allow_time.snap | 8 +- ...on_tests__any_int_multiple_parameters.snap | 24 +- ...ts__any_magnitude_does_not_allow_bits.snap | 20 +- ...s__any_magnitude_does_not_allow_chars.snap | 8 +- ...ts__any_magnitude_does_not_allow_date.snap | 20 +- ..._any_magnitude_does_not_allow_strings.snap | 8 +- ...ts__any_magnitude_multiple_parameters.snap | 16 +- ...on_tests__any_num_does_not_allow_bits.snap | 20 +- ...n_tests__any_num_does_not_allow_chars.snap | 8 +- ...on_tests__any_num_does_not_allow_date.snap | 20 +- ...tests__any_num_does_not_allow_strings.snap | 8 +- ...on_tests__any_num_does_not_allow_time.snap | 8 +- ...on_tests__any_num_multiple_parameters.snap | 20 +- ...n_tests__any_real_does_not_allow_bits.snap | 20 +- ..._tests__any_real_does_not_allow_chars.snap | 8 +- ...n_tests__any_real_does_not_allow_date.snap | 20 +- ...tests__any_real_does_not_allow_string.snap | 8 +- ...n_tests__any_real_does_not_allow_time.snap | 8 +- ...n_tests__any_real_multiple_parameters.snap | 20 +- ...tests__any_signed_does_not_allow_bits.snap | 20 +- ...ests__any_signed_does_not_allow_chars.snap | 8 +- ...tests__any_signed_does_not_allow_date.snap | 20 +- ...ests__any_signed_does_not_allow_reals.snap | 8 +- ...sts__any_signed_does_not_allow_string.snap | 8 +- ...tests__any_signed_does_not_allow_time.snap | 8 +- ...y_signed_does_not_allow_unsigned_ints.snap | 16 +- ...tests__any_signed_multiple_parameters.snap | 28 +- ...tests__any_string_does_not_allow_bits.snap | 20 +- ...ests__any_string_does_not_allow_chars.snap | 8 +- ...tests__any_string_does_not_allow_date.snap | 20 +- ...tests__any_string_does_not_allow_ints.snap | 32 +- ...ests__any_string_does_not_allow_reals.snap | 8 +- ...tests__any_string_does_not_allow_time.snap | 8 +- ...tests__any_string_multiple_parameters.snap | 28 +- ...sts__any_unsigned_does_not_allow_bits.snap | 20 +- ...ts__any_unsigned_does_not_allow_chars.snap | 8 +- ...sts__any_unsigned_does_not_allow_date.snap | 20 +- ...ts__any_unsigned_does_not_allow_reals.snap | 8 +- ...y_unsigned_does_not_allow_signed_ints.snap | 16 +- ...s__any_unsigned_does_not_allow_string.snap | 8 +- ...sts__any_unsigned_does_not_allow_time.snap | 8 +- ...sts__any_unsigned_multiple_parameters.snap | 28 +- ...tests__non_resolved_generics_reported.snap | 4 +- ..._tests__literal_cast_with_non_literal.snap | 4 +- ...ation_tests__function_has_super_class.snap | 4 +- ...dation_tests__program_has_super_class.snap | 4 +- ...on_tests__arrays__one_cycle_aba_input.snap | 5 +- ...n_tests__arrays__one_cycle_aba_output.snap | 5 +- ...lidation_tests__arrays__one_cycle_bcb.snap | 5 +- ...e_with_multiple_identical_members_aba.snap | 5 +- ..._tests__arrays__two_cycles_aa_and_aba.snap | 5 +- ..._arrays__two_cycles_with_branch_input.snap | 10 +- ...__functionblocks__one_cycle_aba_input.snap | 5 +- ..._functionblocks__one_cycle_aba_output.snap | 5 +- ...ts__functionblocks__one_cycle_aba_var.snap | 5 +- ...nblocks__two_cycles_with_branch_input.snap | 10 +- ...d_functionblocks__one_cycle_aba_input.snap | 5 +- ..._functionblocks__one_cycle_aba_output.snap | 5 +- ...nblocks__two_cycles_with_branch_input.snap | 10 +- ...idation_tests__structs__one_cycle_aba.snap | 5 +- ...dation_tests__structs__one_cycle_abca.snap | 5 +- ...idation_tests__structs__one_cycle_bcb.snap | 5 +- ...e_with_multiple_identical_members_aba.snap | 5 +- ...tests__structs__two_cycles_aa_and_aba.snap | 5 +- ...structs__two_cycles_branch_cc_and_cec.snap | 5 +- ...ests__structs__two_cycles_with_branch.snap | 10 +- ...resolve_function_calls_and_parameters.snap | 6 + ...ll_type_to_pointer_result_in_an_error.snap | 4 +- ...validation_tests__assigning_to_rvalue.snap | 16 +- ...ith_incorrect_operator_causes_warning.snap | 4 +- ...tests__exlicit_param_different_casing.snap | 5 + ...ests__exlicit_param_unknown_reference.snap | 17 + ...nce_assignments_in_function_arguments.snap | 24 +- ...icate_integer_non_const_var_reference.snap | 16 +- ...s__builtins_called_with_invalid_index.snap | 24 +- ...ts__overflows__overflows_with_aliases.snap | 6 +- ...ows__overflows_with_array_initializer.snap | 2 +- ...__overflows__overflows_with_constants.snap | 2 +- ...overflows__overflows_with_expressions.snap | 40 +- ...ts__overflows__overflows_with_globals.snap | 4 +- ..._tests__overflows__overflows_with_hex.snap | 2 +- ...s__overflows__overflows_with_literals.snap | 40 +- ...__overflows_with_non_global_constants.snap | 4 +- ..._tests__overflows__overflows_with_not.snap | 2 +- ...ion_tests__sized_varargs_require_type.snap | 4 +- ...__unresolvable_variables_are_reported.snap | 8 +- .../tests/statement_validation_tests.rs | 52 + src/validation/types.rs | 23 +- src/validation/variable.rs | 91 +- .../arithmetic_functions/multiplication.rs | 2 +- .../correctness/comparison_functions/equal.rs | 10 +- .../comparison_functions/greater_than.rs | 10 +- .../greater_than_or_equal.rs | 10 +- .../comparison_functions/less_than.rs | 10 +- .../less_than_or_equal.rs | 10 +- .../comparison_functions/not_equal.rs | 10 +- tests/integration/cfc.rs | 2 +- tests/integration/cfc/validation_tests.rs | 2 +- tests/integration/linking.rs | 6 +- ...on__cfc__ir__conditional_return_debug.snap | 27 +- 314 files changed, 2673 insertions(+), 2513 deletions(-) delete mode 100644 compiler/plc_diagnostics/src/errno.rs create mode 100644 compiler/plc_diagnostics/src/error_codes/E001.md create mode 100644 compiler/plc_diagnostics/src/error_codes/E002.md create mode 100644 compiler/plc_diagnostics/src/error_codes/E003.md create mode 100644 compiler/plc_diagnostics/src/error_codes/E004.md create mode 100644 compiler/plc_diagnostics/src/error_codes/E005.md create mode 100644 compiler/plc_diagnostics/src/error_codes/E006.md create mode 100644 compiler/plc_diagnostics/src/error_codes/E007.md create mode 100644 compiler/plc_diagnostics/src/error_codes/E008.md create mode 100644 compiler/plc_diagnostics/src/error_codes/E009.md create mode 100644 compiler/plc_diagnostics/src/error_codes/E010.md create mode 100644 compiler/plc_diagnostics/src/error_codes/E011.md create mode 100644 compiler/plc_diagnostics/src/error_codes/E012.md create mode 100644 compiler/plc_diagnostics/src/error_codes/E013.md create mode 100644 compiler/plc_diagnostics/src/error_codes/E014.md create mode 100644 compiler/plc_diagnostics/src/error_codes/E015.md create mode 100644 compiler/plc_diagnostics/src/error_codes/E016.md create mode 100644 compiler/plc_diagnostics/src/error_codes/E017.md create mode 100644 compiler/plc_diagnostics/src/error_codes/E018.md create mode 100644 compiler/plc_diagnostics/src/error_codes/E019.md create mode 100644 compiler/plc_diagnostics/src/error_codes/E020.md create mode 100644 compiler/plc_diagnostics/src/error_codes/E021.md create mode 100644 compiler/plc_diagnostics/src/error_codes/E022.md create mode 100644 compiler/plc_diagnostics/src/error_codes/E023.md create mode 100644 compiler/plc_diagnostics/src/error_codes/E024.md create mode 100644 compiler/plc_diagnostics/src/error_codes/E025.md create mode 100644 compiler/plc_diagnostics/src/error_codes/E026.md create mode 100644 compiler/plc_diagnostics/src/error_codes/E027.md create mode 100644 compiler/plc_diagnostics/src/error_codes/E028.md create mode 100644 compiler/plc_diagnostics/src/error_codes/E029.md create mode 100644 compiler/plc_diagnostics/src/error_codes/E030.md create mode 100644 compiler/plc_diagnostics/src/error_codes/E031.md create mode 100644 compiler/plc_diagnostics/src/error_codes/E032.md create mode 100644 compiler/plc_diagnostics/src/error_codes/E033.md create mode 100644 compiler/plc_diagnostics/src/error_codes/E034.md create mode 100644 compiler/plc_diagnostics/src/error_codes/E035.md create mode 100644 compiler/plc_diagnostics/src/error_codes/E036.md create mode 100644 compiler/plc_diagnostics/src/error_codes/E037.md create mode 100644 compiler/plc_diagnostics/src/error_codes/E038.md create mode 100644 compiler/plc_diagnostics/src/error_codes/E039.md create mode 100644 compiler/plc_diagnostics/src/error_codes/E040.md create mode 100644 compiler/plc_diagnostics/src/error_codes/E041.md create mode 100644 compiler/plc_diagnostics/src/error_codes/E042.md create mode 100644 compiler/plc_diagnostics/src/error_codes/E043.md create mode 100644 compiler/plc_diagnostics/src/error_codes/E044.md create mode 100644 compiler/plc_diagnostics/src/error_codes/E045.md create mode 100644 compiler/plc_diagnostics/src/error_codes/E046.md create mode 100644 compiler/plc_diagnostics/src/error_codes/E047.md create mode 100644 compiler/plc_diagnostics/src/error_codes/E048.md create mode 100644 compiler/plc_diagnostics/src/error_codes/E049.md create mode 100644 compiler/plc_diagnostics/src/error_codes/E050.md create mode 100644 compiler/plc_diagnostics/src/error_codes/E051.md create mode 100644 compiler/plc_diagnostics/src/error_codes/E052.md create mode 100644 compiler/plc_diagnostics/src/error_codes/E053.md create mode 100644 compiler/plc_diagnostics/src/error_codes/E054.md create mode 100644 compiler/plc_diagnostics/src/error_codes/E055.md create mode 100644 compiler/plc_diagnostics/src/error_codes/E056.md create mode 100644 compiler/plc_diagnostics/src/error_codes/E057.md create mode 100644 compiler/plc_diagnostics/src/error_codes/E058.md create mode 100644 compiler/plc_diagnostics/src/error_codes/E059.md create mode 100644 compiler/plc_diagnostics/src/error_codes/E060.md create mode 100644 compiler/plc_diagnostics/src/error_codes/E061.md create mode 100644 compiler/plc_diagnostics/src/error_codes/E062.md create mode 100644 compiler/plc_diagnostics/src/error_codes/E063.md create mode 100644 compiler/plc_diagnostics/src/error_codes/E064.md create mode 100644 compiler/plc_diagnostics/src/error_codes/E065.md create mode 100644 compiler/plc_diagnostics/src/error_codes/E066.md create mode 100644 compiler/plc_diagnostics/src/error_codes/E067.md create mode 100644 compiler/plc_diagnostics/src/error_codes/E068.md create mode 100644 compiler/plc_diagnostics/src/error_codes/E069.md create mode 100644 compiler/plc_diagnostics/src/error_codes/E070.md create mode 100644 compiler/plc_diagnostics/src/error_codes/E071.md create mode 100644 compiler/plc_diagnostics/src/error_codes/E072.md create mode 100644 compiler/plc_diagnostics/src/error_codes/E073.md create mode 100644 compiler/plc_diagnostics/src/error_codes/E074.md create mode 100644 compiler/plc_diagnostics/src/error_codes/E075.md create mode 100644 compiler/plc_diagnostics/src/error_codes/E076.md create mode 100644 compiler/plc_diagnostics/src/error_codes/E077.md create mode 100644 compiler/plc_diagnostics/src/error_codes/E078.md create mode 100644 compiler/plc_diagnostics/src/error_codes/E079.md create mode 100644 compiler/plc_diagnostics/src/error_codes/E080.md create mode 100644 compiler/plc_diagnostics/src/error_codes/E081.md create mode 100644 compiler/plc_diagnostics/src/error_codes/E082.md create mode 100644 compiler/plc_diagnostics/src/error_codes/E083.md create mode 100644 compiler/plc_diagnostics/src/error_codes/E084.md create mode 100644 compiler/plc_diagnostics/src/error_codes/E085.md create mode 100644 compiler/plc_diagnostics/src/error_codes/E086.md create mode 100644 compiler/plc_diagnostics/src/error_codes/E087.md create mode 100644 compiler/plc_diagnostics/src/error_codes/E088.md create mode 100644 compiler/plc_diagnostics/src/error_codes/E089.md create mode 100644 compiler/plc_diagnostics/src/error_codes/E090.md create mode 100644 compiler/plc_driver/src/tests/snapshots/plc_driver__tests__external_files__calling_external_file_function_without_including_file_results_in_error.snap create mode 100644 src/validation/tests/snapshots/rusty__validation__tests__statement_validation_tests__exlicit_param_different_casing.snap create mode 100644 src/validation/tests/snapshots/rusty__validation__tests__statement_validation_tests__exlicit_param_unknown_reference.snap diff --git a/.vscode/launch.json b/.vscode/launch.json index bf585bf031..c47ec79013 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -20,7 +20,9 @@ } }, "args": [ - "target/demo.st" + "--check", + "target/demo.st", + "-i","libs/stdlib/iec61131-st/timers.st" ], "cwd": "${workspaceFolder}" }, diff --git a/Cargo.lock b/Cargo.lock index 6f5bc9f2d6..83933171c9 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1978,7 +1978,9 @@ dependencies = [ name = "plc_diagnostics" version = "0.1.0" dependencies = [ + "anyhow", "codespan-reporting", + "lazy_static", "plc_ast", "plc_source", "serde_json", @@ -1988,6 +1990,7 @@ dependencies = [ name = "plc_driver" version = "0.1.0" dependencies = [ + "anyhow", "clap 3.2.25", "encoding_rs", "encoding_rs_io", @@ -2023,6 +2026,7 @@ dependencies = [ name = "plc_project" version = "0.1.0" dependencies = [ + "anyhow", "encoding_rs", "encoding_rs_io", "glob", @@ -2373,6 +2377,7 @@ dependencies = [ name = "rusty" version = "0.2.0" dependencies = [ + "anyhow", "chrono", "clap 3.2.25", "encoding_rs", diff --git a/Cargo.toml b/Cargo.toml index 7348c2536f..6d99fe8935 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -31,7 +31,6 @@ regex = "1" serde = { version = "1.0", features = ["derive"] } serde_json = "1" toml = "0.5" -lazy_static = "1.4.0" shell-words = "1.1.0" plc_derive = { path = "./compiler/plc_derive" } lld_rs = "140.0.0" @@ -40,6 +39,8 @@ log.workspace = true inkwell.workspace = true chrono.workspace = true itertools.workspace = true +anyhow.workspace = true +lazy_static.workspace = true [dev-dependencies] num = "0.4" @@ -81,3 +82,5 @@ encoding_rs_io = "0.1" log = "0.4" chrono = { version = "0.4", default-features = false } itertools = "0.11" +anyhow = "1.0" +lazy_static = "1.4.0" diff --git a/compiler/plc_ast/src/ast.rs b/compiler/plc_ast/src/ast.rs index 2e2e2cd1fb..43a5744da3 100644 --- a/compiler/plc_ast/src/ast.rs +++ b/compiler/plc_ast/src/ast.rs @@ -157,6 +157,30 @@ impl TypeNature { } } +impl Display for TypeNature { + fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { + let name = match self { + TypeNature::Any => "ANY", + TypeNature::Derived => "ANY_DERIVED", + TypeNature::Elementary => "ANY_ELEMENTARY", + TypeNature::Magnitude => "ANY_MAGNITUDE", + TypeNature::Num => "ANY_NUMBER", + TypeNature::Real => "ANY_REAL", + TypeNature::Int => "ANY_INT", + TypeNature::Signed => "ANY_SIGNED", + TypeNature::Unsigned => "ANY_UNSIGNED", + TypeNature::Duration => "ANY_DURATION", + TypeNature::Bit => "ANY_BIT", + TypeNature::Chars => "ANY_CHARS", + TypeNature::String => "ANY_STRING", + TypeNature::Char => "ANY_CHAR", + TypeNature::Date => "ANY_DATE", + TypeNature::__VLA => "__ANY_VLA", + }; + write!(f, "{name}") + } +} + impl DirectAccessType { /// Returns the size of the bitaccess result pub fn get_bit_width(&self) -> u64 { @@ -379,21 +403,6 @@ impl Variable { } } -pub trait DiagnosticInfo { - fn get_description(&self) -> String; - fn get_location(&self) -> SourceLocation; -} - -impl DiagnosticInfo for AstNode { - fn get_description(&self) -> String { - format!("{self:?}") - } - - fn get_location(&self) -> SourceLocation { - self.get_location() - } -} - #[derive(Clone, PartialEq)] pub enum DataTypeDeclaration { DataTypeReference { referenced_type: String, location: SourceLocation }, diff --git a/compiler/plc_diagnostics/Cargo.toml b/compiler/plc_diagnostics/Cargo.toml index c61a8f98e4..baad5e8f62 100644 --- a/compiler/plc_diagnostics/Cargo.toml +++ b/compiler/plc_diagnostics/Cargo.toml @@ -10,3 +10,5 @@ codespan-reporting = "0.11.1" plc_ast = { path = "../plc_ast" } plc_source = { path = "../plc_source" } serde_json = "1" +anyhow.workspace = true +lazy_static.workspace = true diff --git a/compiler/plc_diagnostics/src/diagnostician.rs b/compiler/plc_diagnostics/src/diagnostician.rs index 6ebbb628ef..1d1bc5651c 100644 --- a/compiler/plc_diagnostics/src/diagnostician.rs +++ b/compiler/plc_diagnostics/src/diagnostician.rs @@ -1,8 +1,7 @@ use std::collections::HashMap; use crate::{ - diagnostics::Diagnostic, - errno::ErrNo, + diagnostics::{Diagnostic, Severity}, reporter::{ clang::ClangFormatDiagnosticReporter, codespan::CodeSpanDiagnosticReporter, null::NullDiagnosticReporter, DiagnosticReporter, ResolvedDiagnostics, ResolvedLocation, @@ -35,13 +34,10 @@ impl Diagnostician { pub fn handle(&mut self, diagnostics: &[Diagnostic]) -> Severity { let resolved_diagnostics = diagnostics .iter() - .flat_map(|it| match it { - Diagnostic::CombinedDiagnostic { inner_diagnostics, .. } => { - let mut res = vec![it]; - res.extend(inner_diagnostics.iter().collect::>()); - res - } - _ => vec![it], + .flat_map(|it| { + let mut res = vec![it]; + res.extend(it.get_sub_diagnostics()); + res }) .map(|d| ResolvedDiagnostics { message: d.get_message().to_string(), @@ -148,30 +144,14 @@ pub struct DefaultDiagnosticAssessor; impl DiagnosticAssessor for DefaultDiagnosticAssessor { fn assess(&self, d: &Diagnostic) -> Severity { - match d { - // improvements become warnings - Diagnostic::ImprovementSuggestion { .. } => Severity::Warning, - _ if *d.get_type() == ErrNo::reference__unresolved => Severity::Critical, - // everything else becomes an error - _ => Severity::Error, - } + //TODO: Refer to some severity map to reassign severity here. + d.get_severity() } } -/// a diagnostics severity -#[derive(Default, Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord)] -pub enum Severity { - #[default] - Info, - Warning, - Error, - Critical, -} - impl std::fmt::Display for Severity { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { let severity = match self { - Severity::Critical => "critical", Severity::Error => "error", Severity::Warning => "warning", Severity::Info => "info", diff --git a/compiler/plc_diagnostics/src/diagnostics.rs b/compiler/plc_diagnostics/src/diagnostics.rs index 29ac67b7e2..5ed1afe340 100644 --- a/compiler/plc_diagnostics/src/diagnostics.rs +++ b/compiler/plc_diagnostics/src/diagnostics.rs @@ -1,847 +1,478 @@ -use std::{error::Error, fmt::Display, ops::Range}; - -use plc_ast::ast::{AstNode, DataTypeDeclaration, DiagnosticInfo, PouType}; +use std::fmt::Display; +use plc_ast::ast::AstNode; use plc_source::{ source_location::{SourceLocation, SourceLocationFactory}, - BuildDescriptionSource, + SourceCode, }; -use crate::errno::ErrNo; +mod diagnostics_registry { + macro_rules! add_diagnostic { + ($($number:ident, $desc:expr,)*) => { + use lazy_static::lazy_static; + lazy_static! { + static ref DIAGNOSTICS : HashMap<&'static str, &'static str> = { + let mut m : HashMap<&str, &str> = HashMap::new(); + $( m.insert(stringify!($number), $desc);)* + m + }; + } + } +} + + use std::collections::HashMap; + + #[derive(Default)] + pub struct DiagnosticsRegistry(HashMap<&'static str, &'static str>); + add_diagnostic!( + E001, + include_str!("./error_codes/E001.md"), //General Error + E002, + include_str!("./error_codes/E002.md"), //General IO Error + E003, + include_str!("./error_codes/E003.md"), //Parameter Error + E004, + include_str!("./error_codes/E004.md"), //Duplicate Symbol + E005, + include_str!("./error_codes/E005.md"), //Generic LLVM Error + E006, + include_str!("./error_codes/E006.md"), //Missing Token + E007, + include_str!("./error_codes/E007.md"), //Unexpected Token + E008, + include_str!("./error_codes/E008.md"), //Invalid Range + E009, + include_str!("./error_codes/E009.md"), //Mismatched Parantheses + E010, + include_str!("./error_codes/E010.md"), //Invalid Time Literal + E011, + include_str!("./error_codes/E011.md"), //Invalid Number + E012, + include_str!("./error_codes/E012.md"), //Missing Case Condition + E013, + include_str!("./error_codes/E013.md"), + E014, + include_str!("./error_codes/E014.md"), + E015, + include_str!("./error_codes/E015.md"), + E016, + include_str!("./error_codes/E016.md"), + E017, + include_str!("./error_codes/E017.md"), + E018, + include_str!("./error_codes/E018.md"), + E019, + include_str!("./error_codes/E019.md"), + E020, + include_str!("./error_codes/E020.md"), + E021, + include_str!("./error_codes/E021.md"), + E022, + include_str!("./error_codes/E022.md"), + E023, + include_str!("./error_codes/E023.md"), + E024, + include_str!("./error_codes/E024.md"), + E025, + include_str!("./error_codes/E025.md"), + E026, + include_str!("./error_codes/E026.md"), + E027, + include_str!("./error_codes/E027.md"), + E028, + include_str!("./error_codes/E028.md"), + E029, + include_str!("./error_codes/E029.md"), + E030, + include_str!("./error_codes/E030.md"), + E031, + include_str!("./error_codes/E031.md"), + E032, + include_str!("./error_codes/E032.md"), + E033, + include_str!("./error_codes/E033.md"), + E034, + include_str!("./error_codes/E034.md"), + E035, + include_str!("./error_codes/E035.md"), + E036, + include_str!("./error_codes/E036.md"), + E037, + include_str!("./error_codes/E037.md"), + E038, + include_str!("./error_codes/E038.md"), + E039, + include_str!("./error_codes/E039.md"), + E040, + include_str!("./error_codes/E040.md"), + E041, + include_str!("./error_codes/E041.md"), + E042, + include_str!("./error_codes/E042.md"), + E043, + include_str!("./error_codes/E043.md"), + E044, + include_str!("./error_codes/E044.md"), + E045, + include_str!("./error_codes/E045.md"), + E046, + include_str!("./error_codes/E046.md"), + E047, + include_str!("./error_codes/E047.md"), + E048, + include_str!("./error_codes/E048.md"), + E049, + include_str!("./error_codes/E049.md"), + E050, + include_str!("./error_codes/E050.md"), + E051, + include_str!("./error_codes/E051.md"), + E052, + include_str!("./error_codes/E052.md"), + E053, + include_str!("./error_codes/E053.md"), + E054, + include_str!("./error_codes/E054.md"), + E055, + include_str!("./error_codes/E055.md"), + E056, + include_str!("./error_codes/E056.md"), + E057, + include_str!("./error_codes/E057.md"), + E058, + include_str!("./error_codes/E058.md"), + E059, + include_str!("./error_codes/E059.md"), + E060, + include_str!("./error_codes/E060.md"), + E061, + include_str!("./error_codes/E061.md"), + E062, + include_str!("./error_codes/E062.md"), + E063, + include_str!("./error_codes/E063.md"), + E064, + include_str!("./error_codes/E064.md"), + E065, + include_str!("./error_codes/E065.md"), + E066, + include_str!("./error_codes/E066.md"), + E067, + include_str!("./error_codes/E067.md"), + E068, + include_str!("./error_codes/E068.md"), + E069, + include_str!("./error_codes/E069.md"), + E070, + include_str!("./error_codes/E070.md"), + E071, + include_str!("./error_codes/E071.md"), + E072, + include_str!("./error_codes/E072.md"), + E073, + include_str!("./error_codes/E073.md"), + E074, + include_str!("./error_codes/E074.md"), + E075, + include_str!("./error_codes/E075.md"), + E076, + include_str!("./error_codes/E076.md"), + E077, + include_str!("./error_codes/E077.md"), + E078, + include_str!("./error_codes/E078.md"), + E079, + include_str!("./error_codes/E079.md"), + E080, + include_str!("./error_codes/E080.md"), + E081, + include_str!("./error_codes/E081.md"), + E082, + include_str!("./error_codes/E082.md"), + E083, + include_str!("./error_codes/E083.md"), + E084, + include_str!("./error_codes/E084.md"), + E085, + include_str!("./error_codes/E085.md"), + E086, + include_str!("./error_codes/E086.md"), + E087, + include_str!("./error_codes/E087.md"), + E088, + include_str!("./error_codes/E088.md"), + E089, + include_str!("./error_codes/E089.md"), + E090, + include_str!("./error_codes/E090.md"), + ); +} pub const INTERNAL_LLVM_ERROR: &str = "internal llvm codegen error"; -#[derive(PartialEq, Eq, Debug, Clone)] -pub enum Diagnostic { - SyntaxError { message: String, range: Vec, err_no: ErrNo }, - SemanticError { message: String, range: Vec, err_no: ErrNo }, - GeneralError { message: String, err_no: ErrNo }, - ImprovementSuggestion { message: String, range: Vec }, - CombinedDiagnostic { message: String, inner_diagnostics: Vec, err_no: ErrNo }, +/// a diagnostics severity +#[derive(Default, Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord)] +pub enum Severity { + #[default] + Info, + Warning, + Error, } +/// The `Diagnostics` struct describes an issue encountered during compile time. +/// The issue is defined by an `error_code` and had a defined `severity` +/// Diagnostic severity can be overridden when being reported. #[derive(Debug)] -pub struct SerdeError { +pub struct Diagnostic { + /// The Description of the error being reported. message: String, - line: usize, - column: usize, + /// Primary location where the diagnostic occurred + primary_location: SourceLocation, + /// Seconday locations relevant to the diagnostics + secondary_locations: Option>, + /// Severity of the error being reported + severity: Severity, + /// Error code for reference in the documentation + error_code: &'static str, + /// Children of the current diagnostic + sub_diagnostics: Vec, + /// If the diagnostic is caused by an error, this field contains the original error + internal_error: Option, } -impl Display for Diagnostic { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - write!(f, "{}: {}", self.get_type(), self.get_message())?; - let location = self.get_location(); - if !location.is_undefined() { - write!(f, " at: {location}") - } else { - Ok(()) - } +impl std::error::Error for Diagnostic { + fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { + self.internal_error.as_ref().and_then(|it| it.source()) } } -impl From for Diagnostic { - fn from(e: T) -> Self { - Diagnostic::GeneralError { message: e.to_string(), err_no: ErrNo::general__io_err } +impl From for Diagnostic { + fn from(value: std::io::Error) -> Self { + Diagnostic::error(value.to_string()).with_error_code("E002").with_internal_error(value.into()) } } +/// Builder for Diagnostics impl Diagnostic { - /// Creates a new diagnostic with additional ranges - pub fn with_extra_ranges(self, ranges: &[SourceLocation]) -> Diagnostic { - match self { - Diagnostic::SyntaxError { message, mut range, err_no } => { - range.extend_from_slice(ranges); - Diagnostic::SyntaxError { message, range, err_no } - } - Diagnostic::SemanticError { message, mut range, err_no } => { - range.extend_from_slice(ranges); - Diagnostic::SyntaxError { message, range, err_no } - } - Diagnostic::ImprovementSuggestion { message, mut range } => { - range.extend_from_slice(ranges); - Diagnostic::ImprovementSuggestion { message, range } - } - _ => self, + pub fn new(message: impl Into, severity: Severity) -> Self { + Diagnostic { + message: message.into(), + severity, + primary_location: SourceLocation::undefined(), + secondary_locations: Default::default(), + error_code: "E001", //Default error if none specified + sub_diagnostics: Default::default(), + internal_error: Default::default(), } } - pub fn syntax_error(message: &str, range: SourceLocation) -> Diagnostic { - Diagnostic::SyntaxError { - message: message.to_string(), - range: vec![range], - err_no: ErrNo::syntax__generic_error, - } + pub fn error(message: impl Into) -> Self { + Self::new(message, Severity::Error) } - - pub fn unexpected_token_found(expected: &str, found: &str, range: SourceLocation) -> Diagnostic { - Diagnostic::SyntaxError { - message: format!("Unexpected token: expected {expected} but found {found}"), - range: vec![range], - err_no: ErrNo::syntax__unexpected_token, - } + pub fn warning(message: impl Into) -> Self { + Self::new(message, Severity::Warning) } - - pub fn unexpected_initializer_on_function_return(range: SourceLocation) -> Diagnostic { - Diagnostic::SyntaxError { - message: "Return types cannot have a default value".into(), - range: vec![range], - err_no: ErrNo::syntax__unexpected_token, - } + pub fn info(message: impl Into) -> Self { + Self::new(message, Severity::Info) } - pub fn return_type_not_supported(pou_type: &PouType, range: SourceLocation) -> Diagnostic { - Diagnostic::SyntaxError { - message: format!("POU Type {pou_type:?} does not support a return type. Did you mean Function?"), - range: vec![range], - err_no: ErrNo::pou__unexpected_return_type, - } + pub fn with_location(mut self, location: SourceLocation) -> Self { + self.primary_location = location; + self } - //TODO: This prints a debug version of the datatype, it should have a user readable version instead - pub fn function_unsupported_return_type(data_type: &DataTypeDeclaration) -> Diagnostic { - Diagnostic::SyntaxError { - message: format!("Data Type {data_type:?} not supported as a function return type!"), - range: vec![data_type.get_location()], - err_no: ErrNo::pou__unsupported_return_type, - } + pub fn with_secondary_location(mut self, location: SourceLocation) -> Self { + self.secondary_locations.get_or_insert_with(Default::default).push(location); + self } - pub fn function_return_missing(range: SourceLocation) -> Diagnostic { - Diagnostic::SyntaxError { - message: "Function Return type missing".into(), - range: vec![range], - err_no: ErrNo::pou__missing_return_type, - } + pub fn with_secondary_locations(mut self, locations: Vec) -> Self { + self.secondary_locations.get_or_insert_with(Default::default).extend(locations); + self } - pub fn missing_function(location: SourceLocation) -> Diagnostic { - Diagnostic::SyntaxError { - message: "Cannot generate code outside of function context.".into(), - range: vec![location], - err_no: ErrNo::codegen__missing_function, - } + pub fn with_error_code(mut self, error_code: &'static str) -> Self { + self.error_code = error_code; + self } - pub fn missing_compare_function( - function_name: &str, - data_type: &str, - location: SourceLocation, - ) -> Diagnostic { - Diagnostic::SyntaxError { - message: format!( - "Missing compare function 'FUNCTION {function_name} : BOOL VAR_INPUT a,b : {data_type}; END_VAR ...'." - ), - range: vec![location], - err_no: ErrNo::codegen__missing_compare_function, - } + pub fn with_sub_diagnostic(mut self, diagnostic: Diagnostic) -> Self { + self.sub_diagnostics.push(diagnostic); + self } - pub fn missing_token(expected_token: &str, range: SourceLocation) -> Diagnostic { - Diagnostic::SyntaxError { - message: format!("Missing expected Token {expected_token}"), - range: vec![range], - err_no: ErrNo::syntax__missing_token, - } + pub fn with_sub_diagnostics(mut self, diagnostics: Vec) -> Self { + self.sub_diagnostics.extend(diagnostics); + self } - pub fn missing_action_container(range: SourceLocation) -> Diagnostic { - Diagnostic::ImprovementSuggestion { - message: "Missing Actions Container Name".to_string(), - range: vec![range], - } + pub fn with_internal_error(mut self, error: anyhow::Error) -> Self { + self.internal_error = Some(error); + self } - pub fn unresolved_reference(reference: &str, location: SourceLocation) -> Diagnostic { - Diagnostic::SyntaxError { - message: format!("Could not resolve reference to {reference:}"), - range: vec![location], - err_no: ErrNo::reference__unresolved, - } - } + pub fn from_serde_error(error: serde_json::Error, source: &SourceCode) -> Self { + let factory = SourceLocationFactory::for_source(source); + let line = error.line(); + let column = error.column(); - pub fn illegal_access(reference: &str, location: SourceLocation) -> Diagnostic { - Diagnostic::SyntaxError { - message: format!("Illegal access to private member {reference:}"), - range: vec![location], - err_no: ErrNo::reference__illegal_access, - } + // remove line, column from message + let message = error.to_string(); + let message = if let Some(pos) = message.find("at line") { + message.chars().take(pos).collect() + } else { + message + }; + let range = factory.create_range_to_end_of_line(line, column); + Diagnostic::error(message).with_error_code("E088").with_location(range) } +} - pub fn unresolved_generic_type(symbol: &str, nature: &str, location: SourceLocation) -> Diagnostic { - Diagnostic::SyntaxError { - message: format!("Could not resolve generic type {symbol} with nature {nature}"), - range: vec![location], - err_no: ErrNo::type__unresolved_generic, - } +impl PartialOrd for Diagnostic { + fn partial_cmp(&self, other: &Self) -> Option { + self.severity.partial_cmp(&other.severity) } +} - pub fn unknown_type(type_name: &str, location: SourceLocation) -> Diagnostic { - Diagnostic::SyntaxError { - message: format!("Unknown type: {type_name:}"), - range: vec![location], - err_no: ErrNo::type__unknown_type, - } +impl Ord for Diagnostic { + fn cmp(&self, other: &Self) -> std::cmp::Ordering { + self.severity.cmp(&other.severity) } +} - pub fn casting_error(type_name: &str, target_type: &str, location: SourceLocation) -> Diagnostic { - Diagnostic::SyntaxError { - message: format!("Cannot cast from {type_name:} to {target_type:}"), - range: vec![location], - err_no: ErrNo::type__cast_error, - } +impl PartialEq for Diagnostic { + fn eq(&self, other: &Self) -> bool { + self.error_code == other.error_code + && self.message == other.message + && self.primary_location == other.primary_location + && self.secondary_locations == other.secondary_locations + && self.severity == other.severity + && self.sub_diagnostics == other.sub_diagnostics } +} - pub fn incompatible_directaccess( - access_type: &str, - access_size: u64, - location: SourceLocation, - ) -> Diagnostic { - Diagnostic::SyntaxError { - message: format!( - "{access_type}-Wise access requires a Numerical type larger than {access_size} bits" - ), - range: vec![location], - err_no: ErrNo::type__incompatible_directaccess, - } - } +impl Eq for Diagnostic {} - pub fn incompatible_directaccess_range( - access_type: &str, - target_type: &str, - access_range: Range, - location: SourceLocation, - ) -> Diagnostic { - Diagnostic::SyntaxError { - message: format!( - "{access_type}-Wise access for type {target_type} must be in the range {}..{}", - access_range.start, access_range.end - ), - range: vec![location], - err_no: ErrNo::type__incompatible_directaccess_range, +impl Display for Diagnostic { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + write!(f, "{}: {}", self.get_type(), self.get_message())?; + let location = self.get_location(); + if !location.is_undefined() { + write!(f, " at: {location}") + } else { + Ok(()) } } +} - pub fn incompatible_directaccess_variable(access_type: &str, location: SourceLocation) -> Diagnostic { - Diagnostic::SyntaxError { - message: format!( - "Invalid type {access_type} for direct variable access. Only variables of Integer types are allowed", - ), - range: vec![location], - err_no: ErrNo::type__incompatible_directaccess_variable, - } +impl Diagnostic { + pub fn get_message(&self) -> &str { + self.message.as_str() } - pub fn incompatible_array_access_range(range: Range, location: SourceLocation) -> Diagnostic { - Diagnostic::SyntaxError { - message: format!("Array access must be in the range {}..{}", range.start, range.end), - range: vec![location], - err_no: ErrNo::type__incompatible_arrayaccess_range, - } + pub fn get_location(&self) -> SourceLocation { + self.primary_location.clone() } - pub fn incompatible_array_access_variable(access_type: &str, location: SourceLocation) -> Diagnostic { - Diagnostic::SyntaxError { - message: format!( - "Invalid type {access_type} for array access. Only variables of Array types are allowed", - ), - range: vec![location], - err_no: ErrNo::type__incompatible_arrayaccess_variable, - } + pub fn get_secondary_locations(&self) -> Option<&[SourceLocation]> { + self.secondary_locations.as_deref() } - pub fn incompatible_array_access_type(access_type: &str, location: SourceLocation) -> Diagnostic { - Diagnostic::SyntaxError { - message: format!( - "Invalid type {access_type} for array access. Only variables of Integer types are allowed to access an array", - ), - range: vec![location], - err_no: ErrNo::type__incompatible_arrayaccess_variable, - } + pub fn get_type(&self) -> &'static str { + self.error_code } - pub fn incompatible_literal_cast( - cast_type: &str, - literal_type: &str, - location: SourceLocation, - ) -> Diagnostic { - Diagnostic::SyntaxError { - message: format!("Literal {literal_type} is not compatible to {cast_type}"), - range: vec![location], - err_no: ErrNo::type__incompatible_literal_cast, - } + pub fn get_severity(&self) -> Severity { + self.severity } - pub fn literal_expected(location: SourceLocation) -> Diagnostic { - Diagnostic::SyntaxError { - message: "Expected literal".into(), - range: vec![location], - err_no: ErrNo::type__expected_literal, - } + pub fn get_sub_diagnostics(&self) -> &[Diagnostic] { + &self.sub_diagnostics } +} - pub fn literal_out_of_range(literal: &str, range_hint: &str, location: SourceLocation) -> Diagnostic { - Diagnostic::SyntaxError { - message: format!("Literal {literal} out of range ({range_hint})"), - range: vec![location], - err_no: ErrNo::type__literal_out_of_range, - } +//Helper methods for diagnostics +impl Diagnostic { + pub fn unexpected_token_found(expected: &str, found: &str, range: SourceLocation) -> Diagnostic { + Diagnostic::error(format!("Unexpected token: expected {expected} but found {found}")) + .with_error_code("E007") + .with_location(range) } - pub fn reference_expected(location: SourceLocation) -> Diagnostic { - Diagnostic::SyntaxError { - message: "Expression is not assignable".into(), - range: vec![location], - err_no: ErrNo::reference__expected, - } + pub fn missing_function(location: SourceLocation) -> Diagnostic { + Diagnostic::error("Cannot generate code outside of function context.") + .with_error_code("E072") + .with_location(location) } - pub fn empty_variable_block(location: SourceLocation) -> Diagnostic { - Diagnostic::SyntaxError { - message: "Variable block is empty".into(), - range: vec![location], - err_no: ErrNo::pou__empty_variable_block, - } + pub fn codegen_error(message: impl Into, location: SourceLocation) -> Diagnostic { + Diagnostic::error(message).with_location(location).with_error_code("E071") } - pub fn unresolved_constant( - constant_name: &str, - reason: Option<&str>, - location: SourceLocation, - ) -> Diagnostic { - Diagnostic::SyntaxError { - message: format!( - "Unresolved constant '{constant_name:}' variable{:}", - reason.map(|it| format!(": {it}",)).unwrap_or_else(|| "".into()), - ), - range: vec![location], - err_no: ErrNo::var__unresolved_constant, - } + pub fn llvm_error(file: &str, llvm_error: &str) -> Diagnostic { + Diagnostic::error(format!("{file}: Internal llvm error: {:}", llvm_error)).with_error_code("E005") } - pub fn invalid_constant_block(location: SourceLocation) -> Diagnostic { - Diagnostic::SyntaxError { - message: "This variable block does not support the CONSTANT modifier".to_string(), - range: vec![location], - err_no: ErrNo::var__invalid_constant_block, - } + pub fn missing_token(expected_token: &str, range: SourceLocation) -> Diagnostic { + Diagnostic::error(format!("Missing expected Token {expected_token}")) + .with_location(range) + .with_error_code("E006") } - pub fn invalid_constant(constant_name: &str, location: SourceLocation) -> Diagnostic { - Diagnostic::SyntaxError { - message: format!( - "Invalid constant {constant_name} - Functionblock- and Class-instances cannot be delcared constant", - ), - range: vec![location], - err_no: ErrNo::var__invalid_constant, - } + pub fn invalid_parameter_count(expected: usize, received: usize, location: SourceLocation) -> Diagnostic { + Diagnostic::error( + format!( + "Invalid parameter count. Received {received} parameters while {expected} parameters were expected.", + )).with_error_code("E032") + .with_location(location) } - pub fn cannot_assign_to_constant(qualified_name: &str, location: SourceLocation) -> Diagnostic { - Diagnostic::SyntaxError { - message: format!("Cannot assign to CONSTANT '{qualified_name}'"), - range: vec![location], - err_no: ErrNo::var__cannot_assign_to_const, - } + pub fn unknown_type(type_name: &str, location: SourceLocation) -> Diagnostic { + Diagnostic::error(format!("Unknown type: {type_name:}")) + .with_error_code("E052") + .with_location(location) } - pub fn cannot_generate_initializer(variable_name: &str, location: SourceLocation) -> Diagnostic { - Self::codegen_error( - &format!("Cannot generate literal initializer for '{variable_name}': Value cannot be derived"), - location, - ) + pub fn unresolved_reference(reference: &str, location: SourceLocation) -> Diagnostic { + Diagnostic::error(format!("Could not resolve reference to {reference:}")) + .with_error_code("E048") + .with_location(location) } - pub fn codegen_error(message: &str, location: SourceLocation) -> Diagnostic { - Diagnostic::SyntaxError { - message: message.into(), - range: vec![location], - err_no: ErrNo::codegen__general, - } + pub fn invalid_assignment(right_type: &str, left_type: &str, location: SourceLocation) -> Diagnostic { + Diagnostic::error(format!("Invalid assignment: cannot assign '{right_type}' to '{left_type}'")) + .with_error_code("E037") + .with_location(location) } - pub fn debug_error>(message: T) -> Diagnostic { - Diagnostic::GeneralError { message: message.into(), err_no: ErrNo::debug_general } + pub fn cannot_generate_initializer(variable_name: &str, location: SourceLocation) -> Diagnostic { + Self::error(format!( + "Cannot generate literal initializer for '{variable_name}': Value cannot be derived" + )) + .with_error_code("E041") + .with_location(location) } - pub fn cannot_generate_call_statement(operator: &T) -> Diagnostic { + pub fn cannot_generate_call_statement(operator: &AstNode) -> Diagnostic { + //TODO: We could probably get a better slice here Diagnostic::codegen_error( - &format!("cannot generate call statement for {:?}", operator.get_description()), + format!("cannot generate call statement for {:?}", operator), operator.get_location(), ) } - pub fn io_read_error(file: &str, reason: &str) -> Diagnostic { - Diagnostic::GeneralError { - message: format!("Cannot read file '{file}': {reason}'"), - err_no: ErrNo::general__io_err, - } - } - - pub fn io_write_error(file: &str, reason: &str) -> Diagnostic { - Diagnostic::GeneralError { - message: format!("Cannot write file {file} {reason}'"), - err_no: ErrNo::general__io_err, - } - } - - pub fn param_error(reason: &str) -> Diagnostic { - Diagnostic::GeneralError { message: reason.to_string(), err_no: ErrNo::general__param_err } - } - - pub fn llvm_error(file: &str, llvm_error: &str) -> Diagnostic { - Diagnostic::GeneralError { - message: format!("{file}: Internal llvm error: {:}", llvm_error), - err_no: ErrNo::general__io_err, - } - } - pub fn cannot_generate_from_empty_literal(type_name: &str, location: SourceLocation) -> Diagnostic { Diagnostic::codegen_error( format!("Cannot generate {type_name} from empty literal").as_str(), location, ) } - - pub fn cannot_generate_string_literal(type_name: &str, location: SourceLocation) -> Diagnostic { - Diagnostic::codegen_error( - format!("Cannot generate String-Literal for type {type_name}").as_str(), - location, - ) - } - - pub fn invalid_assignment(right_type: &str, left_type: &str, location: SourceLocation) -> Diagnostic { - Diagnostic::SyntaxError { - message: format!("Invalid assignment: cannot assign '{right_type}' to '{left_type}'"), - range: vec![location], - err_no: ErrNo::var__invalid_assignment, - } - } - - pub fn invalid_type_nature(actual: &str, expected: &str, location: SourceLocation) -> Diagnostic { - Diagnostic::SyntaxError { - message: format!("Invalid type nature for generic argument. {actual} is no {expected}."), - range: vec![location], - err_no: ErrNo::type__invalid_nature, - } - } - - pub fn unknown_type_nature(nature: &str, location: SourceLocation) -> Diagnostic { - Diagnostic::SyntaxError { - message: format!("Unknown type nature {nature}."), - range: vec![location], - err_no: ErrNo::type__unknown_nature, - } - } - - pub fn missing_datatype(reason: Option<&str>, location: SourceLocation) -> Diagnostic { - Diagnostic::SyntaxError { - message: format!("Missing datatype {}", reason.unwrap_or("")), - range: vec![location], - err_no: ErrNo::var__missing_type, - } - } - - pub fn incompatible_type_size( - nature: &str, - size: u32, - error: &str, - location: SourceLocation, - ) -> Diagnostic { - Diagnostic::SyntaxError { - message: format!("The type {nature} {size} is too small to {error} Pointer"), - range: vec![location], - err_no: ErrNo::type__incompatible_size, - } - } - - pub fn link_error(error: &str) -> Diagnostic { - Diagnostic::GeneralError { err_no: ErrNo::linker__generic_error, message: error.to_string() } - } - - pub fn get_message(&self) -> &str { - match self { - Diagnostic::SyntaxError { message, .. } - | Diagnostic::SemanticError { message, .. } - | Diagnostic::ImprovementSuggestion { message, .. } - | Diagnostic::GeneralError { message, .. } - | Diagnostic::CombinedDiagnostic { message, .. } => message.as_str(), - } - } - - pub fn get_location(&self) -> SourceLocation { - match self { - Diagnostic::SyntaxError { range, .. } - | Diagnostic::SemanticError { range, .. } - | Diagnostic::ImprovementSuggestion { range, .. } => { - range.get(0).cloned().unwrap_or_else(SourceLocation::undefined) - } - _ => SourceLocation::undefined(), - } - } - - pub fn get_secondary_locations(&self) -> Option<&[SourceLocation]> { - match self { - Diagnostic::SyntaxError { range, .. } - | Diagnostic::SemanticError { range, .. } - | Diagnostic::ImprovementSuggestion { range, .. } - if range.len() > 1 => - { - Some(&range[1..]) - } - _ => None, - } - } - - pub fn get_type(&self) -> &ErrNo { - match self { - Diagnostic::SyntaxError { err_no, .. } - | Diagnostic::SemanticError { err_no, .. } - | Diagnostic::GeneralError { err_no, .. } - | Diagnostic::CombinedDiagnostic { err_no, .. } => err_no, - Diagnostic::ImprovementSuggestion { .. } => &ErrNo::undefined, - } - } - - /** - * relocates the given diagnostic to the given location if possible and returns it back - */ - pub fn relocate(it: Diagnostic, new_location: SourceLocation) -> Diagnostic { - match it { - Diagnostic::SyntaxError { message, err_no, .. } => { - Diagnostic::SyntaxError { message, range: vec![new_location], err_no } - } - Diagnostic::ImprovementSuggestion { message, .. } => { - Diagnostic::ImprovementSuggestion { message, range: vec![new_location] } - } - _ => it, - } - } - - pub fn invalid_pragma_location(message: &str, range: SourceLocation) -> Diagnostic { - Diagnostic::ImprovementSuggestion { - message: format!("Invalid pragma location: {message}"), - range: vec![range], - } - } - - pub fn non_constant_case_condition(case: &str, range: SourceLocation) -> Diagnostic { - Diagnostic::SyntaxError { - message: format!("{case}. Non constant variables are not supported in case conditions"), - range: vec![range], - err_no: ErrNo::type__invalid_type, - } - } - - pub fn duplicate_case_condition(value: &i128, range: SourceLocation) -> Diagnostic { - Diagnostic::SyntaxError { - message: format!("Duplicate condition value: {value}. Occurred more than once!"), - range: vec![range], - err_no: ErrNo::case__duplicate_condition, - } - } - - pub fn case_condition_used_outside_case_statement(range: SourceLocation) -> Diagnostic { - Diagnostic::SyntaxError { - message: "Case condition used outside of case statement! Did you mean to use ';'?".into(), - range: vec![range], - err_no: ErrNo::case__case_condition_outside_case_statement, - } - } - - pub fn invalid_case_condition(range: SourceLocation) -> Diagnostic { - Diagnostic::SyntaxError { - message: "Invalid case condition!".into(), - range: vec![range], - err_no: ErrNo::case__case_condition_outside_case_statement, - } - } - - pub fn missing_inout_parameter(parameter: &str, range: SourceLocation) -> Diagnostic { - Diagnostic::SyntaxError { - message: format!("Missing inout parameter: {parameter}"), - range: vec![range], - err_no: ErrNo::pou__missing_action_container, - } - } - - pub fn invalid_parameter_type(range: SourceLocation) -> Diagnostic { - Diagnostic::SyntaxError { - message: "Cannot mix implicit and explicit call parameters!".into(), - range: vec![range], - err_no: ErrNo::call__invalid_parameter_type, - } - } - - pub fn invalid_parameter_count(expected: usize, received: usize, range: SourceLocation) -> Diagnostic { - Diagnostic::SyntaxError { - message: format!( - "Invalid parameter count. Received {received} parameters while {expected} parameters were expected.", - ), - range: vec![range], - err_no: ErrNo::call__invalid_parameter_count, - } - } - - pub fn implicit_downcast( - actual_type_name: &str, - assigned_type_name: &str, - range: SourceLocation, - ) -> Diagnostic { - Diagnostic::ImprovementSuggestion { - message: format!( - "Potential loss of information due to assigning '{assigned_type_name}' to variable of type '{actual_type_name}'." - ), - range: vec![range], - } - } - - pub fn invalid_argument_type( - parameter_name: &str, - parameter_type: &str, - range: SourceLocation, - ) -> Diagnostic { - Diagnostic::SyntaxError { - message: format!( - "Expected a reference for parameter {parameter_name} because their type is {parameter_type}" - ), - range: vec![range], - err_no: ErrNo::call__invalid_parameter_type, - } - } - - pub fn invalid_type_name(name: &str, range: Vec) -> Diagnostic { - Diagnostic::SyntaxError { - message: format!("{name} can not be used as a name because it is a built-in datatype"), - range, - err_no: ErrNo::type__invalid_name, - } - } - - pub fn global_name_conflict( - name: &str, - location: SourceLocation, - conflicts: Vec, - ) -> Diagnostic { - Diagnostic::global_name_conflict_with_text(name, location, conflicts, "Duplicate symbol.") - } - - pub fn duplicate_label( - name: &str, - location: SourceLocation, - conflicts: Vec, - ) -> Diagnostic { - Diagnostic::global_name_conflict_with_text(name, location, conflicts, "Duplicate label.") - } - - pub fn global_name_conflict_with_text( - name: &str, - location: SourceLocation, - conflicts: Vec, - additional_text: &str, - ) -> Diagnostic { - let mut locations = vec![location]; - locations.extend(conflicts); - Diagnostic::SyntaxError { - message: format!("{name}: {additional_text}"), - range: locations, - err_no: ErrNo::duplicate_symbol, - } - } - - pub fn invalid_operation(message: &str, range: SourceLocation) -> Diagnostic { - Diagnostic::SyntaxError { - message: message.to_string(), - range: vec![range], - err_no: ErrNo::type__invalid_operation, - } - } - - pub fn array_assignment(range: SourceLocation) -> Diagnostic { - Diagnostic::SyntaxError { - message: "Array assignments must be surrounded with `[]`".to_string(), - range: vec![range], - err_no: ErrNo::arr__invalid_array_assignment, - } - } - - pub fn array_struct_assignment(range: SourceLocation) -> Diagnostic { - Diagnostic::SyntaxError { - message: "Struct initializers within arrays have to be wrapped by `()`".to_string(), - range: vec![range], - err_no: ErrNo::arr__invalid_array_assignment, - } - } - - pub fn array_size(name: &str, len_lhs: usize, len_rhs: usize, range: SourceLocation) -> Diagnostic { - Diagnostic::SemanticError { - message: format!("Array `{name}` has a size of {len_lhs}, but {len_rhs} elements were provided"), - range: vec![range], - err_no: ErrNo::arr__invalid_array_assignment, - } - } - - pub fn recursive_datastructure(path: &str, range: Vec) -> Diagnostic { - Diagnostic::SemanticError { - message: format!("Recursive data structure `{path}` has infinite size"), - range, - err_no: ErrNo::pou__recursive_data_structure, - } - } - - pub fn vla_by_val_warning(range: SourceLocation) -> Diagnostic { - Diagnostic::ImprovementSuggestion { - message: "Variable Length Arrays are always by-ref, even when declared in a by-value block" - .to_string(), - range: vec![range], - } - } - - pub fn invalid_vla_container(message: String, range: SourceLocation) -> Diagnostic { - Diagnostic::SemanticError { message, range: vec![range], err_no: ErrNo::vla__invalid_container } - } - - pub fn invalid_array_access(expected: usize, actual: usize, range: SourceLocation) -> Diagnostic { - Diagnostic::SemanticError { - message: format!("Expected array access with {expected} dimensions, found {actual}"), - range: vec![range], - err_no: ErrNo::vla__invalid_array_access, - } - } - - pub fn invalid_range_statement(entity: &AstNode, range: SourceLocation) -> Diagnostic { - Diagnostic::SyntaxError { - message: format!("Expected a range statement, got {entity:?} instead"), - range: vec![range], - err_no: ErrNo::syntax__unexpected_token, - } - } - - pub fn var_input_ref_assignment(location: SourceLocation) -> Diagnostic { - Diagnostic::ImprovementSuggestion { - message: - "VAR_INPUT {ref} variables are mutable and changes to them will also affect the referenced variable. For increased clarity use VAR_IN_OUT instead." - .into(), - range: vec![location], - } - } - - pub fn overflow(message: String, location: SourceLocation) -> Diagnostic { - Diagnostic::SemanticError { message, range: vec![location], err_no: ErrNo::var__overflow } - } - - pub fn index_out_of_bounds(range: SourceLocation) -> Diagnostic { - Diagnostic::SemanticError { - message: "Index out of bounds.".into(), - range: vec![range], - err_no: ErrNo::vla__dimension_idx_out_of_bounds, - } - } - - pub fn enum_variant_mismatch(enum_type: &str, range: SourceLocation) -> Diagnostic { - Diagnostic::SemanticError { - message: format!("Assigned value is not a variant of {enum_type}"), - range: vec![range], - err_no: ErrNo::var__invalid_enum_variant, - } - } - - pub fn assignment_instead_of_equal(lhs: &str, rhs: &str, statement: &AstNode) -> Diagnostic { - Diagnostic::ImprovementSuggestion { - message: format!("This equal statement has no effect, did you mean `{lhs} := {rhs}`?"), - range: vec![statement.get_location()], - } - } } // CFC related diagnostics impl Diagnostic { - pub fn empty_control_statement(range: SourceLocation) -> Diagnostic { - Diagnostic::SemanticError { - message: "Control statement has no connection".to_string(), - range: vec![range], - err_no: ErrNo::cfc__empty_control_statement, - } - } - - pub fn undefined_node(local_id: usize, ref_local_id: usize, range: SourceLocation) -> Diagnostic { - Diagnostic::SemanticError { - message: format!("Node {local_id} is referencing a non-existing element with ID {ref_local_id}"), - range: vec![range], - err_no: ErrNo::cfc__undefined_node, - } - } - - pub fn unexpected_nodes(range: SourceLocation) -> Diagnostic { - Diagnostic::SemanticError { - message: "Unexpected relationship between nodes".to_string(), - range: vec![range], - err_no: ErrNo::cfc__unexpected_node, - } - } - - pub fn unconnected_source(connector_name: &str, range: SourceLocation) -> Diagnostic { - Diagnostic::SemanticError { - message: format!("Source '{connector_name}' is not connected."), - range: vec![range], - err_no: ErrNo::cfc__unconnected_source, - } - } - - pub fn sink_without_associated_source(connector_name: &str, range: SourceLocation) -> Diagnostic { - Diagnostic::SemanticError { - message: format!("Expected a corresponding source-connection mark for sink '{connector_name}', but could not find one."), - range: vec![range], - err_no: ErrNo::cfc__no_associated_connector, - } - } - - pub fn cyclic_connection(message: String, range: SourceLocation) -> Diagnostic { - Diagnostic::SemanticError { - message: format!("Sink is connected to itself. Found the following recursion: {message}"), - range: vec![range], - err_no: ErrNo::cfc__cyclic_connection, - } - } - - pub fn unnamed_control(range: SourceLocation) -> Diagnostic { - Diagnostic::SemanticError { - message: "Unnamed control".into(), - range: vec![range], - err_no: ErrNo::cfc__unnamed_control, - } - } - - pub fn invalid_build_description_file(message: String, location: Option) -> Diagnostic { - let range = if let Some(range) = location { vec![range] } else { vec![SourceLocation::internal()] }; - Diagnostic::SemanticError { message, range, err_no: ErrNo::plc_json__invalid } - } -} - -// Necessary in-between step to convert serde error to diagnostics, since there is -// a conflicting `From` impl for `Diagnostic` -impl From for SerdeError { - fn from(value: serde_json::Error) -> Self { - let line = value.line(); - let column = value.column(); - - // remove line, column from message - let message = value.to_string(); - let message = if let Some(pos) = message.find("at line") { - message.chars().take(pos).collect() - } else { - message - }; - - SerdeError { message, line, column } - } -} - -impl SerdeError { - pub fn into_diagnostic(self, src: &BuildDescriptionSource) -> Diagnostic { - let factory = SourceLocationFactory::for_source(src); - let range = factory.create_range_to_end_of_line(self.line, self.column); - - Diagnostic::invalid_build_description_file(self.message, Some(range)) + pub fn unnamed_control(location: SourceLocation) -> Diagnostic { + Diagnostic::error("Unnamed control").with_error_code("E087").with_location(location) } } @@ -849,7 +480,7 @@ impl SerdeError { mod tests { use codespan_reporting::files::{Location, SimpleFile}; - use crate::{diagnostician::Severity, reporter::clang::ClangFormatDiagnosticReporter}; + use crate::{diagnostics::Severity, reporter::clang::ClangFormatDiagnosticReporter}; #[test] fn test_build_diagnostic_msg() { diff --git a/compiler/plc_diagnostics/src/errno.rs b/compiler/plc_diagnostics/src/errno.rs deleted file mode 100644 index fb3feb2855..0000000000 --- a/compiler/plc_diagnostics/src/errno.rs +++ /dev/null @@ -1,116 +0,0 @@ -use std::fmt::Display; - -#[allow(non_camel_case_types)] -#[derive(PartialEq, Eq, Debug, Clone, Copy)] -pub enum ErrNo { - undefined, - - //general - general__err, - general__io_err, - general__param_err, - duplicate_symbol, - - //syntax - syntax__generic_error, - syntax__missing_token, - syntax__unexpected_token, - - //semantic - // pou related - pou__missing_return_type, - pou__unexpected_return_type, - pou__unsupported_return_type, - pou__empty_variable_block, - pou__missing_action_container, - pou__recursive_data_structure, - - // call - call__invalid_parameter_type, - call__invalid_parameter_count, - - //variable related - var__unresolved_constant, - var__invalid_constant_block, - var__invalid_constant, - var__cannot_assign_to_const, - var__invalid_assignment, - var__missing_type, - var__assigning_to_var_input_ref, - var__overflow, - var__invalid_enum_variant, - - //array related - arr__invalid_array_assignment, - - // VLA related - vla__invalid_container, - vla__invalid_array_access, - vla__dimension_idx_out_of_bounds, - - //reference related - reference__unresolved, - reference__illegal_access, - reference__expected, - - //type related - type__cast_error, - type__unknown_type, - type__invalid_type, - type__literal_out_of_range, - type__incompatible_literal_cast, - type__incompatible_directaccess, - type__incompatible_directaccess_variable, - type__incompatible_directaccess_range, - type__incompatible_arrayaccess_range, - type__incompatible_arrayaccess_variable, - type__incompatible_arrayaccess_type, - type__expected_literal, - type__invalid_nature, - type__unknown_nature, - type__unresolved_generic, - type__incompatible_size, - type__invalid_operation, - type__invalid_name, - - //codegen related - codegen__general, - codegen__missing_function, - codegen__missing_compare_function, - - //Debug code - debug_general, - //linker - linker__generic_error, - - //switch case - case__duplicate_condition, - case__case_condition_outside_case_statement, - case__invalid_case_condition, - - // CFC related - cfc__empty_control_statement, - cfc__undefined_node, - cfc__unexpected_node, - cfc__unconnected_source, - cfc__cyclic_connection, - cfc__no_associated_connector, - cfc__unnamed_control, - - // Project description file - plc_json__invalid, -} - -impl Display for ErrNo { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - let desc = match self { - Self::general__err => "General Error".into(), - Self::codegen__general => "Codegen Error".into(), - Self::codegen__missing_compare_function => "Codegen Error: No compare function".into(), - Self::codegen__missing_function => "Codegen Error: Missing Function".into(), - _ => format!("{self:#?}"), - }; - - write!(f, "{desc}") - } -} diff --git a/compiler/plc_diagnostics/src/error_codes/E001.md b/compiler/plc_diagnostics/src/error_codes/E001.md new file mode 100644 index 0000000000..c010a25da2 --- /dev/null +++ b/compiler/plc_diagnostics/src/error_codes/E001.md @@ -0,0 +1,4 @@ +# General Error + +This error is a catch all error. It is usually thrown when no other error better matches the case. + diff --git a/compiler/plc_diagnostics/src/error_codes/E002.md b/compiler/plc_diagnostics/src/error_codes/E002.md new file mode 100644 index 0000000000..fb2def7138 --- /dev/null +++ b/compiler/plc_diagnostics/src/error_codes/E002.md @@ -0,0 +1,4 @@ +# General IO Error + +This error describes a problem during an IO operation such as reading or writing a file. +It is usually accompanied by an internal error with further details. diff --git a/compiler/plc_diagnostics/src/error_codes/E003.md b/compiler/plc_diagnostics/src/error_codes/E003.md new file mode 100644 index 0000000000..d4a295dd16 --- /dev/null +++ b/compiler/plc_diagnostics/src/error_codes/E003.md @@ -0,0 +1,3 @@ +# Parameter Error + +This error describes a problem with the command parameters, such as a file required for the compilation not being found.: diff --git a/compiler/plc_diagnostics/src/error_codes/E004.md b/compiler/plc_diagnostics/src/error_codes/E004.md new file mode 100644 index 0000000000..9656ac87dd --- /dev/null +++ b/compiler/plc_diagnostics/src/error_codes/E004.md @@ -0,0 +1,3 @@ +# Duplicate Symbol + +The marked symbol has been fined multiple times. diff --git a/compiler/plc_diagnostics/src/error_codes/E005.md b/compiler/plc_diagnostics/src/error_codes/E005.md new file mode 100644 index 0000000000..f29cb607d7 --- /dev/null +++ b/compiler/plc_diagnostics/src/error_codes/E005.md @@ -0,0 +1,5 @@ +# Generic LLVM Error + +An unexpected error occurred during the LLVM generation phase. +This is usually a follow up problem from a different diagnostics. +If it occurrs without a previous diagnostics please file a bug report. diff --git a/compiler/plc_diagnostics/src/error_codes/E006.md b/compiler/plc_diagnostics/src/error_codes/E006.md new file mode 100644 index 0000000000..27a21e496c --- /dev/null +++ b/compiler/plc_diagnostics/src/error_codes/E006.md @@ -0,0 +1,19 @@ +# Missing Token + +During the parsing phase, an additional _Token_ (Element) was required to correctly interpret the code. +The error message usually indicates what Token was missing. + +## Example +In the following example the name (Identifier) of the program is missing. +```iecst +PROGRAM (*name*) +END_PROGRAM +``` + +``` +error: Unexpected token: expected Identifier but found END_PROGRAM + ┌─ example.st:2:1 + │ +2 │ END_PROGRAM + │ ^^^^^^^^^^^ Unexpected token: expected Identifier but found END_PROGRAM +``` diff --git a/compiler/plc_diagnostics/src/error_codes/E007.md b/compiler/plc_diagnostics/src/error_codes/E007.md new file mode 100644 index 0000000000..9069784582 --- /dev/null +++ b/compiler/plc_diagnostics/src/error_codes/E007.md @@ -0,0 +1,3 @@ +# Unexpected Token + +During parsing, a _Token_ (Element) was encountered in the wrong location. This could be an indication of a missused or misspelled keyword diff --git a/compiler/plc_diagnostics/src/error_codes/E008.md b/compiler/plc_diagnostics/src/error_codes/E008.md new file mode 100644 index 0000000000..53c8bffd03 --- /dev/null +++ b/compiler/plc_diagnostics/src/error_codes/E008.md @@ -0,0 +1 @@ +# Invalid Range diff --git a/compiler/plc_diagnostics/src/error_codes/E009.md b/compiler/plc_diagnostics/src/error_codes/E009.md new file mode 100644 index 0000000000..3da23c4e62 --- /dev/null +++ b/compiler/plc_diagnostics/src/error_codes/E009.md @@ -0,0 +1 @@ +# Mismatched Parantheses diff --git a/compiler/plc_diagnostics/src/error_codes/E010.md b/compiler/plc_diagnostics/src/error_codes/E010.md new file mode 100644 index 0000000000..e6352a85dd --- /dev/null +++ b/compiler/plc_diagnostics/src/error_codes/E010.md @@ -0,0 +1 @@ +# Invalid time literal diff --git a/compiler/plc_diagnostics/src/error_codes/E011.md b/compiler/plc_diagnostics/src/error_codes/E011.md new file mode 100644 index 0000000000..d7043d3263 --- /dev/null +++ b/compiler/plc_diagnostics/src/error_codes/E011.md @@ -0,0 +1 @@ +# Invalid Number diff --git a/compiler/plc_diagnostics/src/error_codes/E012.md b/compiler/plc_diagnostics/src/error_codes/E012.md new file mode 100644 index 0000000000..a90532e3ff --- /dev/null +++ b/compiler/plc_diagnostics/src/error_codes/E012.md @@ -0,0 +1 @@ +# Missing Case Contition diff --git a/compiler/plc_diagnostics/src/error_codes/E013.md b/compiler/plc_diagnostics/src/error_codes/E013.md new file mode 100644 index 0000000000..f957fea2bf --- /dev/null +++ b/compiler/plc_diagnostics/src/error_codes/E013.md @@ -0,0 +1 @@ +# Keywords should contain Underscores diff --git a/compiler/plc_diagnostics/src/error_codes/E014.md b/compiler/plc_diagnostics/src/error_codes/E014.md new file mode 100644 index 0000000000..fd46767ea8 --- /dev/null +++ b/compiler/plc_diagnostics/src/error_codes/E014.md @@ -0,0 +1 @@ +# Wrong paranthese for String delimiter diff --git a/compiler/plc_diagnostics/src/error_codes/E015.md b/compiler/plc_diagnostics/src/error_codes/E015.md new file mode 100644 index 0000000000..e61f30f5e5 --- /dev/null +++ b/compiler/plc_diagnostics/src/error_codes/E015.md @@ -0,0 +1 @@ +# POINTER_TO is no standard keyword diff --git a/compiler/plc_diagnostics/src/error_codes/E016.md b/compiler/plc_diagnostics/src/error_codes/E016.md new file mode 100644 index 0000000000..fd7301c856 --- /dev/null +++ b/compiler/plc_diagnostics/src/error_codes/E016.md @@ -0,0 +1 @@ + # Return types cannot have a default value diff --git a/compiler/plc_diagnostics/src/error_codes/E017.md b/compiler/plc_diagnostics/src/error_codes/E017.md new file mode 100644 index 0000000000..62cd545526 --- /dev/null +++ b/compiler/plc_diagnostics/src/error_codes/E017.md @@ -0,0 +1 @@ +# Classes cannot contain implementation diff --git a/compiler/plc_diagnostics/src/error_codes/E018.md b/compiler/plc_diagnostics/src/error_codes/E018.md new file mode 100644 index 0000000000..a1137a2d0b --- /dev/null +++ b/compiler/plc_diagnostics/src/error_codes/E018.md @@ -0,0 +1 @@ +# Duplicate Label diff --git a/compiler/plc_diagnostics/src/error_codes/E019.md b/compiler/plc_diagnostics/src/error_codes/E019.md new file mode 100644 index 0000000000..2812779e26 --- /dev/null +++ b/compiler/plc_diagnostics/src/error_codes/E019.md @@ -0,0 +1 @@ +# Classes cannot contain IN_OUT variables diff --git a/compiler/plc_diagnostics/src/error_codes/E020.md b/compiler/plc_diagnostics/src/error_codes/E020.md new file mode 100644 index 0000000000..3b27c61b1e --- /dev/null +++ b/compiler/plc_diagnostics/src/error_codes/E020.md @@ -0,0 +1 @@ +# Classes cannot contain a return type diff --git a/compiler/plc_diagnostics/src/error_codes/E021.md b/compiler/plc_diagnostics/src/error_codes/E021.md new file mode 100644 index 0000000000..8ccd6c6e40 --- /dev/null +++ b/compiler/plc_diagnostics/src/error_codes/E021.md @@ -0,0 +1 @@ +# POUs cannot be extended diff --git a/compiler/plc_diagnostics/src/error_codes/E022.md b/compiler/plc_diagnostics/src/error_codes/E022.md new file mode 100644 index 0000000000..657273fcc8 --- /dev/null +++ b/compiler/plc_diagnostics/src/error_codes/E022.md @@ -0,0 +1 @@ +# Missing container name for action diff --git a/compiler/plc_diagnostics/src/error_codes/E023.md b/compiler/plc_diagnostics/src/error_codes/E023.md new file mode 100644 index 0000000000..003b73a8d9 --- /dev/null +++ b/compiler/plc_diagnostics/src/error_codes/E023.md @@ -0,0 +1 @@ +# Statement has no effect diff --git a/compiler/plc_diagnostics/src/error_codes/E024.md b/compiler/plc_diagnostics/src/error_codes/E024.md new file mode 100644 index 0000000000..7e03ef81ee --- /dev/null +++ b/compiler/plc_diagnostics/src/error_codes/E024.md @@ -0,0 +1 @@ +# Invalid Pragma Location diff --git a/compiler/plc_diagnostics/src/error_codes/E025.md b/compiler/plc_diagnostics/src/error_codes/E025.md new file mode 100644 index 0000000000..f095e4ac2b --- /dev/null +++ b/compiler/plc_diagnostics/src/error_codes/E025.md @@ -0,0 +1 @@ +# Missing return type diff --git a/compiler/plc_diagnostics/src/error_codes/E026.md b/compiler/plc_diagnostics/src/error_codes/E026.md new file mode 100644 index 0000000000..e6bab3759c --- /dev/null +++ b/compiler/plc_diagnostics/src/error_codes/E026.md @@ -0,0 +1 @@ +# Unexpected return type diff --git a/compiler/plc_diagnostics/src/error_codes/E027.md b/compiler/plc_diagnostics/src/error_codes/E027.md new file mode 100644 index 0000000000..f647d36a50 --- /dev/null +++ b/compiler/plc_diagnostics/src/error_codes/E027.md @@ -0,0 +1 @@ +# Unsupported return type diff --git a/compiler/plc_diagnostics/src/error_codes/E028.md b/compiler/plc_diagnostics/src/error_codes/E028.md new file mode 100644 index 0000000000..4be8770898 --- /dev/null +++ b/compiler/plc_diagnostics/src/error_codes/E028.md @@ -0,0 +1 @@ +# Empty variable block diff --git a/compiler/plc_diagnostics/src/error_codes/E029.md b/compiler/plc_diagnostics/src/error_codes/E029.md new file mode 100644 index 0000000000..0260dbc1c0 --- /dev/null +++ b/compiler/plc_diagnostics/src/error_codes/E029.md @@ -0,0 +1 @@ +# Recursive data structure diff --git a/compiler/plc_diagnostics/src/error_codes/E030.md b/compiler/plc_diagnostics/src/error_codes/E030.md new file mode 100644 index 0000000000..72923532ae --- /dev/null +++ b/compiler/plc_diagnostics/src/error_codes/E030.md @@ -0,0 +1 @@ +# Missing IN_OUT parameters diff --git a/compiler/plc_diagnostics/src/error_codes/E031.md b/compiler/plc_diagnostics/src/error_codes/E031.md new file mode 100644 index 0000000000..1acb7ec21e --- /dev/null +++ b/compiler/plc_diagnostics/src/error_codes/E031.md @@ -0,0 +1 @@ +# Invalid parameter type diff --git a/compiler/plc_diagnostics/src/error_codes/E032.md b/compiler/plc_diagnostics/src/error_codes/E032.md new file mode 100644 index 0000000000..53e170129c --- /dev/null +++ b/compiler/plc_diagnostics/src/error_codes/E032.md @@ -0,0 +1 @@ +# Invalid number of parameters diff --git a/compiler/plc_diagnostics/src/error_codes/E033.md b/compiler/plc_diagnostics/src/error_codes/E033.md new file mode 100644 index 0000000000..dc98ed2de4 --- /dev/null +++ b/compiler/plc_diagnostics/src/error_codes/E033.md @@ -0,0 +1 @@ +# Unresolved Constant diff --git a/compiler/plc_diagnostics/src/error_codes/E034.md b/compiler/plc_diagnostics/src/error_codes/E034.md new file mode 100644 index 0000000000..71eb7574e8 --- /dev/null +++ b/compiler/plc_diagnostics/src/error_codes/E034.md @@ -0,0 +1 @@ +# Invalid constant block diff --git a/compiler/plc_diagnostics/src/error_codes/E035.md b/compiler/plc_diagnostics/src/error_codes/E035.md new file mode 100644 index 0000000000..ee386e19ac --- /dev/null +++ b/compiler/plc_diagnostics/src/error_codes/E035.md @@ -0,0 +1 @@ +# Invalid Constant diff --git a/compiler/plc_diagnostics/src/error_codes/E036.md b/compiler/plc_diagnostics/src/error_codes/E036.md new file mode 100644 index 0000000000..7be474d364 --- /dev/null +++ b/compiler/plc_diagnostics/src/error_codes/E036.md @@ -0,0 +1 @@ +# Cannot assign to constant diff --git a/compiler/plc_diagnostics/src/error_codes/E037.md b/compiler/plc_diagnostics/src/error_codes/E037.md new file mode 100644 index 0000000000..d6ff1531d6 --- /dev/null +++ b/compiler/plc_diagnostics/src/error_codes/E037.md @@ -0,0 +1 @@ +# Invalid assignment diff --git a/compiler/plc_diagnostics/src/error_codes/E038.md b/compiler/plc_diagnostics/src/error_codes/E038.md new file mode 100644 index 0000000000..d979f608d6 --- /dev/null +++ b/compiler/plc_diagnostics/src/error_codes/E038.md @@ -0,0 +1 @@ +# Missing type diff --git a/compiler/plc_diagnostics/src/error_codes/E039.md b/compiler/plc_diagnostics/src/error_codes/E039.md new file mode 100644 index 0000000000..8dcd3856f1 --- /dev/null +++ b/compiler/plc_diagnostics/src/error_codes/E039.md @@ -0,0 +1 @@ +# Variable Overflow diff --git a/compiler/plc_diagnostics/src/error_codes/E040.md b/compiler/plc_diagnostics/src/error_codes/E040.md new file mode 100644 index 0000000000..cefb8230f9 --- /dev/null +++ b/compiler/plc_diagnostics/src/error_codes/E040.md @@ -0,0 +1 @@ +# Invalid Enum Variant diff --git a/compiler/plc_diagnostics/src/error_codes/E041.md b/compiler/plc_diagnostics/src/error_codes/E041.md new file mode 100644 index 0000000000..520fb33a23 --- /dev/null +++ b/compiler/plc_diagnostics/src/error_codes/E041.md @@ -0,0 +1 @@ +# Invalid variable initializer diff --git a/compiler/plc_diagnostics/src/error_codes/E042.md b/compiler/plc_diagnostics/src/error_codes/E042.md new file mode 100644 index 0000000000..6df0834f94 --- /dev/null +++ b/compiler/plc_diagnostics/src/error_codes/E042.md @@ -0,0 +1 @@ +# Assignment to Reference diff --git a/compiler/plc_diagnostics/src/error_codes/E043.md b/compiler/plc_diagnostics/src/error_codes/E043.md new file mode 100644 index 0000000000..5fee770d8a --- /dev/null +++ b/compiler/plc_diagnostics/src/error_codes/E043.md @@ -0,0 +1 @@ +# Invalid array assignment diff --git a/compiler/plc_diagnostics/src/error_codes/E044.md b/compiler/plc_diagnostics/src/error_codes/E044.md new file mode 100644 index 0000000000..aec7a75799 --- /dev/null +++ b/compiler/plc_diagnostics/src/error_codes/E044.md @@ -0,0 +1 @@ +# Invalid POU for VLA diff --git a/compiler/plc_diagnostics/src/error_codes/E045.md b/compiler/plc_diagnostics/src/error_codes/E045.md new file mode 100644 index 0000000000..c9368a1b9b --- /dev/null +++ b/compiler/plc_diagnostics/src/error_codes/E045.md @@ -0,0 +1 @@ +# Invalid VLA array access diff --git a/compiler/plc_diagnostics/src/error_codes/E046.md b/compiler/plc_diagnostics/src/error_codes/E046.md new file mode 100644 index 0000000000..e331bf8924 --- /dev/null +++ b/compiler/plc_diagnostics/src/error_codes/E046.md @@ -0,0 +1 @@ +# VLA Dimension out of bounds diff --git a/compiler/plc_diagnostics/src/error_codes/E047.md b/compiler/plc_diagnostics/src/error_codes/E047.md new file mode 100644 index 0000000000..af2ec98f30 --- /dev/null +++ b/compiler/plc_diagnostics/src/error_codes/E047.md @@ -0,0 +1 @@ +# VLAs are always By Reference diff --git a/compiler/plc_diagnostics/src/error_codes/E048.md b/compiler/plc_diagnostics/src/error_codes/E048.md new file mode 100644 index 0000000000..7ecd643be0 --- /dev/null +++ b/compiler/plc_diagnostics/src/error_codes/E048.md @@ -0,0 +1 @@ +# Unresolved Reference diff --git a/compiler/plc_diagnostics/src/error_codes/E049.md b/compiler/plc_diagnostics/src/error_codes/E049.md new file mode 100644 index 0000000000..65312f0a06 --- /dev/null +++ b/compiler/plc_diagnostics/src/error_codes/E049.md @@ -0,0 +1 @@ +# Illegal reference access diff --git a/compiler/plc_diagnostics/src/error_codes/E050.md b/compiler/plc_diagnostics/src/error_codes/E050.md new file mode 100644 index 0000000000..7a7023749b --- /dev/null +++ b/compiler/plc_diagnostics/src/error_codes/E050.md @@ -0,0 +1 @@ +# Expression is not assignable diff --git a/compiler/plc_diagnostics/src/error_codes/E051.md b/compiler/plc_diagnostics/src/error_codes/E051.md new file mode 100644 index 0000000000..62538fb2e6 --- /dev/null +++ b/compiler/plc_diagnostics/src/error_codes/E051.md @@ -0,0 +1 @@ +# Typecast error diff --git a/compiler/plc_diagnostics/src/error_codes/E052.md b/compiler/plc_diagnostics/src/error_codes/E052.md new file mode 100644 index 0000000000..16bf0e4566 --- /dev/null +++ b/compiler/plc_diagnostics/src/error_codes/E052.md @@ -0,0 +1 @@ +# Unknown type diff --git a/compiler/plc_diagnostics/src/error_codes/E053.md b/compiler/plc_diagnostics/src/error_codes/E053.md new file mode 100644 index 0000000000..55a79bcdbb --- /dev/null +++ b/compiler/plc_diagnostics/src/error_codes/E053.md @@ -0,0 +1 @@ +# Literal out of range diff --git a/compiler/plc_diagnostics/src/error_codes/E054.md b/compiler/plc_diagnostics/src/error_codes/E054.md new file mode 100644 index 0000000000..acc1f2bca4 --- /dev/null +++ b/compiler/plc_diagnostics/src/error_codes/E054.md @@ -0,0 +1 @@ +# Literal not compatible with type diff --git a/compiler/plc_diagnostics/src/error_codes/E055.md b/compiler/plc_diagnostics/src/error_codes/E055.md new file mode 100644 index 0000000000..74684ca10f --- /dev/null +++ b/compiler/plc_diagnostics/src/error_codes/E055.md @@ -0,0 +1 @@ +# Incompatible direct access diff --git a/compiler/plc_diagnostics/src/error_codes/E056.md b/compiler/plc_diagnostics/src/error_codes/E056.md new file mode 100644 index 0000000000..367481fbed --- /dev/null +++ b/compiler/plc_diagnostics/src/error_codes/E056.md @@ -0,0 +1 @@ +# Incompatible variable for direct access diff --git a/compiler/plc_diagnostics/src/error_codes/E057.md b/compiler/plc_diagnostics/src/error_codes/E057.md new file mode 100644 index 0000000000..e8db71a949 --- /dev/null +++ b/compiler/plc_diagnostics/src/error_codes/E057.md @@ -0,0 +1 @@ +# Invalid range for direct access diff --git a/compiler/plc_diagnostics/src/error_codes/E058.md b/compiler/plc_diagnostics/src/error_codes/E058.md new file mode 100644 index 0000000000..bbae76aa55 --- /dev/null +++ b/compiler/plc_diagnostics/src/error_codes/E058.md @@ -0,0 +1 @@ +# Invalid range for array access diff --git a/compiler/plc_diagnostics/src/error_codes/E059.md b/compiler/plc_diagnostics/src/error_codes/E059.md new file mode 100644 index 0000000000..2c984e606a --- /dev/null +++ b/compiler/plc_diagnostics/src/error_codes/E059.md @@ -0,0 +1 @@ +# Invalid variable for array access diff --git a/compiler/plc_diagnostics/src/error_codes/E060.md b/compiler/plc_diagnostics/src/error_codes/E060.md new file mode 100644 index 0000000000..7d57b5f349 --- /dev/null +++ b/compiler/plc_diagnostics/src/error_codes/E060.md @@ -0,0 +1 @@ +# Direct access to variable with % diff --git a/compiler/plc_diagnostics/src/error_codes/E061.md b/compiler/plc_diagnostics/src/error_codes/E061.md new file mode 100644 index 0000000000..711b6b17ba --- /dev/null +++ b/compiler/plc_diagnostics/src/error_codes/E061.md @@ -0,0 +1 @@ +# Expected literal diff --git a/compiler/plc_diagnostics/src/error_codes/E062.md b/compiler/plc_diagnostics/src/error_codes/E062.md new file mode 100644 index 0000000000..5c748fcf0a --- /dev/null +++ b/compiler/plc_diagnostics/src/error_codes/E062.md @@ -0,0 +1 @@ +# Invalid Nature diff --git a/compiler/plc_diagnostics/src/error_codes/E063.md b/compiler/plc_diagnostics/src/error_codes/E063.md new file mode 100644 index 0000000000..8d0d637f8e --- /dev/null +++ b/compiler/plc_diagnostics/src/error_codes/E063.md @@ -0,0 +1 @@ +# Unknown Nature diff --git a/compiler/plc_diagnostics/src/error_codes/E064.md b/compiler/plc_diagnostics/src/error_codes/E064.md new file mode 100644 index 0000000000..872747b32c --- /dev/null +++ b/compiler/plc_diagnostics/src/error_codes/E064.md @@ -0,0 +1 @@ +# Unresolved Generic diff --git a/compiler/plc_diagnostics/src/error_codes/E065.md b/compiler/plc_diagnostics/src/error_codes/E065.md new file mode 100644 index 0000000000..887b315ba7 --- /dev/null +++ b/compiler/plc_diagnostics/src/error_codes/E065.md @@ -0,0 +1 @@ +# Incompatible size diff --git a/compiler/plc_diagnostics/src/error_codes/E066.md b/compiler/plc_diagnostics/src/error_codes/E066.md new file mode 100644 index 0000000000..bbf0ab5f23 --- /dev/null +++ b/compiler/plc_diagnostics/src/error_codes/E066.md @@ -0,0 +1 @@ +# Invalid operation diff --git a/compiler/plc_diagnostics/src/error_codes/E067.md b/compiler/plc_diagnostics/src/error_codes/E067.md new file mode 100644 index 0000000000..9de4484101 --- /dev/null +++ b/compiler/plc_diagnostics/src/error_codes/E067.md @@ -0,0 +1 @@ +# Implicit typecast diff --git a/compiler/plc_diagnostics/src/error_codes/E068.md b/compiler/plc_diagnostics/src/error_codes/E068.md new file mode 100644 index 0000000000..6237f8d9c8 --- /dev/null +++ b/compiler/plc_diagnostics/src/error_codes/E068.md @@ -0,0 +1 @@ +# Pointer derefernce to non pointer diff --git a/compiler/plc_diagnostics/src/error_codes/E069.md b/compiler/plc_diagnostics/src/error_codes/E069.md new file mode 100644 index 0000000000..70c02a3106 --- /dev/null +++ b/compiler/plc_diagnostics/src/error_codes/E069.md @@ -0,0 +1 @@ +# Array access to non array value diff --git a/compiler/plc_diagnostics/src/error_codes/E070.md b/compiler/plc_diagnostics/src/error_codes/E070.md new file mode 100644 index 0000000000..7ef902c1a1 --- /dev/null +++ b/compiler/plc_diagnostics/src/error_codes/E070.md @@ -0,0 +1 @@ +# Address-of requires a value diff --git a/compiler/plc_diagnostics/src/error_codes/E071.md b/compiler/plc_diagnostics/src/error_codes/E071.md new file mode 100644 index 0000000000..4f4fd03144 --- /dev/null +++ b/compiler/plc_diagnostics/src/error_codes/E071.md @@ -0,0 +1 @@ +# General codegen error diff --git a/compiler/plc_diagnostics/src/error_codes/E072.md b/compiler/plc_diagnostics/src/error_codes/E072.md new file mode 100644 index 0000000000..38d28e4af6 --- /dev/null +++ b/compiler/plc_diagnostics/src/error_codes/E072.md @@ -0,0 +1 @@ +# Missing function diff --git a/compiler/plc_diagnostics/src/error_codes/E073.md b/compiler/plc_diagnostics/src/error_codes/E073.md new file mode 100644 index 0000000000..4513f270fc --- /dev/null +++ b/compiler/plc_diagnostics/src/error_codes/E073.md @@ -0,0 +1 @@ +# Missing compare function diff --git a/compiler/plc_diagnostics/src/error_codes/E074.md b/compiler/plc_diagnostics/src/error_codes/E074.md new file mode 100644 index 0000000000..2cbc355f58 --- /dev/null +++ b/compiler/plc_diagnostics/src/error_codes/E074.md @@ -0,0 +1 @@ +# Cannot generate string literal diff --git a/compiler/plc_diagnostics/src/error_codes/E075.md b/compiler/plc_diagnostics/src/error_codes/E075.md new file mode 100644 index 0000000000..6893403de3 --- /dev/null +++ b/compiler/plc_diagnostics/src/error_codes/E075.md @@ -0,0 +1 @@ +# Initial values were not generate diff --git a/compiler/plc_diagnostics/src/error_codes/E076.md b/compiler/plc_diagnostics/src/error_codes/E076.md new file mode 100644 index 0000000000..e4137a1ff0 --- /dev/null +++ b/compiler/plc_diagnostics/src/error_codes/E076.md @@ -0,0 +1 @@ +# General debug error diff --git a/compiler/plc_diagnostics/src/error_codes/E077.md b/compiler/plc_diagnostics/src/error_codes/E077.md new file mode 100644 index 0000000000..864b9e3282 --- /dev/null +++ b/compiler/plc_diagnostics/src/error_codes/E077.md @@ -0,0 +1 @@ +# Generic linker error diff --git a/compiler/plc_diagnostics/src/error_codes/E078.md b/compiler/plc_diagnostics/src/error_codes/E078.md new file mode 100644 index 0000000000..a56e161151 --- /dev/null +++ b/compiler/plc_diagnostics/src/error_codes/E078.md @@ -0,0 +1 @@ +# Duplicate case condition diff --git a/compiler/plc_diagnostics/src/error_codes/E079.md b/compiler/plc_diagnostics/src/error_codes/E079.md new file mode 100644 index 0000000000..658fb5ec86 --- /dev/null +++ b/compiler/plc_diagnostics/src/error_codes/E079.md @@ -0,0 +1 @@ +# Case condition outside of a case statement diff --git a/compiler/plc_diagnostics/src/error_codes/E080.md b/compiler/plc_diagnostics/src/error_codes/E080.md new file mode 100644 index 0000000000..af75ff7d54 --- /dev/null +++ b/compiler/plc_diagnostics/src/error_codes/E080.md @@ -0,0 +1 @@ +# Invalid case condition diff --git a/compiler/plc_diagnostics/src/error_codes/E081.md b/compiler/plc_diagnostics/src/error_codes/E081.md new file mode 100644 index 0000000000..00fe97c2f7 --- /dev/null +++ b/compiler/plc_diagnostics/src/error_codes/E081.md @@ -0,0 +1 @@ +# Empty control statement diff --git a/compiler/plc_diagnostics/src/error_codes/E082.md b/compiler/plc_diagnostics/src/error_codes/E082.md new file mode 100644 index 0000000000..ce16173736 --- /dev/null +++ b/compiler/plc_diagnostics/src/error_codes/E082.md @@ -0,0 +1 @@ +# Undefined node diff --git a/compiler/plc_diagnostics/src/error_codes/E083.md b/compiler/plc_diagnostics/src/error_codes/E083.md new file mode 100644 index 0000000000..2155d9d6f1 --- /dev/null +++ b/compiler/plc_diagnostics/src/error_codes/E083.md @@ -0,0 +1 @@ +# Unexpected node diff --git a/compiler/plc_diagnostics/src/error_codes/E084.md b/compiler/plc_diagnostics/src/error_codes/E084.md new file mode 100644 index 0000000000..c9303fba0a --- /dev/null +++ b/compiler/plc_diagnostics/src/error_codes/E084.md @@ -0,0 +1 @@ +# Unconnected source diff --git a/compiler/plc_diagnostics/src/error_codes/E085.md b/compiler/plc_diagnostics/src/error_codes/E085.md new file mode 100644 index 0000000000..fcf58e6273 --- /dev/null +++ b/compiler/plc_diagnostics/src/error_codes/E085.md @@ -0,0 +1 @@ +# Cyclic connection diff --git a/compiler/plc_diagnostics/src/error_codes/E086.md b/compiler/plc_diagnostics/src/error_codes/E086.md new file mode 100644 index 0000000000..f731d5630e --- /dev/null +++ b/compiler/plc_diagnostics/src/error_codes/E086.md @@ -0,0 +1 @@ +# No associated connector diff --git a/compiler/plc_diagnostics/src/error_codes/E087.md b/compiler/plc_diagnostics/src/error_codes/E087.md new file mode 100644 index 0000000000..d54df4626b --- /dev/null +++ b/compiler/plc_diagnostics/src/error_codes/E087.md @@ -0,0 +1 @@ +# Unnamed control diff --git a/compiler/plc_diagnostics/src/error_codes/E088.md b/compiler/plc_diagnostics/src/error_codes/E088.md new file mode 100644 index 0000000000..bdae3b4fae --- /dev/null +++ b/compiler/plc_diagnostics/src/error_codes/E088.md @@ -0,0 +1 @@ +# Invalid PLC Json file diff --git a/compiler/plc_diagnostics/src/error_codes/E089.md b/compiler/plc_diagnostics/src/error_codes/E089.md new file mode 100644 index 0000000000..480108cbcf --- /dev/null +++ b/compiler/plc_diagnostics/src/error_codes/E089.md @@ -0,0 +1 @@ +# Invalid Call parameters \ No newline at end of file diff --git a/compiler/plc_diagnostics/src/error_codes/E090.md b/compiler/plc_diagnostics/src/error_codes/E090.md new file mode 100644 index 0000000000..43afd815f9 --- /dev/null +++ b/compiler/plc_diagnostics/src/error_codes/E090.md @@ -0,0 +1 @@ +# Incompatible reference assingment diff --git a/compiler/plc_diagnostics/src/lib.rs b/compiler/plc_diagnostics/src/lib.rs index 3a17b793a9..69c8ab2e15 100644 --- a/compiler/plc_diagnostics/src/lib.rs +++ b/compiler/plc_diagnostics/src/lib.rs @@ -2,5 +2,4 @@ pub mod diagnostician; pub mod diagnostics; -pub mod errno; // TODO: Make this crate-private? pub mod reporter; diff --git a/compiler/plc_diagnostics/src/reporter.rs b/compiler/plc_diagnostics/src/reporter.rs index 7735c775b7..6bcb7b35e1 100644 --- a/compiler/plc_diagnostics/src/reporter.rs +++ b/compiler/plc_diagnostics/src/reporter.rs @@ -1,6 +1,6 @@ use plc_source::source_location::CodeSpan; -use crate::diagnostician::Severity; +use crate::diagnostics::Severity; pub mod clang; pub mod codespan; diff --git a/compiler/plc_diagnostics/src/reporter/clang.rs b/compiler/plc_diagnostics/src/reporter/clang.rs index cd56870ee7..9b7c178b18 100644 --- a/compiler/plc_diagnostics/src/reporter/clang.rs +++ b/compiler/plc_diagnostics/src/reporter/clang.rs @@ -1,6 +1,6 @@ use codespan_reporting::files::{Files, Location, SimpleFile, SimpleFiles}; -use crate::diagnostician::Severity; +use crate::diagnostics::Severity; use super::{DiagnosticReporter, ResolvedDiagnostics}; diff --git a/compiler/plc_diagnostics/src/reporter/codespan.rs b/compiler/plc_diagnostics/src/reporter/codespan.rs index 34f3c2a0bd..201d32ca43 100644 --- a/compiler/plc_diagnostics/src/reporter/codespan.rs +++ b/compiler/plc_diagnostics/src/reporter/codespan.rs @@ -5,7 +5,7 @@ use codespan_reporting::{ }; use plc_source::source_location::CodeSpan; -use crate::diagnostician::Severity; +use crate::diagnostics::Severity; use super::{DiagnosticReporter, ResolvedDiagnostics}; @@ -100,7 +100,7 @@ impl DiagnosticReporter for CodeSpanDiagnosticReporter { fn report(&mut self, diagnostics: &[ResolvedDiagnostics]) { for d in diagnostics { let diagnostic_factory = match d.severity { - Severity::Critical | Severity::Error => codespan_reporting::diagnostic::Diagnostic::error(), + Severity::Error => codespan_reporting::diagnostic::Diagnostic::error(), Severity::Warning => codespan_reporting::diagnostic::Diagnostic::warning(), Severity::Info => codespan_reporting::diagnostic::Diagnostic::note(), }; diff --git a/compiler/plc_driver/Cargo.toml b/compiler/plc_driver/Cargo.toml index c1ece9a6ee..743087961a 100644 --- a/compiler/plc_driver/Cargo.toml +++ b/compiler/plc_driver/Cargo.toml @@ -24,6 +24,7 @@ env_logger = "0.10" log.workspace = true encoding_rs.workspace = true encoding_rs_io.workspace = true +anyhow.workspace = true [dev-dependencies] pretty_assertions = "1.3.0" diff --git a/compiler/plc_driver/src/lib.rs b/compiler/plc_driver/src/lib.rs index 8968f52b65..13914421eb 100644 --- a/compiler/plc_driver/src/lib.rs +++ b/compiler/plc_driver/src/lib.rs @@ -8,6 +8,7 @@ //! - Shared Objects //! - Executables +use anyhow::Result; use std::{ env, ffi::OsStr, @@ -118,7 +119,7 @@ impl Display for CompileError { } } -pub fn compile + AsRef + Debug>(args: &[T]) -> Result<(), CompileError> { +pub fn compile + AsRef + Debug>(args: &[T]) -> Result<()> { //Parse the arguments let compile_parameters = CompileParameters::parse(args)?; let project = get_project(&compile_parameters)?; @@ -195,11 +196,9 @@ pub fn compile + AsRef + Debug>(args: &[T]) -> Result<(), C .map_err(|err| Diagnostic::codegen_error(err.get_message(), err.get_location())); if let Err(res) = res { diagnostician.handle(&[res]); - return Err(Diagnostic::GeneralError { - message: "Compilation aborted due to previous errors".into(), - err_no: plc_diagnostics::errno::ErrNo::codegen__general, - } - .into()); + return Err(Diagnostic::error("Compilation aborted due to previous errors") + .with_error_code("E071") + .into()); } } @@ -251,10 +250,7 @@ fn generate_to_string_internal( } let module = project.generate_single_module(&context, &options)?; - module.map(|it| it.persist_to_string()).ok_or_else(|| Diagnostic::GeneralError { - message: "Cannot generate module".to_string(), - err_no: plc_diagnostics::errno::ErrNo::general__err, - }) + module.map(|it| it.persist_to_string()).ok_or_else(|| Diagnostic::error("Cannot generate module")) } fn generate( @@ -328,7 +324,7 @@ fn generate( Ok(()) } -fn get_project(compile_parameters: &CompileParameters) -> Result, Diagnostic> { +fn get_project(compile_parameters: &CompileParameters) -> Result> { let current_dir = env::current_dir()?; //Create a project from either the subcommand or single params let project = if let Some(command) = &compile_parameters.commands { @@ -345,7 +341,7 @@ fn get_project(compile_parameters: &CompileParameters) -> Result Result<()> { //Initialize the logging env_logger::init(); let args: Vec = env::args().collect(); - if let Err(err) = plc_driver::compile(&args) { - err.exit() - } + plc_driver::compile(&args) } diff --git a/compiler/plc_driver/src/pipelines.rs b/compiler/plc_driver/src/pipelines.rs index 1ef53cb4c0..fb4414192f 100644 --- a/compiler/plc_driver/src/pipelines.rs +++ b/compiler/plc_driver/src/pipelines.rs @@ -21,9 +21,8 @@ use plc::{ ConfigFormat, Target, }; use plc_diagnostics::{ - diagnostician::{Diagnostician, Severity}, - diagnostics::Diagnostic, - errno::ErrNo, + diagnostician::Diagnostician, + diagnostics::{Diagnostic, Severity}, }; use plc_index::GlobalContext; use project::{ @@ -194,11 +193,8 @@ impl AnnotatedProject { let diagnostics = validator.diagnostics(); severity = severity.max(diagnostician.handle(&diagnostics)); }); - if severity == Severity::Critical { - Err(Diagnostic::GeneralError { - message: "Compilation aborted due to critical errors".into(), - err_no: ErrNo::general__err, - }) + if severity == Severity::Error { + Err(Diagnostic::error("Compilation aborted due to critical errors")) } else { Ok(()) } @@ -318,7 +314,13 @@ impl AnnotatedProject { let unit_location = PathBuf::from(&unit.file_name); let unit_location = std::fs::canonicalize(unit_location)?; let output_name = if unit_location.starts_with(current_dir) { - unit_location.strip_prefix(current_dir)? + unit_location.strip_prefix(current_dir).map_err(|it| { + Diagnostic::error(format!( + "Could not strip prefix for {}", + current_dir.to_string_lossy() + )) + .with_internal_error(it.into()) + })? } else if unit_location.has_root() { let root = Path::new("/").canonicalize()?; unit_location.strip_prefix(root).expect("Name has root") @@ -364,7 +366,7 @@ impl AnnotatedProject { let hw_conf = plc::hardware_binding::collect_hardware_configuration(&self.index)?; let generated_conf = plc::hardware_binding::generate_hardware_configuration(&hw_conf, format)?; File::create(location).and_then(|mut it| it.write_all(generated_conf.as_bytes())).map_err(|it| { - Diagnostic::GeneralError { err_no: ErrNo::general__io_err, message: it.to_string() } + Diagnostic::error(it.to_string()).with_internal_error(it.into()).with_error_code("E002") })?; Ok(()) } @@ -450,7 +452,7 @@ impl GeneratedProject { // Only initialize a linker if we need to use it let target_triple = self.target.get_target_triple(); let mut linker = plc::linker::Linker::new( - target_triple.as_str().to_str()?, + &target_triple.as_str().to_string_lossy(), link_options.linker.as_deref(), )?; for obj in &self.objects { diff --git a/compiler/plc_driver/src/tests/external_files.rs b/compiler/plc_driver/src/tests/external_files.rs index 82634939ee..d94ca4d2f3 100644 --- a/compiler/plc_driver/src/tests/external_files.rs +++ b/compiler/plc_driver/src/tests/external_files.rs @@ -1,6 +1,5 @@ use plc::DebugLevel; -use plc_diagnostics::diagnostics::Diagnostic; -use source_code::{source_location::SourceLocationFactory, SourceCode}; +use source_code::SourceCode; use crate::tests::compile_to_string; @@ -74,17 +73,10 @@ fn calling_external_file_function_without_including_file_results_in_error() { "external_file.st", ); //External file is not included - let source_location_factory = SourceLocationFactory::for_source(&prog); let res = compile_to_string(vec![prog], vec![], None, DebugLevel::None); if let Err(msg) = res { - assert_eq!( - Diagnostic::codegen_error( - r#"cannot generate call statement for "ReferenceExpr { kind: Member(Identifier { name: \"external\" }), base: None }""#, - source_location_factory.create_range(33..41) - ), - msg - ) + insta::assert_snapshot!(msg.to_string()) } else { panic!("expected code-gen error but got none") } diff --git a/compiler/plc_driver/src/tests/snapshots/plc_driver__tests__external_files__calling_external_file_function_without_including_file_results_in_error.snap b/compiler/plc_driver/src/tests/snapshots/plc_driver__tests__external_files__calling_external_file_function_without_including_file_results_in_error.snap new file mode 100644 index 0000000000..89abfadca5 --- /dev/null +++ b/compiler/plc_driver/src/tests/snapshots/plc_driver__tests__external_files__calling_external_file_function_without_including_file_results_in_error.snap @@ -0,0 +1,5 @@ +--- +source: compiler/plc_driver/./src/tests/external_files.rs +expression: msg.to_string() +--- +E071: cannot generate call statement for ReferenceExpr { kind: Member(Identifier { name: "external" }), base: None } at: external_file.st:2:8:{2:8-2:16}: diff --git a/compiler/plc_index/src/lib.rs b/compiler/plc_index/src/lib.rs index 6db52c4a48..c0ace21353 100644 --- a/compiler/plc_index/src/lib.rs +++ b/compiler/plc_index/src/lib.rs @@ -34,7 +34,14 @@ impl GlobalContext { { match container.load_source(encoding) { Ok(value) => self.sources.insert(container.get_location_str(), value), - Err(why) => return Err(Diagnostic::io_read_error(container.get_location_str(), &why)), + Err(why) => { + return Err(Diagnostic::error(format!( + "Cannot read file '{}': {}'", + container.get_location_str(), + &why + )) + .with_error_code("E002")) + } }; Ok(()) @@ -66,13 +73,13 @@ impl GlobalContext { /// Returns a (whitespace) trimmed slice representing the specified location of the source code. /// For example if the location represents `ARRAY[1..5]\n\nOF\t DINT` the slice `ARRAY[1..5] OF DINT` will be returned instead. pub fn slice(&self, location: &SourceLocation) -> String { - let slice = self.slice_original(location); + let slice = self.slice_raw(location); slice.split_whitespace().collect::>().join(" ") } /// Returns a slice representing the specified location of the source code. /// If the location, i.e. file path, does not exist an empty string will be returned. - pub fn slice_original(&self, location: &SourceLocation) -> &str { + pub fn slice_raw(&self, location: &SourceLocation) -> &str { let path = location.get_file_name().unwrap_or(""); let Some(code) = self.sources.get(path) else { return "" }; @@ -117,9 +124,6 @@ mod tests { let location = factory.create_range(0..input.source.len()); assert_eq!(ctxt.slice(&location), "ARRAY[1..5] OF DINT"); - assert_eq!( - ctxt.slice_original(&location), - "ARRAY[1..5] \n\n\n\nOF \n\n\n \t DINT" - ); + assert_eq!(ctxt.slice_raw(&location), "ARRAY[1..5] \n\n\n\nOF \n\n\n \t DINT"); } } diff --git a/compiler/plc_project/Cargo.toml b/compiler/plc_project/Cargo.toml index 5845fe8fba..0427b52975 100644 --- a/compiler/plc_project/Cargo.toml +++ b/compiler/plc_project/Cargo.toml @@ -16,6 +16,7 @@ jsonschema = "0.17" encoding_rs.workspace = true encoding_rs_io.workspace = true glob = "*" +anyhow.workspace = true [dev-dependencies] insta = "1.31.0" diff --git a/compiler/plc_project/src/build_config.rs b/compiler/plc_project/src/build_config.rs index 133325d4f7..63c0a1ee9f 100644 --- a/compiler/plc_project/src/build_config.rs +++ b/compiler/plc_project/src/build_config.rs @@ -1,7 +1,7 @@ +use anyhow::Result; use jsonschema::JSONSchema; use plc::Target; use plc_diagnostics::diagnostics::Diagnostic; -use plc_diagnostics::diagnostics::SerdeError; use regex::Captures; use regex::Regex; use serde::{Deserialize, Serialize}; @@ -63,19 +63,17 @@ pub struct ProjectConfig { impl ProjectConfig { /// Returns a project from the given json-source /// All environment variables (marked with `$VAR_NAME`) that can be resovled at this time are resolved before the conversion - pub fn try_parse(source: BuildDescriptionSource) -> Result { + pub fn try_parse(source: BuildDescriptionSource) -> Result { let content = source.source.as_str(); let content = resolve_environment_variables(content)?; - let config: ProjectConfig = serde_json::from_str(&content).map_err(|err| { - let err = SerdeError::from(err); - err.into_diagnostic(&source) - })?; + let config: ProjectConfig = + serde_json::from_str(&content).map_err(|err| Diagnostic::from_serde_error(err, &source))?; config.validate()?; Ok(config) } - pub(crate) fn from_file(config: &Path) -> Result { + pub(crate) fn from_file(config: &Path) -> Result { //read from file let content = fs::read_to_string(config)?; let content = BuildDescriptionSource::new(content, config); @@ -86,7 +84,7 @@ impl ProjectConfig { Ok(project) } - fn get_schema() -> Result { + fn get_schema() -> Result { let current_exe_dir = std::env::current_exe()?.parent().map(|it| it.to_path_buf()).unwrap_or_default(); let schema_dir = current_exe_dir.join("schema"); @@ -100,13 +98,17 @@ impl ProjectConfig { }; let path = schema_dir.join("plc-json.schema"); if !path.exists() { - Err(Diagnostic::io_read_error(&path.to_string_lossy(), "File not found")) + Err(std::io::Error::new( + std::io::ErrorKind::NotFound, + format!("{}: File not found", path.to_string_lossy()), + ) + .into()) } else { Ok(path) } } - fn validate(&self) -> Result<(), Diagnostic> { + fn validate(&self) -> Result<()> { let schema_path = match Self::get_schema() { Ok(path) => path, Err(error) => { @@ -132,13 +134,14 @@ impl ProjectConfig { } // XXX: jsonschema does not provide error messages with location info - Diagnostic::invalid_build_description_file(message, None) - }) + Diagnostic::error(message).with_error_code("E088") + })?; + Ok(()) } } //TODO: I don't think this belongs here -fn resolve_environment_variables(to_replace: &str) -> Result { +fn resolve_environment_variables(to_replace: &str) -> Result { let pattern = Regex::new(r"\$(\w+)")?; let result = pattern.replace_all(to_replace, |it: &Captures| { let original = it.get(0).map(|it| it.as_str().to_string()).unwrap(); diff --git a/compiler/plc_project/src/project.rs b/compiler/plc_project/src/project.rs index 81e2dec4f7..4a24c73a93 100644 --- a/compiler/plc_project/src/project.rs +++ b/compiler/plc_project/src/project.rs @@ -3,8 +3,8 @@ use std::{ path::{Path, PathBuf}, }; +use anyhow::{Context, Result}; use glob::glob; -use plc_diagnostics::diagnostics::Diagnostic; use crate::{ build_config::{LinkageInfo, ProjectConfig}, @@ -123,7 +123,7 @@ impl CompiledLibrary { //configuration impl Project { /// Retrieve a project for compilation from a json description - pub fn from_config(config: &Path) -> Result { + pub fn from_config(config: &Path) -> Result { let project_config = ProjectConfig::from_file(config)?; let libraries = project_config .libraries @@ -155,7 +155,7 @@ impl Project { library: Library::Compiled(compiled_library), }) }) - .collect::, Diagnostic>>()?; + .collect::>>()?; let current_dir = env::current_dir()?; let location = config.parent().map(Path::to_path_buf).or(Some(current_dir)); @@ -283,16 +283,15 @@ impl Project { } } -fn resolve_file_paths(location: Option<&Path>, inputs: Vec) -> Result, Diagnostic> { +fn resolve_file_paths(location: Option<&Path>, inputs: Vec) -> Result> { let mut sources = Vec::new(); for input in &inputs { let input = location.map(|it| it.join(input)).unwrap_or(input.to_path_buf()); let path = &input.to_string_lossy(); - let paths = glob(path) - .map_err(|e| Diagnostic::param_error(&format!("Failed to read glob pattern: {path}, ({e})")))?; + let paths = glob(path).context(format!("Failed to read glob pattern {path}"))?; for p in paths { - let path = p.map_err(|err| Diagnostic::param_error(&format!("Illegal path: {err}")))?; + let path = p.context("Illegal Path")?; sources.push(path); } } diff --git a/compiler/plc_project/src/snapshots/plc_project__build_config__tests__json_with_additional_fields_reports_unexpected_fields.snap b/compiler/plc_project/src/snapshots/plc_project__build_config__tests__json_with_additional_fields_reports_unexpected_fields.snap index 03c3ae9557..098a424528 100644 --- a/compiler/plc_project/src/snapshots/plc_project__build_config__tests__json_with_additional_fields_reports_unexpected_fields.snap +++ b/compiler/plc_project/src/snapshots/plc_project__build_config__tests__json_with_additional_fields_reports_unexpected_fields.snap @@ -2,4 +2,4 @@ source: compiler/plc_project/src/build_config.rs expression: diag.to_string() --- -plc_json__invalid: unknown field `additional_field`, expected one of `name`, `files`, `compile_type`, `output`, `libraries`, `package_commands`, `version`, `format-version`, `format_version` at: :9:27:{9:27-9:215}: +E088: unknown field `additional_field`, expected one of `name`, `files`, `compile_type`, `output`, `libraries`, `package_commands`, `version`, `format-version`, `format_version` at: :9:27:{9:27-9:215}: diff --git a/compiler/plc_project/src/snapshots/plc_project__build_config__tests__json_with_empty_files_array_reports_error.snap b/compiler/plc_project/src/snapshots/plc_project__build_config__tests__json_with_empty_files_array_reports_error.snap index 423f7c98eb..c265222eab 100644 --- a/compiler/plc_project/src/snapshots/plc_project__build_config__tests__json_with_empty_files_array_reports_error.snap +++ b/compiler/plc_project/src/snapshots/plc_project__build_config__tests__json_with_empty_files_array_reports_error.snap @@ -2,6 +2,6 @@ source: compiler/plc_project/src/build_config.rs expression: diag.to_string() --- -plc_json__invalid: plc.json could not be validated due to the following errors: +E088: plc.json could not be validated due to the following errors: files[] has less than 1 item diff --git a/compiler/plc_project/src/snapshots/plc_project__build_config__tests__json_with_invalid_enum_variants_reports_error.snap b/compiler/plc_project/src/snapshots/plc_project__build_config__tests__json_with_invalid_enum_variants_reports_error.snap index 6be1942573..b6c413b68a 100644 --- a/compiler/plc_project/src/snapshots/plc_project__build_config__tests__json_with_invalid_enum_variants_reports_error.snap +++ b/compiler/plc_project/src/snapshots/plc_project__build_config__tests__json_with_invalid_enum_variants_reports_error.snap @@ -2,4 +2,4 @@ source: compiler/plc_project/src/build_config.rs expression: diag.to_string() --- -plc_json__invalid: unknown variant `Interpreted`, expected one of `Object`, `Static`, `PIC`, `Shared`, `NoPIC`, `Relocatable`, `Bitcode`, `IR` at: :7:38:{7:38-7:168}: +E088: unknown variant `Interpreted`, expected one of `Object`, `Static`, `PIC`, `Shared`, `NoPIC`, `Relocatable`, `Bitcode`, `IR` at: :7:38:{7:38-7:168}: diff --git a/compiler/plc_project/src/snapshots/plc_project__build_config__tests__json_with_missing_required_properties_reports_error-2.snap b/compiler/plc_project/src/snapshots/plc_project__build_config__tests__json_with_missing_required_properties_reports_error-2.snap index 557cfea9bc..563b8c7250 100644 --- a/compiler/plc_project/src/snapshots/plc_project__build_config__tests__json_with_missing_required_properties_reports_error-2.snap +++ b/compiler/plc_project/src/snapshots/plc_project__build_config__tests__json_with_missing_required_properties_reports_error-2.snap @@ -2,4 +2,4 @@ source: compiler/plc_project/src/build_config.rs expression: diag.to_string() --- -plc_json__invalid: missing field `path` at: :16:13:{16:13-16:391}: +E088: missing field `path` at: :16:13:{16:13-16:391}: diff --git a/compiler/plc_project/src/snapshots/plc_project__build_config__tests__json_with_missing_required_properties_reports_error.snap b/compiler/plc_project/src/snapshots/plc_project__build_config__tests__json_with_missing_required_properties_reports_error.snap index 764f4e1fb2..a5a0878e5c 100644 --- a/compiler/plc_project/src/snapshots/plc_project__build_config__tests__json_with_missing_required_properties_reports_error.snap +++ b/compiler/plc_project/src/snapshots/plc_project__build_config__tests__json_with_missing_required_properties_reports_error.snap @@ -2,4 +2,4 @@ source: compiler/plc_project/src/build_config.rs expression: diag.to_string() --- -plc_json__invalid: missing field `name` at: :6:9:{6:9-6:100}: +E088: missing field `name` at: :6:9:{6:9-6:100}: diff --git a/compiler/plc_xml/src/model/fbd.rs b/compiler/plc_xml/src/model/fbd.rs index 5951948407..a20da39969 100644 --- a/compiler/plc_xml/src/model/fbd.rs +++ b/compiler/plc_xml/src/model/fbd.rs @@ -235,18 +235,16 @@ impl<'xml> ConnectionResolver<'xml> for NodeIndex<'xml> { kind: ConnectorKind::Source, name, ref_local_id, .. })) => { current = ref_local_id.ok_or_else(|| { - Diagnostic::unconnected_source( - name.as_ref(), - source_location_factory.create_block_location(current, None), - ) + Diagnostic::error(format!("Source '{name}' is not connected.")) + .with_error_code("E084") + .with_location(source_location_factory.create_block_location(current, None)) })? } Some(Node::Connector(Connector { kind: ConnectorKind::Sink, name, .. })) => { current = *source_connections.get(name.as_ref()).ok_or_else(|| { - Diagnostic::sink_without_associated_source( - name.as_ref(), - source_location_factory.create_block_location(current, None), - ) + Diagnostic::error(format!("Expected a corresponding source-connection mark for sink '{name}', but could not find one.")) + .with_error_code("E086") + .with_location(source_location_factory.create_block_location(current, None)) })? } _ => return Ok(current), @@ -262,8 +260,11 @@ impl<'xml> ConnectionResolver<'xml> for NodeIndex<'xml> { let node = self.get(¤t).expect("Node exists"); msg.push_str(node.get_name()); - return Err(Diagnostic::cyclic_connection( - msg.to_string(), + return Err(Diagnostic::error(format!( + "Sink is connected to itself. Found the following recursion: {msg}" + )) + .with_error_code("E085") + .with_location( source_location_factory.create_block_location(node.get_id(), node.get_exec_id()), )); } diff --git a/compiler/plc_xml/src/model/snapshots/plc_xml__model__fbd__tests__recursive_sink_source_connections_are_an_error.snap b/compiler/plc_xml/src/model/snapshots/plc_xml__model__fbd__tests__recursive_sink_source_connections_are_an_error.snap index 8e4cefd2b1..b6dd396011 100644 --- a/compiler/plc_xml/src/model/snapshots/plc_xml__model__fbd__tests__recursive_sink_source_connections_are_an_error.snap +++ b/compiler/plc_xml/src/model/snapshots/plc_xml__model__fbd__tests__recursive_sink_source_connections_are_an_error.snap @@ -3,43 +3,49 @@ source: compiler/plc_xml/src/model/fbd.rs expression: err --- [ - SemanticError { + Diagnostic { message: "Sink is connected to itself. Found the following recursion: connection2 -> connection1 -> connection2", - range: [ - SourceLocation { - span: Block { - local_id: 6, - execution_order: None, - inner_range: None, - }, + primary_location: SourceLocation { + span: Block { + local_id: 6, + execution_order: None, + inner_range: None, }, - ], - err_no: cfc__cyclic_connection, + }, + secondary_locations: None, + severity: Error, + error_code: "E085", + sub_diagnostics: [], + internal_error: None, }, - SemanticError { + Diagnostic { message: "Sink is connected to itself. Found the following recursion: connection2 -> connection1 -> connection2", - range: [ - SourceLocation { - span: Block { - local_id: 6, - execution_order: None, - inner_range: None, - }, + primary_location: SourceLocation { + span: Block { + local_id: 6, + execution_order: None, + inner_range: None, }, - ], - err_no: cfc__cyclic_connection, + }, + secondary_locations: None, + severity: Error, + error_code: "E085", + sub_diagnostics: [], + internal_error: None, }, - SemanticError { + Diagnostic { message: "Sink is connected to itself. Found the following recursion: connection1 -> connection2 -> connection1", - range: [ - SourceLocation { - span: Block { - local_id: 5, - execution_order: None, - inner_range: None, - }, + primary_location: SourceLocation { + span: Block { + local_id: 5, + execution_order: None, + inner_range: None, }, - ], - err_no: cfc__cyclic_connection, + }, + secondary_locations: None, + severity: Error, + error_code: "E085", + sub_diagnostics: [], + internal_error: None, }, ] diff --git a/compiler/plc_xml/src/model/snapshots/plc_xml__model__fbd__tests__unassociated_sink_removed_from_model_with_error.snap b/compiler/plc_xml/src/model/snapshots/plc_xml__model__fbd__tests__unassociated_sink_removed_from_model_with_error.snap index e47adbaeb4..7fd73c3750 100644 --- a/compiler/plc_xml/src/model/snapshots/plc_xml__model__fbd__tests__unassociated_sink_removed_from_model_with_error.snap +++ b/compiler/plc_xml/src/model/snapshots/plc_xml__model__fbd__tests__unassociated_sink_removed_from_model_with_error.snap @@ -3,17 +3,19 @@ source: compiler/plc_xml/src/model/fbd.rs expression: err --- [ - SemanticError { + Diagnostic { message: "Expected a corresponding source-connection mark for sink 'connection1', but could not find one.", - range: [ - SourceLocation { - span: Block { - local_id: 3, - execution_order: None, - inner_range: None, - }, + primary_location: SourceLocation { + span: Block { + local_id: 3, + execution_order: None, + inner_range: None, }, - ], - err_no: cfc__no_associated_connector, + }, + secondary_locations: None, + severity: Error, + error_code: "E086", + sub_diagnostics: [], + internal_error: None, }, ] diff --git a/compiler/plc_xml/src/model/snapshots/plc_xml__model__fbd__tests__unconnected_source_has_no_effect.snap b/compiler/plc_xml/src/model/snapshots/plc_xml__model__fbd__tests__unconnected_source_has_no_effect.snap index d8ce666ffc..9834770bb3 100644 --- a/compiler/plc_xml/src/model/snapshots/plc_xml__model__fbd__tests__unconnected_source_has_no_effect.snap +++ b/compiler/plc_xml/src/model/snapshots/plc_xml__model__fbd__tests__unconnected_source_has_no_effect.snap @@ -3,17 +3,19 @@ source: compiler/plc_xml/src/model/fbd.rs expression: err --- [ - SemanticError { + Diagnostic { message: "Source 'connection1' is not connected.", - range: [ - SourceLocation { - span: Block { - local_id: 3, - execution_order: None, - inner_range: None, - }, + primary_location: SourceLocation { + span: Block { + local_id: 3, + execution_order: None, + inner_range: None, }, - ], - err_no: cfc__unconnected_source, + }, + secondary_locations: None, + severity: Error, + error_code: "E084", + sub_diagnostics: [], + internal_error: None, }, ] diff --git a/compiler/plc_xml/src/xml_parser/control.rs b/compiler/plc_xml/src/xml_parser/control.rs index dc296331f7..ad3a4eef71 100644 --- a/compiler/plc_xml/src/xml_parser/control.rs +++ b/compiler/plc_xml/src/xml_parser/control.rs @@ -26,12 +26,14 @@ fn get_connection( let Some(ref_local_id) = control.ref_local_id else { let location = session.range_factory.create_block_location(control.local_id, control.execution_order_id); - return Err(Diagnostic::empty_control_statement(location)); + return Err(Diagnostic::error("Control statement has no connection").with_error_code("E081").with_location(location)); }; let Some(node) = index.get(&ref_local_id) else { let location = session.range_factory.create_block_location(ref_local_id, None); - return Err(Diagnostic::undefined_node(control.local_id, ref_local_id, location)); + return Err(Diagnostic::error(format!("Node {} is referencing a non-existing element with ID {ref_local_id}",control.local_id)) + .with_error_code("E082") + .with_location(location)); }; match node { @@ -44,7 +46,9 @@ fn get_connection( let location_other = session.range_factory.create_block_location(ref_local_id, node.get_exec_id()); - Err(Diagnostic::unexpected_nodes(location_control.span(&location_other))) + Err(Diagnostic::error("Unexpected relationship between nodes") + .with_error_code("E083") + .with_location(location_control.span(&location_other))) } } } diff --git a/compiler/plc_xml/src/xml_parser/snapshots/plc_xml__xml_parser__control__tests__unconnected_jump_generated_as_empty_statement-2.snap b/compiler/plc_xml/src/xml_parser/snapshots/plc_xml__xml_parser__control__tests__unconnected_jump_generated_as_empty_statement-2.snap index 74eac2ef68..ed6146e596 100644 --- a/compiler/plc_xml/src/xml_parser/snapshots/plc_xml__xml_parser__control__tests__unconnected_jump_generated_as_empty_statement-2.snap +++ b/compiler/plc_xml/src/xml_parser/snapshots/plc_xml__xml_parser__control__tests__unconnected_jump_generated_as_empty_statement-2.snap @@ -3,19 +3,21 @@ source: compiler/plc_xml/src/xml_parser/control.rs expression: diagnostics --- [ - SemanticError { + Diagnostic { message: "Control statement has no connection", - range: [ - SourceLocation { - span: Block { - local_id: 2, - execution_order: Some( - 1, - ), - inner_range: None, - }, + primary_location: SourceLocation { + span: Block { + local_id: 2, + execution_order: Some( + 1, + ), + inner_range: None, }, - ], - err_no: cfc__empty_control_statement, + }, + secondary_locations: None, + severity: Error, + error_code: "E081", + sub_diagnostics: [], + internal_error: None, }, ] diff --git a/compiler/plc_xml/src/xml_parser/snapshots/plc_xml__xml_parser__control__tests__unnamed_controls-2.snap b/compiler/plc_xml/src/xml_parser/snapshots/plc_xml__xml_parser__control__tests__unnamed_controls-2.snap index 8e23c01286..3dfb0622c2 100644 --- a/compiler/plc_xml/src/xml_parser/snapshots/plc_xml__xml_parser__control__tests__unnamed_controls-2.snap +++ b/compiler/plc_xml/src/xml_parser/snapshots/plc_xml__xml_parser__control__tests__unnamed_controls-2.snap @@ -3,34 +3,38 @@ source: compiler/plc_xml/src/xml_parser/control.rs expression: diagnostics --- [ - SemanticError { + Diagnostic { message: "Unnamed control", - range: [ - SourceLocation { - span: Block { - local_id: 1, - execution_order: Some( - 0, - ), - inner_range: None, - }, + primary_location: SourceLocation { + span: Block { + local_id: 1, + execution_order: Some( + 0, + ), + inner_range: None, }, - ], - err_no: cfc__unnamed_control, + }, + secondary_locations: None, + severity: Error, + error_code: "E087", + sub_diagnostics: [], + internal_error: None, }, - SemanticError { + Diagnostic { message: "Unnamed control", - range: [ - SourceLocation { - span: Block { - local_id: 2, - execution_order: Some( - 1, - ), - inner_range: None, - }, + primary_location: SourceLocation { + span: Block { + local_id: 2, + execution_order: Some( + 1, + ), + inner_range: None, }, - ], - err_no: cfc__unnamed_control, + }, + secondary_locations: None, + severity: Error, + error_code: "E087", + sub_diagnostics: [], + internal_error: None, }, ] diff --git a/compiler/plc_xml/src/xml_parser/snapshots/plc_xml__xml_parser__tests__conditional_return_chained_to_another_conditional_return.snap b/compiler/plc_xml/src/xml_parser/snapshots/plc_xml__xml_parser__tests__conditional_return_chained_to_another_conditional_return.snap index 0eeecc467c..080db302ba 100644 --- a/compiler/plc_xml/src/xml_parser/snapshots/plc_xml__xml_parser__tests__conditional_return_chained_to_another_conditional_return.snap +++ b/compiler/plc_xml/src/xml_parser/snapshots/plc_xml__xml_parser__tests__conditional_return_chained_to_another_conditional_return.snap @@ -3,51 +3,55 @@ source: compiler/plc_xml/src/xml_parser/tests.rs expression: diagnostics --- [ - SemanticError { + Diagnostic { message: "Control statement has no connection", - range: [ - SourceLocation { - span: Block { - local_id: 1, - execution_order: Some( - 0, - ), - inner_range: None, - }, - file: Some( - "test.cfc", + primary_location: SourceLocation { + span: Block { + local_id: 1, + execution_order: Some( + 0, ), + inner_range: None, }, - ], - err_no: cfc__empty_control_statement, + file: Some( + "test.cfc", + ), + }, + secondary_locations: None, + severity: Error, + error_code: "E081", + sub_diagnostics: [], + internal_error: None, }, - SemanticError { + Diagnostic { message: "Unexpected relationship between nodes", - range: [ - SourceLocation { - span: Combined( - [ - Block { - local_id: 2, - execution_order: Some( - 1, - ), - inner_range: None, - }, - Block { - local_id: 1, - execution_order: Some( - 0, - ), - inner_range: None, - }, - ], - ), - file: Some( - "test.cfc", - ), - }, - ], - err_no: cfc__unexpected_node, + primary_location: SourceLocation { + span: Combined( + [ + Block { + local_id: 2, + execution_order: Some( + 1, + ), + inner_range: None, + }, + Block { + local_id: 1, + execution_order: Some( + 0, + ), + inner_range: None, + }, + ], + ), + file: Some( + "test.cfc", + ), + }, + secondary_locations: None, + severity: Error, + error_code: "E083", + sub_diagnostics: [], + internal_error: None, }, ] diff --git a/compiler/plc_xml/src/xml_parser/snapshots/plc_xml__xml_parser__tests__conditional_return_without_connection.snap b/compiler/plc_xml/src/xml_parser/snapshots/plc_xml__xml_parser__tests__conditional_return_without_connection.snap index 29693f63d8..b9d13f018a 100644 --- a/compiler/plc_xml/src/xml_parser/snapshots/plc_xml__xml_parser__tests__conditional_return_without_connection.snap +++ b/compiler/plc_xml/src/xml_parser/snapshots/plc_xml__xml_parser__tests__conditional_return_without_connection.snap @@ -3,22 +3,24 @@ source: compiler/plc_xml/src/xml_parser/tests.rs expression: diagnostics --- [ - SemanticError { + Diagnostic { message: "Control statement has no connection", - range: [ - SourceLocation { - span: Block { - local_id: 2, - execution_order: Some( - 0, - ), - inner_range: None, - }, - file: Some( - "test.cfc", + primary_location: SourceLocation { + span: Block { + local_id: 2, + execution_order: Some( + 0, ), + inner_range: None, }, - ], - err_no: cfc__empty_control_statement, + file: Some( + "test.cfc", + ), + }, + secondary_locations: None, + severity: Error, + error_code: "E081", + sub_diagnostics: [], + internal_error: None, }, ] diff --git a/compiler/plc_xml/src/xml_parser/snapshots/plc_xml__xml_parser__tests__sink_source_data_recursion_does_not_overflow_the_stack.snap b/compiler/plc_xml/src/xml_parser/snapshots/plc_xml__xml_parser__tests__sink_source_data_recursion_does_not_overflow_the_stack.snap index db83ea3145..85f0e0e34e 100644 --- a/compiler/plc_xml/src/xml_parser/snapshots/plc_xml__xml_parser__tests__sink_source_data_recursion_does_not_overflow_the_stack.snap +++ b/compiler/plc_xml/src/xml_parser/snapshots/plc_xml__xml_parser__tests__sink_source_data_recursion_does_not_overflow_the_stack.snap @@ -3,52 +3,58 @@ source: compiler/plc_xml/src/xml_parser/tests.rs expression: diagnostics --- [ - SemanticError { + Diagnostic { message: "Sink is connected to itself. Found the following recursion: s3 -> s2 -> s1 -> s3", - range: [ - SourceLocation { - span: Block { - local_id: 23, - execution_order: None, - inner_range: None, - }, - file: Some( - "test", - ), + primary_location: SourceLocation { + span: Block { + local_id: 23, + execution_order: None, + inner_range: None, }, - ], - err_no: cfc__cyclic_connection, + file: Some( + "test", + ), + }, + secondary_locations: None, + severity: Error, + error_code: "E085", + sub_diagnostics: [], + internal_error: None, }, - SemanticError { + Diagnostic { message: "Sink is connected to itself. Found the following recursion: s1 -> s3 -> s2 -> s1", - range: [ - SourceLocation { - span: Block { - local_id: 24, - execution_order: None, - inner_range: None, - }, - file: Some( - "test", - ), + primary_location: SourceLocation { + span: Block { + local_id: 24, + execution_order: None, + inner_range: None, }, - ], - err_no: cfc__cyclic_connection, + file: Some( + "test", + ), + }, + secondary_locations: None, + severity: Error, + error_code: "E085", + sub_diagnostics: [], + internal_error: None, }, - SemanticError { + Diagnostic { message: "Sink is connected to itself. Found the following recursion: s2 -> s1 -> s3 -> s2", - range: [ - SourceLocation { - span: Block { - local_id: 26, - execution_order: None, - inner_range: None, - }, - file: Some( - "test", - ), + primary_location: SourceLocation { + span: Block { + local_id: 26, + execution_order: None, + inner_range: None, }, - ], - err_no: cfc__cyclic_connection, + file: Some( + "test", + ), + }, + secondary_locations: None, + severity: Error, + error_code: "E085", + sub_diagnostics: [], + internal_error: None, }, ] diff --git a/compiler/plc_xml/src/xml_parser/snapshots/plc_xml__xml_parser__tests__unassociated_connections.snap b/compiler/plc_xml/src/xml_parser/snapshots/plc_xml__xml_parser__tests__unassociated_connections.snap index 48da7815dc..73b8776ee9 100644 --- a/compiler/plc_xml/src/xml_parser/snapshots/plc_xml__xml_parser__tests__unassociated_connections.snap +++ b/compiler/plc_xml/src/xml_parser/snapshots/plc_xml__xml_parser__tests__unassociated_connections.snap @@ -3,20 +3,22 @@ source: compiler/plc_xml/src/xml_parser/tests.rs expression: diagnostics --- [ - SemanticError { + Diagnostic { message: "Expected a corresponding source-connection mark for sink 's2', but could not find one.", - range: [ - SourceLocation { - span: Block { - local_id: 3, - execution_order: None, - inner_range: None, - }, - file: Some( - "test", - ), + primary_location: SourceLocation { + span: Block { + local_id: 3, + execution_order: None, + inner_range: None, }, - ], - err_no: cfc__no_associated_connector, + file: Some( + "test", + ), + }, + secondary_locations: None, + severity: Error, + error_code: "E086", + sub_diagnostics: [], + internal_error: None, }, ] diff --git a/compiler/plc_xml/src/xml_parser/snapshots/plc_xml__xml_parser__tests__unconnected_connections.snap b/compiler/plc_xml/src/xml_parser/snapshots/plc_xml__xml_parser__tests__unconnected_connections.snap index 81f6356850..e3fa8eeb65 100644 --- a/compiler/plc_xml/src/xml_parser/snapshots/plc_xml__xml_parser__tests__unconnected_connections.snap +++ b/compiler/plc_xml/src/xml_parser/snapshots/plc_xml__xml_parser__tests__unconnected_connections.snap @@ -3,20 +3,22 @@ source: compiler/plc_xml/src/xml_parser/tests.rs expression: diagnostics --- [ - SemanticError { + Diagnostic { message: "Source 's1' is not connected.", - range: [ - SourceLocation { - span: Block { - local_id: 1, - execution_order: None, - inner_range: None, - }, - file: Some( - "test", - ), + primary_location: SourceLocation { + span: Block { + local_id: 1, + execution_order: None, + inner_range: None, }, - ], - err_no: cfc__unconnected_source, + file: Some( + "test", + ), + }, + secondary_locations: None, + severity: Error, + error_code: "E084", + sub_diagnostics: [], + internal_error: None, }, ] diff --git a/libs/stdlib/iec61131-st/string_conversion.st b/libs/stdlib/iec61131-st/string_conversion.st index 1903738316..bede652f70 100644 --- a/libs/stdlib/iec61131-st/string_conversion.st +++ b/libs/stdlib/iec61131-st/string_conversion.st @@ -25,15 +25,11 @@ END_FUNCTION * Converts WSTRING to WCHAR * *********************) +{external} FUNCTION WSTRING_TO_WCHAR : WCHAR VAR_INPUT {ref} in : WSTRING; END_VAR -VAR - ptr : REF_TO WCHAR; -END_VAR - ptr := ∈ - WSTRING_TO_WCHAR := ptr^; END_FUNCTION (******************** @@ -64,15 +60,11 @@ END_FUNCTION * Converts STRING to CHAR * *********************) +{external} FUNCTION STRING_TO_CHAR : CHAR VAR_INPUT {ref} in : STRING; END_VAR -VAR - ptr : REF_TO CHAR; -END_VAR - ptr := ∈ - STRING_TO_CHAR := ptr^; END_FUNCTION (******************** @@ -80,15 +72,11 @@ END_FUNCTION * Converts WCHAR to WSTRING * *********************) +{external} FUNCTION WCHAR_TO_WSTRING : WSTRING VAR_INPUT in : WCHAR; END_VAR -VAR - ptr : REF_TO WSTRING; -END_VAR - ptr := ∈ - WCHAR_TO_WSTRING := ptr^; END_FUNCTION (******************** @@ -108,15 +96,11 @@ END_FUNCTION * Converts CHAR to STRING * *********************) +{external} FUNCTION CHAR_TO_STRING : STRING VAR_INPUT in : CHAR; END_VAR -VAR - ptr : REF_TO STRING; -END_VAR - ptr := ∈ - CHAR_TO_STRING := ptr^; END_FUNCTION (******************** diff --git a/libs/stdlib/src/string_conversion.rs b/libs/stdlib/src/string_conversion.rs index 61ff7806dc..cc3999696e 100644 --- a/libs/stdlib/src/string_conversion.rs +++ b/libs/stdlib/src/string_conversion.rs @@ -69,3 +69,49 @@ pub extern "C" fn CHAR_TO_WCHAR(input: u8) -> u16 { res.encode_utf16(&mut arr); arr[0] } + +///. +/// Converts STRING to CHAR +/// # Safety +/// uses raw pointer +/// +#[allow(non_snake_case)] +#[no_mangle] +pub unsafe extern "C" fn STRING_TO_CHAR(input: *const u8) -> u8 { + *input +} + +///. +/// Converts WSTRING to WCHAR +/// # Safety +/// uses raw pointer +/// +#[allow(non_snake_case)] +#[no_mangle] +pub unsafe extern "C" fn WSTRING_TO_WCHAR(input: *const u16) -> u16 { + *input +} + +///. +/// Converts CHAR to STRING +/// # Safety +/// uses raw pointer +/// +#[allow(non_snake_case)] +#[no_mangle] +pub unsafe extern "C" fn CHAR_TO_STRING(dest: *mut u8, input: u8) -> i32 { + *dest = input; + 0 +} + +///. +/// Converts WCHAR to WSTRING +/// # Safety +/// uses raw pointer +/// +#[allow(non_snake_case)] +#[no_mangle] +pub unsafe extern "C" fn WCHAR_TO_WSTRING(dest: *mut u16, input: u16) -> i32 { + *dest = input; + 0 +} diff --git a/libs/stdlib/tests/common/mod.rs b/libs/stdlib/tests/common/mod.rs index 93eba4e5ba..8d4895fdfc 100644 --- a/libs/stdlib/tests/common/mod.rs +++ b/libs/stdlib/tests/common/mod.rs @@ -84,6 +84,10 @@ pub fn compile_with_native(context: &CodegenContext, source: T) - ("REAL_TO_DWORD", iec61131std::bit_num_conversion::REAL_TO_DWORD as usize), ("WSTRING_TO_STRING_EXT", iec61131std::string_conversion::WSTRING_TO_STRING_EXT as usize), ("STRING_TO_WSTRING_EXT", iec61131std::string_conversion::STRING_TO_WSTRING_EXT as usize), + ("STRING_TO_CHAR", iec61131std::string_conversion::STRING_TO_CHAR as usize), + ("WSTRING_TO_WCHAR", iec61131std::string_conversion::WSTRING_TO_WCHAR as usize), + ("CHAR_TO_STRING", iec61131std::string_conversion::CHAR_TO_STRING as usize), + ("WCHAR_TO_WSTRING", iec61131std::string_conversion::WCHAR_TO_WSTRING as usize), ("WCHAR_TO_CHAR", iec61131std::string_conversion::WCHAR_TO_CHAR as usize), ("CHAR_TO_WCHAR", iec61131std::string_conversion::CHAR_TO_WCHAR as usize), ("SHL__BYTE", iec61131std::bit_shift_functions::SHL__BYTE as usize), diff --git a/src/builtins.rs b/src/builtins.rs index 5ea50f91dc..9ea1f232be 100644 --- a/src/builtins.rs +++ b/src/builtins.rs @@ -263,7 +263,7 @@ lazy_static! { // return size of llvm type let size = generator.llvm_index .get_associated_type(type_name) - .map_err(|_| Diagnostic::codegen_error(&format!("Could not find associated data type: {type_name}"), location.clone()) + .map_err(|_| Diagnostic::codegen_error(format!("Could not find associated data type: {type_name}"), location.clone()) )?.size_of() .ok_or_else(|| Diagnostic::codegen_error("Parameter type is not sized.", location.clone()))? .as_basic_value_enum(); @@ -767,11 +767,15 @@ fn validate_variable_length_array_bound_function( let idx_type = annotations.get_type_or_void(idx, index); if !idx_type.has_nature(TypeNature::Int, index) { - validator.push_diagnostic(Diagnostic::invalid_type_nature( - idx_type.get_name(), - &format!("{:?}", TypeNature::Int), - idx.get_location(), - )) + validator.push_diagnostic( + Diagnostic::error(format!( + "Invalid type nature for generic argument. {} is no {}", + idx_type.get_name(), + TypeNature::Int + )) + .with_error_code("E062") + .with_location(idx.get_location()), + ) } // TODO: consider adding validation for consts and enums once https://github.com/PLC-lang/rusty/issues/847 has been implemented @@ -786,7 +790,11 @@ fn validate_variable_length_array_bound_function( }; if dimension_idx < 1 || dimension_idx > n_dimensions { - validator.push_diagnostic(Diagnostic::index_out_of_bounds(operator.get_location())) + validator.push_diagnostic( + Diagnostic::error("Index out of bound") + .with_error_code("E046") + .with_location(operator.get_location()), + ) } }; } @@ -814,7 +822,7 @@ fn generate_variable_length_array_bound_function<'ink>( // once we abort codegen on critical errors, revisit and change to unreachable where possible if !data_type_information.is_vla() { return Err(Diagnostic::codegen_error( - &format!("Expected VLA type, received {}", data_type_information.get_name()), + format!("Expected VLA type, received {}", data_type_information.get_name()), location, )); }; @@ -830,7 +838,7 @@ fn generate_variable_length_array_bound_function<'ink>( unreachable!("type cannot be VOID") }; return Err(Diagnostic::codegen_error( - &format!("Invalid literal type. Expected INT type, received {type_name} type"), + format!("Invalid literal type. Expected INT type, received {type_name} type"), location, )); }; @@ -846,7 +854,7 @@ fn generate_variable_length_array_bound_function<'ink>( if !value.is_int_value() { return Err(Diagnostic::codegen_error( - &format!("Expected INT value, found {}", value.get_type()), + format!("Expected INT value, found {}", value.get_type()), location, )); }; diff --git a/src/codegen.rs b/src/codegen.rs index fb9f5ce00e..12918eeda8 100644 --- a/src/codegen.rs +++ b/src/codegen.rs @@ -216,10 +216,7 @@ impl<'ink> CodeGen<'ink> { { self.module .verify() - .map_err(|it| Diagnostic::GeneralError { - message: it.to_string(), - err_no: crate::diagnostics::ErrNo::codegen__general, - }) + .map_err(|it| Diagnostic::GeneralError { message: it.to_string(), err_no: "E071" }) .map(|_| GeneratedModule { module: self.module, debug: self.debug }) } @@ -230,13 +227,17 @@ impl<'ink> CodeGen<'ink> { impl<'ink> GeneratedModule<'ink> { pub fn try_from_bitcode(context: &'ink CodegenContext, path: &Path) -> Result { - let module = Module::parse_bitcode_from_path(path, context.deref())?; + let module = Module::parse_bitcode_from_path(path, context.deref()) + .map_err(|it| Diagnostic::error(it.to_string_lossy()).with_error_code("E071"))?; Ok(GeneratedModule { module, engine: RefCell::new(None) }) } pub fn try_from_ir(context: &'ink CodegenContext, path: &Path) -> Result { - let buffer = MemoryBuffer::create_from_file(path)?; - let module = context.create_module_from_ir(buffer)?; + let buffer = MemoryBuffer::create_from_file(path) + .map_err(|it| Diagnostic::error(it.to_string_lossy()).with_error_code("E071"))?; + let module = context + .create_module_from_ir(buffer) + .map_err(|it| Diagnostic::error(it.to_string_lossy()).with_error_code("E071"))?; log::debug!("{}", module.to_string()); @@ -244,7 +245,9 @@ impl<'ink> GeneratedModule<'ink> { } pub fn merge(self, other: GeneratedModule<'ink>) -> Result { - self.module.link_in_module(other.module)?; + self.module + .link_in_module(other.module) + .map_err(|it| Diagnostic::error(it.to_string_lossy()).with_error_code("E071"))?; log::debug!("Merged: {}", self.module.to_string()); Ok(self) @@ -305,7 +308,7 @@ impl<'ink> GeneratedModule<'ink> { let target = inkwell::targets::Target::from_triple(&triple).map_err(|it| { Diagnostic::codegen_error( - &format!("Invalid target-tripple '{triple}' - {it:?}"), + format!("Invalid target-tripple '{triple}' - {it:?}"), SourceLocation::undefined(), ) })?; @@ -333,11 +336,11 @@ impl<'ink> GeneratedModule<'ink> { self.module .run_passes(optimization_level.opt_params(), &it, PassBuilderOptions::create()) .map_err(|it| { - Diagnostic::llvm_error(output.to_str().unwrap_or_default(), &it.to_string()) + Diagnostic::llvm_error(output.to_str().unwrap_or_default(), &it.to_string_lossy()) }) .and_then(|_| { it.write_to_file(&self.module, FileType::Object, output.as_path()).map_err(|it| { - Diagnostic::llvm_error(output.to_str().unwrap_or_default(), &it.to_string()) + Diagnostic::llvm_error(output.to_str().unwrap_or_default(), &it.to_string_lossy()) }) }) }) @@ -423,7 +426,12 @@ impl<'ink> GeneratedModule<'ink> { self.module .print_to_file(&output) .map_err(|err| { - Diagnostic::io_write_error(output.to_str().unwrap_or_default(), err.to_string().as_str()) + Diagnostic::error(format!( + "Cannot write file {} {}", + output.to_str().unwrap_or_default(), + err.to_string() + )) + .with_error_code("E002") }) .map(|_| output) } diff --git a/src/codegen/debug.rs b/src/codegen/debug.rs index 2eb056ba93..3618e8325d 100644 --- a/src/codegen/debug.rs +++ b/src/codegen/debug.rs @@ -334,7 +334,7 @@ impl<'ink> DebugBuilder<'ink> { .map(|it| it.get_range(index)) //Convert to normal range .collect::>, _>>() - .map_err(|err| Diagnostic::codegen_error(&err, SourceLocation::undefined()))?; + .map_err(|err| Diagnostic::codegen_error(err, SourceLocation::undefined()))?; let inner_type = self.get_or_create_debug_type(inner_type, index)?; let array_type = self.debug_info.create_array_type( inner_type.into(), @@ -380,7 +380,8 @@ impl<'ink> DebugBuilder<'ink> { self.types .get(&dt_name) .ok_or_else(|| { - Diagnostic::debug_error(format!("Cannot find debug information for type {dt_name}")) + Diagnostic::error(format!("Cannot find debug information for type {dt_name}")) + .with_error_code("E076") }) .map(|it| it.to_owned()) } @@ -658,7 +659,7 @@ impl<'ink> Debug<'ink> for DebugBuilder<'ink> { DataTypeInformation::String { size: string_size, encoding, .. } => { let length = string_size .as_int_value(index) - .map_err(|err| Diagnostic::codegen_error(&err, SourceLocation::undefined()))?; + .map_err(|err| Diagnostic::codegen_error(err, SourceLocation::undefined()))?; self.create_string_type(name, length, *encoding, size, alignment, index) } DataTypeInformation::Alias { name, referenced_type } diff --git a/src/codegen/generators/data_type_generator.rs b/src/codegen/generators/data_type_generator.rs index 09a3786565..d6c5ecf579 100644 --- a/src/codegen/generators/data_type_generator.rs +++ b/src/codegen/generators/data_type_generator.rs @@ -20,7 +20,6 @@ use inkwell::{ use plc_ast::ast::{AstNode, AstStatement}; use plc_ast::literals::AstLiteral; use plc_diagnostics::diagnostics::Diagnostic; -use plc_diagnostics::errno::ErrNo; use plc_source::source_location::SourceLocation; /// the data_type_generator generates user defined data-types /// - Structures @@ -155,16 +154,14 @@ pub fn generate_data_types<'ink>( .map(|(name, ty)| { errors .remove(name) - .map(|diag| diag.with_extra_ranges(&[ty.location.clone()])) + .map(|diag| diag.with_secondary_location(ty.location.clone())) .unwrap_or_else(|| Diagnostic::cannot_generate_initializer(name, ty.location.clone())) }) .collect::>(); //Report the operation failure - return Err(Diagnostic::CombinedDiagnostic { - message: "Some initial values were not generated".to_string(), - err_no: ErrNo::codegen__general, - inner_diagnostics: diags, - }); + return Err(Diagnostic::error("Some initial values were not generated") + .with_error_code("E075") + .with_sub_diagnostics(diags)); } Ok(generator.types_index) } @@ -230,11 +227,11 @@ impl<'ink, 'b> DataTypeGenerator<'ink, 'b> { if let DataTypeInformation::Integer { .. } = effective_type.get_type_information() { self.create_type(name, effective_type) } else { - Err(Diagnostic::invalid_type_nature( - effective_type.get_name(), - "ANY_INT", - SourceLocation::undefined(), + Err(Diagnostic::error(format!( + "Invalid type nature for generic argument. {} is no `ANY_INT`.", + effective_type.get_name() )) + .with_error_code("E062")) } } DataTypeInformation::Float { size, .. } => { @@ -405,7 +402,7 @@ impl<'ink, 'b> DataTypeGenerator<'ink, 'b> { Ok(Some(generator.generate_literal(initializer)?.get_basic_value_enum())) } else { Err(Diagnostic::codegen_error( - &format!("Expected {expected_ast} but found {initializer:?}"), + format!("Expected {expected_ast} but found {initializer:?}"), initializer.get_location(), )) } diff --git a/src/codegen/generators/expression_generator.rs b/src/codegen/generators/expression_generator.rs index 3b7f34588a..6693b9705c 100644 --- a/src/codegen/generators/expression_generator.rs +++ b/src/codegen/generators/expression_generator.rs @@ -344,7 +344,9 @@ impl<'ink, 'b> ExpressionCodeGenerator<'ink, 'b> { Ok(reference) } } else { - Err(Diagnostic::casting_error(access_type.get_name(), "Integer Type", index.get_location())) + Err(Diagnostic::error(format!("Cannot cast from {} to Integer Type", access_type.get_name())) + .with_error_code("E051") + .with_location(index.get_location())) } } @@ -445,7 +447,7 @@ impl<'ink, 'b> ExpressionCodeGenerator<'ink, 'b> { .find_associated_implementation(implementation_name) // using the non error option to control the output error .ok_or_else(|| { Diagnostic::codegen_error( - &format!("No callable implementation associated to {implementation_name:?}"), + format!("No callable implementation associated to {implementation_name:?}"), operator.get_location(), ) })?; @@ -556,7 +558,7 @@ impl<'ink, 'b> ExpressionCodeGenerator<'ink, 'b> { let output = builder.build_struct_gep(parameter_struct, index, "").map_err(|_| { Diagnostic::codegen_error( - &format!("Cannot build generate parameter: {parameter:#?}"), + format!("Cannot build generate parameter: {parameter:#?}"), parameter.source_location.clone(), ) })?; @@ -1015,7 +1017,7 @@ impl<'ink, 'b> ExpressionCodeGenerator<'ink, 'b> { .find_associated_pou_type(function_name) //Using find instead of get to control the compile error .ok_or_else(|| { Diagnostic::codegen_error( - &format!("No type associated with '{instance_name:}'"), + format!("No type associated with '{instance_name:}'"), context.get_location(), ) })?; @@ -1154,7 +1156,7 @@ impl<'ink, 'b> ExpressionCodeGenerator<'ink, 'b> { let pointer_to_param = builder.build_struct_gep(parameter_struct, index, "").map_err(|_| { Diagnostic::codegen_error( - &format!("Cannot build generate parameter: {expression:#?}"), + format!("Cannot build generate parameter: {expression:#?}"), expression.get_location(), ) })?; @@ -1355,7 +1357,7 @@ impl<'ink, 'b> ExpressionCodeGenerator<'ink, 'b> { let start_offset = dimension .start_offset .as_int_value(self.index) - .map_err(|it| Diagnostic::codegen_error(&it, access_expression.get_location()))?; + .map_err(|it| Diagnostic::codegen_error(it, access_expression.get_location()))?; let access_value = self.generate_expression(access_expression)?; //If start offset is not 0, adjust the current statement with an add operation @@ -1769,7 +1771,7 @@ impl<'ink, 'b> ExpressionCodeGenerator<'ink, 'b> { pub fn generate_literal(&self, literal_statement: &AstNode) -> Result, Diagnostic> { let cannot_generate_literal = || { Diagnostic::codegen_error( - &format!("Cannot generate Literal for {literal_statement:?}"), + format!("Cannot generate Literal for {literal_statement:?}"), literal_statement.get_location(), ) }; @@ -1901,7 +1903,12 @@ impl<'ink, 'b> ExpressionCodeGenerator<'ink, 'b> { DataTypeInformation::Integer { size: 16, .. } if expected_type.is_character() => { self.llvm.create_llvm_const_i16_char(value, location).map(ExpressionValue::RValue) } - _ => Err(Diagnostic::cannot_generate_string_literal(expected_type.get_name(), location.clone())), + _ => Err(Diagnostic::error(format!( + "Cannot generate String-Literal for type {}", + expected_type.get_name() + )) + .with_error_code("E074") + .with_location(location.clone())), } } @@ -1923,7 +1930,7 @@ impl<'ink, 'b> ExpressionCodeGenerator<'ink, 'b> { .or_else(|| self.annotations.get_type(statement, self.index)) .ok_or_else(|| { Diagnostic::codegen_error( - &format!("no type hint available for {statement:#?}"), + format!("no type hint available for {statement:#?}"), statement.get_location(), ) }) @@ -1992,7 +1999,7 @@ impl<'ink, 'b> ExpressionCodeGenerator<'ink, 'b> { )); } else { Err(Diagnostic::codegen_error( - &format!( + format!( "Expected {} fields for Struct {}, but found {}.", struct_type.count_fields(), struct_name, @@ -2003,7 +2010,7 @@ impl<'ink, 'b> ExpressionCodeGenerator<'ink, 'b> { } } else { Err(Diagnostic::codegen_error( - &format!("Expected Struct-literal, got {assignments:#?}"), + format!("Expected Struct-literal, got {assignments:#?}"), assignments.get_location(), )) } @@ -2181,7 +2188,7 @@ impl<'ink, 'b> ExpressionCodeGenerator<'ink, 'b> { Operator::And => builder.build_conditional_branch(lhs, right_branch, continue_branch), _ => { return Err(Diagnostic::codegen_error( - &format!("Cannot generate phi-expression for operator {operator:}"), + format!("Cannot generate phi-expression for operator {operator:}"), left.get_location(), )) } @@ -2570,11 +2577,16 @@ pub fn get_implicit_call_parameter<'a>( AstStatement::Assignment(data) | AstStatement::OutputAssignment(data) => { //explicit let Some(left_name) = data.left.as_ref().get_flat_reference_name() else { - return Err(Diagnostic::reference_expected(param_statement.get_location())); + return Err( + //TODO: use global context to get an expression slice + Diagnostic::error("Expression is not assignable") + .with_error_code("E050") + .with_location(param_statement.get_location()) + ); }; let loc = declared_parameters .iter() - .position(|p| p.get_name() == left_name) + .position(|p| p.get_name().eq_ignore_ascii_case(left_name)) .ok_or_else(|| Diagnostic::unresolved_reference(left_name, data.left.get_location()))?; (loc, data.right.as_ref(), false) } diff --git a/src/codegen/generators/llvm.rs b/src/codegen/generators/llvm.rs index 6023dc3b15..4dca0a578f 100644 --- a/src/codegen/generators/llvm.rs +++ b/src/codegen/generators/llvm.rs @@ -133,7 +133,7 @@ impl<'a> Llvm<'a> { ) -> Result, Diagnostic> { self.builder.build_struct_gep(pointer_to_struct_instance, member_index, name).map_err(|_| { Diagnostic::codegen_error( - &format!("Cannot generate qualified reference for {name:}"), + format!("Cannot generate qualified reference for {name:}"), offset.clone(), ) }) @@ -184,7 +184,7 @@ impl<'a> Llvm<'a> { match target_type { BasicTypeEnum::IntType { 0: int_type } => int_type .const_int_from_string(value, StringRadix::Decimal) - .ok_or_else(|| Diagnostic::codegen_error(&format!("Cannot parse {value} as int"), location)) + .ok_or_else(|| Diagnostic::codegen_error(format!("Cannot parse {value} as int"), location)) .map(BasicValueEnum::IntValue), BasicTypeEnum::FloatType { 0: float_type } => { let value = float_type.const_float_from_string(value); diff --git a/src/codegen/generators/pou_generator.rs b/src/codegen/generators/pou_generator.rs index fd12513cc1..f45f1acd24 100644 --- a/src/codegen/generators/pou_generator.rs +++ b/src/codegen/generators/pou_generator.rs @@ -289,7 +289,7 @@ impl<'ink, 'cg> PouGenerator<'ink, 'cg> { let current_function = self.llvm_index.find_associated_implementation(pou_name).ok_or_else(|| { Diagnostic::codegen_error( - &format!("Could not find generated stub for {pou_name}"), + format!("Could not find generated stub for {pou_name}"), implementation.location.clone(), ) })?; @@ -322,7 +322,7 @@ impl<'ink, 'cg> PouGenerator<'ink, 'cg> { linking_context: self.index.find_implementation_by_name(&implementation.name).ok_or_else( || { Diagnostic::codegen_error( - &format!("Could not find implementation for {}", &implementation.name), + format!("Could not find implementation for {}", &implementation.name), implementation.location.clone(), ) }, @@ -431,7 +431,7 @@ impl<'ink, 'cg> PouGenerator<'ink, 'cg> { } None => Ok(self.llvm.context.void_type().fn_type(¶ms, is_var_args)), _ => Err(Diagnostic::codegen_error( - &format!("Unsupported return type {return_type:?}"), + format!("Unsupported return type {return_type:?}"), SourceLocation::undefined(), )), } @@ -632,7 +632,7 @@ impl<'ink, 'cg> PouGenerator<'ink, 'cg> { let variable_llvm_type = self .llvm_index .get_associated_type(variable.get_type_name()) - .map_err(|err| Diagnostic::relocate(err, variable.source_location.clone()))?; + .map_err(|err| err.with_location(variable.source_location.clone()))?; let type_size = variable_llvm_type.size_of().ok_or_else(|| { Diagnostic::codegen_error("Couldn't determine type size", variable.source_location.clone()) diff --git a/src/codegen/generators/statement_generator.rs b/src/codegen/generators/statement_generator.rs index 0a65c636f7..6b0ed52bd5 100644 --- a/src/codegen/generators/statement_generator.rs +++ b/src/codegen/generators/statement_generator.rs @@ -322,10 +322,10 @@ impl<'a, 'b> StatementCodeGenerator<'a, 'b> { left_type, ) } else { - Err(Diagnostic::syntax_error( - &format!("{element:?} not a direct access"), - element.get_location(), - )) + //TODO: using the global context we could get a slice here + Err(Diagnostic::error(&format!("{element:?} not a direct access")) + .with_error_code("E055") + .with_location(element.get_location())) }?; for element in direct_access { let rhs_next = if let AstStatement::DirectAccess(data, ..) = element.get_stmt() { @@ -336,10 +336,10 @@ impl<'a, 'b> StatementCodeGenerator<'a, 'b> { left_type, ) } else { - Err(Diagnostic::syntax_error( - &format!("{element:?} not a direct access"), - element.get_location(), - )) + //TODO: using the global context we could get a slice here + Err(Diagnostic::error(&format!("{element:?} not a direct access")) + .with_error_code("E055") + .with_location(element.get_location())) }?; rhs = self.llvm.builder.build_int_add(rhs, rhs_next, ""); } @@ -796,7 +796,7 @@ impl<'a, 'b> StatementCodeGenerator<'a, 'b> { let value_ptr = self.llvm_index.find_loaded_associated_variable_value(ret_name).ok_or_else(|| { Diagnostic::codegen_error( - &format!("Cannot generate return variable for {call_name:}"), + format!("Cannot generate return variable for {call_name:}"), SourceLocation::undefined(), ) })?; diff --git a/src/codegen/generators/variable_generator.rs b/src/codegen/generators/variable_generator.rs index 82f2413c70..6df81c9ced 100644 --- a/src/codegen/generators/variable_generator.rs +++ b/src/codegen/generators/variable_generator.rs @@ -9,8 +9,7 @@ use crate::{ use indexmap::IndexSet; use inkwell::{module::Module, values::GlobalValue}; use plc_ast::ast::LinkageType; -use plc_diagnostics::{diagnostics::Diagnostic, errno::ErrNo}; -use plc_source::source_location::SourceLocation; +use plc_diagnostics::diagnostics::Diagnostic; use super::{ data_type_generator::get_default_for, @@ -80,8 +79,10 @@ impl<'ctx, 'b> VariableGenerator<'ctx, 'b> { if !variable.is_in_unit(location) { LinkageType::External } else { variable.get_linkage() }; let global_variable = self.generate_global_variable(variable, linkage).map_err(|err| match err.get_type() { - ErrNo::codegen__missing_function | ErrNo::reference__unresolved => { - Diagnostic::cannot_generate_initializer(name, SourceLocation::undefined()) + "E072" | "E048" => { + Diagnostic::error(format!("Cannot generate literal initializer for `{name}`.")) + .with_error_code("E041") + .with_sub_diagnostic(err) } _ => err, })?; diff --git a/src/codegen/tests/switch_case_tests.rs b/src/codegen/tests/switch_case_tests.rs index 8ba6841ca0..0ead01653a 100644 --- a/src/codegen/tests/switch_case_tests.rs +++ b/src/codegen/tests/switch_case_tests.rs @@ -42,7 +42,7 @@ fn switch_case_duplicate_integer_literal_integer() { assert_eq!( Diagnostic::GeneralError { message: "Duplicate integer as switch case\n switch i32 %load_input, label %else [\n i32 2, label %case\n i32 2, label %case1\n ]\ni32 2\n".into(), - err_no: crate::diagnostics::ErrNo::codegen__general, + err_no: "E071", }, msg ) @@ -76,7 +76,7 @@ fn switch_case_duplicate_integer_literal_integer_and_const() { assert_eq!( Diagnostic::GeneralError { message: "Duplicate integer as switch case\n switch i32 %load_input, label %else [\n i32 2, label %case\n i32 2, label %case1\n ]\ni32 2\n".into(), - err_no: crate::diagnostics::ErrNo::codegen__general, + err_no: "E071", }, msg ) @@ -106,7 +106,7 @@ fn switch_case_duplicate_integer_literal_integer_and_binary_expression() { assert_eq!( Diagnostic::GeneralError { message: "Duplicate integer as switch case\n switch i32 %load_input, label %else [\n i32 2, label %case\n i32 2, label %case1\n ]\ni32 2\n".into(), - err_no: crate::diagnostics::ErrNo::codegen__general, + err_no: "E071", }, msg ) @@ -142,7 +142,7 @@ fn switch_case_duplicate_integer_const() { assert_eq!( Diagnostic::GeneralError { message: "Duplicate integer as switch case\n switch i32 %load_input, label %else [\n i32 2, label %case\n i32 2, label %case1\n ]\ni32 2\n".into(), - err_no: crate::diagnostics::ErrNo::codegen__general, + err_no: "E071", }, msg ) @@ -176,7 +176,7 @@ fn switch_case_duplicate_integer_const_and_binary_expression() { assert_eq!( Diagnostic::GeneralError { message: "Duplicate integer as switch case\n switch i32 %load_input, label %else [\n i32 2, label %case\n i32 2, label %case1\n ]\ni32 2\n".into(), - err_no: crate::diagnostics::ErrNo::codegen__general, + err_no: "E071", }, msg ) @@ -206,7 +206,7 @@ fn switch_case_duplicate_integer_binary_expression() { assert_eq!( Diagnostic::GeneralError { message: "Duplicate integer as switch case\n switch i32 %load_input, label %else [\n i32 2, label %case\n i32 2, label %case1\n ]\ni32 2\n".into(), - err_no: crate::diagnostics::ErrNo::codegen__general, + err_no: "E071", }, msg ) diff --git a/src/hardware_binding.rs b/src/hardware_binding.rs index c16f73fdd8..fc000e5d58 100644 --- a/src/hardware_binding.rs +++ b/src/hardware_binding.rs @@ -1,5 +1,5 @@ use plc_ast::ast::{DirectAccessType, HardwareAccessType}; -use plc_diagnostics::{diagnostics::Diagnostic, errno::ErrNo}; +use plc_diagnostics::diagnostics::Diagnostic; use serde::{ ser::{SerializeSeq, SerializeStruct}, Serialize, Serializer, @@ -142,7 +142,7 @@ pub fn collect_hardware_configuration(index: &Index) -> Result Result { match format { - ConfigFormat::JSON => serde_json::to_string_pretty(&config) - .map_err(|e| Diagnostic::GeneralError { message: e.to_string(), err_no: ErrNo::general__io_err }), - ConfigFormat::TOML => toml::ser::to_string_pretty(&config) - .map_err(|e| Diagnostic::GeneralError { message: e.to_string(), err_no: ErrNo::general__io_err }), + ConfigFormat::JSON => serde_json::to_string_pretty(&config).map_err(|e| { + Diagnostic::error(e.to_string()).with_error_code("E002").with_internal_error(e.into()) + }), + ConfigFormat::TOML => toml::ser::to_string_pretty(&config).map_err(|e| { + Diagnostic::error(e.to_string()).with_error_code("E002").with_internal_error(e.into()) + }), } } diff --git a/src/index/visitor.rs b/src/index/visitor.rs index bc34fc3ca9..90de61de71 100644 --- a/src/index/visitor.rs +++ b/src/index/visitor.rs @@ -668,12 +668,12 @@ fn visit_array( Ok(Dimension { start_offset: TypeSize::from_expression(constants.add_constant_expression( *start.clone(), - typesystem::INT_TYPE.to_string(), + typesystem::DINT_TYPE.to_string(), scope.clone(), )), end_offset: TypeSize::from_expression(constants.add_constant_expression( *end.clone(), - typesystem::INT_TYPE.to_string(), + typesystem::DINT_TYPE.to_string(), scope.clone(), )), }) diff --git a/src/lexer.rs b/src/lexer.rs index 7e6e066dd7..ceff7102df 100644 --- a/src/lexer.rs +++ b/src/lexer.rs @@ -142,10 +142,14 @@ impl<'a> ParseSession<'a> { | Token::KeywordEndMethod | Token::KeywordEndClass => { if !self.slice().to_string().contains('_') { - self.accept_diagnostic(Diagnostic::ImprovementSuggestion { - message: format!("the words in {} should be separated by a '_'", self.slice()), - range: vec![self.location()], - }); + self.accept_diagnostic( + Diagnostic::warning(format!( + "the words in {} should be separated by a `_`", + self.slice() + )) + .with_error_code("E013") + .with_location(self.location()), + ); } } _ => {} diff --git a/src/lexer/tests/lexer_tests.rs b/src/lexer/tests/lexer_tests.rs index eff07b213e..1befe8edc7 100644 --- a/src/lexer/tests/lexer_tests.rs +++ b/src/lexer/tests/lexer_tests.rs @@ -794,10 +794,10 @@ fn multi_named_keywords_without_underscore_test() { let d1 = lexer.diagnostics.first().unwrap(); let d2 = lexer.diagnostics.last().unwrap(); - assert_eq!(d1.get_message(), "the words in VARINPUT should be separated by a '_'"); + assert_eq!(d1.get_message(), "the words in VARINPUT should be separated by a `_`"); assert_eq!(d1.get_location().to_range().unwrap(), (0..8)); - assert_eq!(d2.get_message(), "the words in ENDREPEAT should be separated by a '_'"); + assert_eq!(d2.get_message(), "the words in ENDREPEAT should be separated by a `_`"); assert_eq!(d2.get_location().to_range().unwrap(), (191..200)); } diff --git a/src/linker.rs b/src/linker.rs index 5ed9635077..4ece1cf0de 100644 --- a/src/linker.rs +++ b/src/linker.rs @@ -205,15 +205,20 @@ pub enum LinkerError { Path(PathBuf), } +//TODO: This should be of type error, or we should be using anyhow/thiserror here impl From for Diagnostic { fn from(error: LinkerError) -> Self { match error { - LinkerError::Link(e) => Diagnostic::link_error(&e), + LinkerError::Link(e) => { + Diagnostic::error(format!("An error occurred during linking: {e}")).with_error_code("E077") + } LinkerError::Path(path) => { - Diagnostic::link_error(&format!("path contains invalid UTF-8 characters: {}", path.display())) + Diagnostic::error(format!("path contains invalid UTF-8 characters: {}", path.display())) + .with_error_code("E077") } LinkerError::Target(tgt) => { - Diagnostic::link_error(&format!("linker not available for target platform: {tgt}")) + Diagnostic::error(format!("linker not available for target platform: {tgt}")) + .with_error_code("E077") } } } diff --git a/src/parser.rs b/src/parser.rs index 3e7a213d82..9ca95a6282 100644 --- a/src/parser.rs +++ b/src/parser.rs @@ -302,7 +302,11 @@ fn parse_type_nature(lexer: &mut ParseSession, nature: &str) -> TypeNature { "ANY_DATE" => TypeNature::Date, "__ANY_VLA" => TypeNature::__VLA, _ => { - lexer.accept_diagnostic(Diagnostic::unknown_type_nature(nature, lexer.location())); + lexer.accept_diagnostic( + Diagnostic::error(format!("Unkown type nature `{nature}`")) + .with_location(lexer.location()) + .with_error_code("E063"), + ); TypeNature::Any } } @@ -340,21 +344,42 @@ fn parse_return_type(lexer: &mut ParseSession, pou_type: &PouType) -> Option Option { if (opening_token == KeywordParensOpen && lexer.token == KeywordSquareParensClose) || (opening_token == KeywordSquareParensOpen && lexer.token == KeywordParensClose) { - lexer.accept_diagnostic(Diagnostic::ImprovementSuggestion { - message: "Mismatched types of parentheses around string size expression".into(), - range: vec![error_range], - }); + lexer.accept_diagnostic( + Diagnostic::error("Mismatched types of parentheses around string size expression") + .with_location(error_range) + .with_error_code("E009"), + ); } else if opening_token == KeywordParensOpen || lexer.token == KeywordParensClose { - lexer.accept_diagnostic(Diagnostic::ImprovementSuggestion { - message: "Unusual type of parentheses around string size expression, consider using square parentheses '[]'" - .into(), - range: vec![error_range], - }); + lexer.accept_diagnostic(Diagnostic::warning( + "Unusual type of parentheses around string size expression, consider using square parentheses '[]'"). + with_location(error_range) + .with_error_code("E014") + ); } Some(size_expr) @@ -871,7 +898,11 @@ fn parse_array_type_definition( let is_variable_length = match is_variable_length { Some(val) => val, None => { - Diagnostic::invalid_range_statement(&range, range.get_location()); + lexer.accept_diagnostic( + Diagnostic::error(format!("Expected a range statement, got {range:?} instead")) + .with_location(range.get_location()) + .with_error_code("E008"), + ); false } }; @@ -965,10 +996,11 @@ fn parse_variable_block_type(lexer: &mut ParseSession) -> VariableBlockType { let argument_property = if lexer.try_consume(&PropertyByRef) { //Report a diagnostic if blocktype is incompatible if !matches!(block_type, KeywordVarInput) { - lexer.accept_diagnostic(Diagnostic::invalid_pragma_location( - "Only VAR_INPUT support by ref properties", - lexer.location(), - )) + lexer.accept_diagnostic( + Diagnostic::warning("Invalid pragma location: Only VAR_INPUT support by ref properties") + .with_error_code("E024") + .with_location(lexer.location()), + ) } ArgumentProperty::ByRef } else { diff --git a/src/parser/control_parser.rs b/src/parser/control_parser.rs index ce42bf94b9..c1feca1c45 100644 --- a/src/parser/control_parser.rs +++ b/src/parser/control_parser.rs @@ -182,10 +182,11 @@ fn parse_case_statement(lexer: &mut ParseSession) -> AstNode { } else { //If no current condition is available, log a diagnostic and add an empty condition if current_condition.is_none() { - lexer.accept_diagnostic(Diagnostic::syntax_error( - "Missing Case-Condition", - lexer.location(), - )); + lexer.accept_diagnostic( + Diagnostic::error("Missing Case-Condition") + .with_error_code("E012") + .with_location(lexer.location()), + ); current_condition = Some(Box::new(AstFactory::create_empty_statement(lexer.location(), lexer.next_id()))); } diff --git a/src/parser/expressions_parser.rs b/src/parser/expressions_parser.rs index 8576144282..2131dfa37d 100644 --- a/src/parser/expressions_parser.rs +++ b/src/parser/expressions_parser.rs @@ -523,10 +523,10 @@ fn parse_literal_number(lexer: &mut ParseSession, is_negative: bool) -> Result().map_err(|e| { - Diagnostic::syntax_error( - format!("{e}").as_str(), - lexer.source_range_factory.create_range(location), - ) + Diagnostic::error(format!("Failed parsing number {result}")) + .with_error_code("E011") + .with_location(lexer.source_range_factory.create_range(location)) + .with_internal_error(e.into()) })?; let element = parse_expression(lexer); lexer.expect(KeywordParensClose)?; @@ -570,7 +570,9 @@ pub fn parse_strict_literal_integer(lexer: &mut ParseSession) -> Result(text: &str, location: &SourceLocation) -> Result { text.parse::().map_err(|_| { - Diagnostic::syntax_error(format!("Failed parsing number {text}").as_str(), location.clone()) + Diagnostic::error(format!("Failed parsing number {text}")) + .with_error_code("E011") + .with_location(location.clone()) }) } @@ -693,7 +695,9 @@ fn parse_literal_time(lexer: &mut ParseSession) -> Result { //just eat all the digits char = chars.find(|(_, ch)| !ch.is_ascii_digit() && !ch.eq(&'.')); char.ok_or_else(|| { - Diagnostic::syntax_error("Invalid TIME Literal: Cannot parse segment.", location.clone()) + Diagnostic::error("Invalid TIME Literal: Cannot parse segment.") + .with_error_code("E010") + .with_location(location.clone()) }) .and_then(|(index, _)| parse_number::(&slice[start..index], &location))? }; @@ -701,10 +705,9 @@ fn parse_literal_time(lexer: &mut ParseSession) -> Result { //expect a unit let unit = { let start = char.map(|(index, _)| index).ok_or_else(|| { - Diagnostic::syntax_error( - "Invalid TIME Literal: Missing unit (d|h|m|s|ms|us|ns)", - location.clone(), - ) + Diagnostic::error("Invalid TIME Literal: Missing unit (d|h|m|s|ms|us|ns)") + .with_error_code("E010") + .with_location(location.clone()) })?; //just eat all the characters @@ -727,25 +730,22 @@ fn parse_literal_time(lexer: &mut ParseSession) -> Result { if let Some(position) = position { //check if we assign out of order - every assignment before must have been a smaller position if prev_pos > position { - return Err(Diagnostic::syntax_error( - "Invalid TIME Literal: segments out of order, use d-h-m-s-ms", - location, - )); + return Err(Diagnostic::error("Invalid TIME Literal: segments out of order, use d-h-m-s-ms") + .with_error_code("E010") + .with_location(location)); } prev_pos = position; //remember that we wrote this position if values[position].is_some() { - return Err(Diagnostic::syntax_error( - "Invalid TIME Literal: segments must be unique", - location, - )); + return Err(Diagnostic::error("Invalid TIME Literal: segments must be unique") + .with_error_code("E010") + .with_location(location)); } values[position] = Some(number); //store the number } else { - return Err(Diagnostic::syntax_error( - format!("Invalid TIME Literal: illegal unit '{unit}'").as_str(), - location, - )); + return Err(Diagnostic::error(format!("Invalid TIME Literal: illegal unit '{unit}'")) + .with_error_code("E010") + .with_location(location)); } } diff --git a/src/parser/tests/parse_errors/snapshots/rusty__parser__tests__parse_errors__parse_error_containers_tests__function_return_type_with_initializer.snap b/src/parser/tests/parse_errors/snapshots/rusty__parser__tests__parse_errors__parse_error_containers_tests__function_return_type_with_initializer.snap index 6c9d44d6b9..008ff486e1 100644 --- a/src/parser/tests/parse_errors/snapshots/rusty__parser__tests__parse_errors__parse_error_containers_tests__function_return_type_with_initializer.snap +++ b/src/parser/tests/parse_errors/snapshots/rusty__parser__tests__parse_errors__parse_error_containers_tests__function_return_type_with_initializer.snap @@ -2,10 +2,10 @@ source: src/parser/tests/parse_errors/parse_error_containers_tests.rs expression: diagnostics --- -error: Return types cannot have a default value +warning: Return types cannot have a default value, the value will be ignored ┌─ :2:35 │ 2 │ FUNCTION foo : INT := 3 - │ ^ Return types cannot have a default value + │ ^ Return types cannot have a default value, the value will be ignored diff --git a/src/parser/tests/parse_errors/snapshots/rusty__parser__tests__parse_errors__parse_error_literals_tests__string_with_round_parens_can_be_parsed.snap b/src/parser/tests/parse_errors/snapshots/rusty__parser__tests__parse_errors__parse_error_literals_tests__string_with_round_parens_can_be_parsed.snap index 6dcdfbc038..6104250513 100644 --- a/src/parser/tests/parse_errors/snapshots/rusty__parser__tests__parse_errors__parse_error_literals_tests__string_with_round_parens_can_be_parsed.snap +++ b/src/parser/tests/parse_errors/snapshots/rusty__parser__tests__parse_errors__parse_error_literals_tests__string_with_round_parens_can_be_parsed.snap @@ -8,13 +8,13 @@ warning: Unusual type of parentheses around string size expression, consider usi 2 │ TYPE MyString1 : STRING(253); END_TYPE │ ^^^^ Unusual type of parentheses around string size expression, consider using square parentheses '[]' -warning: Mismatched types of parentheses around string size expression +error: Mismatched types of parentheses around string size expression ┌─ :3:37 │ 3 │ TYPE MyString2 : STRING[254) := 'abc'; END_TYPE │ ^^^^ Mismatched types of parentheses around string size expression -warning: Mismatched types of parentheses around string size expression +error: Mismatched types of parentheses around string size expression ┌─ :4:37 │ 4 │ TYPE MyString3 : STRING(255]; END_TYPE diff --git a/src/parser/tests/parse_errors/snapshots/rusty__parser__tests__parse_errors__parse_error_statements_tests__pointer_type_with_wrong_keyword_to_test.snap b/src/parser/tests/parse_errors/snapshots/rusty__parser__tests__parse_errors__parse_error_statements_tests__pointer_type_with_wrong_keyword_to_test.snap index b937c33306..36719f3515 100644 --- a/src/parser/tests/parse_errors/snapshots/rusty__parser__tests__parse_errors__parse_error_statements_tests__pointer_type_with_wrong_keyword_to_test.snap +++ b/src/parser/tests/parse_errors/snapshots/rusty__parser__tests__parse_errors__parse_error_statements_tests__pointer_type_with_wrong_keyword_to_test.snap @@ -2,11 +2,11 @@ source: src/parser/tests/parse_errors/parse_error_statements_tests.rs expression: diagnostics --- -warning: 'POINTER TO' is not a standard keyword, use REF_TO instead +warning: `POINTER TO` is not a standard keyword, use `REF_TO` instead ┌─ :3:13 │ 3 │ POINTER tu INT; - │ ^^^^^^^ 'POINTER TO' is not a standard keyword, use REF_TO instead + │ ^^^^^^^ `POINTER TO` is not a standard keyword, use `REF_TO` instead error: Unexpected token: expected KeywordTo but found tu ┌─ :3:21 diff --git a/src/parser/tests/parse_errors/snapshots/rusty__parser__tests__parse_errors__parse_error_statements_tests__pointer_type_without_to_test.snap b/src/parser/tests/parse_errors/snapshots/rusty__parser__tests__parse_errors__parse_error_statements_tests__pointer_type_without_to_test.snap index 0c9778ff66..2adf21ddeb 100644 --- a/src/parser/tests/parse_errors/snapshots/rusty__parser__tests__parse_errors__parse_error_statements_tests__pointer_type_without_to_test.snap +++ b/src/parser/tests/parse_errors/snapshots/rusty__parser__tests__parse_errors__parse_error_statements_tests__pointer_type_without_to_test.snap @@ -2,11 +2,11 @@ source: src/parser/tests/parse_errors/parse_error_statements_tests.rs expression: diagnostics --- -warning: 'POINTER TO' is not a standard keyword, use REF_TO instead +warning: `POINTER TO` is not a standard keyword, use `REF_TO` instead ┌─ :3:13 │ 3 │ POINTER INT; - │ ^^^^^^^ 'POINTER TO' is not a standard keyword, use REF_TO instead + │ ^^^^^^^ `POINTER TO` is not a standard keyword, use `REF_TO` instead error: Unexpected token: expected KeywordTo but found INT ┌─ :3:21 diff --git a/src/parser/tests/snapshots/rusty__parser__tests__container_parser_tests__actions_with_invalid_token.snap b/src/parser/tests/snapshots/rusty__parser__tests__container_parser_tests__actions_with_invalid_token.snap index 99974e4e73..828af6a8e9 100644 --- a/src/parser/tests/snapshots/rusty__parser__tests__container_parser_tests__actions_with_invalid_token.snap +++ b/src/parser/tests/snapshots/rusty__parser__tests__container_parser_tests__actions_with_invalid_token.snap @@ -2,22 +2,24 @@ source: src/parser/tests/container_parser_tests.rs expression: errors.first().unwrap() --- -SyntaxError { +Diagnostic { message: "Unexpected token: expected KeywordAction but found BRAVO", - range: [ - SourceLocation { - span: Range( - TextLocation { - line: 0, - column: 13, - offset: 13, - }..TextLocation { - line: 0, - column: 18, - offset: 18, - }, - ), - }, - ], - err_no: syntax__unexpected_token, + primary_location: SourceLocation { + span: Range( + TextLocation { + line: 0, + column: 13, + offset: 13, + }..TextLocation { + line: 0, + column: 18, + offset: 18, + }, + ), + }, + secondary_locations: None, + severity: Error, + error_code: "E007", + sub_diagnostics: [], + internal_error: None, } diff --git a/src/parser/tests/snapshots/rusty__parser__tests__function_parser_tests__function_inline_enum_return_unsupported.snap b/src/parser/tests/snapshots/rusty__parser__tests__function_parser_tests__function_inline_enum_return_unsupported.snap index 34c6bc91b4..c9422d9bfe 100644 --- a/src/parser/tests/snapshots/rusty__parser__tests__function_parser_tests__function_inline_enum_return_unsupported.snap +++ b/src/parser/tests/snapshots/rusty__parser__tests__function_parser_tests__function_inline_enum_return_unsupported.snap @@ -2,10 +2,10 @@ source: src/parser/tests/function_parser_tests.rs expression: diagnostics --- -error: Data Type DataTypeDefinition { data_type: EnumType { name: None, numeric_type: "DINT", elements: ExpressionList { expressions: [ReferenceExpr { kind: Member(Identifier { name: "green" }), base: None }, ReferenceExpr { kind: Member(Identifier { name: "yellow" }), base: None }, ReferenceExpr { kind: Member(Identifier { name: "red" }), base: None }] } } } not supported as a function return type! +error: Data Type (green, yellow, red) not supported as a function return type! ┌─ :1:16 │ 1 │ FUNCTION foo : (green, yellow, red) VAR_INPUT END_VAR END_FUNCTION - │ ^^^^^^^^^^^^^^^^^^^^ Data Type DataTypeDefinition { data_type: EnumType { name: None, numeric_type: "DINT", elements: ExpressionList { expressions: [ReferenceExpr { kind: Member(Identifier { name: "green" }), base: None }, ReferenceExpr { kind: Member(Identifier { name: "yellow" }), base: None }, ReferenceExpr { kind: Member(Identifier { name: "red" }), base: None }] } } } not supported as a function return type! + │ ^^^^^^^^^^^^^^^^^^^^ Data Type (green, yellow, red) not supported as a function return type! diff --git a/src/parser/tests/snapshots/rusty__parser__tests__function_parser_tests__function_inline_struct_return_unsupported.snap b/src/parser/tests/snapshots/rusty__parser__tests__function_parser_tests__function_inline_struct_return_unsupported.snap index ab09be8ccd..24ff9692db 100644 --- a/src/parser/tests/snapshots/rusty__parser__tests__function_parser_tests__function_inline_struct_return_unsupported.snap +++ b/src/parser/tests/snapshots/rusty__parser__tests__function_parser_tests__function_inline_struct_return_unsupported.snap @@ -2,11 +2,11 @@ source: src/parser/tests/function_parser_tests.rs expression: diagnostics --- -error: Data Type DataTypeDefinition { data_type: StructType { name: None, variables: [Variable { name: "x", data_type: DataTypeReference { referenced_type: "INT" } }, Variable { name: "y", data_type: DataTypeReference { referenced_type: "INT" } }] } } not supported as a function return type! +error: Data Type STRUCT x : INT; y : INT; END_STRUCT not supported as a function return type! ┌─ :1:16 │ 1 │ FUNCTION foo : STRUCT x : INT; y : INT; END_STRUCT VAR_INPUT END_VAR END_FUNCTION - │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Data Type DataTypeDefinition { data_type: StructType { name: None, variables: [Variable { name: "x", data_type: DataTypeReference { referenced_type: "INT" } }, Variable { name: "y", data_type: DataTypeReference { referenced_type: "INT" } }] } } not supported as a function return type! + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Data Type STRUCT x : INT; y : INT; END_STRUCT not supported as a function return type! error: Unexpected token: expected Literal but found END_STRUCT ┌─ :1:41 diff --git a/src/parser/tests/snapshots/rusty__parser__tests__type_parser_tests__global_pointer_declaration-3.snap b/src/parser/tests/snapshots/rusty__parser__tests__type_parser_tests__global_pointer_declaration-3.snap index 5ba7f938d2..0f55cbd50f 100644 --- a/src/parser/tests/snapshots/rusty__parser__tests__type_parser_tests__global_pointer_declaration-3.snap +++ b/src/parser/tests/snapshots/rusty__parser__tests__type_parser_tests__global_pointer_declaration-3.snap @@ -2,10 +2,10 @@ source: src/parser/tests/type_parser_tests.rs expression: diagnostics --- -warning: 'POINTER TO' is not a standard keyword, use REF_TO instead +warning: `POINTER TO` is not a standard keyword, use `REF_TO` instead ┌─ :4:29 │ 4 │ SamplePointer : POINTER TO INT; - │ ^^^^^^^ 'POINTER TO' is not a standard keyword, use REF_TO instead + │ ^^^^^^^ `POINTER TO` is not a standard keyword, use `REF_TO` instead diff --git a/src/resolver/const_evaluator.rs b/src/resolver/const_evaluator.rs index a108adcf80..cfda5b1bcf 100644 --- a/src/resolver/const_evaluator.rs +++ b/src/resolver/const_evaluator.rs @@ -562,7 +562,7 @@ fn resolve_const_reference( index: &Index, ) -> Result, UnresolvableKind> { if !variable.is_constant() { - return Err(UnresolvableKind::Misc(format!("'{name}' is no const reference"))); + return Err(UnresolvableKind::Misc(format!("`{name}` is no const reference"))); } if let Some(ConstExpression::Resolved(statement)) = diff --git a/src/resolver/tests/const_resolver_tests.rs b/src/resolver/tests/const_resolver_tests.rs index d5ac99e58d..5fd4a3cf8a 100644 --- a/src/resolver/tests/const_resolver_tests.rs +++ b/src/resolver/tests/const_resolver_tests.rs @@ -228,9 +228,9 @@ fn non_const_references_to_int_compile_time_evaluation() { debug_assert_eq!( vec![ - UnresolvableConstant::new(global!(index, "nok_a"), "'a' is no const reference"), - UnresolvableConstant::new(global!(index, "nok_b"), "'b' is no const reference"), - UnresolvableConstant::new(global!(index, "temp"), "'a' is no const reference"), + UnresolvableConstant::new(global!(index, "nok_a"), "`a` is no const reference"), + UnresolvableConstant::new(global!(index, "nok_b"), "`b` is no const reference"), + UnresolvableConstant::new(global!(index, "temp"), "`a` is no const reference"), UnresolvableConstant::incomplete_initialzation(&global!(index, "incomplete")), //this one is fine, but one depency cannot be resolved ], unresolvable diff --git a/src/resolver/tests/resolve_literals_tests.rs b/src/resolver/tests/resolve_literals_tests.rs index 5997737c1e..790ae527de 100644 --- a/src/resolver/tests/resolve_literals_tests.rs +++ b/src/resolver/tests/resolve_literals_tests.rs @@ -545,7 +545,7 @@ fn struct_field_members_assignments_are_annotated_correctly_in_array_of_structs( // x := 0 let x = &elements[0]; - assert_eq!(&annotations.get_type_hint(&x, &index).unwrap().name, "STRUCT1"); + assert_eq!(&annotations.get_type_hint(x, &index).unwrap().name, "STRUCT1"); // arr := [(y := 0), (z := 0)] let AstStatement::Assignment(assignment) = &elements[1].stmt else { panic!() }; @@ -556,9 +556,9 @@ fn struct_field_members_assignments_are_annotated_correctly_in_array_of_structs( // y := 0 let AstStatement::ParenExpression(y) = &elements[0].stmt else { panic!() }; - assert_eq!(&annotations.get_type_hint(&y, &index).unwrap().name, "STRUCT2"); + assert_eq!(&annotations.get_type_hint(y, &index).unwrap().name, "STRUCT2"); // z := 0 let AstStatement::ParenExpression(z) = &elements[1].stmt else { panic!() }; - assert_eq!(&annotations.get_type_hint(&z, &index).unwrap().name, "STRUCT2"); + assert_eq!(&annotations.get_type_hint(z, &index).unwrap().name, "STRUCT2"); } diff --git a/src/typesystem.rs b/src/typesystem.rs index e97cdd34d7..df5bc6b53d 100644 --- a/src/typesystem.rs +++ b/src/typesystem.rs @@ -171,6 +171,10 @@ impl DataType { self.get_type_information().is_vla() } + pub fn is_pointer(&self) -> bool { + self.get_type_information().is_pointer() + } + /// returns true if this type is an array, struct or string pub fn is_aggregate_type(&self) -> bool { self.get_type_information().is_aggregate() diff --git a/src/validation.rs b/src/validation.rs index d1038b6ca6..6c5e058550 100644 --- a/src/validation.rs +++ b/src/validation.rs @@ -143,7 +143,9 @@ impl<'a> Validator<'a> { continue; }; - self.push_diagnostic(Diagnostic::overflow(reason.to_owned(), location.to_owned())); + self.push_diagnostic( + Diagnostic::warning(reason).with_error_code("E038").with_location(location.to_owned()), + ); } } diff --git a/src/validation/array.rs b/src/validation/array.rs index baa2038ea0..509a3c8274 100644 --- a/src/validation/array.rs +++ b/src/validation/array.rs @@ -69,7 +69,11 @@ fn validate_array( ) { let stmt_rhs = peel(rhs_stmt); if !(stmt_rhs.is_literal_array() || stmt_rhs.is_reference() || stmt_rhs.is_call()) { - validator.push_diagnostic(Diagnostic::array_assignment(stmt_rhs.get_location())); + validator.push_diagnostic( + Diagnostic::error("Array assignments must be surrounded with `[]`") + .with_error_code("E043") + .with_location(stmt_rhs.get_location()), + ); return; // Return here, because array size validation is error-prone with incorrect assignments } @@ -83,7 +87,13 @@ fn validate_array( if len_lhs < len_rhs { let name = statement.lhs_name(validator.context); let location = stmt_rhs.get_location(); - validator.push_diagnostic(Diagnostic::array_size(&name, len_lhs, len_rhs, location)); + validator.push_diagnostic( + Diagnostic::error(format!( + "Array `{name}` has a size of {len_lhs}, but {len_rhs} elements were provided" + )) + .with_error_code("E043") + .with_location(location), + ); } } @@ -105,13 +115,21 @@ fn validate_array_of_structs( match elements { AstStatement::ExpressionList(expressions) => { for invalid in expressions.iter().filter(|it| !it.is_paren()) { - validator.push_diagnostic(Diagnostic::array_struct_assignment(invalid.get_location())); + validator.push_diagnostic( + Diagnostic::error("Struct initializers within arrays have to be wrapped by `()`") + .with_error_code("E043") + .with_location(invalid.get_location()), + ); } } // arr := [foo := 0] AstStatement::Assignment(..) => { - validator.push_diagnostic(Diagnostic::array_struct_assignment(rhs_stmt.get_location())); + validator.push_diagnostic( + Diagnostic::error("Struct initializers within arrays have to be wrapped by `()`") + .with_error_code("E043") + .with_location(rhs_stmt.get_location()), + ); } _ => (), diff --git a/src/validation/global.rs b/src/validation/global.rs index 6672334fde..b620015c49 100644 --- a/src/validation/global.rs +++ b/src/validation/global.rs @@ -34,30 +34,29 @@ impl GlobalValidator { locations: &[&SourceLocation], additional_text: Option<&str>, ) { - for (idx, v) in locations.iter().enumerate() { - let others = locations - .iter() - .enumerate() - .filter(|(j, _)| idx != (*j)) - .map(|(_, it)| (*it).clone()) - .collect::>(); + for v in locations.iter() { + let others = locations.iter().filter(|it| *it != v).map(|it| (*it).clone()).collect::>(); // If the SourceRange of `v` is undefined, we can assume the user choose a name which clashes // with an (internal) built-in datatype, hence the undefined location. if v.is_undefined() { - self.diagnostics.push(Diagnostic::invalid_type_name(name, others)); - continue; // Skip this iteration, otherwise we would also report an internal error - } - - if let Some(additional_text) = additional_text { - self.push_diagnostic(Diagnostic::global_name_conflict_with_text( - name, - (*v).clone(), - others, - additional_text, - )); + for other in others { + self.diagnostics.push( + Diagnostic::error(format!( + "{name} can not be used as a name because it is a built-in datatype" + )) + .with_location((other).clone()) + .with_error_code("E004"), + ); + } } else { - self.push_diagnostic(Diagnostic::global_name_conflict(name, (*v).clone(), others)); + let additional_text = additional_text.unwrap_or("Duplicate symbol."); + self.push_diagnostic( + Diagnostic::error(format!("{name}: {additional_text}")) + .with_error_code("E004") + .with_location((*v).clone()) + .with_secondary_locations(others), + ); } } } diff --git a/src/validation/pou.rs b/src/validation/pou.rs index 3105682098..19227aa7d9 100644 --- a/src/validation/pou.rs +++ b/src/validation/pou.rs @@ -22,14 +22,16 @@ pub fn visit_implementation( context: &ValidationContext<'_, T>, ) { if implementation.pou_type == PouType::Class && !implementation.statements.is_empty() { - validator.push_diagnostic(Diagnostic::syntax_error( - "A class cannot have an implementation", - implementation.location.to_owned(), - )); + validator.push_diagnostic( + Diagnostic::error("A class cannot have an implementation") + .with_error_code("E017") + .with_location(implementation.location.to_owned()), + ); } if implementation.linkage != LinkageType::External { validate_action_container(validator, implementation); - //Validate the label uniquiness + //Validate the label uniqueness + if let Some(labels) = context.index.get_labels(&implementation.name) { for (_, labels) in labels.entries() { let mut label_iter = labels.iter(); @@ -39,11 +41,12 @@ pub fn visit_implementation( let mut locations: Vec<_> = label_iter.map(|it| it.location.clone()).collect(); locations.push(first.location.clone()); locations.push(second.location.clone()); - validator.push_diagnostic(Diagnostic::duplicate_label( - &first.name, - first.location.clone(), - locations, - )); + validator.push_diagnostic( + Diagnostic::error(format!("{}: Duplicate label.", &first.name)) + .with_error_code("E018") + .with_location(first.location.clone()) + .with_secondary_locations(locations), + ); } } } @@ -68,55 +71,68 @@ fn validate_pou(validator: &mut Validator, pou: &Pou, context: fn validate_class(validator: &mut Validator, pou: &Pou, context: &ValidationContext) { // var in/out/inout blocks are not allowed inside of class declaration + // TODO: This should be on each block if pou.variable_blocks.iter().any(|it| { matches!( it.variable_block_type, VariableBlockType::InOut | VariableBlockType::Input(_) | VariableBlockType::Output ) }) { - validator.push_diagnostic(Diagnostic::syntax_error( - "A class cannot have a var in/out/inout blocks", - pou.name_location.to_owned(), - )); + validator.push_diagnostic( + Diagnostic::error("A class cannot have a var in/out/inout blocks") + .with_error_code("E019") + .with_location(pou.name_location.to_owned()), + ); } // classes cannot have a return type if context.index.find_return_type(&pou.name).is_some() { - validator.push_diagnostic(Diagnostic::syntax_error( - "A class cannot have a return type", - pou.name_location.to_owned(), - )); + validator.push_diagnostic( + Diagnostic::error("A class cannot have a return type") + .with_error_code("E020") + .with_location(pou.name_location.clone()), + ); } } fn validate_function(validator: &mut Validator, pou: &Pou, context: &ValidationContext) { // functions cannot use EXTENDS if pou.super_class.is_some() { - validator.push_diagnostic(Diagnostic::syntax_error( - "A function cannot use EXTEND", - pou.name_location.to_owned(), - )); + validator.push_diagnostic( + Diagnostic::error("A function cannot use `EXTEND`") + .with_error_code("E021") + .with_location(pou.name_location.to_owned()), + ); } let return_type = context.index.find_return_type(&pou.name); // functions must have a return type if return_type.is_none() { - validator.push_diagnostic(Diagnostic::function_return_missing(pou.name_location.to_owned())); + validator.push_diagnostic( + Diagnostic::error("Function Return type missing") + .with_error_code("E025") + .with_location(pou.name_location.clone()), + ); } } fn validate_program(validator: &mut Validator, pou: &Pou) { // programs cannot use EXTENDS if pou.super_class.is_some() { - validator.push_diagnostic(Diagnostic::syntax_error( - "A program cannot use EXTEND", - pou.name_location.to_owned(), - )); + validator.push_diagnostic( + Diagnostic::error("A program cannot use `EXTEND`") + .with_error_code("E021") + .with_location(pou.name_location.to_owned()), + ); } } pub fn validate_action_container(validator: &mut Validator, implementation: &Implementation) { if implementation.pou_type == PouType::Action && implementation.type_name == "__unknown__" { - validator.push_diagnostic(Diagnostic::missing_action_container(implementation.location.clone())); + validator.push_diagnostic( + Diagnostic::warning("Missing Actions Container Name") + .with_error_code("E022") + .with_location(implementation.location.clone()), + ); } } diff --git a/src/validation/recursive.rs b/src/validation/recursive.rs index b48a3aa1f8..96ff19b7ba 100644 --- a/src/validation/recursive.rs +++ b/src/validation/recursive.rs @@ -103,11 +103,26 @@ impl RecursiveValidator { match path.get_index_of(node) { Some(idx) => { let mut slice = path.iter().skip(idx).copied().collect::>(); - let ranges = slice.iter().map(|node| node.location.to_owned()).collect(); + let ranges = slice.iter().map(|node| node.location.to_owned()).collect::>(); slice.push(node); // Append to get `B -> C -> B` instead of `B -> C` in the report let error = slice.iter().map(|it| it.get_name()).join(" -> "); - self.diagnostics.push(Diagnostic::recursive_datastructure(&error, ranges)); + let diagnostic = + Diagnostic::error(format!("Recursive data structure `{}` has infinite size", error)) + .with_error_code("E029"); + + let diagnostic = if let Some(first) = ranges.first() { + diagnostic.with_location(first.clone()) + } else { + diagnostic + }; + + let diagnostic = if ranges.len() > 1 { + ranges.iter().fold(diagnostic, |prev, it| prev.with_secondary_location(it.clone())) + } else { + diagnostic + }; + self.diagnostics.push(diagnostic); } None => unreachable!("Node has to be in the IndexSet"), diff --git a/src/validation/statement.rs b/src/validation/statement.rs index fc1228390b..7445fa8ba9 100644 --- a/src/validation/statement.rs +++ b/src/validation/statement.rs @@ -110,9 +110,11 @@ pub fn visit_statement( // if we get here, then a `CaseCondition` is used outside a `CaseStatement` // `CaseCondition` are used as a marker for `CaseStatements` and are not passed as such to the `CaseStatement.case_blocks` // see `control_parser` `parse_case_statement()` - validator.push_diagnostic(Diagnostic::case_condition_used_outside_case_statement( - condition.get_location(), - )); + validator.push_diagnostic( + Diagnostic::error("Case condition used outside of case statement! Did you mean to use ';'?") + .with_error_code("E079") + .with_location(condition.get_location()), + ); visit_statement(validator, condition, context); } AstStatement::JumpStatement(JumpStatement { condition, target }) => { @@ -161,10 +163,11 @@ fn validate_reference_expression( if let Some(base) = base { visit_array_access(validator, base, i, context) } else { - validator.push_diagnostic(Diagnostic::invalid_operation( - "Index-Access requires an array-value.", - statement.get_location(), - )); + validator.push_diagnostic( + Diagnostic::error("Index-Access requires an array-value.") + .with_error_code("E069") + .with_location(statement.get_location()), + ); } } ReferenceAccess::Cast(c) => { @@ -186,20 +189,22 @@ fn validate_reference_expression( } ReferenceAccess::Deref => { if base.is_none() { - validator.diagnostics.push(Diagnostic::invalid_operation( - "Dereferencing requires a pointer-value.", - statement.get_location(), - )); + validator.diagnostics.push( + Diagnostic::error("Dereferencing requires a pointer-value.") + .with_error_code("E068") + .with_location(statement.get_location()), + ); } } ReferenceAccess::Address => { if let Some(base) = base { validate_address_of_expression(validator, base, statement.get_location(), context); } else { - validator.diagnostics.push(Diagnostic::invalid_operation( - "Address-of requires a value.", - statement.get_location(), - )); + validator.diagnostics.push( + Diagnostic::error("Address-of requires a value.") + .with_error_code("E070") + .with_location(statement.get_location()), + ); } } } @@ -217,10 +222,11 @@ fn validate_address_of_expression( } let a = context.annotations.get(target); - //TODO: resolver should also annotate information whether this results in an LValue or RValue - // array-access results in a value, but it is an LValue :-( + if !matches!(a, Some(StatementAnnotation::Variable { .. })) && !target.is_array_access() { - validator.push_diagnostic(Diagnostic::invalid_operation("Invalid address-of operation", location)); + validator.push_diagnostic( + Diagnostic::error("Invalid address-of operation").with_error_code("E066").with_location(location), + ); } } @@ -240,22 +246,17 @@ fn validate_direct_access( .get_type_for_annotation(context.index, base_annotation) .unwrap_or(context.index.get_void_type()) .get_type_information(); - if base_type.is_int() { - if !helper::is_compatible(access, base_type, context.index) { - validator.push_diagnostic(Diagnostic::incompatible_directaccess( - &format!("{access:?}"), - access.get_bit_width(), - m.get_location(), - )) - } else { - validate_access_index(validator, context, index, access, base_type, &m.get_location()); - } + if base_type.is_int() && helper::is_compatible(access, base_type, context.index) { + validate_access_index(validator, context, index, access, base_type, &m.get_location()); } else { - validator.push_diagnostic(Diagnostic::incompatible_directaccess( - &format!("{access:?}"), - access.get_bit_width(), - m.get_location(), - )) + validator.push_diagnostic( + Diagnostic::error(format!( + "{access:?}-Wise access requires a Numerical type larger than {} bits", + access.get_bit_width() + )) + .with_error_code("E055") + .with_location(m.get_location()), + ) } } } @@ -301,6 +302,22 @@ fn validate_cast_literal( location: &SourceLocation, context: &ValidationContext, ) { + fn incompatible_literal_cast( + cast_type: &str, + literal_type: &str, + location: SourceLocation, + ) -> Diagnostic { + Diagnostic::error(format!("Literal {literal_type} is not compatible to {cast_type}")) + .with_error_code("E054") + .with_location(location) + } + + fn literal_out_of_range(literal: &str, range_hint: &str, location: SourceLocation) -> Diagnostic { + Diagnostic::error(format!("Literal {literal} out of range ({range_hint})")) + .with_error_code("E053") + .with_location(location) + } + let cast_type = context.index.get_effective_type_or_void_by_name(type_name).get_type_information(); let literal_type = context.index.get_type_information_or_void( get_literal_actual_signed_type_name(literal, !cast_type.is_unsigned_int()) @@ -309,9 +326,16 @@ fn validate_cast_literal( ); if !literal.is_cast_prefix_eligible() { - validator.push_diagnostic(Diagnostic::literal_expected(location.clone())) + validator.push_diagnostic( + Diagnostic::error(format!( + "Cannot cast into {}, only elementary types are allowed", + validator.context.slice(&statement.get_location()) + )) + .with_error_code("E061") + .with_location(location.clone()), + ) } else if cast_type.is_date_or_time_type() || literal_type.is_date_or_time_type() { - validator.push_diagnostic(Diagnostic::incompatible_literal_cast( + validator.push_diagnostic(incompatible_literal_cast( cast_type.get_name(), literal_type.get_name(), location.clone(), @@ -320,7 +344,7 @@ fn validate_cast_literal( } else if cast_type.is_int() && literal_type.is_int() { // INTs with INTs if cast_type.get_semantic_size(context.index) < literal_type.get_semantic_size(context.index) { - validator.push_diagnostic(Diagnostic::literal_out_of_range( + validator.push_diagnostic(literal_out_of_range( literal.get_literal_value().as_str(), cast_type.get_name(), location.clone(), @@ -330,7 +354,7 @@ fn validate_cast_literal( let value = literal.get_literal_value(); // value contains "" / '' if value.len() > 3 { - validator.push_diagnostic(Diagnostic::literal_out_of_range( + validator.push_diagnostic(literal_out_of_range( value.as_str(), cast_type.get_name(), location.clone(), @@ -340,7 +364,7 @@ fn validate_cast_literal( // different types // REAL#100 is fine, other differences are not if !(cast_type.is_float() && literal_type.is_int()) { - validator.push_diagnostic(Diagnostic::incompatible_literal_cast( + validator.push_diagnostic(incompatible_literal_cast( cast_type.get_name(), literal.get_literal_value().as_str(), location.clone(), @@ -365,21 +389,27 @@ fn validate_access_index( target_type, context.index, ) { - validator.push_diagnostic(Diagnostic::incompatible_directaccess_range( - &format!("{access_type:?}"), - target_type.get_name(), - helper::get_range(access_type, target_type, context.index), - location.clone(), - )) + let range = helper::get_range(access_type, target_type, context.index); + validator.push_diagnostic( + Diagnostic::error(format!( + "{access_type:?}-Wise access for type {} must be in range {}..{}", + target_type.get_name(), + &range.start, + &range.end + )) + .with_error_code("E057") + .with_location(location.clone()), + ) } } AstStatement::ReferenceExpr(_) => { let ref_type = context.annotations.get_type_or_void(access_index, context.index); if !ref_type.get_type_information().is_int() { - validator.push_diagnostic(Diagnostic::incompatible_directaccess_variable( - ref_type.get_name(), - location.clone(), - )) + validator.push_diagnostic( + Diagnostic::error(format!("Invalid type {} for direct variable access. Only variables of Integer types are allowed", ref_type.get_name())) + .with_error_code("E056") + .with_location(location.clone()) + ) } } _ => unreachable!(), @@ -408,12 +438,11 @@ fn validate_reference( if base.is_some() && (alternative_target_type.is_numerical() || alternative_target_type.is_enum()) { // we accessed a member that does not exist, but we could find a global/local variable that fits - validator.push_diagnostic(Diagnostic::ImprovementSuggestion { - message: format!( - "If you meant to directly access a bit/byte/word/.., use %X/%B/%W{ref_name} instead.", - ), - range: vec![location.clone()], - }); + validator.push_diagnostic( + Diagnostic::info(format!("If you meant to directly access a bit/byte/word/..., use %X/%B/%W{ref_name} instead.")) + .with_error_code("E060") + .with_location(location.clone()) + ); } } } else if let Some(StatementAnnotation::Variable { qualified_name, argument_type, .. }) = @@ -430,7 +459,12 @@ fn validate_reference( !qualified_name.starts_with(pou) && !qualified_name.starts_with(container) }) { - validator.push_diagnostic(Diagnostic::illegal_access(qualified_name.as_str(), location.clone())); + validator.push_diagnostic( + //TODO: maybe default to warning? + Diagnostic::error(format!("Illegal access to private member {qualified_name}")) + .with_error_code("E049") + .with_location(location.clone()), + ); } } } @@ -471,16 +505,24 @@ fn visit_array_access( validate_array_access_dimensions(*ndims, dims, validator, access); } - _ => validator.push_diagnostic(Diagnostic::incompatible_array_access_variable( - target_type.get_name(), - access.get_location(), - )), + _ => validator.push_diagnostic( + Diagnostic::error(format!( + "Invalid type {} for array access. Only variables of Array types are allowed", + target_type.get_name() + )) + .with_error_code("E059") + .with_location(access.get_location()), + ), } } fn validate_array_access_dimensions(ndims: usize, dims: usize, validator: &mut Validator, access: &AstNode) { if ndims != dims { - validator.push_diagnostic(Diagnostic::invalid_array_access(ndims, dims, access.get_location())) + validator.push_diagnostic( + Diagnostic::error(format!("Expected array access with {ndims} dimensions, found {dims}")) + .with_error_code("E045") + .with_location(access.get_location()), + ) } } @@ -495,20 +537,28 @@ fn validate_array_access( if let Some(dimension) = dimensions.get(dimension_index) { if let Ok(range) = dimension.get_range(context.index) { if !(range.start as i128 <= *value && range.end as i128 >= *value) { - validator.push_diagnostic(Diagnostic::incompatible_array_access_range( - range, - access.get_location(), - )) + validator.push_diagnostic( + Diagnostic::error(format!( + "Array access must be in the range {}..{}", + range.start, range.end + )) + .with_error_code("E058") + .with_location(access.get_location()), + ) } } } } else { let type_info = context.annotations.get_type_or_void(access, context.index).get_type_information(); if !type_info.is_int() { - validator.push_diagnostic(Diagnostic::incompatible_array_access_type( - type_info.get_name(), - access.get_location(), - )) + validator.push_diagnostic( + Diagnostic::error(format!( + "Invalid type {} for array access. Only variables of Integer types are allowed to access an array", + type_info.get_name() + )) + .with_error_code("E059") + .with_location(access.get_location()) + ) } } } @@ -524,12 +574,16 @@ fn visit_binary_expression( match operator { Operator::Equal => { if context.annotations.get_type_hint(statement, context.index).is_none() { - let slice_lhs = validator.context.slice(&left.location); - let slice_rhs = validator.context.slice(&right.location); + let lhs = validator.context.slice(&left.location); + let rhs = validator.context.slice(&right.location); - validator.push_diagnostic(Diagnostic::assignment_instead_of_equal( - &slice_lhs, &slice_rhs, statement, - )); + validator.push_diagnostic( + Diagnostic::warning(format!( + "This equal statement has no effect, did you mean `{lhs} := {rhs}`?" + )) + .with_error_code("E023") + .with_location(statement.get_location()), + ); } validate_binary_expression(validator, statement, operator, left, right, context) @@ -574,13 +628,17 @@ fn validate_binary_expression( if operator.is_comparison_operator() && !compare_function_exists(left_type.get_name(), operator, context) { - validator.push_diagnostic(Diagnostic::missing_compare_function( - crate::typesystem::get_equals_function_name_for(left_type.get_name(), operator) - .unwrap_or_default() - .as_str(), - left_type.get_name(), - statement.get_location(), - )); + validator.push_diagnostic( + Diagnostic::error(format!( + "Missing compare function 'FUNCTION {} : BOOL VAR_INPUT a,b : {}; END_VAR ...'.", + crate::typesystem::get_equals_function_name_for(left_type.get_name(), operator) + .unwrap_or_default() + .as_str(), + left_type.get_name(), + )) + .with_error_code("E073") + .with_location(statement.get_location()), + ); } } } @@ -652,11 +710,15 @@ fn validate_call_by_ref(validator: &mut Validator, param: &VariableIndexEntry, a validate_call_by_ref(validator, param, &data.right); } - _ => validator.push_diagnostic(Diagnostic::invalid_argument_type( - param.get_name(), - ¶m.get_variable_type().to_string(), - arg.get_location(), - )), + _ => validator.push_diagnostic( + Diagnostic::error(format!( + "Expected a reference for parameter {} because their type is {}", + param.get_name(), + param.get_variable_type() + )) + .with_error_code("E031") + .with_location(arg.get_location()), + ), } } @@ -674,10 +736,11 @@ fn validate_assignment( { // ...constant variable if *constant { - validator.push_diagnostic(Diagnostic::cannot_assign_to_constant( - qualified_name.as_str(), - left.get_location(), - )); + validator.push_diagnostic( + Diagnostic::error(format!("Cannot assign to CONSTANT '{qualified_name}'")) + .with_error_code("E036") + .with_location(left.get_location()), + ); } else { // ...enum variable where the RHS does not match its variants validate_enum_variant_assignment( @@ -691,13 +754,22 @@ fn validate_assignment( // ...VAR_INPUT {ref} variable if matches!(argument_type, ArgumentType::ByRef(VariableType::Input)) { - validator.push_diagnostic(Diagnostic::var_input_ref_assignment(location.to_owned())); + validator.push_diagnostic( + Diagnostic::warning("VAR_INPUT {ref} variables are mutable and changes to them will also affect the referenced variable. For increased clarity use VAR_IN_OUT instead.") + .with_error_code("E042") + .with_location(location.to_owned()) + ); } } // ...or if whatever we got is not assignable, output an error if !left.can_be_assigned_to() { - validator.push_diagnostic(Diagnostic::reference_expected(left.get_location())); + let expression = validator.context.slice(&left.get_location()); + validator.push_diagnostic( + Diagnostic::error(format!("Expression {expression} is not assignable.")) + .with_error_code("E050") + .with_location(left.get_location()), + ); } } @@ -726,11 +798,23 @@ fn validate_assignment( if !(left_type.is_compatible_with_type(right_type) && is_valid_assignment(left_type, right_type, right, context.index, location, validator)) { - validator.push_diagnostic(Diagnostic::invalid_assignment( - &get_datatype_name_or_slice(validator.context, right_type), - &get_datatype_name_or_slice(validator.context, left_type), - location.clone(), - )); + if left_type.is_pointer() && right_type.is_pointer() { + validator.push_diagnostic( + Diagnostic::warning(format!( + "Pointers {} and {} have different types", + get_datatype_name_or_slice(validator.context, left_type), + get_datatype_name_or_slice(validator.context, right_type) + )) + .with_error_code("E090") + .with_location(location.clone()), + ); + } else { + validator.push_diagnostic(Diagnostic::invalid_assignment( + &get_datatype_name_or_slice(validator.context, right_type), + &get_datatype_name_or_slice(validator.context, left_type), + location.clone(), + )); + } } else if right.is_literal() { // TODO: See https://github.com/PLC-lang/rusty/issues/857 // validate_assignment_type_sizes(validator, left_type, right_type, location, context) @@ -746,7 +830,11 @@ pub(crate) fn validate_enum_variant_assignment( location: SourceLocation, ) { if left.is_enum() && left.get_name() != right.get_name() { - validator.push_diagnostic(Diagnostic::enum_variant_mismatch(qualified_name, location)) + validator.push_diagnostic( + Diagnostic::error(format!("Assigned value is not a variant of {qualified_name}")) + .with_error_code("E039") + .with_location(location), + ) } } @@ -818,10 +906,14 @@ fn is_valid_string_to_char_assignment( if value.len() == 1 { return true; } else { - validator.push_diagnostic(Diagnostic::syntax_error( - format!("Value: '{value}' exceeds length for type: {}", left_type.get_name()).as_str(), - location.clone(), - )); + validator.push_diagnostic( + Diagnostic::error( + format!("Value: '{value}' exceeds length for type: {}", left_type.get_name()) + .as_str(), + ) + .with_error_code("E065") + .with_location(location.clone()), + ); return false; } } @@ -844,12 +936,15 @@ fn is_invalid_pointer_assignment( && !left_type.is_pointer() && left_type.get_size_in_bits(index) < POINTER_SIZE { - validator.push_diagnostic(Diagnostic::incompatible_type_size( - left_type.get_name(), - left_type.get_size_in_bits(index), - "hold a", - location.clone(), - )); + validator.push_diagnostic( + Diagnostic::error(format!( + "The type {} {} is too small to hold a Pointer", + left_type.get_name(), + left_type.get_size_in_bits(index) + )) + .with_error_code("E065") + .with_location(location.clone()), + ); return true; } //check if size allocated to Pointer is standart pointer size (u64) @@ -857,12 +952,15 @@ fn is_invalid_pointer_assignment( && !right_type.is_pointer() && right_type.get_size_in_bits(index) < POINTER_SIZE { - validator.push_diagnostic(Diagnostic::incompatible_type_size( - right_type.get_name(), - right_type.get_size_in_bits(index), - "to be stored in a", - location.clone(), - )); + validator.push_diagnostic( + Diagnostic::error(format!( + "The type {} {} is too small to be stored in a Pointer", + right_type.get_name(), + right_type.get_size_in_bits(index) + )) + .with_error_code("E065") + .with_location(location.clone()), + ); return true; } false @@ -918,29 +1016,42 @@ fn validate_call( // validate parameters for (i, param) in passed_parameters.iter().enumerate() { - if let Ok((parameter_location_in_parent, right, is_implicit)) = - get_implicit_call_parameter(param, &declared_parameters, i) - { - let left = declared_parameters.get(parameter_location_in_parent); - if let Some(left) = left { - validate_call_by_ref(validator, left, param); - // 'parameter location in parent' and 'variable location in parent' are not the same (e.g VAR blocks are not counted as param). - // save actual location in parent for InOut validation - variable_location_in_parent.push(left.get_location_in_parent()); - } + match get_implicit_call_parameter(param, &declared_parameters, i) { + Ok((parameter_location_in_parent, right, is_implicit)) => { + let left = declared_parameters.get(parameter_location_in_parent); + if let Some(left) = left { + validate_call_by_ref(validator, left, param); + // 'parameter location in parent' and 'variable location in parent' are not the same (e.g VAR blocks are not counted as param). + // save actual location in parent for InOut validation + variable_location_in_parent.push(left.get_location_in_parent()); + } - // explicit call parameter assignments will be handled by - // `visit_statement()` via `Assignment` and `OutputAssignment` - if is_implicit { - validate_assignment(validator, right, None, ¶m.get_location(), context); - } + // explicit call parameter assignments will be handled by + // `visit_statement()` via `Assignment` and `OutputAssignment` + if is_implicit { + validate_assignment(validator, right, None, ¶m.get_location(), context); + } - // mixing implicit and explicit parameters is not allowed - // allways compare to the first passed parameter - if i == 0 { - are_implicit_parameters = is_implicit; - } else if are_implicit_parameters != is_implicit { - validator.push_diagnostic(Diagnostic::invalid_parameter_type(param.get_location())); + // mixing implicit and explicit parameters is not allowed + // allways compare to the first passed parameter + if i == 0 { + are_implicit_parameters = is_implicit; + } else if are_implicit_parameters != is_implicit { + validator.push_diagnostic( + Diagnostic::error("Cannot mix implicit and explicit call parameters!") + .with_error_code("E031") + .with_location(param.get_location()), + ); + } + } + Err(err) => { + validator.push_diagnostic( + Diagnostic::error("Invalid call parameters") + .with_error_code("E089") + .with_location(param.get_location()) + .with_sub_diagnostic(err), + ); + break; } } @@ -963,10 +1074,11 @@ fn validate_call( // check if all inouts were passed to the pou call declared_in_out_params.into_iter().for_each(|p| { if !variable_location_in_parent.contains(&p.get_location_in_parent()) { - validator.push_diagnostic(Diagnostic::missing_inout_parameter( - p.get_name(), - operator.get_location(), - )); + validator.push_diagnostic( + Diagnostic::error(format!("Missing inout parameter: {}", p.get_name())) + .with_error_code("E030") + .with_location(operator.get_location()), + ); } }); } @@ -1019,7 +1131,11 @@ fn validate_case_statement( // invalid case conditions if matches!(condition.get_stmt(), AstStatement::Assignment(_) | AstStatement::CallStatement(_)) { - validator.push_diagnostic(Diagnostic::invalid_case_condition(condition.get_location())); + validator.push_diagnostic( + Diagnostic::error("Invalid case condition!") + .with_error_code("E079") + .with_location(condition.get_location()), + ); } // validate for duplicate conditions @@ -1027,19 +1143,26 @@ fn validate_case_statement( const_evaluator::evaluate(condition, context.qualifier, context.index) .map_err(|err| { // value evaluation and validation not possible with non constants - validator.push_diagnostic(Diagnostic::non_constant_case_condition( - err.get_reason(), - condition.get_location(), - )) + validator.push_diagnostic( + Diagnostic::error(format!( + "{}. Non constant variables are not supported in case conditions", + err.get_reason() + )) + .with_error_code("E080") + .with_location(condition.get_location()), + ) }) .map(|v| { // check for duplicates if we got a value if let Some(AstNode { stmt: AstStatement::Literal(AstLiteral::Integer(value)), .. }) = v { if !cases.insert(value) { - validator.push_diagnostic(Diagnostic::duplicate_case_condition( - &value, - condition.get_location(), - )); + validator.push_diagnostic( + Diagnostic::error(format!( + "Duplicate condition value: {value}. Occurred more than once!" + )) + .with_error_code("E078") + .with_location(condition.get_location()), + ); } }; }) @@ -1066,11 +1189,11 @@ fn validate_type_nature( { if let DataTypeInformation::Generic { generic_symbol, nature, .. } = type_hint.get_type_information() { - validator.push_diagnostic(Diagnostic::unresolved_generic_type( - generic_symbol, - &format!("{nature:?}"), - statement.get_location(), - )) + validator.push_diagnostic( + Diagnostic::error(format!("Could not resolve generic type {generic_symbol} with {nature}")) + .with_error_code("E064") + .with_location(statement.get_location()), + ); } else if let Some((actual_type, generic_nature)) = context .annotations .get_type(statement, context.index) @@ -1082,11 +1205,15 @@ fn validate_type_nature( // INT parameter for REAL is allowed | (type_hint.is_real() & actual_type.is_numerical())) { - validator.push_diagnostic(Diagnostic::invalid_type_nature( - actual_type.get_name(), - format!("{generic_nature:?}").as_str(), - statement.get_location(), - )); + validator.push_diagnostic( + Diagnostic::error(format!( + "Invalid type nature for generic argument. {} is no {}", + actual_type.get_name(), + generic_nature + )) + .with_error_code("E062") + .with_location(statement.get_location()), + ); } } } @@ -1102,11 +1229,15 @@ fn _validate_assignment_type_sizes( if left.get_type_information().get_size(context.index) < right.get_type_information().get_size(context.index) { - validator.push_diagnostic(Diagnostic::implicit_downcast( - left.get_name(), - right.get_name(), - location.clone(), - )) + validator.push_diagnostic( + Diagnostic::info(format!( + "Potential loss of information due to assigning '{}' to variable of type '{}'.", + left.get_name(), + right.get_name() + )) + .with_error_code("E067") + .with_location(location.clone()), + ) } } diff --git a/src/validation/tests/snapshots/rusty__validation__tests__assignment_validation_tests__pointer_assignment_validation.snap b/src/validation/tests/snapshots/rusty__validation__tests__assignment_validation_tests__pointer_assignment_validation.snap index b6fe039abc..b6fdcb242b 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__assignment_validation_tests__pointer_assignment_validation.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__assignment_validation_tests__pointer_assignment_validation.snap @@ -26,17 +26,17 @@ error: Invalid assignment: cannot assign 'REF_TO INT' to 'WORD' 29 │ v_word := v_ptr_int; // INVALID │ ^^^^^^^^^^^^^^^^^^^ Invalid assignment: cannot assign 'REF_TO INT' to 'WORD' -error: Invalid assignment: cannot assign '__POINTER_TO_REAL' to 'REF_TO INT' +warning: Pointers REF_TO INT and __POINTER_TO_REAL have different types ┌─ :31:5 │ 31 │ v_ptr_int := &v_real; // INVALID -> TODO: should be valid - │ ^^^^^^^^^^^^^^^^^^^^ Invalid assignment: cannot assign '__POINTER_TO_REAL' to 'REF_TO INT' + │ ^^^^^^^^^^^^^^^^^^^^ Pointers REF_TO INT and __POINTER_TO_REAL have different types -error: Invalid assignment: cannot assign '__POINTER_TO_STRING' to 'REF_TO INT' +warning: Pointers REF_TO INT and __POINTER_TO_STRING have different types ┌─ :41:5 │ 41 │ v_ptr_int := &v_string; // INVALID - │ ^^^^^^^^^^^^^^^^^^^^^^ Invalid assignment: cannot assign '__POINTER_TO_STRING' to 'REF_TO INT' + │ ^^^^^^^^^^^^^^^^^^^^^^ Pointers REF_TO INT and __POINTER_TO_STRING have different types error: Invalid assignment: cannot assign 'STRING' to 'INT' ┌─ :42:5 diff --git a/src/validation/tests/snapshots/rusty__validation__tests__assignment_validation_tests__struct_assignment_validation.snap b/src/validation/tests/snapshots/rusty__validation__tests__assignment_validation_tests__struct_assignment_validation.snap index 25d46b29bf..f46282b749 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__assignment_validation_tests__struct_assignment_validation.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__assignment_validation_tests__struct_assignment_validation.snap @@ -32,40 +32,40 @@ error: Invalid assignment: cannot assign 'STRUCT2' to 'STRUCT1' 56 │ myFB(var_inout_struct1 := v_struct2); // INVALID │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Invalid assignment: cannot assign 'STRUCT2' to 'STRUCT1' -error: Invalid assignment: cannot assign '__POINTER_TO_REAL' to 'REF_TO STRUCT1' +warning: Pointers REF_TO STRUCT1 and __POINTER_TO_REAL have different types ┌─ :67:5 │ 67 │ v_ref_to_struct1 := REF(v_real); // INVALID - │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Invalid assignment: cannot assign '__POINTER_TO_REAL' to 'REF_TO STRUCT1' + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Pointers REF_TO STRUCT1 and __POINTER_TO_REAL have different types -error: Invalid assignment: cannot assign '__POINTER_TO_STRING' to 'REF_TO STRUCT1' +warning: Pointers REF_TO STRUCT1 and __POINTER_TO_STRING have different types ┌─ :68:5 │ 68 │ v_ref_to_struct1 := REF(v_string); // INVALID - │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Invalid assignment: cannot assign '__POINTER_TO_STRING' to 'REF_TO STRUCT1' + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Pointers REF_TO STRUCT1 and __POINTER_TO_STRING have different types -error: Invalid assignment: cannot assign '__POINTER_TO_CHAR' to 'REF_TO STRUCT1' +warning: Pointers REF_TO STRUCT1 and __POINTER_TO_CHAR have different types ┌─ :69:5 │ 69 │ v_ref_to_struct1 := REF(v_char); // INVALID - │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Invalid assignment: cannot assign '__POINTER_TO_CHAR' to 'REF_TO STRUCT1' + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Pointers REF_TO STRUCT1 and __POINTER_TO_CHAR have different types -error: Invalid assignment: cannot assign '__POINTER_TO_REAL' to 'REF_TO STRUCT1' +warning: Pointers REF_TO STRUCT1 and __POINTER_TO_REAL have different types ┌─ :71:5 │ 71 │ v_ref_to_struct1 := &(v_real); // INVALID - │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Invalid assignment: cannot assign '__POINTER_TO_REAL' to 'REF_TO STRUCT1' + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Pointers REF_TO STRUCT1 and __POINTER_TO_REAL have different types -error: Invalid assignment: cannot assign '__POINTER_TO_STRING' to 'REF_TO STRUCT1' +warning: Pointers REF_TO STRUCT1 and __POINTER_TO_STRING have different types ┌─ :72:5 │ 72 │ v_ref_to_struct1 := &(v_string); // INVALID - │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Invalid assignment: cannot assign '__POINTER_TO_STRING' to 'REF_TO STRUCT1' + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Pointers REF_TO STRUCT1 and __POINTER_TO_STRING have different types -error: Invalid assignment: cannot assign '__POINTER_TO_CHAR' to 'REF_TO STRUCT1' +warning: Pointers REF_TO STRUCT1 and __POINTER_TO_CHAR have different types ┌─ :73:5 │ 73 │ v_ref_to_struct1 := &(v_char); // INVALID - │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Invalid assignment: cannot assign '__POINTER_TO_CHAR' to 'REF_TO STRUCT1' + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Pointers REF_TO STRUCT1 and __POINTER_TO_CHAR have different types diff --git a/src/validation/tests/snapshots/rusty__validation__tests__bitaccess_validation_test__bitaccess_range_test.snap b/src/validation/tests/snapshots/rusty__validation__tests__bitaccess_validation_test__bitaccess_range_test.snap index 804d1979eb..00ab78f17f 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__bitaccess_validation_test__bitaccess_range_test.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__bitaccess_validation_test__bitaccess_range_test.snap @@ -2,28 +2,28 @@ source: src/validation/tests/bitaccess_validation_test.rs expression: "&diagnostics" --- -error: Bit-Wise access for type BYTE must be in the range 0..7 +error: Bit-Wise access for type BYTE must be in range 0..7 ┌─ :6:19 │ 6 │ a.8; - │ ^ Bit-Wise access for type BYTE must be in the range 0..7 + │ ^ Bit-Wise access for type BYTE must be in range 0..7 -error: Bit-Wise access for type WORD must be in the range 0..15 +error: Bit-Wise access for type WORD must be in range 0..15 ┌─ :7:19 │ 7 │ b.16; - │ ^^ Bit-Wise access for type WORD must be in the range 0..15 + │ ^^ Bit-Wise access for type WORD must be in range 0..15 -error: Bit-Wise access for type DWORD must be in the range 0..31 +error: Bit-Wise access for type DWORD must be in range 0..31 ┌─ :8:19 │ 8 │ c.32; - │ ^^ Bit-Wise access for type DWORD must be in the range 0..31 + │ ^^ Bit-Wise access for type DWORD must be in range 0..31 -error: Bit-Wise access for type LWORD must be in the range 0..63 +error: Bit-Wise access for type LWORD must be in range 0..63 ┌─ :9:19 │ 9 │ d.64; - │ ^^ Bit-Wise access for type LWORD must be in the range 0..63 + │ ^^ Bit-Wise access for type LWORD must be in range 0..63 diff --git a/src/validation/tests/snapshots/rusty__validation__tests__bitaccess_validation_test__byteaccess_range_test.snap b/src/validation/tests/snapshots/rusty__validation__tests__bitaccess_validation_test__byteaccess_range_test.snap index fbdbcc2eb1..29640d9f7d 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__bitaccess_validation_test__byteaccess_range_test.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__bitaccess_validation_test__byteaccess_range_test.snap @@ -2,22 +2,22 @@ source: src/validation/tests/bitaccess_validation_test.rs expression: "&diagnostics" --- -error: Byte-Wise access for type WORD must be in the range 0..1 +error: Byte-Wise access for type WORD must be in range 0..1 ┌─ :6:19 │ 6 │ b.%B2; - │ ^^^ Byte-Wise access for type WORD must be in the range 0..1 + │ ^^^ Byte-Wise access for type WORD must be in range 0..1 -error: Byte-Wise access for type DWORD must be in the range 0..3 +error: Byte-Wise access for type DWORD must be in range 0..3 ┌─ :7:19 │ 7 │ c.%B4; - │ ^^^ Byte-Wise access for type DWORD must be in the range 0..3 + │ ^^^ Byte-Wise access for type DWORD must be in range 0..3 -error: Byte-Wise access for type LWORD must be in the range 0..7 +error: Byte-Wise access for type LWORD must be in range 0..7 ┌─ :8:19 │ 8 │ d.%B8; - │ ^^^ Byte-Wise access for type LWORD must be in the range 0..7 + │ ^^^ Byte-Wise access for type LWORD must be in range 0..7 diff --git a/src/validation/tests/snapshots/rusty__validation__tests__bitaccess_validation_test__dwordaccess_range_test.snap b/src/validation/tests/snapshots/rusty__validation__tests__bitaccess_validation_test__dwordaccess_range_test.snap index 7cb499e1b8..a36bc9d38f 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__bitaccess_validation_test__dwordaccess_range_test.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__bitaccess_validation_test__dwordaccess_range_test.snap @@ -2,10 +2,10 @@ source: src/validation/tests/bitaccess_validation_test.rs expression: "&diagnostics" --- -error: DWord-Wise access for type LWORD must be in the range 0..1 +error: DWord-Wise access for type LWORD must be in range 0..1 ┌─ :6:19 │ 6 │ d.%D2; - │ ^^^ DWord-Wise access for type LWORD must be in the range 0..1 + │ ^^^ DWord-Wise access for type LWORD must be in range 0..1 diff --git a/src/validation/tests/snapshots/rusty__validation__tests__bitaccess_validation_test__wordaccess_range_test.snap b/src/validation/tests/snapshots/rusty__validation__tests__bitaccess_validation_test__wordaccess_range_test.snap index 2a33cc4578..34693ff841 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__bitaccess_validation_test__wordaccess_range_test.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__bitaccess_validation_test__wordaccess_range_test.snap @@ -2,16 +2,16 @@ source: src/validation/tests/bitaccess_validation_test.rs expression: "&diagnostics" --- -error: Word-Wise access for type DWORD must be in the range 0..1 +error: Word-Wise access for type DWORD must be in range 0..1 ┌─ :6:19 │ 6 │ c.%W2; - │ ^^^ Word-Wise access for type DWORD must be in the range 0..1 + │ ^^^ Word-Wise access for type DWORD must be in range 0..1 -error: Word-Wise access for type LWORD must be in the range 0..3 +error: Word-Wise access for type LWORD must be in range 0..3 ┌─ :7:19 │ 7 │ d.%W4; - │ ^^^ Word-Wise access for type LWORD must be in the range 0..3 + │ ^^^ Word-Wise access for type LWORD must be in range 0..3 diff --git a/src/validation/tests/snapshots/rusty__validation__tests__builtin_validation_tests__arithmetic_builtins_called_with_invalid_param_count.snap b/src/validation/tests/snapshots/rusty__validation__tests__builtin_validation_tests__arithmetic_builtins_called_with_invalid_param_count.snap index 98b76750af..b931e3f89b 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__builtin_validation_tests__arithmetic_builtins_called_with_invalid_param_count.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__builtin_validation_tests__arithmetic_builtins_called_with_invalid_param_count.snap @@ -8,11 +8,11 @@ error: Invalid parameter count. Received 0 parameters while 2 parameters were ex 7 │ ADD(); │ ^^^ Invalid parameter count. Received 0 parameters while 2 parameters were expected. -error: Could not resolve generic type T with nature Num +error: Could not resolve generic type T with ANY_NUMBER ┌─ :7:13 │ 7 │ ADD(); - │ ^^^^^^ Could not resolve generic type T with nature Num + │ ^^^^^^ Could not resolve generic type T with ANY_NUMBER error: Invalid parameter count. Received 1 parameters while 2 parameters were expected. ┌─ :8:13 diff --git a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_bit_does_not_allow_chars.snap b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_bit_does_not_allow_chars.snap index 020ab54286..37369341b0 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_bit_does_not_allow_chars.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_bit_does_not_allow_chars.snap @@ -8,11 +8,11 @@ error: Invalid assignment: cannot assign 'CHAR' to 'BOOL' 3 │ FUNCTION func1 : INT VAR x : CHAR; END_VAR test(x); END_FUNCTION │ ^ Invalid assignment: cannot assign 'CHAR' to 'BOOL' -error: Invalid type nature for generic argument. CHAR is no Bit. +error: Invalid type nature for generic argument. CHAR is no ANY_BIT ┌─ :3:58 │ 3 │ FUNCTION func1 : INT VAR x : CHAR; END_VAR test(x); END_FUNCTION - │ ^ Invalid type nature for generic argument. CHAR is no Bit. + │ ^ Invalid type nature for generic argument. CHAR is no ANY_BIT error: Invalid assignment: cannot assign 'WCHAR' to 'BOOL' ┌─ :4:59 @@ -20,10 +20,10 @@ error: Invalid assignment: cannot assign 'WCHAR' to 'BOOL' 4 │ FUNCTION func2 : INT VAR x : WCHAR; END_VAR test(x); END_FUNCTION │ ^ Invalid assignment: cannot assign 'WCHAR' to 'BOOL' -error: Invalid type nature for generic argument. WCHAR is no Bit. +error: Invalid type nature for generic argument. WCHAR is no ANY_BIT ┌─ :4:59 │ 4 │ FUNCTION func2 : INT VAR x : WCHAR; END_VAR test(x); END_FUNCTION - │ ^ Invalid type nature for generic argument. WCHAR is no Bit. + │ ^ Invalid type nature for generic argument. WCHAR is no ANY_BIT diff --git a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_bit_does_not_allow_date.snap b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_bit_does_not_allow_date.snap index 7227a62e07..4abafae68a 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_bit_does_not_allow_date.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_bit_does_not_allow_date.snap @@ -2,34 +2,34 @@ source: src/validation/tests/generic_validation_tests.rs expression: "&diagnostics" --- -error: Invalid type nature for generic argument. DATE_AND_TIME is no Bit. +error: Invalid type nature for generic argument. DATE_AND_TIME is no ANY_BIT ┌─ :3:56 │ 3 │ FUNCTION func1 : INT VAR x : DT; END_VAR test(x); END_FUNCTION - │ ^ Invalid type nature for generic argument. DATE_AND_TIME is no Bit. + │ ^ Invalid type nature for generic argument. DATE_AND_TIME is no ANY_BIT -error: Invalid type nature for generic argument. DATE_AND_TIME is no Bit. +error: Invalid type nature for generic argument. DATE_AND_TIME is no ANY_BIT ┌─ :4:57 │ 4 │ FUNCTION func2 : INT VAR x : LDT; END_VAR test(x); END_FUNCTION - │ ^ Invalid type nature for generic argument. DATE_AND_TIME is no Bit. + │ ^ Invalid type nature for generic argument. DATE_AND_TIME is no ANY_BIT -error: Invalid type nature for generic argument. DATE is no Bit. +error: Invalid type nature for generic argument. DATE is no ANY_BIT ┌─ :5:58 │ 5 │ FUNCTION func3 : INT VAR x : DATE; END_VAR test(x); END_FUNCTION - │ ^ Invalid type nature for generic argument. DATE is no Bit. + │ ^ Invalid type nature for generic argument. DATE is no ANY_BIT -error: Invalid type nature for generic argument. TIME_OF_DAY is no Bit. +error: Invalid type nature for generic argument. TIME_OF_DAY is no ANY_BIT ┌─ :6:57 │ 6 │ FUNCTION func4 : INT VAR x : TOD; END_VAR test(x); END_FUNCTION - │ ^ Invalid type nature for generic argument. TIME_OF_DAY is no Bit. + │ ^ Invalid type nature for generic argument. TIME_OF_DAY is no ANY_BIT -error: Invalid type nature for generic argument. TIME_OF_DAY is no Bit. +error: Invalid type nature for generic argument. TIME_OF_DAY is no ANY_BIT ┌─ :7:58 │ 7 │ FUNCTION func5 : INT VAR x : LTOD; END_VAR test(x); END_FUNCTION - │ ^ Invalid type nature for generic argument. TIME_OF_DAY is no Bit. + │ ^ Invalid type nature for generic argument. TIME_OF_DAY is no ANY_BIT diff --git a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_bit_does_not_allow_ints.snap b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_bit_does_not_allow_ints.snap index 8341e11c46..77f700d06c 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_bit_does_not_allow_ints.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_bit_does_not_allow_ints.snap @@ -2,52 +2,52 @@ source: src/validation/tests/generic_validation_tests.rs expression: "&diagnostics" --- -error: Invalid type nature for generic argument. USINT is no Bit. +error: Invalid type nature for generic argument. USINT is no ANY_BIT ┌─ :4:59 │ 4 │ FUNCTION func1 : INT VAR x : USINT; END_VAR test(x); END_FUNCTION - │ ^ Invalid type nature for generic argument. USINT is no Bit. + │ ^ Invalid type nature for generic argument. USINT is no ANY_BIT -error: Invalid type nature for generic argument. UINT is no Bit. +error: Invalid type nature for generic argument. UINT is no ANY_BIT ┌─ :5:58 │ 5 │ FUNCTION func2 : INT VAR x : UINT; END_VAR test(x); END_FUNCTION - │ ^ Invalid type nature for generic argument. UINT is no Bit. + │ ^ Invalid type nature for generic argument. UINT is no ANY_BIT -error: Invalid type nature for generic argument. UDINT is no Bit. +error: Invalid type nature for generic argument. UDINT is no ANY_BIT ┌─ :6:59 │ 6 │ FUNCTION func3 : INT VAR x : UDINT; END_VAR test(x); END_FUNCTION - │ ^ Invalid type nature for generic argument. UDINT is no Bit. + │ ^ Invalid type nature for generic argument. UDINT is no ANY_BIT -error: Invalid type nature for generic argument. ULINT is no Bit. +error: Invalid type nature for generic argument. ULINT is no ANY_BIT ┌─ :7:59 │ 7 │ FUNCTION func4 : INT VAR x : ULINT; END_VAR test(x); END_FUNCTION - │ ^ Invalid type nature for generic argument. ULINT is no Bit. + │ ^ Invalid type nature for generic argument. ULINT is no ANY_BIT -error: Invalid type nature for generic argument. SINT is no Bit. +error: Invalid type nature for generic argument. SINT is no ANY_BIT ┌─ :9:58 │ 9 │ FUNCTION func5 : INT VAR x : SINT; END_VAR test(x); END_FUNCTION - │ ^ Invalid type nature for generic argument. SINT is no Bit. + │ ^ Invalid type nature for generic argument. SINT is no ANY_BIT -error: Invalid type nature for generic argument. INT is no Bit. +error: Invalid type nature for generic argument. INT is no ANY_BIT ┌─ :10:57 │ 10 │ FUNCTION func6 : INT VAR x : INT; END_VAR test(x); END_FUNCTION - │ ^ Invalid type nature for generic argument. INT is no Bit. + │ ^ Invalid type nature for generic argument. INT is no ANY_BIT -error: Invalid type nature for generic argument. DINT is no Bit. +error: Invalid type nature for generic argument. DINT is no ANY_BIT ┌─ :11:58 │ 11 │ FUNCTION func7 : INT VAR x : DINT; END_VAR test(x); END_FUNCTION - │ ^ Invalid type nature for generic argument. DINT is no Bit. + │ ^ Invalid type nature for generic argument. DINT is no ANY_BIT -error: Invalid type nature for generic argument. LINT is no Bit. +error: Invalid type nature for generic argument. LINT is no ANY_BIT ┌─ :12:58 │ 12 │ FUNCTION func8 : INT VAR x : LINT; END_VAR test(x); END_FUNCTION - │ ^ Invalid type nature for generic argument. LINT is no Bit. + │ ^ Invalid type nature for generic argument. LINT is no ANY_BIT diff --git a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_bit_does_not_allow_reals.snap b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_bit_does_not_allow_reals.snap index 4071b5e73e..c8283fc9e5 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_bit_does_not_allow_reals.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_bit_does_not_allow_reals.snap @@ -2,16 +2,16 @@ source: src/validation/tests/generic_validation_tests.rs expression: "&diagnostics" --- -error: Invalid type nature for generic argument. REAL is no Bit. +error: Invalid type nature for generic argument. REAL is no ANY_BIT ┌─ :3:57 │ 3 │ FUNCTION func : INT VAR x : REAL; END_VAR test(x); END_FUNCTION - │ ^ Invalid type nature for generic argument. REAL is no Bit. + │ ^ Invalid type nature for generic argument. REAL is no ANY_BIT -error: Invalid type nature for generic argument. LREAL is no Bit. +error: Invalid type nature for generic argument. LREAL is no ANY_BIT ┌─ :4:59 │ 4 │ FUNCTION func1 : INT VAR x : LREAL; END_VAR test(x); END_FUNCTION - │ ^ Invalid type nature for generic argument. LREAL is no Bit. + │ ^ Invalid type nature for generic argument. LREAL is no ANY_BIT diff --git a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_bit_does_not_allow_string.snap b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_bit_does_not_allow_string.snap index dbb485e496..310d83affc 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_bit_does_not_allow_string.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_bit_does_not_allow_string.snap @@ -8,11 +8,11 @@ error: Invalid assignment: cannot assign 'STRING' to 'BOOL' 3 │ FUNCTION func1 : INT VAR x : STRING; END_VAR test(x); END_FUNCTION │ ^ Invalid assignment: cannot assign 'STRING' to 'BOOL' -error: Invalid type nature for generic argument. STRING is no Bit. +error: Invalid type nature for generic argument. STRING is no ANY_BIT ┌─ :3:61 │ 3 │ FUNCTION func1 : INT VAR x : STRING; END_VAR test(x); END_FUNCTION - │ ^ Invalid type nature for generic argument. STRING is no Bit. + │ ^ Invalid type nature for generic argument. STRING is no ANY_BIT error: Invalid assignment: cannot assign 'WSTRING' to 'BOOL' ┌─ :4:61 @@ -20,10 +20,10 @@ error: Invalid assignment: cannot assign 'WSTRING' to 'BOOL' 4 │ FUNCTION func2 : INT VAR x : WSTRING; END_VAR test(x); END_FUNCTION │ ^ Invalid assignment: cannot assign 'WSTRING' to 'BOOL' -error: Invalid type nature for generic argument. WSTRING is no Bit. +error: Invalid type nature for generic argument. WSTRING is no ANY_BIT ┌─ :4:61 │ 4 │ FUNCTION func2 : INT VAR x : WSTRING; END_VAR test(x); END_FUNCTION - │ ^ Invalid type nature for generic argument. WSTRING is no Bit. + │ ^ Invalid type nature for generic argument. WSTRING is no ANY_BIT diff --git a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_bit_does_not_allow_time.snap b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_bit_does_not_allow_time.snap index 24689e2db5..e425d19237 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_bit_does_not_allow_time.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_bit_does_not_allow_time.snap @@ -2,16 +2,16 @@ source: src/validation/tests/generic_validation_tests.rs expression: "&diagnostics" --- -error: Invalid type nature for generic argument. TIME is no Bit. +error: Invalid type nature for generic argument. TIME is no ANY_BIT ┌─ :3:58 │ 3 │ FUNCTION func1 : INT VAR x : TIME; END_VAR test(x); END_FUNCTION - │ ^ Invalid type nature for generic argument. TIME is no Bit. + │ ^ Invalid type nature for generic argument. TIME is no ANY_BIT -error: Invalid type nature for generic argument. TIME is no Bit. +error: Invalid type nature for generic argument. TIME is no ANY_BIT ┌─ :4:59 │ 4 │ FUNCTION func2 : INT VAR x : LTIME; END_VAR test(x); END_FUNCTION - │ ^ Invalid type nature for generic argument. TIME is no Bit. + │ ^ Invalid type nature for generic argument. TIME is no ANY_BIT diff --git a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_bit_multiple_parameters.snap b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_bit_multiple_parameters.snap index 11905946ad..95e66bd499 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_bit_multiple_parameters.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_bit_multiple_parameters.snap @@ -2,29 +2,29 @@ source: src/validation/tests/generic_validation_tests.rs expression: "&diagnostics" --- -error: Invalid type nature for generic argument. REAL is no Bit. +error: Invalid type nature for generic argument. REAL is no ANY_BIT ┌─ :15:14 │ 15 │ func(var_real, var_unsigned, var_signed, var_time, var_byte, var_str, var_char, var_date); - │ ^^^^^^^^ Invalid type nature for generic argument. REAL is no Bit. + │ ^^^^^^^^ Invalid type nature for generic argument. REAL is no ANY_BIT -error: Invalid type nature for generic argument. UDINT is no Bit. +error: Invalid type nature for generic argument. UDINT is no ANY_BIT ┌─ :15:24 │ 15 │ func(var_real, var_unsigned, var_signed, var_time, var_byte, var_str, var_char, var_date); - │ ^^^^^^^^^^^^ Invalid type nature for generic argument. UDINT is no Bit. + │ ^^^^^^^^^^^^ Invalid type nature for generic argument. UDINT is no ANY_BIT -error: Invalid type nature for generic argument. DINT is no Bit. +error: Invalid type nature for generic argument. DINT is no ANY_BIT ┌─ :15:38 │ 15 │ func(var_real, var_unsigned, var_signed, var_time, var_byte, var_str, var_char, var_date); - │ ^^^^^^^^^^ Invalid type nature for generic argument. DINT is no Bit. + │ ^^^^^^^^^^ Invalid type nature for generic argument. DINT is no ANY_BIT -error: Invalid type nature for generic argument. TIME is no Bit. +error: Invalid type nature for generic argument. TIME is no ANY_BIT ┌─ :15:50 │ 15 │ func(var_real, var_unsigned, var_signed, var_time, var_byte, var_str, var_char, var_date); - │ ^^^^^^^^ Invalid type nature for generic argument. TIME is no Bit. + │ ^^^^^^^^ Invalid type nature for generic argument. TIME is no ANY_BIT error: Invalid assignment: cannot assign 'STRING' to 'BYTE' ┌─ :15:70 @@ -32,11 +32,11 @@ error: Invalid assignment: cannot assign 'STRING' to 'BYTE' 15 │ func(var_real, var_unsigned, var_signed, var_time, var_byte, var_str, var_char, var_date); │ ^^^^^^^ Invalid assignment: cannot assign 'STRING' to 'BYTE' -error: Invalid type nature for generic argument. STRING is no Bit. +error: Invalid type nature for generic argument. STRING is no ANY_BIT ┌─ :15:70 │ 15 │ func(var_real, var_unsigned, var_signed, var_time, var_byte, var_str, var_char, var_date); - │ ^^^^^^^ Invalid type nature for generic argument. STRING is no Bit. + │ ^^^^^^^ Invalid type nature for generic argument. STRING is no ANY_BIT error: Invalid assignment: cannot assign 'CHAR' to 'BYTE' ┌─ :15:79 @@ -44,16 +44,16 @@ error: Invalid assignment: cannot assign 'CHAR' to 'BYTE' 15 │ func(var_real, var_unsigned, var_signed, var_time, var_byte, var_str, var_char, var_date); │ ^^^^^^^^ Invalid assignment: cannot assign 'CHAR' to 'BYTE' -error: Invalid type nature for generic argument. CHAR is no Bit. +error: Invalid type nature for generic argument. CHAR is no ANY_BIT ┌─ :15:79 │ 15 │ func(var_real, var_unsigned, var_signed, var_time, var_byte, var_str, var_char, var_date); - │ ^^^^^^^^ Invalid type nature for generic argument. CHAR is no Bit. + │ ^^^^^^^^ Invalid type nature for generic argument. CHAR is no ANY_BIT -error: Invalid type nature for generic argument. DATE is no Bit. +error: Invalid type nature for generic argument. DATE is no ANY_BIT ┌─ :15:89 │ 15 │ func(var_real, var_unsigned, var_signed, var_time, var_byte, var_str, var_char, var_date); - │ ^^^^^^^^ Invalid type nature for generic argument. DATE is no Bit. + │ ^^^^^^^^ Invalid type nature for generic argument. DATE is no ANY_BIT diff --git a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_char_does_not_allow_bits.snap b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_char_does_not_allow_bits.snap index b17146fe1e..9902712c73 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_char_does_not_allow_bits.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_char_does_not_allow_bits.snap @@ -8,11 +8,11 @@ error: Invalid assignment: cannot assign 'BOOL' to 'CHAR' 3 │ FUNCTION func1 : INT VAR x : BOOL; END_VAR test(x); END_FUNCTION │ ^ Invalid assignment: cannot assign 'BOOL' to 'CHAR' -error: Invalid type nature for generic argument. BOOL is no Char. +error: Invalid type nature for generic argument. BOOL is no ANY_CHAR ┌─ :3:58 │ 3 │ FUNCTION func1 : INT VAR x : BOOL; END_VAR test(x); END_FUNCTION - │ ^ Invalid type nature for generic argument. BOOL is no Char. + │ ^ Invalid type nature for generic argument. BOOL is no ANY_CHAR error: Invalid assignment: cannot assign 'BYTE' to 'CHAR' ┌─ :4:58 @@ -20,11 +20,11 @@ error: Invalid assignment: cannot assign 'BYTE' to 'CHAR' 4 │ FUNCTION func2 : INT VAR x : BYTE; END_VAR test(x); END_FUNCTION │ ^ Invalid assignment: cannot assign 'BYTE' to 'CHAR' -error: Invalid type nature for generic argument. BYTE is no Char. +error: Invalid type nature for generic argument. BYTE is no ANY_CHAR ┌─ :4:58 │ 4 │ FUNCTION func2 : INT VAR x : BYTE; END_VAR test(x); END_FUNCTION - │ ^ Invalid type nature for generic argument. BYTE is no Char. + │ ^ Invalid type nature for generic argument. BYTE is no ANY_CHAR error: Invalid assignment: cannot assign 'WORD' to 'CHAR' ┌─ :5:58 @@ -32,11 +32,11 @@ error: Invalid assignment: cannot assign 'WORD' to 'CHAR' 5 │ FUNCTION func3 : INT VAR x : WORD; END_VAR test(x); END_FUNCTION │ ^ Invalid assignment: cannot assign 'WORD' to 'CHAR' -error: Invalid type nature for generic argument. WORD is no Char. +error: Invalid type nature for generic argument. WORD is no ANY_CHAR ┌─ :5:58 │ 5 │ FUNCTION func3 : INT VAR x : WORD; END_VAR test(x); END_FUNCTION - │ ^ Invalid type nature for generic argument. WORD is no Char. + │ ^ Invalid type nature for generic argument. WORD is no ANY_CHAR error: Invalid assignment: cannot assign 'DWORD' to 'CHAR' ┌─ :6:59 @@ -44,11 +44,11 @@ error: Invalid assignment: cannot assign 'DWORD' to 'CHAR' 6 │ FUNCTION func4 : INT VAR x : DWORD; END_VAR test(x); END_FUNCTION │ ^ Invalid assignment: cannot assign 'DWORD' to 'CHAR' -error: Invalid type nature for generic argument. DWORD is no Char. +error: Invalid type nature for generic argument. DWORD is no ANY_CHAR ┌─ :6:59 │ 6 │ FUNCTION func4 : INT VAR x : DWORD; END_VAR test(x); END_FUNCTION - │ ^ Invalid type nature for generic argument. DWORD is no Char. + │ ^ Invalid type nature for generic argument. DWORD is no ANY_CHAR error: Invalid assignment: cannot assign 'LWORD' to 'CHAR' ┌─ :7:59 @@ -56,10 +56,10 @@ error: Invalid assignment: cannot assign 'LWORD' to 'CHAR' 7 │ FUNCTION func5 : INT VAR x : LWORD; END_VAR test(x); END_FUNCTION │ ^ Invalid assignment: cannot assign 'LWORD' to 'CHAR' -error: Invalid type nature for generic argument. LWORD is no Char. +error: Invalid type nature for generic argument. LWORD is no ANY_CHAR ┌─ :7:59 │ 7 │ FUNCTION func5 : INT VAR x : LWORD; END_VAR test(x); END_FUNCTION - │ ^ Invalid type nature for generic argument. LWORD is no Char. + │ ^ Invalid type nature for generic argument. LWORD is no ANY_CHAR diff --git a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_char_does_not_allow_date.snap b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_char_does_not_allow_date.snap index 2dcbc188eb..34cbc0030c 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_char_does_not_allow_date.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_char_does_not_allow_date.snap @@ -8,11 +8,11 @@ error: Invalid assignment: cannot assign 'DATE_AND_TIME' to 'CHAR' 3 │ FUNCTION func1 : INT VAR x : DT; END_VAR test(x); END_FUNCTION │ ^ Invalid assignment: cannot assign 'DATE_AND_TIME' to 'CHAR' -error: Invalid type nature for generic argument. DATE_AND_TIME is no Char. +error: Invalid type nature for generic argument. DATE_AND_TIME is no ANY_CHAR ┌─ :3:56 │ 3 │ FUNCTION func1 : INT VAR x : DT; END_VAR test(x); END_FUNCTION - │ ^ Invalid type nature for generic argument. DATE_AND_TIME is no Char. + │ ^ Invalid type nature for generic argument. DATE_AND_TIME is no ANY_CHAR error: Invalid assignment: cannot assign 'DATE_AND_TIME' to 'CHAR' ┌─ :4:57 @@ -20,11 +20,11 @@ error: Invalid assignment: cannot assign 'DATE_AND_TIME' to 'CHAR' 4 │ FUNCTION func2 : INT VAR x : LDT; END_VAR test(x); END_FUNCTION │ ^ Invalid assignment: cannot assign 'DATE_AND_TIME' to 'CHAR' -error: Invalid type nature for generic argument. DATE_AND_TIME is no Char. +error: Invalid type nature for generic argument. DATE_AND_TIME is no ANY_CHAR ┌─ :4:57 │ 4 │ FUNCTION func2 : INT VAR x : LDT; END_VAR test(x); END_FUNCTION - │ ^ Invalid type nature for generic argument. DATE_AND_TIME is no Char. + │ ^ Invalid type nature for generic argument. DATE_AND_TIME is no ANY_CHAR error: Invalid assignment: cannot assign 'DATE' to 'CHAR' ┌─ :5:58 @@ -32,11 +32,11 @@ error: Invalid assignment: cannot assign 'DATE' to 'CHAR' 5 │ FUNCTION func3 : INT VAR x : DATE; END_VAR test(x); END_FUNCTION │ ^ Invalid assignment: cannot assign 'DATE' to 'CHAR' -error: Invalid type nature for generic argument. DATE is no Char. +error: Invalid type nature for generic argument. DATE is no ANY_CHAR ┌─ :5:58 │ 5 │ FUNCTION func3 : INT VAR x : DATE; END_VAR test(x); END_FUNCTION - │ ^ Invalid type nature for generic argument. DATE is no Char. + │ ^ Invalid type nature for generic argument. DATE is no ANY_CHAR error: Invalid assignment: cannot assign 'TIME_OF_DAY' to 'CHAR' ┌─ :6:57 @@ -44,11 +44,11 @@ error: Invalid assignment: cannot assign 'TIME_OF_DAY' to 'CHAR' 6 │ FUNCTION func4 : INT VAR x : TOD; END_VAR test(x); END_FUNCTION │ ^ Invalid assignment: cannot assign 'TIME_OF_DAY' to 'CHAR' -error: Invalid type nature for generic argument. TIME_OF_DAY is no Char. +error: Invalid type nature for generic argument. TIME_OF_DAY is no ANY_CHAR ┌─ :6:57 │ 6 │ FUNCTION func4 : INT VAR x : TOD; END_VAR test(x); END_FUNCTION - │ ^ Invalid type nature for generic argument. TIME_OF_DAY is no Char. + │ ^ Invalid type nature for generic argument. TIME_OF_DAY is no ANY_CHAR error: Invalid assignment: cannot assign 'TIME_OF_DAY' to 'CHAR' ┌─ :7:58 @@ -56,10 +56,10 @@ error: Invalid assignment: cannot assign 'TIME_OF_DAY' to 'CHAR' 7 │ FUNCTION func5 : INT VAR x : LTOD; END_VAR test(x); END_FUNCTION │ ^ Invalid assignment: cannot assign 'TIME_OF_DAY' to 'CHAR' -error: Invalid type nature for generic argument. TIME_OF_DAY is no Char. +error: Invalid type nature for generic argument. TIME_OF_DAY is no ANY_CHAR ┌─ :7:58 │ 7 │ FUNCTION func5 : INT VAR x : LTOD; END_VAR test(x); END_FUNCTION - │ ^ Invalid type nature for generic argument. TIME_OF_DAY is no Char. + │ ^ Invalid type nature for generic argument. TIME_OF_DAY is no ANY_CHAR diff --git a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_char_does_not_allow_ints.snap b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_char_does_not_allow_ints.snap index ef1540f3e9..26731f36e8 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_char_does_not_allow_ints.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_char_does_not_allow_ints.snap @@ -8,11 +8,11 @@ error: Invalid assignment: cannot assign 'USINT' to 'CHAR' 4 │ FUNCTION func1 : INT VAR x : USINT; END_VAR test(x); END_FUNCTION │ ^ Invalid assignment: cannot assign 'USINT' to 'CHAR' -error: Invalid type nature for generic argument. USINT is no Char. +error: Invalid type nature for generic argument. USINT is no ANY_CHAR ┌─ :4:59 │ 4 │ FUNCTION func1 : INT VAR x : USINT; END_VAR test(x); END_FUNCTION - │ ^ Invalid type nature for generic argument. USINT is no Char. + │ ^ Invalid type nature for generic argument. USINT is no ANY_CHAR error: Invalid assignment: cannot assign 'UINT' to 'CHAR' ┌─ :5:58 @@ -20,11 +20,11 @@ error: Invalid assignment: cannot assign 'UINT' to 'CHAR' 5 │ FUNCTION func2 : INT VAR x : UINT; END_VAR test(x); END_FUNCTION │ ^ Invalid assignment: cannot assign 'UINT' to 'CHAR' -error: Invalid type nature for generic argument. UINT is no Char. +error: Invalid type nature for generic argument. UINT is no ANY_CHAR ┌─ :5:58 │ 5 │ FUNCTION func2 : INT VAR x : UINT; END_VAR test(x); END_FUNCTION - │ ^ Invalid type nature for generic argument. UINT is no Char. + │ ^ Invalid type nature for generic argument. UINT is no ANY_CHAR error: Invalid assignment: cannot assign 'UDINT' to 'CHAR' ┌─ :6:59 @@ -32,11 +32,11 @@ error: Invalid assignment: cannot assign 'UDINT' to 'CHAR' 6 │ FUNCTION func3 : INT VAR x : UDINT; END_VAR test(x); END_FUNCTION │ ^ Invalid assignment: cannot assign 'UDINT' to 'CHAR' -error: Invalid type nature for generic argument. UDINT is no Char. +error: Invalid type nature for generic argument. UDINT is no ANY_CHAR ┌─ :6:59 │ 6 │ FUNCTION func3 : INT VAR x : UDINT; END_VAR test(x); END_FUNCTION - │ ^ Invalid type nature for generic argument. UDINT is no Char. + │ ^ Invalid type nature for generic argument. UDINT is no ANY_CHAR error: Invalid assignment: cannot assign 'ULINT' to 'CHAR' ┌─ :7:59 @@ -44,11 +44,11 @@ error: Invalid assignment: cannot assign 'ULINT' to 'CHAR' 7 │ FUNCTION func4 : INT VAR x : ULINT; END_VAR test(x); END_FUNCTION │ ^ Invalid assignment: cannot assign 'ULINT' to 'CHAR' -error: Invalid type nature for generic argument. ULINT is no Char. +error: Invalid type nature for generic argument. ULINT is no ANY_CHAR ┌─ :7:59 │ 7 │ FUNCTION func4 : INT VAR x : ULINT; END_VAR test(x); END_FUNCTION - │ ^ Invalid type nature for generic argument. ULINT is no Char. + │ ^ Invalid type nature for generic argument. ULINT is no ANY_CHAR error: Invalid assignment: cannot assign 'SINT' to 'CHAR' ┌─ :9:58 @@ -56,11 +56,11 @@ error: Invalid assignment: cannot assign 'SINT' to 'CHAR' 9 │ FUNCTION func5 : INT VAR x : SINT; END_VAR test(x); END_FUNCTION │ ^ Invalid assignment: cannot assign 'SINT' to 'CHAR' -error: Invalid type nature for generic argument. SINT is no Char. +error: Invalid type nature for generic argument. SINT is no ANY_CHAR ┌─ :9:58 │ 9 │ FUNCTION func5 : INT VAR x : SINT; END_VAR test(x); END_FUNCTION - │ ^ Invalid type nature for generic argument. SINT is no Char. + │ ^ Invalid type nature for generic argument. SINT is no ANY_CHAR error: Invalid assignment: cannot assign 'INT' to 'CHAR' ┌─ :10:57 @@ -68,11 +68,11 @@ error: Invalid assignment: cannot assign 'INT' to 'CHAR' 10 │ FUNCTION func6 : INT VAR x : INT; END_VAR test(x); END_FUNCTION │ ^ Invalid assignment: cannot assign 'INT' to 'CHAR' -error: Invalid type nature for generic argument. INT is no Char. +error: Invalid type nature for generic argument. INT is no ANY_CHAR ┌─ :10:57 │ 10 │ FUNCTION func6 : INT VAR x : INT; END_VAR test(x); END_FUNCTION - │ ^ Invalid type nature for generic argument. INT is no Char. + │ ^ Invalid type nature for generic argument. INT is no ANY_CHAR error: Invalid assignment: cannot assign 'DINT' to 'CHAR' ┌─ :11:58 @@ -80,11 +80,11 @@ error: Invalid assignment: cannot assign 'DINT' to 'CHAR' 11 │ FUNCTION func7 : INT VAR x : DINT; END_VAR test(x); END_FUNCTION │ ^ Invalid assignment: cannot assign 'DINT' to 'CHAR' -error: Invalid type nature for generic argument. DINT is no Char. +error: Invalid type nature for generic argument. DINT is no ANY_CHAR ┌─ :11:58 │ 11 │ FUNCTION func7 : INT VAR x : DINT; END_VAR test(x); END_FUNCTION - │ ^ Invalid type nature for generic argument. DINT is no Char. + │ ^ Invalid type nature for generic argument. DINT is no ANY_CHAR error: Invalid assignment: cannot assign 'LINT' to 'CHAR' ┌─ :12:58 @@ -92,10 +92,10 @@ error: Invalid assignment: cannot assign 'LINT' to 'CHAR' 12 │ FUNCTION func8 : INT VAR x : LINT; END_VAR test(x); END_FUNCTION │ ^ Invalid assignment: cannot assign 'LINT' to 'CHAR' -error: Invalid type nature for generic argument. LINT is no Char. +error: Invalid type nature for generic argument. LINT is no ANY_CHAR ┌─ :12:58 │ 12 │ FUNCTION func8 : INT VAR x : LINT; END_VAR test(x); END_FUNCTION - │ ^ Invalid type nature for generic argument. LINT is no Char. + │ ^ Invalid type nature for generic argument. LINT is no ANY_CHAR diff --git a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_char_does_not_allow_reals.snap b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_char_does_not_allow_reals.snap index 9603ae431e..13574c1e0d 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_char_does_not_allow_reals.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_char_does_not_allow_reals.snap @@ -8,11 +8,11 @@ error: Invalid assignment: cannot assign 'REAL' to 'CHAR' 3 │ FUNCTION func : INT VAR x : REAL; END_VAR test(x); END_FUNCTION │ ^ Invalid assignment: cannot assign 'REAL' to 'CHAR' -error: Invalid type nature for generic argument. REAL is no Char. +error: Invalid type nature for generic argument. REAL is no ANY_CHAR ┌─ :3:57 │ 3 │ FUNCTION func : INT VAR x : REAL; END_VAR test(x); END_FUNCTION - │ ^ Invalid type nature for generic argument. REAL is no Char. + │ ^ Invalid type nature for generic argument. REAL is no ANY_CHAR error: Invalid assignment: cannot assign 'LREAL' to 'CHAR' ┌─ :4:59 @@ -20,10 +20,10 @@ error: Invalid assignment: cannot assign 'LREAL' to 'CHAR' 4 │ FUNCTION func1 : INT VAR x : LREAL; END_VAR test(x); END_FUNCTION │ ^ Invalid assignment: cannot assign 'LREAL' to 'CHAR' -error: Invalid type nature for generic argument. LREAL is no Char. +error: Invalid type nature for generic argument. LREAL is no ANY_CHAR ┌─ :4:59 │ 4 │ FUNCTION func1 : INT VAR x : LREAL; END_VAR test(x); END_FUNCTION - │ ^ Invalid type nature for generic argument. LREAL is no Char. + │ ^ Invalid type nature for generic argument. LREAL is no ANY_CHAR diff --git a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_char_does_not_allow_string.snap b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_char_does_not_allow_string.snap index 735004186f..f150ce2525 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_char_does_not_allow_string.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_char_does_not_allow_string.snap @@ -8,11 +8,11 @@ error: Invalid assignment: cannot assign 'STRING' to 'CHAR' 3 │ FUNCTION func1 : INT VAR x : STRING; END_VAR test(x); END_FUNCTION │ ^ Invalid assignment: cannot assign 'STRING' to 'CHAR' -error: Invalid type nature for generic argument. STRING is no Char. +error: Invalid type nature for generic argument. STRING is no ANY_CHAR ┌─ :3:61 │ 3 │ FUNCTION func1 : INT VAR x : STRING; END_VAR test(x); END_FUNCTION - │ ^ Invalid type nature for generic argument. STRING is no Char. + │ ^ Invalid type nature for generic argument. STRING is no ANY_CHAR error: Invalid assignment: cannot assign 'WSTRING' to 'CHAR' ┌─ :4:61 @@ -20,10 +20,10 @@ error: Invalid assignment: cannot assign 'WSTRING' to 'CHAR' 4 │ FUNCTION func2 : INT VAR x : WSTRING; END_VAR test(x); END_FUNCTION │ ^ Invalid assignment: cannot assign 'WSTRING' to 'CHAR' -error: Invalid type nature for generic argument. WSTRING is no Char. +error: Invalid type nature for generic argument. WSTRING is no ANY_CHAR ┌─ :4:61 │ 4 │ FUNCTION func2 : INT VAR x : WSTRING; END_VAR test(x); END_FUNCTION - │ ^ Invalid type nature for generic argument. WSTRING is no Char. + │ ^ Invalid type nature for generic argument. WSTRING is no ANY_CHAR diff --git a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_char_does_not_allow_time.snap b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_char_does_not_allow_time.snap index 9b128886f5..9dcbb0b99a 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_char_does_not_allow_time.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_char_does_not_allow_time.snap @@ -8,11 +8,11 @@ error: Invalid assignment: cannot assign 'TIME' to 'CHAR' 3 │ FUNCTION func1 : INT VAR x : TIME; END_VAR test(x); END_FUNCTION │ ^ Invalid assignment: cannot assign 'TIME' to 'CHAR' -error: Invalid type nature for generic argument. TIME is no Char. +error: Invalid type nature for generic argument. TIME is no ANY_CHAR ┌─ :3:58 │ 3 │ FUNCTION func1 : INT VAR x : TIME; END_VAR test(x); END_FUNCTION - │ ^ Invalid type nature for generic argument. TIME is no Char. + │ ^ Invalid type nature for generic argument. TIME is no ANY_CHAR error: Invalid assignment: cannot assign 'TIME' to 'CHAR' ┌─ :4:59 @@ -20,10 +20,10 @@ error: Invalid assignment: cannot assign 'TIME' to 'CHAR' 4 │ FUNCTION func2 : INT VAR x : LTIME; END_VAR test(x); END_FUNCTION │ ^ Invalid assignment: cannot assign 'TIME' to 'CHAR' -error: Invalid type nature for generic argument. TIME is no Char. +error: Invalid type nature for generic argument. TIME is no ANY_CHAR ┌─ :4:59 │ 4 │ FUNCTION func2 : INT VAR x : LTIME; END_VAR test(x); END_FUNCTION - │ ^ Invalid type nature for generic argument. TIME is no Char. + │ ^ Invalid type nature for generic argument. TIME is no ANY_CHAR diff --git a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_char_multiple_parameters.snap b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_char_multiple_parameters.snap index 69d138b214..414b917691 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_char_multiple_parameters.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_char_multiple_parameters.snap @@ -8,11 +8,11 @@ error: Invalid assignment: cannot assign 'REAL' to 'CHAR' 15 │ func(var_real, var_unsigned, var_signed, var_time, var_byte, var_str, var_char, var_date); │ ^^^^^^^^ Invalid assignment: cannot assign 'REAL' to 'CHAR' -error: Invalid type nature for generic argument. REAL is no Char. +error: Invalid type nature for generic argument. REAL is no ANY_CHAR ┌─ :15:14 │ 15 │ func(var_real, var_unsigned, var_signed, var_time, var_byte, var_str, var_char, var_date); - │ ^^^^^^^^ Invalid type nature for generic argument. REAL is no Char. + │ ^^^^^^^^ Invalid type nature for generic argument. REAL is no ANY_CHAR error: Invalid assignment: cannot assign 'UDINT' to 'CHAR' ┌─ :15:24 @@ -20,11 +20,11 @@ error: Invalid assignment: cannot assign 'UDINT' to 'CHAR' 15 │ func(var_real, var_unsigned, var_signed, var_time, var_byte, var_str, var_char, var_date); │ ^^^^^^^^^^^^ Invalid assignment: cannot assign 'UDINT' to 'CHAR' -error: Invalid type nature for generic argument. UDINT is no Char. +error: Invalid type nature for generic argument. UDINT is no ANY_CHAR ┌─ :15:24 │ 15 │ func(var_real, var_unsigned, var_signed, var_time, var_byte, var_str, var_char, var_date); - │ ^^^^^^^^^^^^ Invalid type nature for generic argument. UDINT is no Char. + │ ^^^^^^^^^^^^ Invalid type nature for generic argument. UDINT is no ANY_CHAR error: Invalid assignment: cannot assign 'DINT' to 'CHAR' ┌─ :15:38 @@ -32,11 +32,11 @@ error: Invalid assignment: cannot assign 'DINT' to 'CHAR' 15 │ func(var_real, var_unsigned, var_signed, var_time, var_byte, var_str, var_char, var_date); │ ^^^^^^^^^^ Invalid assignment: cannot assign 'DINT' to 'CHAR' -error: Invalid type nature for generic argument. DINT is no Char. +error: Invalid type nature for generic argument. DINT is no ANY_CHAR ┌─ :15:38 │ 15 │ func(var_real, var_unsigned, var_signed, var_time, var_byte, var_str, var_char, var_date); - │ ^^^^^^^^^^ Invalid type nature for generic argument. DINT is no Char. + │ ^^^^^^^^^^ Invalid type nature for generic argument. DINT is no ANY_CHAR error: Invalid assignment: cannot assign 'TIME' to 'CHAR' ┌─ :15:50 @@ -44,11 +44,11 @@ error: Invalid assignment: cannot assign 'TIME' to 'CHAR' 15 │ func(var_real, var_unsigned, var_signed, var_time, var_byte, var_str, var_char, var_date); │ ^^^^^^^^ Invalid assignment: cannot assign 'TIME' to 'CHAR' -error: Invalid type nature for generic argument. TIME is no Char. +error: Invalid type nature for generic argument. TIME is no ANY_CHAR ┌─ :15:50 │ 15 │ func(var_real, var_unsigned, var_signed, var_time, var_byte, var_str, var_char, var_date); - │ ^^^^^^^^ Invalid type nature for generic argument. TIME is no Char. + │ ^^^^^^^^ Invalid type nature for generic argument. TIME is no ANY_CHAR error: Invalid assignment: cannot assign 'BYTE' to 'CHAR' ┌─ :15:60 @@ -56,11 +56,11 @@ error: Invalid assignment: cannot assign 'BYTE' to 'CHAR' 15 │ func(var_real, var_unsigned, var_signed, var_time, var_byte, var_str, var_char, var_date); │ ^^^^^^^^ Invalid assignment: cannot assign 'BYTE' to 'CHAR' -error: Invalid type nature for generic argument. BYTE is no Char. +error: Invalid type nature for generic argument. BYTE is no ANY_CHAR ┌─ :15:60 │ 15 │ func(var_real, var_unsigned, var_signed, var_time, var_byte, var_str, var_char, var_date); - │ ^^^^^^^^ Invalid type nature for generic argument. BYTE is no Char. + │ ^^^^^^^^ Invalid type nature for generic argument. BYTE is no ANY_CHAR error: Invalid assignment: cannot assign 'STRING' to 'CHAR' ┌─ :15:70 @@ -68,11 +68,11 @@ error: Invalid assignment: cannot assign 'STRING' to 'CHAR' 15 │ func(var_real, var_unsigned, var_signed, var_time, var_byte, var_str, var_char, var_date); │ ^^^^^^^ Invalid assignment: cannot assign 'STRING' to 'CHAR' -error: Invalid type nature for generic argument. STRING is no Char. +error: Invalid type nature for generic argument. STRING is no ANY_CHAR ┌─ :15:70 │ 15 │ func(var_real, var_unsigned, var_signed, var_time, var_byte, var_str, var_char, var_date); - │ ^^^^^^^ Invalid type nature for generic argument. STRING is no Char. + │ ^^^^^^^ Invalid type nature for generic argument. STRING is no ANY_CHAR error: Invalid assignment: cannot assign 'DATE' to 'CHAR' ┌─ :15:89 @@ -80,10 +80,10 @@ error: Invalid assignment: cannot assign 'DATE' to 'CHAR' 15 │ func(var_real, var_unsigned, var_signed, var_time, var_byte, var_str, var_char, var_date); │ ^^^^^^^^ Invalid assignment: cannot assign 'DATE' to 'CHAR' -error: Invalid type nature for generic argument. DATE is no Char. +error: Invalid type nature for generic argument. DATE is no ANY_CHAR ┌─ :15:89 │ 15 │ func(var_real, var_unsigned, var_signed, var_time, var_byte, var_str, var_char, var_date); - │ ^^^^^^^^ Invalid type nature for generic argument. DATE is no Char. + │ ^^^^^^^^ Invalid type nature for generic argument. DATE is no ANY_CHAR diff --git a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_chars_does_not_allow_bits.snap b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_chars_does_not_allow_bits.snap index 09e0e945b5..b1821a4106 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_chars_does_not_allow_bits.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_chars_does_not_allow_bits.snap @@ -8,11 +8,11 @@ error: Invalid assignment: cannot assign 'BOOL' to 'CHAR' 3 │ FUNCTION func1 : INT VAR x : BOOL; END_VAR test(x); END_FUNCTION │ ^ Invalid assignment: cannot assign 'BOOL' to 'CHAR' -error: Invalid type nature for generic argument. BOOL is no Chars. +error: Invalid type nature for generic argument. BOOL is no ANY_CHARS ┌─ :3:58 │ 3 │ FUNCTION func1 : INT VAR x : BOOL; END_VAR test(x); END_FUNCTION - │ ^ Invalid type nature for generic argument. BOOL is no Chars. + │ ^ Invalid type nature for generic argument. BOOL is no ANY_CHARS error: Invalid assignment: cannot assign 'BYTE' to 'CHAR' ┌─ :4:58 @@ -20,11 +20,11 @@ error: Invalid assignment: cannot assign 'BYTE' to 'CHAR' 4 │ FUNCTION func2 : INT VAR x : BYTE; END_VAR test(x); END_FUNCTION │ ^ Invalid assignment: cannot assign 'BYTE' to 'CHAR' -error: Invalid type nature for generic argument. BYTE is no Chars. +error: Invalid type nature for generic argument. BYTE is no ANY_CHARS ┌─ :4:58 │ 4 │ FUNCTION func2 : INT VAR x : BYTE; END_VAR test(x); END_FUNCTION - │ ^ Invalid type nature for generic argument. BYTE is no Chars. + │ ^ Invalid type nature for generic argument. BYTE is no ANY_CHARS error: Invalid assignment: cannot assign 'WORD' to 'CHAR' ┌─ :5:58 @@ -32,11 +32,11 @@ error: Invalid assignment: cannot assign 'WORD' to 'CHAR' 5 │ FUNCTION func3 : INT VAR x : WORD; END_VAR test(x); END_FUNCTION │ ^ Invalid assignment: cannot assign 'WORD' to 'CHAR' -error: Invalid type nature for generic argument. WORD is no Chars. +error: Invalid type nature for generic argument. WORD is no ANY_CHARS ┌─ :5:58 │ 5 │ FUNCTION func3 : INT VAR x : WORD; END_VAR test(x); END_FUNCTION - │ ^ Invalid type nature for generic argument. WORD is no Chars. + │ ^ Invalid type nature for generic argument. WORD is no ANY_CHARS error: Invalid assignment: cannot assign 'DWORD' to 'CHAR' ┌─ :6:59 @@ -44,11 +44,11 @@ error: Invalid assignment: cannot assign 'DWORD' to 'CHAR' 6 │ FUNCTION func4 : INT VAR x : DWORD; END_VAR test(x); END_FUNCTION │ ^ Invalid assignment: cannot assign 'DWORD' to 'CHAR' -error: Invalid type nature for generic argument. DWORD is no Chars. +error: Invalid type nature for generic argument. DWORD is no ANY_CHARS ┌─ :6:59 │ 6 │ FUNCTION func4 : INT VAR x : DWORD; END_VAR test(x); END_FUNCTION - │ ^ Invalid type nature for generic argument. DWORD is no Chars. + │ ^ Invalid type nature for generic argument. DWORD is no ANY_CHARS error: Invalid assignment: cannot assign 'LWORD' to 'CHAR' ┌─ :7:59 @@ -56,10 +56,10 @@ error: Invalid assignment: cannot assign 'LWORD' to 'CHAR' 7 │ FUNCTION func5 : INT VAR x : LWORD; END_VAR test(x); END_FUNCTION │ ^ Invalid assignment: cannot assign 'LWORD' to 'CHAR' -error: Invalid type nature for generic argument. LWORD is no Chars. +error: Invalid type nature for generic argument. LWORD is no ANY_CHARS ┌─ :7:59 │ 7 │ FUNCTION func5 : INT VAR x : LWORD; END_VAR test(x); END_FUNCTION - │ ^ Invalid type nature for generic argument. LWORD is no Chars. + │ ^ Invalid type nature for generic argument. LWORD is no ANY_CHARS diff --git a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_chars_does_not_allow_date.snap b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_chars_does_not_allow_date.snap index da583782fd..9f8effc46a 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_chars_does_not_allow_date.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_chars_does_not_allow_date.snap @@ -8,11 +8,11 @@ error: Invalid assignment: cannot assign 'DATE_AND_TIME' to 'CHAR' 3 │ FUNCTION func1 : INT VAR x : DT; END_VAR test(x); END_FUNCTION │ ^ Invalid assignment: cannot assign 'DATE_AND_TIME' to 'CHAR' -error: Invalid type nature for generic argument. DATE_AND_TIME is no Chars. +error: Invalid type nature for generic argument. DATE_AND_TIME is no ANY_CHARS ┌─ :3:56 │ 3 │ FUNCTION func1 : INT VAR x : DT; END_VAR test(x); END_FUNCTION - │ ^ Invalid type nature for generic argument. DATE_AND_TIME is no Chars. + │ ^ Invalid type nature for generic argument. DATE_AND_TIME is no ANY_CHARS error: Invalid assignment: cannot assign 'DATE_AND_TIME' to 'CHAR' ┌─ :4:57 @@ -20,11 +20,11 @@ error: Invalid assignment: cannot assign 'DATE_AND_TIME' to 'CHAR' 4 │ FUNCTION func2 : INT VAR x : LDT; END_VAR test(x); END_FUNCTION │ ^ Invalid assignment: cannot assign 'DATE_AND_TIME' to 'CHAR' -error: Invalid type nature for generic argument. DATE_AND_TIME is no Chars. +error: Invalid type nature for generic argument. DATE_AND_TIME is no ANY_CHARS ┌─ :4:57 │ 4 │ FUNCTION func2 : INT VAR x : LDT; END_VAR test(x); END_FUNCTION - │ ^ Invalid type nature for generic argument. DATE_AND_TIME is no Chars. + │ ^ Invalid type nature for generic argument. DATE_AND_TIME is no ANY_CHARS error: Invalid assignment: cannot assign 'DATE' to 'CHAR' ┌─ :5:58 @@ -32,11 +32,11 @@ error: Invalid assignment: cannot assign 'DATE' to 'CHAR' 5 │ FUNCTION func3 : INT VAR x : DATE; END_VAR test(x); END_FUNCTION │ ^ Invalid assignment: cannot assign 'DATE' to 'CHAR' -error: Invalid type nature for generic argument. DATE is no Chars. +error: Invalid type nature for generic argument. DATE is no ANY_CHARS ┌─ :5:58 │ 5 │ FUNCTION func3 : INT VAR x : DATE; END_VAR test(x); END_FUNCTION - │ ^ Invalid type nature for generic argument. DATE is no Chars. + │ ^ Invalid type nature for generic argument. DATE is no ANY_CHARS error: Invalid assignment: cannot assign 'TIME_OF_DAY' to 'CHAR' ┌─ :6:57 @@ -44,11 +44,11 @@ error: Invalid assignment: cannot assign 'TIME_OF_DAY' to 'CHAR' 6 │ FUNCTION func4 : INT VAR x : TOD; END_VAR test(x); END_FUNCTION │ ^ Invalid assignment: cannot assign 'TIME_OF_DAY' to 'CHAR' -error: Invalid type nature for generic argument. TIME_OF_DAY is no Chars. +error: Invalid type nature for generic argument. TIME_OF_DAY is no ANY_CHARS ┌─ :6:57 │ 6 │ FUNCTION func4 : INT VAR x : TOD; END_VAR test(x); END_FUNCTION - │ ^ Invalid type nature for generic argument. TIME_OF_DAY is no Chars. + │ ^ Invalid type nature for generic argument. TIME_OF_DAY is no ANY_CHARS error: Invalid assignment: cannot assign 'TIME_OF_DAY' to 'CHAR' ┌─ :7:58 @@ -56,10 +56,10 @@ error: Invalid assignment: cannot assign 'TIME_OF_DAY' to 'CHAR' 7 │ FUNCTION func5 : INT VAR x : LTOD; END_VAR test(x); END_FUNCTION │ ^ Invalid assignment: cannot assign 'TIME_OF_DAY' to 'CHAR' -error: Invalid type nature for generic argument. TIME_OF_DAY is no Chars. +error: Invalid type nature for generic argument. TIME_OF_DAY is no ANY_CHARS ┌─ :7:58 │ 7 │ FUNCTION func5 : INT VAR x : LTOD; END_VAR test(x); END_FUNCTION - │ ^ Invalid type nature for generic argument. TIME_OF_DAY is no Chars. + │ ^ Invalid type nature for generic argument. TIME_OF_DAY is no ANY_CHARS diff --git a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_chars_does_not_allow_ints.snap b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_chars_does_not_allow_ints.snap index 5b220a10a7..5adf0b6123 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_chars_does_not_allow_ints.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_chars_does_not_allow_ints.snap @@ -8,11 +8,11 @@ error: Invalid assignment: cannot assign 'USINT' to 'CHAR' 4 │ FUNCTION func1 : INT VAR x : USINT; END_VAR test(x); END_FUNCTION │ ^ Invalid assignment: cannot assign 'USINT' to 'CHAR' -error: Invalid type nature for generic argument. USINT is no Chars. +error: Invalid type nature for generic argument. USINT is no ANY_CHARS ┌─ :4:59 │ 4 │ FUNCTION func1 : INT VAR x : USINT; END_VAR test(x); END_FUNCTION - │ ^ Invalid type nature for generic argument. USINT is no Chars. + │ ^ Invalid type nature for generic argument. USINT is no ANY_CHARS error: Invalid assignment: cannot assign 'UINT' to 'CHAR' ┌─ :5:58 @@ -20,11 +20,11 @@ error: Invalid assignment: cannot assign 'UINT' to 'CHAR' 5 │ FUNCTION func2 : INT VAR x : UINT; END_VAR test(x); END_FUNCTION │ ^ Invalid assignment: cannot assign 'UINT' to 'CHAR' -error: Invalid type nature for generic argument. UINT is no Chars. +error: Invalid type nature for generic argument. UINT is no ANY_CHARS ┌─ :5:58 │ 5 │ FUNCTION func2 : INT VAR x : UINT; END_VAR test(x); END_FUNCTION - │ ^ Invalid type nature for generic argument. UINT is no Chars. + │ ^ Invalid type nature for generic argument. UINT is no ANY_CHARS error: Invalid assignment: cannot assign 'UDINT' to 'CHAR' ┌─ :6:59 @@ -32,11 +32,11 @@ error: Invalid assignment: cannot assign 'UDINT' to 'CHAR' 6 │ FUNCTION func3 : INT VAR x : UDINT; END_VAR test(x); END_FUNCTION │ ^ Invalid assignment: cannot assign 'UDINT' to 'CHAR' -error: Invalid type nature for generic argument. UDINT is no Chars. +error: Invalid type nature for generic argument. UDINT is no ANY_CHARS ┌─ :6:59 │ 6 │ FUNCTION func3 : INT VAR x : UDINT; END_VAR test(x); END_FUNCTION - │ ^ Invalid type nature for generic argument. UDINT is no Chars. + │ ^ Invalid type nature for generic argument. UDINT is no ANY_CHARS error: Invalid assignment: cannot assign 'ULINT' to 'CHAR' ┌─ :7:59 @@ -44,11 +44,11 @@ error: Invalid assignment: cannot assign 'ULINT' to 'CHAR' 7 │ FUNCTION func4 : INT VAR x : ULINT; END_VAR test(x); END_FUNCTION │ ^ Invalid assignment: cannot assign 'ULINT' to 'CHAR' -error: Invalid type nature for generic argument. ULINT is no Chars. +error: Invalid type nature for generic argument. ULINT is no ANY_CHARS ┌─ :7:59 │ 7 │ FUNCTION func4 : INT VAR x : ULINT; END_VAR test(x); END_FUNCTION - │ ^ Invalid type nature for generic argument. ULINT is no Chars. + │ ^ Invalid type nature for generic argument. ULINT is no ANY_CHARS error: Invalid assignment: cannot assign 'SINT' to 'CHAR' ┌─ :9:58 @@ -56,11 +56,11 @@ error: Invalid assignment: cannot assign 'SINT' to 'CHAR' 9 │ FUNCTION func5 : INT VAR x : SINT; END_VAR test(x); END_FUNCTION │ ^ Invalid assignment: cannot assign 'SINT' to 'CHAR' -error: Invalid type nature for generic argument. SINT is no Chars. +error: Invalid type nature for generic argument. SINT is no ANY_CHARS ┌─ :9:58 │ 9 │ FUNCTION func5 : INT VAR x : SINT; END_VAR test(x); END_FUNCTION - │ ^ Invalid type nature for generic argument. SINT is no Chars. + │ ^ Invalid type nature for generic argument. SINT is no ANY_CHARS error: Invalid assignment: cannot assign 'INT' to 'CHAR' ┌─ :10:57 @@ -68,11 +68,11 @@ error: Invalid assignment: cannot assign 'INT' to 'CHAR' 10 │ FUNCTION func6 : INT VAR x : INT; END_VAR test(x); END_FUNCTION │ ^ Invalid assignment: cannot assign 'INT' to 'CHAR' -error: Invalid type nature for generic argument. INT is no Chars. +error: Invalid type nature for generic argument. INT is no ANY_CHARS ┌─ :10:57 │ 10 │ FUNCTION func6 : INT VAR x : INT; END_VAR test(x); END_FUNCTION - │ ^ Invalid type nature for generic argument. INT is no Chars. + │ ^ Invalid type nature for generic argument. INT is no ANY_CHARS error: Invalid assignment: cannot assign 'DINT' to 'CHAR' ┌─ :11:58 @@ -80,11 +80,11 @@ error: Invalid assignment: cannot assign 'DINT' to 'CHAR' 11 │ FUNCTION func7 : INT VAR x : DINT; END_VAR test(x); END_FUNCTION │ ^ Invalid assignment: cannot assign 'DINT' to 'CHAR' -error: Invalid type nature for generic argument. DINT is no Chars. +error: Invalid type nature for generic argument. DINT is no ANY_CHARS ┌─ :11:58 │ 11 │ FUNCTION func7 : INT VAR x : DINT; END_VAR test(x); END_FUNCTION - │ ^ Invalid type nature for generic argument. DINT is no Chars. + │ ^ Invalid type nature for generic argument. DINT is no ANY_CHARS error: Invalid assignment: cannot assign 'LINT' to 'CHAR' ┌─ :12:58 @@ -92,10 +92,10 @@ error: Invalid assignment: cannot assign 'LINT' to 'CHAR' 12 │ FUNCTION func8 : INT VAR x : LINT; END_VAR test(x); END_FUNCTION │ ^ Invalid assignment: cannot assign 'LINT' to 'CHAR' -error: Invalid type nature for generic argument. LINT is no Chars. +error: Invalid type nature for generic argument. LINT is no ANY_CHARS ┌─ :12:58 │ 12 │ FUNCTION func8 : INT VAR x : LINT; END_VAR test(x); END_FUNCTION - │ ^ Invalid type nature for generic argument. LINT is no Chars. + │ ^ Invalid type nature for generic argument. LINT is no ANY_CHARS diff --git a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_chars_does_not_allow_reals.snap b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_chars_does_not_allow_reals.snap index e5cdb6434e..9ba61fa049 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_chars_does_not_allow_reals.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_chars_does_not_allow_reals.snap @@ -8,11 +8,11 @@ error: Invalid assignment: cannot assign 'REAL' to 'CHAR' 3 │ FUNCTION func : INT VAR x : REAL; END_VAR test(x); END_FUNCTION │ ^ Invalid assignment: cannot assign 'REAL' to 'CHAR' -error: Invalid type nature for generic argument. REAL is no Chars. +error: Invalid type nature for generic argument. REAL is no ANY_CHARS ┌─ :3:57 │ 3 │ FUNCTION func : INT VAR x : REAL; END_VAR test(x); END_FUNCTION - │ ^ Invalid type nature for generic argument. REAL is no Chars. + │ ^ Invalid type nature for generic argument. REAL is no ANY_CHARS error: Invalid assignment: cannot assign 'LREAL' to 'CHAR' ┌─ :4:59 @@ -20,10 +20,10 @@ error: Invalid assignment: cannot assign 'LREAL' to 'CHAR' 4 │ FUNCTION func1 : INT VAR x : LREAL; END_VAR test(x); END_FUNCTION │ ^ Invalid assignment: cannot assign 'LREAL' to 'CHAR' -error: Invalid type nature for generic argument. LREAL is no Chars. +error: Invalid type nature for generic argument. LREAL is no ANY_CHARS ┌─ :4:59 │ 4 │ FUNCTION func1 : INT VAR x : LREAL; END_VAR test(x); END_FUNCTION - │ ^ Invalid type nature for generic argument. LREAL is no Chars. + │ ^ Invalid type nature for generic argument. LREAL is no ANY_CHARS diff --git a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_chars_does_not_allow_time.snap b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_chars_does_not_allow_time.snap index db90b9b0e1..17b6ef7308 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_chars_does_not_allow_time.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_chars_does_not_allow_time.snap @@ -8,11 +8,11 @@ error: Invalid assignment: cannot assign 'TIME' to 'CHAR' 3 │ FUNCTION func1 : INT VAR x : TIME; END_VAR test(x); END_FUNCTION │ ^ Invalid assignment: cannot assign 'TIME' to 'CHAR' -error: Invalid type nature for generic argument. TIME is no Chars. +error: Invalid type nature for generic argument. TIME is no ANY_CHARS ┌─ :3:58 │ 3 │ FUNCTION func1 : INT VAR x : TIME; END_VAR test(x); END_FUNCTION - │ ^ Invalid type nature for generic argument. TIME is no Chars. + │ ^ Invalid type nature for generic argument. TIME is no ANY_CHARS error: Invalid assignment: cannot assign 'TIME' to 'CHAR' ┌─ :4:59 @@ -20,10 +20,10 @@ error: Invalid assignment: cannot assign 'TIME' to 'CHAR' 4 │ FUNCTION func2 : INT VAR x : LTIME; END_VAR test(x); END_FUNCTION │ ^ Invalid assignment: cannot assign 'TIME' to 'CHAR' -error: Invalid type nature for generic argument. TIME is no Chars. +error: Invalid type nature for generic argument. TIME is no ANY_CHARS ┌─ :4:59 │ 4 │ FUNCTION func2 : INT VAR x : LTIME; END_VAR test(x); END_FUNCTION - │ ^ Invalid type nature for generic argument. TIME is no Chars. + │ ^ Invalid type nature for generic argument. TIME is no ANY_CHARS diff --git a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_chars_multiple_parameters.snap b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_chars_multiple_parameters.snap index 620c8345a4..74e69313ca 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_chars_multiple_parameters.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_chars_multiple_parameters.snap @@ -8,11 +8,11 @@ error: Invalid assignment: cannot assign 'REAL' to 'STRING' 15 │ func(var_real, var_unsigned, var_signed, var_time, var_byte, var_str, var_char, var_date); │ ^^^^^^^^ Invalid assignment: cannot assign 'REAL' to 'STRING' -error: Invalid type nature for generic argument. REAL is no Chars. +error: Invalid type nature for generic argument. REAL is no ANY_CHARS ┌─ :15:14 │ 15 │ func(var_real, var_unsigned, var_signed, var_time, var_byte, var_str, var_char, var_date); - │ ^^^^^^^^ Invalid type nature for generic argument. REAL is no Chars. + │ ^^^^^^^^ Invalid type nature for generic argument. REAL is no ANY_CHARS error: Invalid assignment: cannot assign 'UDINT' to 'STRING' ┌─ :15:24 @@ -20,11 +20,11 @@ error: Invalid assignment: cannot assign 'UDINT' to 'STRING' 15 │ func(var_real, var_unsigned, var_signed, var_time, var_byte, var_str, var_char, var_date); │ ^^^^^^^^^^^^ Invalid assignment: cannot assign 'UDINT' to 'STRING' -error: Invalid type nature for generic argument. UDINT is no Chars. +error: Invalid type nature for generic argument. UDINT is no ANY_CHARS ┌─ :15:24 │ 15 │ func(var_real, var_unsigned, var_signed, var_time, var_byte, var_str, var_char, var_date); - │ ^^^^^^^^^^^^ Invalid type nature for generic argument. UDINT is no Chars. + │ ^^^^^^^^^^^^ Invalid type nature for generic argument. UDINT is no ANY_CHARS error: Invalid assignment: cannot assign 'DINT' to 'STRING' ┌─ :15:38 @@ -32,11 +32,11 @@ error: Invalid assignment: cannot assign 'DINT' to 'STRING' 15 │ func(var_real, var_unsigned, var_signed, var_time, var_byte, var_str, var_char, var_date); │ ^^^^^^^^^^ Invalid assignment: cannot assign 'DINT' to 'STRING' -error: Invalid type nature for generic argument. DINT is no Chars. +error: Invalid type nature for generic argument. DINT is no ANY_CHARS ┌─ :15:38 │ 15 │ func(var_real, var_unsigned, var_signed, var_time, var_byte, var_str, var_char, var_date); - │ ^^^^^^^^^^ Invalid type nature for generic argument. DINT is no Chars. + │ ^^^^^^^^^^ Invalid type nature for generic argument. DINT is no ANY_CHARS error: Invalid assignment: cannot assign 'TIME' to 'STRING' ┌─ :15:50 @@ -44,11 +44,11 @@ error: Invalid assignment: cannot assign 'TIME' to 'STRING' 15 │ func(var_real, var_unsigned, var_signed, var_time, var_byte, var_str, var_char, var_date); │ ^^^^^^^^ Invalid assignment: cannot assign 'TIME' to 'STRING' -error: Invalid type nature for generic argument. TIME is no Chars. +error: Invalid type nature for generic argument. TIME is no ANY_CHARS ┌─ :15:50 │ 15 │ func(var_real, var_unsigned, var_signed, var_time, var_byte, var_str, var_char, var_date); - │ ^^^^^^^^ Invalid type nature for generic argument. TIME is no Chars. + │ ^^^^^^^^ Invalid type nature for generic argument. TIME is no ANY_CHARS error: Invalid assignment: cannot assign 'BYTE' to 'STRING' ┌─ :15:60 @@ -56,11 +56,11 @@ error: Invalid assignment: cannot assign 'BYTE' to 'STRING' 15 │ func(var_real, var_unsigned, var_signed, var_time, var_byte, var_str, var_char, var_date); │ ^^^^^^^^ Invalid assignment: cannot assign 'BYTE' to 'STRING' -error: Invalid type nature for generic argument. BYTE is no Chars. +error: Invalid type nature for generic argument. BYTE is no ANY_CHARS ┌─ :15:60 │ 15 │ func(var_real, var_unsigned, var_signed, var_time, var_byte, var_str, var_char, var_date); - │ ^^^^^^^^ Invalid type nature for generic argument. BYTE is no Chars. + │ ^^^^^^^^ Invalid type nature for generic argument. BYTE is no ANY_CHARS error: Invalid assignment: cannot assign 'CHAR' to 'STRING' ┌─ :15:79 @@ -74,10 +74,10 @@ error: Invalid assignment: cannot assign 'DATE' to 'STRING' 15 │ func(var_real, var_unsigned, var_signed, var_time, var_byte, var_str, var_char, var_date); │ ^^^^^^^^ Invalid assignment: cannot assign 'DATE' to 'STRING' -error: Invalid type nature for generic argument. DATE is no Chars. +error: Invalid type nature for generic argument. DATE is no ANY_CHARS ┌─ :15:89 │ 15 │ func(var_real, var_unsigned, var_signed, var_time, var_byte, var_str, var_char, var_date); - │ ^^^^^^^^ Invalid type nature for generic argument. DATE is no Chars. + │ ^^^^^^^^ Invalid type nature for generic argument. DATE is no ANY_CHARS diff --git a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_date_does_not_allow_bits.snap b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_date_does_not_allow_bits.snap index 6ace8daa12..cb6f4528f1 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_date_does_not_allow_bits.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_date_does_not_allow_bits.snap @@ -2,34 +2,34 @@ source: src/validation/tests/generic_validation_tests.rs expression: "&diagnostics" --- -error: Invalid type nature for generic argument. BOOL is no Date. +error: Invalid type nature for generic argument. BOOL is no ANY_DATE ┌─ :3:58 │ 3 │ FUNCTION func1 : INT VAR x : BOOL; END_VAR test(x); END_FUNCTION - │ ^ Invalid type nature for generic argument. BOOL is no Date. + │ ^ Invalid type nature for generic argument. BOOL is no ANY_DATE -error: Invalid type nature for generic argument. BYTE is no Date. +error: Invalid type nature for generic argument. BYTE is no ANY_DATE ┌─ :4:58 │ 4 │ FUNCTION func2 : INT VAR x : BYTE; END_VAR test(x); END_FUNCTION - │ ^ Invalid type nature for generic argument. BYTE is no Date. + │ ^ Invalid type nature for generic argument. BYTE is no ANY_DATE -error: Invalid type nature for generic argument. WORD is no Date. +error: Invalid type nature for generic argument. WORD is no ANY_DATE ┌─ :5:58 │ 5 │ FUNCTION func3 : INT VAR x : WORD; END_VAR test(x); END_FUNCTION - │ ^ Invalid type nature for generic argument. WORD is no Date. + │ ^ Invalid type nature for generic argument. WORD is no ANY_DATE -error: Invalid type nature for generic argument. DWORD is no Date. +error: Invalid type nature for generic argument. DWORD is no ANY_DATE ┌─ :6:59 │ 6 │ FUNCTION func4 : INT VAR x : DWORD; END_VAR test(x); END_FUNCTION - │ ^ Invalid type nature for generic argument. DWORD is no Date. + │ ^ Invalid type nature for generic argument. DWORD is no ANY_DATE -error: Invalid type nature for generic argument. LWORD is no Date. +error: Invalid type nature for generic argument. LWORD is no ANY_DATE ┌─ :7:59 │ 7 │ FUNCTION func5 : INT VAR x : LWORD; END_VAR test(x); END_FUNCTION - │ ^ Invalid type nature for generic argument. LWORD is no Date. + │ ^ Invalid type nature for generic argument. LWORD is no ANY_DATE diff --git a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_date_does_not_allow_chars.snap b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_date_does_not_allow_chars.snap index d0eac5254d..466b4511b6 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_date_does_not_allow_chars.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_date_does_not_allow_chars.snap @@ -8,11 +8,11 @@ error: Invalid assignment: cannot assign 'CHAR' to 'DATE' 3 │ FUNCTION func1 : INT VAR x : CHAR; END_VAR test(x); END_FUNCTION │ ^ Invalid assignment: cannot assign 'CHAR' to 'DATE' -error: Invalid type nature for generic argument. CHAR is no Date. +error: Invalid type nature for generic argument. CHAR is no ANY_DATE ┌─ :3:58 │ 3 │ FUNCTION func1 : INT VAR x : CHAR; END_VAR test(x); END_FUNCTION - │ ^ Invalid type nature for generic argument. CHAR is no Date. + │ ^ Invalid type nature for generic argument. CHAR is no ANY_DATE error: Invalid assignment: cannot assign 'WCHAR' to 'DATE' ┌─ :4:59 @@ -20,10 +20,10 @@ error: Invalid assignment: cannot assign 'WCHAR' to 'DATE' 4 │ FUNCTION func2 : INT VAR x : WCHAR; END_VAR test(x); END_FUNCTION │ ^ Invalid assignment: cannot assign 'WCHAR' to 'DATE' -error: Invalid type nature for generic argument. WCHAR is no Date. +error: Invalid type nature for generic argument. WCHAR is no ANY_DATE ┌─ :4:59 │ 4 │ FUNCTION func2 : INT VAR x : WCHAR; END_VAR test(x); END_FUNCTION - │ ^ Invalid type nature for generic argument. WCHAR is no Date. + │ ^ Invalid type nature for generic argument. WCHAR is no ANY_DATE diff --git a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_date_does_not_allow_ints.snap b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_date_does_not_allow_ints.snap index 421908b22a..0fa4a34970 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_date_does_not_allow_ints.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_date_does_not_allow_ints.snap @@ -2,52 +2,52 @@ source: src/validation/tests/generic_validation_tests.rs expression: "&diagnostics" --- -error: Invalid type nature for generic argument. USINT is no Date. +error: Invalid type nature for generic argument. USINT is no ANY_DATE ┌─ :4:59 │ 4 │ FUNCTION func1 : INT VAR x : USINT; END_VAR test(x); END_FUNCTION - │ ^ Invalid type nature for generic argument. USINT is no Date. + │ ^ Invalid type nature for generic argument. USINT is no ANY_DATE -error: Invalid type nature for generic argument. UINT is no Date. +error: Invalid type nature for generic argument. UINT is no ANY_DATE ┌─ :5:58 │ 5 │ FUNCTION func2 : INT VAR x : UINT; END_VAR test(x); END_FUNCTION - │ ^ Invalid type nature for generic argument. UINT is no Date. + │ ^ Invalid type nature for generic argument. UINT is no ANY_DATE -error: Invalid type nature for generic argument. UDINT is no Date. +error: Invalid type nature for generic argument. UDINT is no ANY_DATE ┌─ :6:59 │ 6 │ FUNCTION func3 : INT VAR x : UDINT; END_VAR test(x); END_FUNCTION - │ ^ Invalid type nature for generic argument. UDINT is no Date. + │ ^ Invalid type nature for generic argument. UDINT is no ANY_DATE -error: Invalid type nature for generic argument. ULINT is no Date. +error: Invalid type nature for generic argument. ULINT is no ANY_DATE ┌─ :7:59 │ 7 │ FUNCTION func4 : INT VAR x : ULINT; END_VAR test(x); END_FUNCTION - │ ^ Invalid type nature for generic argument. ULINT is no Date. + │ ^ Invalid type nature for generic argument. ULINT is no ANY_DATE -error: Invalid type nature for generic argument. SINT is no Date. +error: Invalid type nature for generic argument. SINT is no ANY_DATE ┌─ :9:58 │ 9 │ FUNCTION func5 : INT VAR x : SINT; END_VAR test(x); END_FUNCTION - │ ^ Invalid type nature for generic argument. SINT is no Date. + │ ^ Invalid type nature for generic argument. SINT is no ANY_DATE -error: Invalid type nature for generic argument. INT is no Date. +error: Invalid type nature for generic argument. INT is no ANY_DATE ┌─ :10:57 │ 10 │ FUNCTION func6 : INT VAR x : INT; END_VAR test(x); END_FUNCTION - │ ^ Invalid type nature for generic argument. INT is no Date. + │ ^ Invalid type nature for generic argument. INT is no ANY_DATE -error: Invalid type nature for generic argument. DINT is no Date. +error: Invalid type nature for generic argument. DINT is no ANY_DATE ┌─ :11:58 │ 11 │ FUNCTION func7 : INT VAR x : DINT; END_VAR test(x); END_FUNCTION - │ ^ Invalid type nature for generic argument. DINT is no Date. + │ ^ Invalid type nature for generic argument. DINT is no ANY_DATE -error: Invalid type nature for generic argument. LINT is no Date. +error: Invalid type nature for generic argument. LINT is no ANY_DATE ┌─ :12:58 │ 12 │ FUNCTION func8 : INT VAR x : LINT; END_VAR test(x); END_FUNCTION - │ ^ Invalid type nature for generic argument. LINT is no Date. + │ ^ Invalid type nature for generic argument. LINT is no ANY_DATE diff --git a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_date_does_not_allow_reals.snap b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_date_does_not_allow_reals.snap index 7cd736402e..4271e69a11 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_date_does_not_allow_reals.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_date_does_not_allow_reals.snap @@ -2,16 +2,16 @@ source: src/validation/tests/generic_validation_tests.rs expression: "&diagnostics" --- -error: Invalid type nature for generic argument. REAL is no Date. +error: Invalid type nature for generic argument. REAL is no ANY_DATE ┌─ :3:57 │ 3 │ FUNCTION func : INT VAR x : REAL; END_VAR test(x); END_FUNCTION - │ ^ Invalid type nature for generic argument. REAL is no Date. + │ ^ Invalid type nature for generic argument. REAL is no ANY_DATE -error: Invalid type nature for generic argument. LREAL is no Date. +error: Invalid type nature for generic argument. LREAL is no ANY_DATE ┌─ :4:59 │ 4 │ FUNCTION func1 : INT VAR x : LREAL; END_VAR test(x); END_FUNCTION - │ ^ Invalid type nature for generic argument. LREAL is no Date. + │ ^ Invalid type nature for generic argument. LREAL is no ANY_DATE diff --git a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_date_does_not_allow_string.snap b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_date_does_not_allow_string.snap index 2fc7e6a30f..7438756319 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_date_does_not_allow_string.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_date_does_not_allow_string.snap @@ -8,11 +8,11 @@ error: Invalid assignment: cannot assign 'STRING' to 'DATE' 3 │ FUNCTION func1 : INT VAR x : STRING; END_VAR test(x); END_FUNCTION │ ^ Invalid assignment: cannot assign 'STRING' to 'DATE' -error: Invalid type nature for generic argument. STRING is no Date. +error: Invalid type nature for generic argument. STRING is no ANY_DATE ┌─ :3:61 │ 3 │ FUNCTION func1 : INT VAR x : STRING; END_VAR test(x); END_FUNCTION - │ ^ Invalid type nature for generic argument. STRING is no Date. + │ ^ Invalid type nature for generic argument. STRING is no ANY_DATE error: Invalid assignment: cannot assign 'WSTRING' to 'DATE' ┌─ :4:61 @@ -20,10 +20,10 @@ error: Invalid assignment: cannot assign 'WSTRING' to 'DATE' 4 │ FUNCTION func2 : INT VAR x : WSTRING; END_VAR test(x); END_FUNCTION │ ^ Invalid assignment: cannot assign 'WSTRING' to 'DATE' -error: Invalid type nature for generic argument. WSTRING is no Date. +error: Invalid type nature for generic argument. WSTRING is no ANY_DATE ┌─ :4:61 │ 4 │ FUNCTION func2 : INT VAR x : WSTRING; END_VAR test(x); END_FUNCTION - │ ^ Invalid type nature for generic argument. WSTRING is no Date. + │ ^ Invalid type nature for generic argument. WSTRING is no ANY_DATE diff --git a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_date_does_not_allow_time.snap b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_date_does_not_allow_time.snap index 27d315be4f..49d74fc5dc 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_date_does_not_allow_time.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_date_does_not_allow_time.snap @@ -2,16 +2,16 @@ source: src/validation/tests/generic_validation_tests.rs expression: "&diagnostics" --- -error: Invalid type nature for generic argument. TIME is no Date. +error: Invalid type nature for generic argument. TIME is no ANY_DATE ┌─ :3:58 │ 3 │ FUNCTION func1 : INT VAR x : TIME; END_VAR test(x); END_FUNCTION - │ ^ Invalid type nature for generic argument. TIME is no Date. + │ ^ Invalid type nature for generic argument. TIME is no ANY_DATE -error: Invalid type nature for generic argument. TIME is no Date. +error: Invalid type nature for generic argument. TIME is no ANY_DATE ┌─ :4:59 │ 4 │ FUNCTION func2 : INT VAR x : LTIME; END_VAR test(x); END_FUNCTION - │ ^ Invalid type nature for generic argument. TIME is no Date. + │ ^ Invalid type nature for generic argument. TIME is no ANY_DATE diff --git a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_date_multiple_parameters.snap b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_date_multiple_parameters.snap index ceccf60f90..86fec33ee2 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_date_multiple_parameters.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_date_multiple_parameters.snap @@ -2,35 +2,35 @@ source: src/validation/tests/generic_validation_tests.rs expression: "&diagnostics" --- -error: Invalid type nature for generic argument. REAL is no Date. +error: Invalid type nature for generic argument. REAL is no ANY_DATE ┌─ :15:14 │ 15 │ func(var_real, var_unsigned, var_signed, var_time, var_byte, var_str, var_char, var_date); - │ ^^^^^^^^ Invalid type nature for generic argument. REAL is no Date. + │ ^^^^^^^^ Invalid type nature for generic argument. REAL is no ANY_DATE -error: Invalid type nature for generic argument. UDINT is no Date. +error: Invalid type nature for generic argument. UDINT is no ANY_DATE ┌─ :15:24 │ 15 │ func(var_real, var_unsigned, var_signed, var_time, var_byte, var_str, var_char, var_date); - │ ^^^^^^^^^^^^ Invalid type nature for generic argument. UDINT is no Date. + │ ^^^^^^^^^^^^ Invalid type nature for generic argument. UDINT is no ANY_DATE -error: Invalid type nature for generic argument. DINT is no Date. +error: Invalid type nature for generic argument. DINT is no ANY_DATE ┌─ :15:38 │ 15 │ func(var_real, var_unsigned, var_signed, var_time, var_byte, var_str, var_char, var_date); - │ ^^^^^^^^^^ Invalid type nature for generic argument. DINT is no Date. + │ ^^^^^^^^^^ Invalid type nature for generic argument. DINT is no ANY_DATE -error: Invalid type nature for generic argument. TIME is no Date. +error: Invalid type nature for generic argument. TIME is no ANY_DATE ┌─ :15:50 │ 15 │ func(var_real, var_unsigned, var_signed, var_time, var_byte, var_str, var_char, var_date); - │ ^^^^^^^^ Invalid type nature for generic argument. TIME is no Date. + │ ^^^^^^^^ Invalid type nature for generic argument. TIME is no ANY_DATE -error: Invalid type nature for generic argument. BYTE is no Date. +error: Invalid type nature for generic argument. BYTE is no ANY_DATE ┌─ :15:60 │ 15 │ func(var_real, var_unsigned, var_signed, var_time, var_byte, var_str, var_char, var_date); - │ ^^^^^^^^ Invalid type nature for generic argument. BYTE is no Date. + │ ^^^^^^^^ Invalid type nature for generic argument. BYTE is no ANY_DATE error: Invalid assignment: cannot assign 'STRING' to 'DATE' ┌─ :15:70 @@ -38,11 +38,11 @@ error: Invalid assignment: cannot assign 'STRING' to 'DATE' 15 │ func(var_real, var_unsigned, var_signed, var_time, var_byte, var_str, var_char, var_date); │ ^^^^^^^ Invalid assignment: cannot assign 'STRING' to 'DATE' -error: Invalid type nature for generic argument. STRING is no Date. +error: Invalid type nature for generic argument. STRING is no ANY_DATE ┌─ :15:70 │ 15 │ func(var_real, var_unsigned, var_signed, var_time, var_byte, var_str, var_char, var_date); - │ ^^^^^^^ Invalid type nature for generic argument. STRING is no Date. + │ ^^^^^^^ Invalid type nature for generic argument. STRING is no ANY_DATE error: Invalid assignment: cannot assign 'CHAR' to 'DATE' ┌─ :15:79 @@ -50,10 +50,10 @@ error: Invalid assignment: cannot assign 'CHAR' to 'DATE' 15 │ func(var_real, var_unsigned, var_signed, var_time, var_byte, var_str, var_char, var_date); │ ^^^^^^^^ Invalid assignment: cannot assign 'CHAR' to 'DATE' -error: Invalid type nature for generic argument. CHAR is no Date. +error: Invalid type nature for generic argument. CHAR is no ANY_DATE ┌─ :15:79 │ 15 │ func(var_real, var_unsigned, var_signed, var_time, var_byte, var_str, var_char, var_date); - │ ^^^^^^^^ Invalid type nature for generic argument. CHAR is no Date. + │ ^^^^^^^^ Invalid type nature for generic argument. CHAR is no ANY_DATE diff --git a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_duration_does_not_allow_bits.snap b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_duration_does_not_allow_bits.snap index e8ca3d9935..4ad6d5c1c2 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_duration_does_not_allow_bits.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_duration_does_not_allow_bits.snap @@ -2,34 +2,34 @@ source: src/validation/tests/generic_validation_tests.rs expression: "&diagnostics" --- -error: Invalid type nature for generic argument. BOOL is no Duration. +error: Invalid type nature for generic argument. BOOL is no ANY_DURATION ┌─ :3:58 │ 3 │ FUNCTION func1 : INT VAR x : BOOL; END_VAR test(x); END_FUNCTION - │ ^ Invalid type nature for generic argument. BOOL is no Duration. + │ ^ Invalid type nature for generic argument. BOOL is no ANY_DURATION -error: Invalid type nature for generic argument. BYTE is no Duration. +error: Invalid type nature for generic argument. BYTE is no ANY_DURATION ┌─ :4:58 │ 4 │ FUNCTION func2 : INT VAR x : BYTE; END_VAR test(x); END_FUNCTION - │ ^ Invalid type nature for generic argument. BYTE is no Duration. + │ ^ Invalid type nature for generic argument. BYTE is no ANY_DURATION -error: Invalid type nature for generic argument. WORD is no Duration. +error: Invalid type nature for generic argument. WORD is no ANY_DURATION ┌─ :5:58 │ 5 │ FUNCTION func3 : INT VAR x : WORD; END_VAR test(x); END_FUNCTION - │ ^ Invalid type nature for generic argument. WORD is no Duration. + │ ^ Invalid type nature for generic argument. WORD is no ANY_DURATION -error: Invalid type nature for generic argument. DWORD is no Duration. +error: Invalid type nature for generic argument. DWORD is no ANY_DURATION ┌─ :6:59 │ 6 │ FUNCTION func4 : INT VAR x : DWORD; END_VAR test(x); END_FUNCTION - │ ^ Invalid type nature for generic argument. DWORD is no Duration. + │ ^ Invalid type nature for generic argument. DWORD is no ANY_DURATION -error: Invalid type nature for generic argument. LWORD is no Duration. +error: Invalid type nature for generic argument. LWORD is no ANY_DURATION ┌─ :7:59 │ 7 │ FUNCTION func5 : INT VAR x : LWORD; END_VAR test(x); END_FUNCTION - │ ^ Invalid type nature for generic argument. LWORD is no Duration. + │ ^ Invalid type nature for generic argument. LWORD is no ANY_DURATION diff --git a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_duration_does_not_allow_chars.snap b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_duration_does_not_allow_chars.snap index 2f09f4cc9f..62d4ef34e7 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_duration_does_not_allow_chars.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_duration_does_not_allow_chars.snap @@ -8,11 +8,11 @@ error: Invalid assignment: cannot assign 'CHAR' to 'TIME' 3 │ FUNCTION func1 : INT VAR x : CHAR; END_VAR test(x); END_FUNCTION │ ^ Invalid assignment: cannot assign 'CHAR' to 'TIME' -error: Invalid type nature for generic argument. CHAR is no Duration. +error: Invalid type nature for generic argument. CHAR is no ANY_DURATION ┌─ :3:58 │ 3 │ FUNCTION func1 : INT VAR x : CHAR; END_VAR test(x); END_FUNCTION - │ ^ Invalid type nature for generic argument. CHAR is no Duration. + │ ^ Invalid type nature for generic argument. CHAR is no ANY_DURATION error: Invalid assignment: cannot assign 'WCHAR' to 'TIME' ┌─ :4:59 @@ -20,10 +20,10 @@ error: Invalid assignment: cannot assign 'WCHAR' to 'TIME' 4 │ FUNCTION func2 : INT VAR x : WCHAR; END_VAR test(x); END_FUNCTION │ ^ Invalid assignment: cannot assign 'WCHAR' to 'TIME' -error: Invalid type nature for generic argument. WCHAR is no Duration. +error: Invalid type nature for generic argument. WCHAR is no ANY_DURATION ┌─ :4:59 │ 4 │ FUNCTION func2 : INT VAR x : WCHAR; END_VAR test(x); END_FUNCTION - │ ^ Invalid type nature for generic argument. WCHAR is no Duration. + │ ^ Invalid type nature for generic argument. WCHAR is no ANY_DURATION diff --git a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_duration_does_not_allow_date.snap b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_duration_does_not_allow_date.snap index 0e4acd19f3..e9de756f91 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_duration_does_not_allow_date.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_duration_does_not_allow_date.snap @@ -2,34 +2,34 @@ source: src/validation/tests/generic_validation_tests.rs expression: "&diagnostics" --- -error: Invalid type nature for generic argument. DATE_AND_TIME is no Duration. +error: Invalid type nature for generic argument. DATE_AND_TIME is no ANY_DURATION ┌─ :3:56 │ 3 │ FUNCTION func1 : INT VAR x : DT; END_VAR test(x); END_FUNCTION - │ ^ Invalid type nature for generic argument. DATE_AND_TIME is no Duration. + │ ^ Invalid type nature for generic argument. DATE_AND_TIME is no ANY_DURATION -error: Invalid type nature for generic argument. DATE_AND_TIME is no Duration. +error: Invalid type nature for generic argument. DATE_AND_TIME is no ANY_DURATION ┌─ :4:57 │ 4 │ FUNCTION func2 : INT VAR x : LDT; END_VAR test(x); END_FUNCTION - │ ^ Invalid type nature for generic argument. DATE_AND_TIME is no Duration. + │ ^ Invalid type nature for generic argument. DATE_AND_TIME is no ANY_DURATION -error: Invalid type nature for generic argument. DATE is no Duration. +error: Invalid type nature for generic argument. DATE is no ANY_DURATION ┌─ :5:58 │ 5 │ FUNCTION func3 : INT VAR x : DATE; END_VAR test(x); END_FUNCTION - │ ^ Invalid type nature for generic argument. DATE is no Duration. + │ ^ Invalid type nature for generic argument. DATE is no ANY_DURATION -error: Invalid type nature for generic argument. TIME_OF_DAY is no Duration. +error: Invalid type nature for generic argument. TIME_OF_DAY is no ANY_DURATION ┌─ :6:57 │ 6 │ FUNCTION func4 : INT VAR x : TOD; END_VAR test(x); END_FUNCTION - │ ^ Invalid type nature for generic argument. TIME_OF_DAY is no Duration. + │ ^ Invalid type nature for generic argument. TIME_OF_DAY is no ANY_DURATION -error: Invalid type nature for generic argument. TIME_OF_DAY is no Duration. +error: Invalid type nature for generic argument. TIME_OF_DAY is no ANY_DURATION ┌─ :7:58 │ 7 │ FUNCTION func5 : INT VAR x : LTOD; END_VAR test(x); END_FUNCTION - │ ^ Invalid type nature for generic argument. TIME_OF_DAY is no Duration. + │ ^ Invalid type nature for generic argument. TIME_OF_DAY is no ANY_DURATION diff --git a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_duration_does_not_allow_ints.snap b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_duration_does_not_allow_ints.snap index 44ecfd8305..f9877f3586 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_duration_does_not_allow_ints.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_duration_does_not_allow_ints.snap @@ -2,52 +2,52 @@ source: src/validation/tests/generic_validation_tests.rs expression: "&diagnostics" --- -error: Invalid type nature for generic argument. USINT is no Duration. +error: Invalid type nature for generic argument. USINT is no ANY_DURATION ┌─ :4:59 │ 4 │ FUNCTION func1 : INT VAR x : USINT; END_VAR test(x); END_FUNCTION - │ ^ Invalid type nature for generic argument. USINT is no Duration. + │ ^ Invalid type nature for generic argument. USINT is no ANY_DURATION -error: Invalid type nature for generic argument. UINT is no Duration. +error: Invalid type nature for generic argument. UINT is no ANY_DURATION ┌─ :5:58 │ 5 │ FUNCTION func2 : INT VAR x : UINT; END_VAR test(x); END_FUNCTION - │ ^ Invalid type nature for generic argument. UINT is no Duration. + │ ^ Invalid type nature for generic argument. UINT is no ANY_DURATION -error: Invalid type nature for generic argument. UDINT is no Duration. +error: Invalid type nature for generic argument. UDINT is no ANY_DURATION ┌─ :6:59 │ 6 │ FUNCTION func3 : INT VAR x : UDINT; END_VAR test(x); END_FUNCTION - │ ^ Invalid type nature for generic argument. UDINT is no Duration. + │ ^ Invalid type nature for generic argument. UDINT is no ANY_DURATION -error: Invalid type nature for generic argument. ULINT is no Duration. +error: Invalid type nature for generic argument. ULINT is no ANY_DURATION ┌─ :7:59 │ 7 │ FUNCTION func4 : INT VAR x : ULINT; END_VAR test(x); END_FUNCTION - │ ^ Invalid type nature for generic argument. ULINT is no Duration. + │ ^ Invalid type nature for generic argument. ULINT is no ANY_DURATION -error: Invalid type nature for generic argument. SINT is no Duration. +error: Invalid type nature for generic argument. SINT is no ANY_DURATION ┌─ :9:58 │ 9 │ FUNCTION func5 : INT VAR x : SINT; END_VAR test(x); END_FUNCTION - │ ^ Invalid type nature for generic argument. SINT is no Duration. + │ ^ Invalid type nature for generic argument. SINT is no ANY_DURATION -error: Invalid type nature for generic argument. INT is no Duration. +error: Invalid type nature for generic argument. INT is no ANY_DURATION ┌─ :10:57 │ 10 │ FUNCTION func6 : INT VAR x : INT; END_VAR test(x); END_FUNCTION - │ ^ Invalid type nature for generic argument. INT is no Duration. + │ ^ Invalid type nature for generic argument. INT is no ANY_DURATION -error: Invalid type nature for generic argument. DINT is no Duration. +error: Invalid type nature for generic argument. DINT is no ANY_DURATION ┌─ :11:58 │ 11 │ FUNCTION func7 : INT VAR x : DINT; END_VAR test(x); END_FUNCTION - │ ^ Invalid type nature for generic argument. DINT is no Duration. + │ ^ Invalid type nature for generic argument. DINT is no ANY_DURATION -error: Invalid type nature for generic argument. LINT is no Duration. +error: Invalid type nature for generic argument. LINT is no ANY_DURATION ┌─ :12:58 │ 12 │ FUNCTION func8 : INT VAR x : LINT; END_VAR test(x); END_FUNCTION - │ ^ Invalid type nature for generic argument. LINT is no Duration. + │ ^ Invalid type nature for generic argument. LINT is no ANY_DURATION diff --git a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_duration_does_not_allow_reals.snap b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_duration_does_not_allow_reals.snap index e6e156a737..4f19b3519a 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_duration_does_not_allow_reals.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_duration_does_not_allow_reals.snap @@ -2,16 +2,16 @@ source: src/validation/tests/generic_validation_tests.rs expression: "&diagnostics" --- -error: Invalid type nature for generic argument. REAL is no Duration. +error: Invalid type nature for generic argument. REAL is no ANY_DURATION ┌─ :3:57 │ 3 │ FUNCTION func : INT VAR x : REAL; END_VAR test(x); END_FUNCTION - │ ^ Invalid type nature for generic argument. REAL is no Duration. + │ ^ Invalid type nature for generic argument. REAL is no ANY_DURATION -error: Invalid type nature for generic argument. LREAL is no Duration. +error: Invalid type nature for generic argument. LREAL is no ANY_DURATION ┌─ :4:59 │ 4 │ FUNCTION func1 : INT VAR x : LREAL; END_VAR test(x); END_FUNCTION - │ ^ Invalid type nature for generic argument. LREAL is no Duration. + │ ^ Invalid type nature for generic argument. LREAL is no ANY_DURATION diff --git a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_duration_does_not_allow_string.snap b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_duration_does_not_allow_string.snap index d878b01e93..38fbb76740 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_duration_does_not_allow_string.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_duration_does_not_allow_string.snap @@ -8,11 +8,11 @@ error: Invalid assignment: cannot assign 'STRING' to 'TIME' 3 │ FUNCTION func1 : INT VAR x : STRING; END_VAR test(x); END_FUNCTION │ ^ Invalid assignment: cannot assign 'STRING' to 'TIME' -error: Invalid type nature for generic argument. STRING is no Duration. +error: Invalid type nature for generic argument. STRING is no ANY_DURATION ┌─ :3:61 │ 3 │ FUNCTION func1 : INT VAR x : STRING; END_VAR test(x); END_FUNCTION - │ ^ Invalid type nature for generic argument. STRING is no Duration. + │ ^ Invalid type nature for generic argument. STRING is no ANY_DURATION error: Invalid assignment: cannot assign 'WSTRING' to 'TIME' ┌─ :4:61 @@ -20,10 +20,10 @@ error: Invalid assignment: cannot assign 'WSTRING' to 'TIME' 4 │ FUNCTION func2 : INT VAR x : WSTRING; END_VAR test(x); END_FUNCTION │ ^ Invalid assignment: cannot assign 'WSTRING' to 'TIME' -error: Invalid type nature for generic argument. WSTRING is no Duration. +error: Invalid type nature for generic argument. WSTRING is no ANY_DURATION ┌─ :4:61 │ 4 │ FUNCTION func2 : INT VAR x : WSTRING; END_VAR test(x); END_FUNCTION - │ ^ Invalid type nature for generic argument. WSTRING is no Duration. + │ ^ Invalid type nature for generic argument. WSTRING is no ANY_DURATION diff --git a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_duration_multiple_parameters.snap b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_duration_multiple_parameters.snap index 3679326b2c..d60eca5ba4 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_duration_multiple_parameters.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_duration_multiple_parameters.snap @@ -2,29 +2,29 @@ source: src/validation/tests/generic_validation_tests.rs expression: "&diagnostics" --- -error: Invalid type nature for generic argument. REAL is no Duration. +error: Invalid type nature for generic argument. REAL is no ANY_DURATION ┌─ :15:14 │ 15 │ func(var_real, var_unsigned, var_signed, var_time, var_byte, var_str, var_char, var_date); - │ ^^^^^^^^ Invalid type nature for generic argument. REAL is no Duration. + │ ^^^^^^^^ Invalid type nature for generic argument. REAL is no ANY_DURATION -error: Invalid type nature for generic argument. UDINT is no Duration. +error: Invalid type nature for generic argument. UDINT is no ANY_DURATION ┌─ :15:24 │ 15 │ func(var_real, var_unsigned, var_signed, var_time, var_byte, var_str, var_char, var_date); - │ ^^^^^^^^^^^^ Invalid type nature for generic argument. UDINT is no Duration. + │ ^^^^^^^^^^^^ Invalid type nature for generic argument. UDINT is no ANY_DURATION -error: Invalid type nature for generic argument. DINT is no Duration. +error: Invalid type nature for generic argument. DINT is no ANY_DURATION ┌─ :15:38 │ 15 │ func(var_real, var_unsigned, var_signed, var_time, var_byte, var_str, var_char, var_date); - │ ^^^^^^^^^^ Invalid type nature for generic argument. DINT is no Duration. + │ ^^^^^^^^^^ Invalid type nature for generic argument. DINT is no ANY_DURATION -error: Invalid type nature for generic argument. BYTE is no Duration. +error: Invalid type nature for generic argument. BYTE is no ANY_DURATION ┌─ :15:60 │ 15 │ func(var_real, var_unsigned, var_signed, var_time, var_byte, var_str, var_char, var_date); - │ ^^^^^^^^ Invalid type nature for generic argument. BYTE is no Duration. + │ ^^^^^^^^ Invalid type nature for generic argument. BYTE is no ANY_DURATION error: Invalid assignment: cannot assign 'STRING' to 'TIME' ┌─ :15:70 @@ -32,11 +32,11 @@ error: Invalid assignment: cannot assign 'STRING' to 'TIME' 15 │ func(var_real, var_unsigned, var_signed, var_time, var_byte, var_str, var_char, var_date); │ ^^^^^^^ Invalid assignment: cannot assign 'STRING' to 'TIME' -error: Invalid type nature for generic argument. STRING is no Duration. +error: Invalid type nature for generic argument. STRING is no ANY_DURATION ┌─ :15:70 │ 15 │ func(var_real, var_unsigned, var_signed, var_time, var_byte, var_str, var_char, var_date); - │ ^^^^^^^ Invalid type nature for generic argument. STRING is no Duration. + │ ^^^^^^^ Invalid type nature for generic argument. STRING is no ANY_DURATION error: Invalid assignment: cannot assign 'CHAR' to 'TIME' ┌─ :15:79 @@ -44,16 +44,16 @@ error: Invalid assignment: cannot assign 'CHAR' to 'TIME' 15 │ func(var_real, var_unsigned, var_signed, var_time, var_byte, var_str, var_char, var_date); │ ^^^^^^^^ Invalid assignment: cannot assign 'CHAR' to 'TIME' -error: Invalid type nature for generic argument. CHAR is no Duration. +error: Invalid type nature for generic argument. CHAR is no ANY_DURATION ┌─ :15:79 │ 15 │ func(var_real, var_unsigned, var_signed, var_time, var_byte, var_str, var_char, var_date); - │ ^^^^^^^^ Invalid type nature for generic argument. CHAR is no Duration. + │ ^^^^^^^^ Invalid type nature for generic argument. CHAR is no ANY_DURATION -error: Invalid type nature for generic argument. DATE is no Duration. +error: Invalid type nature for generic argument. DATE is no ANY_DURATION ┌─ :15:89 │ 15 │ func(var_real, var_unsigned, var_signed, var_time, var_byte, var_str, var_char, var_date); - │ ^^^^^^^^ Invalid type nature for generic argument. DATE is no Duration. + │ ^^^^^^^^ Invalid type nature for generic argument. DATE is no ANY_DURATION diff --git a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_int_does_not_allow_bits.snap b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_int_does_not_allow_bits.snap index 43419695c2..5f1f260988 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_int_does_not_allow_bits.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_int_does_not_allow_bits.snap @@ -2,34 +2,34 @@ source: src/validation/tests/generic_validation_tests.rs expression: "&diagnostics" --- -error: Invalid type nature for generic argument. BOOL is no Int. +error: Invalid type nature for generic argument. BOOL is no ANY_INT ┌─ :3:58 │ 3 │ FUNCTION func1 : INT VAR x : BOOL; END_VAR test(x); END_FUNCTION - │ ^ Invalid type nature for generic argument. BOOL is no Int. + │ ^ Invalid type nature for generic argument. BOOL is no ANY_INT -error: Invalid type nature for generic argument. BYTE is no Int. +error: Invalid type nature for generic argument. BYTE is no ANY_INT ┌─ :4:58 │ 4 │ FUNCTION func2 : INT VAR x : BYTE; END_VAR test(x); END_FUNCTION - │ ^ Invalid type nature for generic argument. BYTE is no Int. + │ ^ Invalid type nature for generic argument. BYTE is no ANY_INT -error: Invalid type nature for generic argument. WORD is no Int. +error: Invalid type nature for generic argument. WORD is no ANY_INT ┌─ :5:58 │ 5 │ FUNCTION func3 : INT VAR x : WORD; END_VAR test(x); END_FUNCTION - │ ^ Invalid type nature for generic argument. WORD is no Int. + │ ^ Invalid type nature for generic argument. WORD is no ANY_INT -error: Invalid type nature for generic argument. DWORD is no Int. +error: Invalid type nature for generic argument. DWORD is no ANY_INT ┌─ :6:59 │ 6 │ FUNCTION func4 : INT VAR x : DWORD; END_VAR test(x); END_FUNCTION - │ ^ Invalid type nature for generic argument. DWORD is no Int. + │ ^ Invalid type nature for generic argument. DWORD is no ANY_INT -error: Invalid type nature for generic argument. LWORD is no Int. +error: Invalid type nature for generic argument. LWORD is no ANY_INT ┌─ :7:59 │ 7 │ FUNCTION func5 : INT VAR x : LWORD; END_VAR test(x); END_FUNCTION - │ ^ Invalid type nature for generic argument. LWORD is no Int. + │ ^ Invalid type nature for generic argument. LWORD is no ANY_INT diff --git a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_int_does_not_allow_chars.snap b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_int_does_not_allow_chars.snap index 3f964e6123..25c6632c05 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_int_does_not_allow_chars.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_int_does_not_allow_chars.snap @@ -8,11 +8,11 @@ error: Invalid assignment: cannot assign 'CHAR' to 'USINT' 3 │ FUNCTION func1 : INT VAR x : CHAR; END_VAR test(x); END_FUNCTION │ ^ Invalid assignment: cannot assign 'CHAR' to 'USINT' -error: Invalid type nature for generic argument. CHAR is no Int. +error: Invalid type nature for generic argument. CHAR is no ANY_INT ┌─ :3:58 │ 3 │ FUNCTION func1 : INT VAR x : CHAR; END_VAR test(x); END_FUNCTION - │ ^ Invalid type nature for generic argument. CHAR is no Int. + │ ^ Invalid type nature for generic argument. CHAR is no ANY_INT error: Invalid assignment: cannot assign 'WCHAR' to 'USINT' ┌─ :4:59 @@ -20,10 +20,10 @@ error: Invalid assignment: cannot assign 'WCHAR' to 'USINT' 4 │ FUNCTION func2 : INT VAR x : WCHAR; END_VAR test(x); END_FUNCTION │ ^ Invalid assignment: cannot assign 'WCHAR' to 'USINT' -error: Invalid type nature for generic argument. WCHAR is no Int. +error: Invalid type nature for generic argument. WCHAR is no ANY_INT ┌─ :4:59 │ 4 │ FUNCTION func2 : INT VAR x : WCHAR; END_VAR test(x); END_FUNCTION - │ ^ Invalid type nature for generic argument. WCHAR is no Int. + │ ^ Invalid type nature for generic argument. WCHAR is no ANY_INT diff --git a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_int_does_not_allow_date.snap b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_int_does_not_allow_date.snap index 27e18918e7..2a757d1135 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_int_does_not_allow_date.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_int_does_not_allow_date.snap @@ -2,34 +2,34 @@ source: src/validation/tests/generic_validation_tests.rs expression: "&diagnostics" --- -error: Invalid type nature for generic argument. DATE_AND_TIME is no Int. +error: Invalid type nature for generic argument. DATE_AND_TIME is no ANY_INT ┌─ :3:56 │ 3 │ FUNCTION func1 : INT VAR x : DT; END_VAR test(x); END_FUNCTION - │ ^ Invalid type nature for generic argument. DATE_AND_TIME is no Int. + │ ^ Invalid type nature for generic argument. DATE_AND_TIME is no ANY_INT -error: Invalid type nature for generic argument. DATE_AND_TIME is no Int. +error: Invalid type nature for generic argument. DATE_AND_TIME is no ANY_INT ┌─ :4:57 │ 4 │ FUNCTION func2 : INT VAR x : LDT; END_VAR test(x); END_FUNCTION - │ ^ Invalid type nature for generic argument. DATE_AND_TIME is no Int. + │ ^ Invalid type nature for generic argument. DATE_AND_TIME is no ANY_INT -error: Invalid type nature for generic argument. DATE is no Int. +error: Invalid type nature for generic argument. DATE is no ANY_INT ┌─ :5:58 │ 5 │ FUNCTION func3 : INT VAR x : DATE; END_VAR test(x); END_FUNCTION - │ ^ Invalid type nature for generic argument. DATE is no Int. + │ ^ Invalid type nature for generic argument. DATE is no ANY_INT -error: Invalid type nature for generic argument. TIME_OF_DAY is no Int. +error: Invalid type nature for generic argument. TIME_OF_DAY is no ANY_INT ┌─ :6:57 │ 6 │ FUNCTION func4 : INT VAR x : TOD; END_VAR test(x); END_FUNCTION - │ ^ Invalid type nature for generic argument. TIME_OF_DAY is no Int. + │ ^ Invalid type nature for generic argument. TIME_OF_DAY is no ANY_INT -error: Invalid type nature for generic argument. TIME_OF_DAY is no Int. +error: Invalid type nature for generic argument. TIME_OF_DAY is no ANY_INT ┌─ :7:58 │ 7 │ FUNCTION func5 : INT VAR x : LTOD; END_VAR test(x); END_FUNCTION - │ ^ Invalid type nature for generic argument. TIME_OF_DAY is no Int. + │ ^ Invalid type nature for generic argument. TIME_OF_DAY is no ANY_INT diff --git a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_int_does_not_allow_reals.snap b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_int_does_not_allow_reals.snap index 017e924c29..3d74075a44 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_int_does_not_allow_reals.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_int_does_not_allow_reals.snap @@ -2,16 +2,16 @@ source: src/validation/tests/generic_validation_tests.rs expression: "&diagnostics" --- -error: Invalid type nature for generic argument. REAL is no Int. +error: Invalid type nature for generic argument. REAL is no ANY_INT ┌─ :3:57 │ 3 │ FUNCTION func : INT VAR x : REAL; END_VAR test(x); END_FUNCTION - │ ^ Invalid type nature for generic argument. REAL is no Int. + │ ^ Invalid type nature for generic argument. REAL is no ANY_INT -error: Invalid type nature for generic argument. LREAL is no Int. +error: Invalid type nature for generic argument. LREAL is no ANY_INT ┌─ :4:59 │ 4 │ FUNCTION func1 : INT VAR x : LREAL; END_VAR test(x); END_FUNCTION - │ ^ Invalid type nature for generic argument. LREAL is no Int. + │ ^ Invalid type nature for generic argument. LREAL is no ANY_INT diff --git a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_int_does_not_allow_string.snap b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_int_does_not_allow_string.snap index d1ba5ec0e1..dabc5789b5 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_int_does_not_allow_string.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_int_does_not_allow_string.snap @@ -8,11 +8,11 @@ error: Invalid assignment: cannot assign 'STRING' to 'USINT' 3 │ FUNCTION func1 : INT VAR x : STRING; END_VAR test(x); END_FUNCTION │ ^ Invalid assignment: cannot assign 'STRING' to 'USINT' -error: Invalid type nature for generic argument. STRING is no Int. +error: Invalid type nature for generic argument. STRING is no ANY_INT ┌─ :3:61 │ 3 │ FUNCTION func1 : INT VAR x : STRING; END_VAR test(x); END_FUNCTION - │ ^ Invalid type nature for generic argument. STRING is no Int. + │ ^ Invalid type nature for generic argument. STRING is no ANY_INT error: Invalid assignment: cannot assign 'WSTRING' to 'USINT' ┌─ :4:61 @@ -20,10 +20,10 @@ error: Invalid assignment: cannot assign 'WSTRING' to 'USINT' 4 │ FUNCTION func2 : INT VAR x : WSTRING; END_VAR test(x); END_FUNCTION │ ^ Invalid assignment: cannot assign 'WSTRING' to 'USINT' -error: Invalid type nature for generic argument. WSTRING is no Int. +error: Invalid type nature for generic argument. WSTRING is no ANY_INT ┌─ :4:61 │ 4 │ FUNCTION func2 : INT VAR x : WSTRING; END_VAR test(x); END_FUNCTION - │ ^ Invalid type nature for generic argument. WSTRING is no Int. + │ ^ Invalid type nature for generic argument. WSTRING is no ANY_INT diff --git a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_int_does_not_allow_time.snap b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_int_does_not_allow_time.snap index 00ff188a46..07f30d742e 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_int_does_not_allow_time.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_int_does_not_allow_time.snap @@ -2,16 +2,16 @@ source: src/validation/tests/generic_validation_tests.rs expression: "&diagnostics" --- -error: Invalid type nature for generic argument. TIME is no Int. +error: Invalid type nature for generic argument. TIME is no ANY_INT ┌─ :3:58 │ 3 │ FUNCTION func1 : INT VAR x : TIME; END_VAR test(x); END_FUNCTION - │ ^ Invalid type nature for generic argument. TIME is no Int. + │ ^ Invalid type nature for generic argument. TIME is no ANY_INT -error: Invalid type nature for generic argument. TIME is no Int. +error: Invalid type nature for generic argument. TIME is no ANY_INT ┌─ :4:59 │ 4 │ FUNCTION func2 : INT VAR x : LTIME; END_VAR test(x); END_FUNCTION - │ ^ Invalid type nature for generic argument. TIME is no Int. + │ ^ Invalid type nature for generic argument. TIME is no ANY_INT diff --git a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_int_multiple_parameters.snap b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_int_multiple_parameters.snap index 4a87c24f97..9d2358d48a 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_int_multiple_parameters.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_int_multiple_parameters.snap @@ -2,23 +2,23 @@ source: src/validation/tests/generic_validation_tests.rs expression: "&diagnostics" --- -error: Invalid type nature for generic argument. REAL is no Int. +error: Invalid type nature for generic argument. REAL is no ANY_INT ┌─ :15:14 │ 15 │ func(var_real, var_unsigned, var_signed, var_time, var_byte, var_str, var_char, var_date); - │ ^^^^^^^^ Invalid type nature for generic argument. REAL is no Int. + │ ^^^^^^^^ Invalid type nature for generic argument. REAL is no ANY_INT -error: Invalid type nature for generic argument. TIME is no Int. +error: Invalid type nature for generic argument. TIME is no ANY_INT ┌─ :15:50 │ 15 │ func(var_real, var_unsigned, var_signed, var_time, var_byte, var_str, var_char, var_date); - │ ^^^^^^^^ Invalid type nature for generic argument. TIME is no Int. + │ ^^^^^^^^ Invalid type nature for generic argument. TIME is no ANY_INT -error: Invalid type nature for generic argument. BYTE is no Int. +error: Invalid type nature for generic argument. BYTE is no ANY_INT ┌─ :15:60 │ 15 │ func(var_real, var_unsigned, var_signed, var_time, var_byte, var_str, var_char, var_date); - │ ^^^^^^^^ Invalid type nature for generic argument. BYTE is no Int. + │ ^^^^^^^^ Invalid type nature for generic argument. BYTE is no ANY_INT error: Invalid assignment: cannot assign 'STRING' to 'DINT' ┌─ :15:70 @@ -26,11 +26,11 @@ error: Invalid assignment: cannot assign 'STRING' to 'DINT' 15 │ func(var_real, var_unsigned, var_signed, var_time, var_byte, var_str, var_char, var_date); │ ^^^^^^^ Invalid assignment: cannot assign 'STRING' to 'DINT' -error: Invalid type nature for generic argument. STRING is no Int. +error: Invalid type nature for generic argument. STRING is no ANY_INT ┌─ :15:70 │ 15 │ func(var_real, var_unsigned, var_signed, var_time, var_byte, var_str, var_char, var_date); - │ ^^^^^^^ Invalid type nature for generic argument. STRING is no Int. + │ ^^^^^^^ Invalid type nature for generic argument. STRING is no ANY_INT error: Invalid assignment: cannot assign 'CHAR' to 'DINT' ┌─ :15:79 @@ -38,16 +38,16 @@ error: Invalid assignment: cannot assign 'CHAR' to 'DINT' 15 │ func(var_real, var_unsigned, var_signed, var_time, var_byte, var_str, var_char, var_date); │ ^^^^^^^^ Invalid assignment: cannot assign 'CHAR' to 'DINT' -error: Invalid type nature for generic argument. CHAR is no Int. +error: Invalid type nature for generic argument. CHAR is no ANY_INT ┌─ :15:79 │ 15 │ func(var_real, var_unsigned, var_signed, var_time, var_byte, var_str, var_char, var_date); - │ ^^^^^^^^ Invalid type nature for generic argument. CHAR is no Int. + │ ^^^^^^^^ Invalid type nature for generic argument. CHAR is no ANY_INT -error: Invalid type nature for generic argument. DATE is no Int. +error: Invalid type nature for generic argument. DATE is no ANY_INT ┌─ :15:89 │ 15 │ func(var_real, var_unsigned, var_signed, var_time, var_byte, var_str, var_char, var_date); - │ ^^^^^^^^ Invalid type nature for generic argument. DATE is no Int. + │ ^^^^^^^^ Invalid type nature for generic argument. DATE is no ANY_INT diff --git a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_magnitude_does_not_allow_bits.snap b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_magnitude_does_not_allow_bits.snap index 4d5b3a6032..a144d12335 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_magnitude_does_not_allow_bits.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_magnitude_does_not_allow_bits.snap @@ -2,34 +2,34 @@ source: src/validation/tests/generic_validation_tests.rs expression: "&diagnostics" --- -error: Invalid type nature for generic argument. BOOL is no Magnitude. +error: Invalid type nature for generic argument. BOOL is no ANY_MAGNITUDE ┌─ :3:58 │ 3 │ FUNCTION func1 : INT VAR x : BOOL; END_VAR test(x); END_FUNCTION - │ ^ Invalid type nature for generic argument. BOOL is no Magnitude. + │ ^ Invalid type nature for generic argument. BOOL is no ANY_MAGNITUDE -error: Invalid type nature for generic argument. BYTE is no Magnitude. +error: Invalid type nature for generic argument. BYTE is no ANY_MAGNITUDE ┌─ :4:58 │ 4 │ FUNCTION func2 : INT VAR x : BYTE; END_VAR test(x); END_FUNCTION - │ ^ Invalid type nature for generic argument. BYTE is no Magnitude. + │ ^ Invalid type nature for generic argument. BYTE is no ANY_MAGNITUDE -error: Invalid type nature for generic argument. WORD is no Magnitude. +error: Invalid type nature for generic argument. WORD is no ANY_MAGNITUDE ┌─ :5:58 │ 5 │ FUNCTION func3 : INT VAR x : WORD; END_VAR test(x); END_FUNCTION - │ ^ Invalid type nature for generic argument. WORD is no Magnitude. + │ ^ Invalid type nature for generic argument. WORD is no ANY_MAGNITUDE -error: Invalid type nature for generic argument. DWORD is no Magnitude. +error: Invalid type nature for generic argument. DWORD is no ANY_MAGNITUDE ┌─ :6:59 │ 6 │ FUNCTION func4 : INT VAR x : DWORD; END_VAR test(x); END_FUNCTION - │ ^ Invalid type nature for generic argument. DWORD is no Magnitude. + │ ^ Invalid type nature for generic argument. DWORD is no ANY_MAGNITUDE -error: Invalid type nature for generic argument. LWORD is no Magnitude. +error: Invalid type nature for generic argument. LWORD is no ANY_MAGNITUDE ┌─ :7:59 │ 7 │ FUNCTION func5 : INT VAR x : LWORD; END_VAR test(x); END_FUNCTION - │ ^ Invalid type nature for generic argument. LWORD is no Magnitude. + │ ^ Invalid type nature for generic argument. LWORD is no ANY_MAGNITUDE diff --git a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_magnitude_does_not_allow_chars.snap b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_magnitude_does_not_allow_chars.snap index 8b76a7ff85..f373e84358 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_magnitude_does_not_allow_chars.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_magnitude_does_not_allow_chars.snap @@ -8,11 +8,11 @@ error: Invalid assignment: cannot assign 'CHAR' to 'USINT' 3 │ FUNCTION func1 : INT VAR x : CHAR; END_VAR test(x); END_FUNCTION │ ^ Invalid assignment: cannot assign 'CHAR' to 'USINT' -error: Invalid type nature for generic argument. CHAR is no Magnitude. +error: Invalid type nature for generic argument. CHAR is no ANY_MAGNITUDE ┌─ :3:58 │ 3 │ FUNCTION func1 : INT VAR x : CHAR; END_VAR test(x); END_FUNCTION - │ ^ Invalid type nature for generic argument. CHAR is no Magnitude. + │ ^ Invalid type nature for generic argument. CHAR is no ANY_MAGNITUDE error: Invalid assignment: cannot assign 'WCHAR' to 'USINT' ┌─ :4:59 @@ -20,10 +20,10 @@ error: Invalid assignment: cannot assign 'WCHAR' to 'USINT' 4 │ FUNCTION func2 : INT VAR x : WCHAR; END_VAR test(x); END_FUNCTION │ ^ Invalid assignment: cannot assign 'WCHAR' to 'USINT' -error: Invalid type nature for generic argument. WCHAR is no Magnitude. +error: Invalid type nature for generic argument. WCHAR is no ANY_MAGNITUDE ┌─ :4:59 │ 4 │ FUNCTION func2 : INT VAR x : WCHAR; END_VAR test(x); END_FUNCTION - │ ^ Invalid type nature for generic argument. WCHAR is no Magnitude. + │ ^ Invalid type nature for generic argument. WCHAR is no ANY_MAGNITUDE diff --git a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_magnitude_does_not_allow_date.snap b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_magnitude_does_not_allow_date.snap index 923b43c2c6..01373f7dfd 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_magnitude_does_not_allow_date.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_magnitude_does_not_allow_date.snap @@ -2,34 +2,34 @@ source: src/validation/tests/generic_validation_tests.rs expression: "&diagnostics" --- -error: Invalid type nature for generic argument. DATE_AND_TIME is no Magnitude. +error: Invalid type nature for generic argument. DATE_AND_TIME is no ANY_MAGNITUDE ┌─ :3:56 │ 3 │ FUNCTION func1 : INT VAR x : DT; END_VAR test(x); END_FUNCTION - │ ^ Invalid type nature for generic argument. DATE_AND_TIME is no Magnitude. + │ ^ Invalid type nature for generic argument. DATE_AND_TIME is no ANY_MAGNITUDE -error: Invalid type nature for generic argument. DATE_AND_TIME is no Magnitude. +error: Invalid type nature for generic argument. DATE_AND_TIME is no ANY_MAGNITUDE ┌─ :4:57 │ 4 │ FUNCTION func2 : INT VAR x : LDT; END_VAR test(x); END_FUNCTION - │ ^ Invalid type nature for generic argument. DATE_AND_TIME is no Magnitude. + │ ^ Invalid type nature for generic argument. DATE_AND_TIME is no ANY_MAGNITUDE -error: Invalid type nature for generic argument. DATE is no Magnitude. +error: Invalid type nature for generic argument. DATE is no ANY_MAGNITUDE ┌─ :5:58 │ 5 │ FUNCTION func3 : INT VAR x : DATE; END_VAR test(x); END_FUNCTION - │ ^ Invalid type nature for generic argument. DATE is no Magnitude. + │ ^ Invalid type nature for generic argument. DATE is no ANY_MAGNITUDE -error: Invalid type nature for generic argument. TIME_OF_DAY is no Magnitude. +error: Invalid type nature for generic argument. TIME_OF_DAY is no ANY_MAGNITUDE ┌─ :6:57 │ 6 │ FUNCTION func4 : INT VAR x : TOD; END_VAR test(x); END_FUNCTION - │ ^ Invalid type nature for generic argument. TIME_OF_DAY is no Magnitude. + │ ^ Invalid type nature for generic argument. TIME_OF_DAY is no ANY_MAGNITUDE -error: Invalid type nature for generic argument. TIME_OF_DAY is no Magnitude. +error: Invalid type nature for generic argument. TIME_OF_DAY is no ANY_MAGNITUDE ┌─ :7:58 │ 7 │ FUNCTION func5 : INT VAR x : LTOD; END_VAR test(x); END_FUNCTION - │ ^ Invalid type nature for generic argument. TIME_OF_DAY is no Magnitude. + │ ^ Invalid type nature for generic argument. TIME_OF_DAY is no ANY_MAGNITUDE diff --git a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_magnitude_does_not_allow_strings.snap b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_magnitude_does_not_allow_strings.snap index f0020a8736..1166ac6416 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_magnitude_does_not_allow_strings.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_magnitude_does_not_allow_strings.snap @@ -8,11 +8,11 @@ error: Invalid assignment: cannot assign 'STRING' to 'USINT' 3 │ FUNCTION func1 : INT VAR x : STRING; END_VAR test(x); END_FUNCTION │ ^ Invalid assignment: cannot assign 'STRING' to 'USINT' -error: Invalid type nature for generic argument. STRING is no Magnitude. +error: Invalid type nature for generic argument. STRING is no ANY_MAGNITUDE ┌─ :3:60 │ 3 │ FUNCTION func1 : INT VAR x : STRING; END_VAR test(x); END_FUNCTION - │ ^ Invalid type nature for generic argument. STRING is no Magnitude. + │ ^ Invalid type nature for generic argument. STRING is no ANY_MAGNITUDE error: Invalid assignment: cannot assign 'WSTRING' to 'USINT' ┌─ :4:61 @@ -20,10 +20,10 @@ error: Invalid assignment: cannot assign 'WSTRING' to 'USINT' 4 │ FUNCTION func2 : INT VAR x : WSTRING; END_VAR test(x); END_FUNCTION │ ^ Invalid assignment: cannot assign 'WSTRING' to 'USINT' -error: Invalid type nature for generic argument. WSTRING is no Magnitude. +error: Invalid type nature for generic argument. WSTRING is no ANY_MAGNITUDE ┌─ :4:61 │ 4 │ FUNCTION func2 : INT VAR x : WSTRING; END_VAR test(x); END_FUNCTION - │ ^ Invalid type nature for generic argument. WSTRING is no Magnitude. + │ ^ Invalid type nature for generic argument. WSTRING is no ANY_MAGNITUDE diff --git a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_magnitude_multiple_parameters.snap b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_magnitude_multiple_parameters.snap index f53e2e03a2..838546b94e 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_magnitude_multiple_parameters.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_magnitude_multiple_parameters.snap @@ -2,11 +2,11 @@ source: src/validation/tests/generic_validation_tests.rs expression: "&diagnostics" --- -error: Invalid type nature for generic argument. BYTE is no Magnitude. +error: Invalid type nature for generic argument. BYTE is no ANY_MAGNITUDE ┌─ :15:60 │ 15 │ func(var_real, var_unsigned, var_signed, var_time, var_byte, var_str, var_char, var_date); - │ ^^^^^^^^ Invalid type nature for generic argument. BYTE is no Magnitude. + │ ^^^^^^^^ Invalid type nature for generic argument. BYTE is no ANY_MAGNITUDE error: Invalid assignment: cannot assign 'STRING' to 'TIME' ┌─ :15:70 @@ -14,11 +14,11 @@ error: Invalid assignment: cannot assign 'STRING' to 'TIME' 15 │ func(var_real, var_unsigned, var_signed, var_time, var_byte, var_str, var_char, var_date); │ ^^^^^^^ Invalid assignment: cannot assign 'STRING' to 'TIME' -error: Invalid type nature for generic argument. STRING is no Magnitude. +error: Invalid type nature for generic argument. STRING is no ANY_MAGNITUDE ┌─ :15:70 │ 15 │ func(var_real, var_unsigned, var_signed, var_time, var_byte, var_str, var_char, var_date); - │ ^^^^^^^ Invalid type nature for generic argument. STRING is no Magnitude. + │ ^^^^^^^ Invalid type nature for generic argument. STRING is no ANY_MAGNITUDE error: Invalid assignment: cannot assign 'CHAR' to 'TIME' ┌─ :15:79 @@ -26,16 +26,16 @@ error: Invalid assignment: cannot assign 'CHAR' to 'TIME' 15 │ func(var_real, var_unsigned, var_signed, var_time, var_byte, var_str, var_char, var_date); │ ^^^^^^^^ Invalid assignment: cannot assign 'CHAR' to 'TIME' -error: Invalid type nature for generic argument. CHAR is no Magnitude. +error: Invalid type nature for generic argument. CHAR is no ANY_MAGNITUDE ┌─ :15:79 │ 15 │ func(var_real, var_unsigned, var_signed, var_time, var_byte, var_str, var_char, var_date); - │ ^^^^^^^^ Invalid type nature for generic argument. CHAR is no Magnitude. + │ ^^^^^^^^ Invalid type nature for generic argument. CHAR is no ANY_MAGNITUDE -error: Invalid type nature for generic argument. DATE is no Magnitude. +error: Invalid type nature for generic argument. DATE is no ANY_MAGNITUDE ┌─ :15:89 │ 15 │ func(var_real, var_unsigned, var_signed, var_time, var_byte, var_str, var_char, var_date); - │ ^^^^^^^^ Invalid type nature for generic argument. DATE is no Magnitude. + │ ^^^^^^^^ Invalid type nature for generic argument. DATE is no ANY_MAGNITUDE diff --git a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_num_does_not_allow_bits.snap b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_num_does_not_allow_bits.snap index bc1dced5f7..a274a557a1 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_num_does_not_allow_bits.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_num_does_not_allow_bits.snap @@ -2,34 +2,34 @@ source: src/validation/tests/generic_validation_tests.rs expression: "&diagnostics" --- -error: Invalid type nature for generic argument. BOOL is no Num. +error: Invalid type nature for generic argument. BOOL is no ANY_NUMBER ┌─ :3:58 │ 3 │ FUNCTION func1 : INT VAR x : BOOL; END_VAR test(x); END_FUNCTION - │ ^ Invalid type nature for generic argument. BOOL is no Num. + │ ^ Invalid type nature for generic argument. BOOL is no ANY_NUMBER -error: Invalid type nature for generic argument. BYTE is no Num. +error: Invalid type nature for generic argument. BYTE is no ANY_NUMBER ┌─ :4:58 │ 4 │ FUNCTION func2 : INT VAR x : BYTE; END_VAR test(x); END_FUNCTION - │ ^ Invalid type nature for generic argument. BYTE is no Num. + │ ^ Invalid type nature for generic argument. BYTE is no ANY_NUMBER -error: Invalid type nature for generic argument. WORD is no Num. +error: Invalid type nature for generic argument. WORD is no ANY_NUMBER ┌─ :5:58 │ 5 │ FUNCTION func3 : INT VAR x : WORD; END_VAR test(x); END_FUNCTION - │ ^ Invalid type nature for generic argument. WORD is no Num. + │ ^ Invalid type nature for generic argument. WORD is no ANY_NUMBER -error: Invalid type nature for generic argument. DWORD is no Num. +error: Invalid type nature for generic argument. DWORD is no ANY_NUMBER ┌─ :6:59 │ 6 │ FUNCTION func4 : INT VAR x : DWORD; END_VAR test(x); END_FUNCTION - │ ^ Invalid type nature for generic argument. DWORD is no Num. + │ ^ Invalid type nature for generic argument. DWORD is no ANY_NUMBER -error: Invalid type nature for generic argument. LWORD is no Num. +error: Invalid type nature for generic argument. LWORD is no ANY_NUMBER ┌─ :7:59 │ 7 │ FUNCTION func5 : INT VAR x : LWORD; END_VAR test(x); END_FUNCTION - │ ^ Invalid type nature for generic argument. LWORD is no Num. + │ ^ Invalid type nature for generic argument. LWORD is no ANY_NUMBER diff --git a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_num_does_not_allow_chars.snap b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_num_does_not_allow_chars.snap index d404a5389b..762e8457ff 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_num_does_not_allow_chars.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_num_does_not_allow_chars.snap @@ -8,11 +8,11 @@ error: Invalid assignment: cannot assign 'CHAR' to 'USINT' 3 │ FUNCTION func1 : INT VAR x : CHAR; END_VAR test(x); END_FUNCTION │ ^ Invalid assignment: cannot assign 'CHAR' to 'USINT' -error: Invalid type nature for generic argument. CHAR is no Num. +error: Invalid type nature for generic argument. CHAR is no ANY_NUMBER ┌─ :3:58 │ 3 │ FUNCTION func1 : INT VAR x : CHAR; END_VAR test(x); END_FUNCTION - │ ^ Invalid type nature for generic argument. CHAR is no Num. + │ ^ Invalid type nature for generic argument. CHAR is no ANY_NUMBER error: Invalid assignment: cannot assign 'WCHAR' to 'USINT' ┌─ :4:59 @@ -20,10 +20,10 @@ error: Invalid assignment: cannot assign 'WCHAR' to 'USINT' 4 │ FUNCTION func2 : INT VAR x : WCHAR; END_VAR test(x); END_FUNCTION │ ^ Invalid assignment: cannot assign 'WCHAR' to 'USINT' -error: Invalid type nature for generic argument. WCHAR is no Num. +error: Invalid type nature for generic argument. WCHAR is no ANY_NUMBER ┌─ :4:59 │ 4 │ FUNCTION func2 : INT VAR x : WCHAR; END_VAR test(x); END_FUNCTION - │ ^ Invalid type nature for generic argument. WCHAR is no Num. + │ ^ Invalid type nature for generic argument. WCHAR is no ANY_NUMBER diff --git a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_num_does_not_allow_date.snap b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_num_does_not_allow_date.snap index f9ac77beea..7624b00a8e 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_num_does_not_allow_date.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_num_does_not_allow_date.snap @@ -2,34 +2,34 @@ source: src/validation/tests/generic_validation_tests.rs expression: "&diagnostics" --- -error: Invalid type nature for generic argument. DATE_AND_TIME is no Num. +error: Invalid type nature for generic argument. DATE_AND_TIME is no ANY_NUMBER ┌─ :3:56 │ 3 │ FUNCTION func1 : INT VAR x : DT; END_VAR test(x); END_FUNCTION - │ ^ Invalid type nature for generic argument. DATE_AND_TIME is no Num. + │ ^ Invalid type nature for generic argument. DATE_AND_TIME is no ANY_NUMBER -error: Invalid type nature for generic argument. DATE_AND_TIME is no Num. +error: Invalid type nature for generic argument. DATE_AND_TIME is no ANY_NUMBER ┌─ :4:57 │ 4 │ FUNCTION func2 : INT VAR x : LDT; END_VAR test(x); END_FUNCTION - │ ^ Invalid type nature for generic argument. DATE_AND_TIME is no Num. + │ ^ Invalid type nature for generic argument. DATE_AND_TIME is no ANY_NUMBER -error: Invalid type nature for generic argument. DATE is no Num. +error: Invalid type nature for generic argument. DATE is no ANY_NUMBER ┌─ :5:58 │ 5 │ FUNCTION func3 : INT VAR x : DATE; END_VAR test(x); END_FUNCTION - │ ^ Invalid type nature for generic argument. DATE is no Num. + │ ^ Invalid type nature for generic argument. DATE is no ANY_NUMBER -error: Invalid type nature for generic argument. TIME_OF_DAY is no Num. +error: Invalid type nature for generic argument. TIME_OF_DAY is no ANY_NUMBER ┌─ :6:57 │ 6 │ FUNCTION func4 : INT VAR x : TOD; END_VAR test(x); END_FUNCTION - │ ^ Invalid type nature for generic argument. TIME_OF_DAY is no Num. + │ ^ Invalid type nature for generic argument. TIME_OF_DAY is no ANY_NUMBER -error: Invalid type nature for generic argument. TIME_OF_DAY is no Num. +error: Invalid type nature for generic argument. TIME_OF_DAY is no ANY_NUMBER ┌─ :7:58 │ 7 │ FUNCTION func5 : INT VAR x : LTOD; END_VAR test(x); END_FUNCTION - │ ^ Invalid type nature for generic argument. TIME_OF_DAY is no Num. + │ ^ Invalid type nature for generic argument. TIME_OF_DAY is no ANY_NUMBER diff --git a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_num_does_not_allow_strings.snap b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_num_does_not_allow_strings.snap index 4ad2e4c6a8..93509773c4 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_num_does_not_allow_strings.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_num_does_not_allow_strings.snap @@ -8,11 +8,11 @@ error: Invalid assignment: cannot assign 'STRING' to 'USINT' 3 │ FUNCTION func1 : INT VAR x : STRING; END_VAR test(x); END_FUNCTION │ ^ Invalid assignment: cannot assign 'STRING' to 'USINT' -error: Invalid type nature for generic argument. STRING is no Num. +error: Invalid type nature for generic argument. STRING is no ANY_NUMBER ┌─ :3:60 │ 3 │ FUNCTION func1 : INT VAR x : STRING; END_VAR test(x); END_FUNCTION - │ ^ Invalid type nature for generic argument. STRING is no Num. + │ ^ Invalid type nature for generic argument. STRING is no ANY_NUMBER error: Invalid assignment: cannot assign 'WSTRING' to 'USINT' ┌─ :4:61 @@ -20,10 +20,10 @@ error: Invalid assignment: cannot assign 'WSTRING' to 'USINT' 4 │ FUNCTION func2 : INT VAR x : WSTRING; END_VAR test(x); END_FUNCTION │ ^ Invalid assignment: cannot assign 'WSTRING' to 'USINT' -error: Invalid type nature for generic argument. WSTRING is no Num. +error: Invalid type nature for generic argument. WSTRING is no ANY_NUMBER ┌─ :4:61 │ 4 │ FUNCTION func2 : INT VAR x : WSTRING; END_VAR test(x); END_FUNCTION - │ ^ Invalid type nature for generic argument. WSTRING is no Num. + │ ^ Invalid type nature for generic argument. WSTRING is no ANY_NUMBER diff --git a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_num_does_not_allow_time.snap b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_num_does_not_allow_time.snap index f51a4020d9..f95fea3ef9 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_num_does_not_allow_time.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_num_does_not_allow_time.snap @@ -2,16 +2,16 @@ source: src/validation/tests/generic_validation_tests.rs expression: "&diagnostics" --- -error: Invalid type nature for generic argument. TIME is no Num. +error: Invalid type nature for generic argument. TIME is no ANY_NUMBER ┌─ :3:58 │ 3 │ FUNCTION func1 : INT VAR x : TIME; END_VAR test(x); END_FUNCTION - │ ^ Invalid type nature for generic argument. TIME is no Num. + │ ^ Invalid type nature for generic argument. TIME is no ANY_NUMBER -error: Invalid type nature for generic argument. TIME is no Num. +error: Invalid type nature for generic argument. TIME is no ANY_NUMBER ┌─ :4:59 │ 4 │ FUNCTION func2 : INT VAR x : LTIME; END_VAR test(x); END_FUNCTION - │ ^ Invalid type nature for generic argument. TIME is no Num. + │ ^ Invalid type nature for generic argument. TIME is no ANY_NUMBER diff --git a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_num_multiple_parameters.snap b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_num_multiple_parameters.snap index 9bbd34a83a..b81d3cd0b0 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_num_multiple_parameters.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_num_multiple_parameters.snap @@ -2,17 +2,17 @@ source: src/validation/tests/generic_validation_tests.rs expression: "&diagnostics" --- -error: Invalid type nature for generic argument. TIME is no Num. +error: Invalid type nature for generic argument. TIME is no ANY_NUMBER ┌─ :15:50 │ 15 │ func(var_real, var_unsigned, var_signed, var_time, var_byte, var_str, var_char, var_date); - │ ^^^^^^^^ Invalid type nature for generic argument. TIME is no Num. + │ ^^^^^^^^ Invalid type nature for generic argument. TIME is no ANY_NUMBER -error: Invalid type nature for generic argument. BYTE is no Num. +error: Invalid type nature for generic argument. BYTE is no ANY_NUMBER ┌─ :15:60 │ 15 │ func(var_real, var_unsigned, var_signed, var_time, var_byte, var_str, var_char, var_date); - │ ^^^^^^^^ Invalid type nature for generic argument. BYTE is no Num. + │ ^^^^^^^^ Invalid type nature for generic argument. BYTE is no ANY_NUMBER error: Invalid assignment: cannot assign 'STRING' to 'REAL' ┌─ :15:70 @@ -20,11 +20,11 @@ error: Invalid assignment: cannot assign 'STRING' to 'REAL' 15 │ func(var_real, var_unsigned, var_signed, var_time, var_byte, var_str, var_char, var_date); │ ^^^^^^^ Invalid assignment: cannot assign 'STRING' to 'REAL' -error: Invalid type nature for generic argument. STRING is no Num. +error: Invalid type nature for generic argument. STRING is no ANY_NUMBER ┌─ :15:70 │ 15 │ func(var_real, var_unsigned, var_signed, var_time, var_byte, var_str, var_char, var_date); - │ ^^^^^^^ Invalid type nature for generic argument. STRING is no Num. + │ ^^^^^^^ Invalid type nature for generic argument. STRING is no ANY_NUMBER error: Invalid assignment: cannot assign 'CHAR' to 'REAL' ┌─ :15:79 @@ -32,16 +32,16 @@ error: Invalid assignment: cannot assign 'CHAR' to 'REAL' 15 │ func(var_real, var_unsigned, var_signed, var_time, var_byte, var_str, var_char, var_date); │ ^^^^^^^^ Invalid assignment: cannot assign 'CHAR' to 'REAL' -error: Invalid type nature for generic argument. CHAR is no Num. +error: Invalid type nature for generic argument. CHAR is no ANY_NUMBER ┌─ :15:79 │ 15 │ func(var_real, var_unsigned, var_signed, var_time, var_byte, var_str, var_char, var_date); - │ ^^^^^^^^ Invalid type nature for generic argument. CHAR is no Num. + │ ^^^^^^^^ Invalid type nature for generic argument. CHAR is no ANY_NUMBER -error: Invalid type nature for generic argument. DATE is no Num. +error: Invalid type nature for generic argument. DATE is no ANY_NUMBER ┌─ :15:89 │ 15 │ func(var_real, var_unsigned, var_signed, var_time, var_byte, var_str, var_char, var_date); - │ ^^^^^^^^ Invalid type nature for generic argument. DATE is no Num. + │ ^^^^^^^^ Invalid type nature for generic argument. DATE is no ANY_NUMBER diff --git a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_real_does_not_allow_bits.snap b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_real_does_not_allow_bits.snap index afb286323d..8afbcb8c2e 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_real_does_not_allow_bits.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_real_does_not_allow_bits.snap @@ -2,34 +2,34 @@ source: src/validation/tests/generic_validation_tests.rs expression: "&diagnostics" --- -error: Invalid type nature for generic argument. BOOL is no Real. +error: Invalid type nature for generic argument. BOOL is no ANY_REAL ┌─ :3:58 │ 3 │ FUNCTION func1 : INT VAR x : BOOL; END_VAR test(x); END_FUNCTION - │ ^ Invalid type nature for generic argument. BOOL is no Real. + │ ^ Invalid type nature for generic argument. BOOL is no ANY_REAL -error: Invalid type nature for generic argument. BYTE is no Real. +error: Invalid type nature for generic argument. BYTE is no ANY_REAL ┌─ :4:58 │ 4 │ FUNCTION func2 : INT VAR x : BYTE; END_VAR test(x); END_FUNCTION - │ ^ Invalid type nature for generic argument. BYTE is no Real. + │ ^ Invalid type nature for generic argument. BYTE is no ANY_REAL -error: Invalid type nature for generic argument. WORD is no Real. +error: Invalid type nature for generic argument. WORD is no ANY_REAL ┌─ :5:58 │ 5 │ FUNCTION func3 : INT VAR x : WORD; END_VAR test(x); END_FUNCTION - │ ^ Invalid type nature for generic argument. WORD is no Real. + │ ^ Invalid type nature for generic argument. WORD is no ANY_REAL -error: Invalid type nature for generic argument. DWORD is no Real. +error: Invalid type nature for generic argument. DWORD is no ANY_REAL ┌─ :6:59 │ 6 │ FUNCTION func4 : INT VAR x : DWORD; END_VAR test(x); END_FUNCTION - │ ^ Invalid type nature for generic argument. DWORD is no Real. + │ ^ Invalid type nature for generic argument. DWORD is no ANY_REAL -error: Invalid type nature for generic argument. LWORD is no Real. +error: Invalid type nature for generic argument. LWORD is no ANY_REAL ┌─ :7:59 │ 7 │ FUNCTION func5 : INT VAR x : LWORD; END_VAR test(x); END_FUNCTION - │ ^ Invalid type nature for generic argument. LWORD is no Real. + │ ^ Invalid type nature for generic argument. LWORD is no ANY_REAL diff --git a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_real_does_not_allow_chars.snap b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_real_does_not_allow_chars.snap index b070f5217e..ecf94dabc5 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_real_does_not_allow_chars.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_real_does_not_allow_chars.snap @@ -8,11 +8,11 @@ error: Invalid assignment: cannot assign 'CHAR' to 'REAL' 3 │ FUNCTION func1 : INT VAR x : CHAR; END_VAR test(x); END_FUNCTION │ ^ Invalid assignment: cannot assign 'CHAR' to 'REAL' -error: Invalid type nature for generic argument. CHAR is no Real. +error: Invalid type nature for generic argument. CHAR is no ANY_REAL ┌─ :3:58 │ 3 │ FUNCTION func1 : INT VAR x : CHAR; END_VAR test(x); END_FUNCTION - │ ^ Invalid type nature for generic argument. CHAR is no Real. + │ ^ Invalid type nature for generic argument. CHAR is no ANY_REAL error: Invalid assignment: cannot assign 'WCHAR' to 'REAL' ┌─ :4:59 @@ -20,10 +20,10 @@ error: Invalid assignment: cannot assign 'WCHAR' to 'REAL' 4 │ FUNCTION func2 : INT VAR x : WCHAR; END_VAR test(x); END_FUNCTION │ ^ Invalid assignment: cannot assign 'WCHAR' to 'REAL' -error: Invalid type nature for generic argument. WCHAR is no Real. +error: Invalid type nature for generic argument. WCHAR is no ANY_REAL ┌─ :4:59 │ 4 │ FUNCTION func2 : INT VAR x : WCHAR; END_VAR test(x); END_FUNCTION - │ ^ Invalid type nature for generic argument. WCHAR is no Real. + │ ^ Invalid type nature for generic argument. WCHAR is no ANY_REAL diff --git a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_real_does_not_allow_date.snap b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_real_does_not_allow_date.snap index 320d5c32e7..a697a166bf 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_real_does_not_allow_date.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_real_does_not_allow_date.snap @@ -2,34 +2,34 @@ source: src/validation/tests/generic_validation_tests.rs expression: "&diagnostics" --- -error: Invalid type nature for generic argument. DATE_AND_TIME is no Real. +error: Invalid type nature for generic argument. DATE_AND_TIME is no ANY_REAL ┌─ :3:56 │ 3 │ FUNCTION func1 : INT VAR x : DT; END_VAR test(x); END_FUNCTION - │ ^ Invalid type nature for generic argument. DATE_AND_TIME is no Real. + │ ^ Invalid type nature for generic argument. DATE_AND_TIME is no ANY_REAL -error: Invalid type nature for generic argument. DATE_AND_TIME is no Real. +error: Invalid type nature for generic argument. DATE_AND_TIME is no ANY_REAL ┌─ :4:57 │ 4 │ FUNCTION func2 : INT VAR x : LDT; END_VAR test(x); END_FUNCTION - │ ^ Invalid type nature for generic argument. DATE_AND_TIME is no Real. + │ ^ Invalid type nature for generic argument. DATE_AND_TIME is no ANY_REAL -error: Invalid type nature for generic argument. DATE is no Real. +error: Invalid type nature for generic argument. DATE is no ANY_REAL ┌─ :5:58 │ 5 │ FUNCTION func3 : INT VAR x : DATE; END_VAR test(x); END_FUNCTION - │ ^ Invalid type nature for generic argument. DATE is no Real. + │ ^ Invalid type nature for generic argument. DATE is no ANY_REAL -error: Invalid type nature for generic argument. TIME_OF_DAY is no Real. +error: Invalid type nature for generic argument. TIME_OF_DAY is no ANY_REAL ┌─ :6:57 │ 6 │ FUNCTION func4 : INT VAR x : TOD; END_VAR test(x); END_FUNCTION - │ ^ Invalid type nature for generic argument. TIME_OF_DAY is no Real. + │ ^ Invalid type nature for generic argument. TIME_OF_DAY is no ANY_REAL -error: Invalid type nature for generic argument. TIME_OF_DAY is no Real. +error: Invalid type nature for generic argument. TIME_OF_DAY is no ANY_REAL ┌─ :7:58 │ 7 │ FUNCTION func5 : INT VAR x : LTOD; END_VAR test(x); END_FUNCTION - │ ^ Invalid type nature for generic argument. TIME_OF_DAY is no Real. + │ ^ Invalid type nature for generic argument. TIME_OF_DAY is no ANY_REAL diff --git a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_real_does_not_allow_string.snap b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_real_does_not_allow_string.snap index 12f605053f..e679954fb4 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_real_does_not_allow_string.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_real_does_not_allow_string.snap @@ -8,11 +8,11 @@ error: Invalid assignment: cannot assign 'STRING' to 'REAL' 3 │ FUNCTION func1 : INT VAR x : STRING; END_VAR test(x); END_FUNCTION │ ^ Invalid assignment: cannot assign 'STRING' to 'REAL' -error: Invalid type nature for generic argument. STRING is no Real. +error: Invalid type nature for generic argument. STRING is no ANY_REAL ┌─ :3:61 │ 3 │ FUNCTION func1 : INT VAR x : STRING; END_VAR test(x); END_FUNCTION - │ ^ Invalid type nature for generic argument. STRING is no Real. + │ ^ Invalid type nature for generic argument. STRING is no ANY_REAL error: Invalid assignment: cannot assign 'WSTRING' to 'REAL' ┌─ :4:61 @@ -20,10 +20,10 @@ error: Invalid assignment: cannot assign 'WSTRING' to 'REAL' 4 │ FUNCTION func2 : INT VAR x : WSTRING; END_VAR test(x); END_FUNCTION │ ^ Invalid assignment: cannot assign 'WSTRING' to 'REAL' -error: Invalid type nature for generic argument. WSTRING is no Real. +error: Invalid type nature for generic argument. WSTRING is no ANY_REAL ┌─ :4:61 │ 4 │ FUNCTION func2 : INT VAR x : WSTRING; END_VAR test(x); END_FUNCTION - │ ^ Invalid type nature for generic argument. WSTRING is no Real. + │ ^ Invalid type nature for generic argument. WSTRING is no ANY_REAL diff --git a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_real_does_not_allow_time.snap b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_real_does_not_allow_time.snap index 1123655367..aa6e9209dc 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_real_does_not_allow_time.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_real_does_not_allow_time.snap @@ -2,16 +2,16 @@ source: src/validation/tests/generic_validation_tests.rs expression: "&diagnostics" --- -error: Invalid type nature for generic argument. TIME is no Real. +error: Invalid type nature for generic argument. TIME is no ANY_REAL ┌─ :3:58 │ 3 │ FUNCTION func1 : INT VAR x : TIME; END_VAR test(x); END_FUNCTION - │ ^ Invalid type nature for generic argument. TIME is no Real. + │ ^ Invalid type nature for generic argument. TIME is no ANY_REAL -error: Invalid type nature for generic argument. TIME is no Real. +error: Invalid type nature for generic argument. TIME is no ANY_REAL ┌─ :4:59 │ 4 │ FUNCTION func2 : INT VAR x : LTIME; END_VAR test(x); END_FUNCTION - │ ^ Invalid type nature for generic argument. TIME is no Real. + │ ^ Invalid type nature for generic argument. TIME is no ANY_REAL diff --git a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_real_multiple_parameters.snap b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_real_multiple_parameters.snap index 9a54a74a17..26514c55f4 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_real_multiple_parameters.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_real_multiple_parameters.snap @@ -2,17 +2,17 @@ source: src/validation/tests/generic_validation_tests.rs expression: "&diagnostics" --- -error: Invalid type nature for generic argument. TIME is no Real. +error: Invalid type nature for generic argument. TIME is no ANY_REAL ┌─ :15:50 │ 15 │ func(var_real, var_unsigned, var_signed, var_time, var_byte, var_str, var_char, var_date); - │ ^^^^^^^^ Invalid type nature for generic argument. TIME is no Real. + │ ^^^^^^^^ Invalid type nature for generic argument. TIME is no ANY_REAL -error: Invalid type nature for generic argument. BYTE is no Real. +error: Invalid type nature for generic argument. BYTE is no ANY_REAL ┌─ :15:60 │ 15 │ func(var_real, var_unsigned, var_signed, var_time, var_byte, var_str, var_char, var_date); - │ ^^^^^^^^ Invalid type nature for generic argument. BYTE is no Real. + │ ^^^^^^^^ Invalid type nature for generic argument. BYTE is no ANY_REAL error: Invalid assignment: cannot assign 'STRING' to 'REAL' ┌─ :15:70 @@ -20,11 +20,11 @@ error: Invalid assignment: cannot assign 'STRING' to 'REAL' 15 │ func(var_real, var_unsigned, var_signed, var_time, var_byte, var_str, var_char, var_date); │ ^^^^^^^ Invalid assignment: cannot assign 'STRING' to 'REAL' -error: Invalid type nature for generic argument. STRING is no Real. +error: Invalid type nature for generic argument. STRING is no ANY_REAL ┌─ :15:70 │ 15 │ func(var_real, var_unsigned, var_signed, var_time, var_byte, var_str, var_char, var_date); - │ ^^^^^^^ Invalid type nature for generic argument. STRING is no Real. + │ ^^^^^^^ Invalid type nature for generic argument. STRING is no ANY_REAL error: Invalid assignment: cannot assign 'CHAR' to 'REAL' ┌─ :15:79 @@ -32,16 +32,16 @@ error: Invalid assignment: cannot assign 'CHAR' to 'REAL' 15 │ func(var_real, var_unsigned, var_signed, var_time, var_byte, var_str, var_char, var_date); │ ^^^^^^^^ Invalid assignment: cannot assign 'CHAR' to 'REAL' -error: Invalid type nature for generic argument. CHAR is no Real. +error: Invalid type nature for generic argument. CHAR is no ANY_REAL ┌─ :15:79 │ 15 │ func(var_real, var_unsigned, var_signed, var_time, var_byte, var_str, var_char, var_date); - │ ^^^^^^^^ Invalid type nature for generic argument. CHAR is no Real. + │ ^^^^^^^^ Invalid type nature for generic argument. CHAR is no ANY_REAL -error: Invalid type nature for generic argument. DATE is no Real. +error: Invalid type nature for generic argument. DATE is no ANY_REAL ┌─ :15:89 │ 15 │ func(var_real, var_unsigned, var_signed, var_time, var_byte, var_str, var_char, var_date); - │ ^^^^^^^^ Invalid type nature for generic argument. DATE is no Real. + │ ^^^^^^^^ Invalid type nature for generic argument. DATE is no ANY_REAL diff --git a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_signed_does_not_allow_bits.snap b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_signed_does_not_allow_bits.snap index bafa2b092c..7518ca75c2 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_signed_does_not_allow_bits.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_signed_does_not_allow_bits.snap @@ -2,34 +2,34 @@ source: src/validation/tests/generic_validation_tests.rs expression: "&diagnostics" --- -error: Invalid type nature for generic argument. BOOL is no Signed. +error: Invalid type nature for generic argument. BOOL is no ANY_SIGNED ┌─ :3:58 │ 3 │ FUNCTION func1 : INT VAR x : BOOL; END_VAR test(x); END_FUNCTION - │ ^ Invalid type nature for generic argument. BOOL is no Signed. + │ ^ Invalid type nature for generic argument. BOOL is no ANY_SIGNED -error: Invalid type nature for generic argument. BYTE is no Signed. +error: Invalid type nature for generic argument. BYTE is no ANY_SIGNED ┌─ :4:58 │ 4 │ FUNCTION func2 : INT VAR x : BYTE; END_VAR test(x); END_FUNCTION - │ ^ Invalid type nature for generic argument. BYTE is no Signed. + │ ^ Invalid type nature for generic argument. BYTE is no ANY_SIGNED -error: Invalid type nature for generic argument. WORD is no Signed. +error: Invalid type nature for generic argument. WORD is no ANY_SIGNED ┌─ :5:58 │ 5 │ FUNCTION func3 : INT VAR x : WORD; END_VAR test(x); END_FUNCTION - │ ^ Invalid type nature for generic argument. WORD is no Signed. + │ ^ Invalid type nature for generic argument. WORD is no ANY_SIGNED -error: Invalid type nature for generic argument. DWORD is no Signed. +error: Invalid type nature for generic argument. DWORD is no ANY_SIGNED ┌─ :6:59 │ 6 │ FUNCTION func4 : INT VAR x : DWORD; END_VAR test(x); END_FUNCTION - │ ^ Invalid type nature for generic argument. DWORD is no Signed. + │ ^ Invalid type nature for generic argument. DWORD is no ANY_SIGNED -error: Invalid type nature for generic argument. LWORD is no Signed. +error: Invalid type nature for generic argument. LWORD is no ANY_SIGNED ┌─ :7:59 │ 7 │ FUNCTION func5 : INT VAR x : LWORD; END_VAR test(x); END_FUNCTION - │ ^ Invalid type nature for generic argument. LWORD is no Signed. + │ ^ Invalid type nature for generic argument. LWORD is no ANY_SIGNED diff --git a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_signed_does_not_allow_chars.snap b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_signed_does_not_allow_chars.snap index 89736a966c..72fb259228 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_signed_does_not_allow_chars.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_signed_does_not_allow_chars.snap @@ -8,11 +8,11 @@ error: Invalid assignment: cannot assign 'CHAR' to 'SINT' 3 │ FUNCTION func1 : INT VAR x : CHAR; END_VAR test(x); END_FUNCTION │ ^ Invalid assignment: cannot assign 'CHAR' to 'SINT' -error: Invalid type nature for generic argument. CHAR is no Signed. +error: Invalid type nature for generic argument. CHAR is no ANY_SIGNED ┌─ :3:58 │ 3 │ FUNCTION func1 : INT VAR x : CHAR; END_VAR test(x); END_FUNCTION - │ ^ Invalid type nature for generic argument. CHAR is no Signed. + │ ^ Invalid type nature for generic argument. CHAR is no ANY_SIGNED error: Invalid assignment: cannot assign 'WCHAR' to 'SINT' ┌─ :4:59 @@ -20,10 +20,10 @@ error: Invalid assignment: cannot assign 'WCHAR' to 'SINT' 4 │ FUNCTION func2 : INT VAR x : WCHAR; END_VAR test(x); END_FUNCTION │ ^ Invalid assignment: cannot assign 'WCHAR' to 'SINT' -error: Invalid type nature for generic argument. WCHAR is no Signed. +error: Invalid type nature for generic argument. WCHAR is no ANY_SIGNED ┌─ :4:59 │ 4 │ FUNCTION func2 : INT VAR x : WCHAR; END_VAR test(x); END_FUNCTION - │ ^ Invalid type nature for generic argument. WCHAR is no Signed. + │ ^ Invalid type nature for generic argument. WCHAR is no ANY_SIGNED diff --git a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_signed_does_not_allow_date.snap b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_signed_does_not_allow_date.snap index a42147a337..7c686f0232 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_signed_does_not_allow_date.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_signed_does_not_allow_date.snap @@ -2,34 +2,34 @@ source: src/validation/tests/generic_validation_tests.rs expression: "&diagnostics" --- -error: Invalid type nature for generic argument. DATE_AND_TIME is no Signed. +error: Invalid type nature for generic argument. DATE_AND_TIME is no ANY_SIGNED ┌─ :3:56 │ 3 │ FUNCTION func1 : INT VAR x : DT; END_VAR test(x); END_FUNCTION - │ ^ Invalid type nature for generic argument. DATE_AND_TIME is no Signed. + │ ^ Invalid type nature for generic argument. DATE_AND_TIME is no ANY_SIGNED -error: Invalid type nature for generic argument. DATE_AND_TIME is no Signed. +error: Invalid type nature for generic argument. DATE_AND_TIME is no ANY_SIGNED ┌─ :4:57 │ 4 │ FUNCTION func2 : INT VAR x : LDT; END_VAR test(x); END_FUNCTION - │ ^ Invalid type nature for generic argument. DATE_AND_TIME is no Signed. + │ ^ Invalid type nature for generic argument. DATE_AND_TIME is no ANY_SIGNED -error: Invalid type nature for generic argument. DATE is no Signed. +error: Invalid type nature for generic argument. DATE is no ANY_SIGNED ┌─ :5:58 │ 5 │ FUNCTION func3 : INT VAR x : DATE; END_VAR test(x); END_FUNCTION - │ ^ Invalid type nature for generic argument. DATE is no Signed. + │ ^ Invalid type nature for generic argument. DATE is no ANY_SIGNED -error: Invalid type nature for generic argument. TIME_OF_DAY is no Signed. +error: Invalid type nature for generic argument. TIME_OF_DAY is no ANY_SIGNED ┌─ :6:57 │ 6 │ FUNCTION func4 : INT VAR x : TOD; END_VAR test(x); END_FUNCTION - │ ^ Invalid type nature for generic argument. TIME_OF_DAY is no Signed. + │ ^ Invalid type nature for generic argument. TIME_OF_DAY is no ANY_SIGNED -error: Invalid type nature for generic argument. TIME_OF_DAY is no Signed. +error: Invalid type nature for generic argument. TIME_OF_DAY is no ANY_SIGNED ┌─ :7:58 │ 7 │ FUNCTION func5 : INT VAR x : LTOD; END_VAR test(x); END_FUNCTION - │ ^ Invalid type nature for generic argument. TIME_OF_DAY is no Signed. + │ ^ Invalid type nature for generic argument. TIME_OF_DAY is no ANY_SIGNED diff --git a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_signed_does_not_allow_reals.snap b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_signed_does_not_allow_reals.snap index a2451a885d..1a02983d31 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_signed_does_not_allow_reals.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_signed_does_not_allow_reals.snap @@ -2,16 +2,16 @@ source: src/validation/tests/generic_validation_tests.rs expression: "&diagnostics" --- -error: Invalid type nature for generic argument. REAL is no Signed. +error: Invalid type nature for generic argument. REAL is no ANY_SIGNED ┌─ :3:57 │ 3 │ FUNCTION func : INT VAR x : REAL; END_VAR test(x); END_FUNCTION - │ ^ Invalid type nature for generic argument. REAL is no Signed. + │ ^ Invalid type nature for generic argument. REAL is no ANY_SIGNED -error: Invalid type nature for generic argument. LREAL is no Signed. +error: Invalid type nature for generic argument. LREAL is no ANY_SIGNED ┌─ :4:59 │ 4 │ FUNCTION func1 : INT VAR x : LREAL; END_VAR test(x); END_FUNCTION - │ ^ Invalid type nature for generic argument. LREAL is no Signed. + │ ^ Invalid type nature for generic argument. LREAL is no ANY_SIGNED diff --git a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_signed_does_not_allow_string.snap b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_signed_does_not_allow_string.snap index 6792f138d2..3bbf12d6a6 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_signed_does_not_allow_string.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_signed_does_not_allow_string.snap @@ -8,11 +8,11 @@ error: Invalid assignment: cannot assign 'STRING' to 'SINT' 3 │ FUNCTION func1 : INT VAR x : STRING; END_VAR test(x); END_FUNCTION │ ^ Invalid assignment: cannot assign 'STRING' to 'SINT' -error: Invalid type nature for generic argument. STRING is no Signed. +error: Invalid type nature for generic argument. STRING is no ANY_SIGNED ┌─ :3:61 │ 3 │ FUNCTION func1 : INT VAR x : STRING; END_VAR test(x); END_FUNCTION - │ ^ Invalid type nature for generic argument. STRING is no Signed. + │ ^ Invalid type nature for generic argument. STRING is no ANY_SIGNED error: Invalid assignment: cannot assign 'WSTRING' to 'SINT' ┌─ :4:61 @@ -20,10 +20,10 @@ error: Invalid assignment: cannot assign 'WSTRING' to 'SINT' 4 │ FUNCTION func2 : INT VAR x : WSTRING; END_VAR test(x); END_FUNCTION │ ^ Invalid assignment: cannot assign 'WSTRING' to 'SINT' -error: Invalid type nature for generic argument. WSTRING is no Signed. +error: Invalid type nature for generic argument. WSTRING is no ANY_SIGNED ┌─ :4:61 │ 4 │ FUNCTION func2 : INT VAR x : WSTRING; END_VAR test(x); END_FUNCTION - │ ^ Invalid type nature for generic argument. WSTRING is no Signed. + │ ^ Invalid type nature for generic argument. WSTRING is no ANY_SIGNED diff --git a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_signed_does_not_allow_time.snap b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_signed_does_not_allow_time.snap index 2bc83b9ec4..5450e7b5da 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_signed_does_not_allow_time.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_signed_does_not_allow_time.snap @@ -2,16 +2,16 @@ source: src/validation/tests/generic_validation_tests.rs expression: "&diagnostics" --- -error: Invalid type nature for generic argument. TIME is no Signed. +error: Invalid type nature for generic argument. TIME is no ANY_SIGNED ┌─ :3:58 │ 3 │ FUNCTION func1 : INT VAR x : TIME; END_VAR test(x); END_FUNCTION - │ ^ Invalid type nature for generic argument. TIME is no Signed. + │ ^ Invalid type nature for generic argument. TIME is no ANY_SIGNED -error: Invalid type nature for generic argument. TIME is no Signed. +error: Invalid type nature for generic argument. TIME is no ANY_SIGNED ┌─ :4:59 │ 4 │ FUNCTION func2 : INT VAR x : LTIME; END_VAR test(x); END_FUNCTION - │ ^ Invalid type nature for generic argument. TIME is no Signed. + │ ^ Invalid type nature for generic argument. TIME is no ANY_SIGNED diff --git a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_signed_does_not_allow_unsigned_ints.snap b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_signed_does_not_allow_unsigned_ints.snap index 0575ab186d..a4c4b30997 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_signed_does_not_allow_unsigned_ints.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_signed_does_not_allow_unsigned_ints.snap @@ -2,28 +2,28 @@ source: src/validation/tests/generic_validation_tests.rs expression: "&diagnostics" --- -error: Invalid type nature for generic argument. USINT is no Signed. +error: Invalid type nature for generic argument. USINT is no ANY_SIGNED ┌─ :3:59 │ 3 │ FUNCTION func1 : INT VAR x : USINT; END_VAR test(x); END_FUNCTION - │ ^ Invalid type nature for generic argument. USINT is no Signed. + │ ^ Invalid type nature for generic argument. USINT is no ANY_SIGNED -error: Invalid type nature for generic argument. UINT is no Signed. +error: Invalid type nature for generic argument. UINT is no ANY_SIGNED ┌─ :4:58 │ 4 │ FUNCTION func2 : INT VAR x : UINT; END_VAR test(x); END_FUNCTION - │ ^ Invalid type nature for generic argument. UINT is no Signed. + │ ^ Invalid type nature for generic argument. UINT is no ANY_SIGNED -error: Invalid type nature for generic argument. UDINT is no Signed. +error: Invalid type nature for generic argument. UDINT is no ANY_SIGNED ┌─ :5:59 │ 5 │ FUNCTION func3 : INT VAR x : UDINT; END_VAR test(x); END_FUNCTION - │ ^ Invalid type nature for generic argument. UDINT is no Signed. + │ ^ Invalid type nature for generic argument. UDINT is no ANY_SIGNED -error: Invalid type nature for generic argument. ULINT is no Signed. +error: Invalid type nature for generic argument. ULINT is no ANY_SIGNED ┌─ :6:59 │ 6 │ FUNCTION func4 : INT VAR x : ULINT; END_VAR test(x); END_FUNCTION - │ ^ Invalid type nature for generic argument. ULINT is no Signed. + │ ^ Invalid type nature for generic argument. ULINT is no ANY_SIGNED diff --git a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_signed_multiple_parameters.snap b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_signed_multiple_parameters.snap index 59c8109954..ef01b27c8e 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_signed_multiple_parameters.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_signed_multiple_parameters.snap @@ -2,29 +2,29 @@ source: src/validation/tests/generic_validation_tests.rs expression: "&diagnostics" --- -error: Invalid type nature for generic argument. REAL is no Signed. +error: Invalid type nature for generic argument. REAL is no ANY_SIGNED ┌─ :15:14 │ 15 │ func(var_real, var_unsigned, var_signed, var_time, var_byte, var_str, var_char, var_date); - │ ^^^^^^^^ Invalid type nature for generic argument. REAL is no Signed. + │ ^^^^^^^^ Invalid type nature for generic argument. REAL is no ANY_SIGNED -error: Invalid type nature for generic argument. UDINT is no Signed. +error: Invalid type nature for generic argument. UDINT is no ANY_SIGNED ┌─ :15:24 │ 15 │ func(var_real, var_unsigned, var_signed, var_time, var_byte, var_str, var_char, var_date); - │ ^^^^^^^^^^^^ Invalid type nature for generic argument. UDINT is no Signed. + │ ^^^^^^^^^^^^ Invalid type nature for generic argument. UDINT is no ANY_SIGNED -error: Invalid type nature for generic argument. TIME is no Signed. +error: Invalid type nature for generic argument. TIME is no ANY_SIGNED ┌─ :15:50 │ 15 │ func(var_real, var_unsigned, var_signed, var_time, var_byte, var_str, var_char, var_date); - │ ^^^^^^^^ Invalid type nature for generic argument. TIME is no Signed. + │ ^^^^^^^^ Invalid type nature for generic argument. TIME is no ANY_SIGNED -error: Invalid type nature for generic argument. BYTE is no Signed. +error: Invalid type nature for generic argument. BYTE is no ANY_SIGNED ┌─ :15:60 │ 15 │ func(var_real, var_unsigned, var_signed, var_time, var_byte, var_str, var_char, var_date); - │ ^^^^^^^^ Invalid type nature for generic argument. BYTE is no Signed. + │ ^^^^^^^^ Invalid type nature for generic argument. BYTE is no ANY_SIGNED error: Invalid assignment: cannot assign 'STRING' to 'DINT' ┌─ :15:70 @@ -32,11 +32,11 @@ error: Invalid assignment: cannot assign 'STRING' to 'DINT' 15 │ func(var_real, var_unsigned, var_signed, var_time, var_byte, var_str, var_char, var_date); │ ^^^^^^^ Invalid assignment: cannot assign 'STRING' to 'DINT' -error: Invalid type nature for generic argument. STRING is no Signed. +error: Invalid type nature for generic argument. STRING is no ANY_SIGNED ┌─ :15:70 │ 15 │ func(var_real, var_unsigned, var_signed, var_time, var_byte, var_str, var_char, var_date); - │ ^^^^^^^ Invalid type nature for generic argument. STRING is no Signed. + │ ^^^^^^^ Invalid type nature for generic argument. STRING is no ANY_SIGNED error: Invalid assignment: cannot assign 'CHAR' to 'DINT' ┌─ :15:79 @@ -44,16 +44,16 @@ error: Invalid assignment: cannot assign 'CHAR' to 'DINT' 15 │ func(var_real, var_unsigned, var_signed, var_time, var_byte, var_str, var_char, var_date); │ ^^^^^^^^ Invalid assignment: cannot assign 'CHAR' to 'DINT' -error: Invalid type nature for generic argument. CHAR is no Signed. +error: Invalid type nature for generic argument. CHAR is no ANY_SIGNED ┌─ :15:79 │ 15 │ func(var_real, var_unsigned, var_signed, var_time, var_byte, var_str, var_char, var_date); - │ ^^^^^^^^ Invalid type nature for generic argument. CHAR is no Signed. + │ ^^^^^^^^ Invalid type nature for generic argument. CHAR is no ANY_SIGNED -error: Invalid type nature for generic argument. DATE is no Signed. +error: Invalid type nature for generic argument. DATE is no ANY_SIGNED ┌─ :15:89 │ 15 │ func(var_real, var_unsigned, var_signed, var_time, var_byte, var_str, var_char, var_date); - │ ^^^^^^^^ Invalid type nature for generic argument. DATE is no Signed. + │ ^^^^^^^^ Invalid type nature for generic argument. DATE is no ANY_SIGNED diff --git a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_string_does_not_allow_bits.snap b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_string_does_not_allow_bits.snap index a5fa4cc826..f02cb9d092 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_string_does_not_allow_bits.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_string_does_not_allow_bits.snap @@ -8,11 +8,11 @@ error: Invalid assignment: cannot assign 'BOOL' to 'STRING' 3 │ FUNCTION func1 : INT VAR x : BOOL; END_VAR test(x); END_FUNCTION │ ^ Invalid assignment: cannot assign 'BOOL' to 'STRING' -error: Invalid type nature for generic argument. BOOL is no String. +error: Invalid type nature for generic argument. BOOL is no ANY_STRING ┌─ :3:58 │ 3 │ FUNCTION func1 : INT VAR x : BOOL; END_VAR test(x); END_FUNCTION - │ ^ Invalid type nature for generic argument. BOOL is no String. + │ ^ Invalid type nature for generic argument. BOOL is no ANY_STRING error: Invalid assignment: cannot assign 'BYTE' to 'STRING' ┌─ :4:58 @@ -20,11 +20,11 @@ error: Invalid assignment: cannot assign 'BYTE' to 'STRING' 4 │ FUNCTION func2 : INT VAR x : BYTE; END_VAR test(x); END_FUNCTION │ ^ Invalid assignment: cannot assign 'BYTE' to 'STRING' -error: Invalid type nature for generic argument. BYTE is no String. +error: Invalid type nature for generic argument. BYTE is no ANY_STRING ┌─ :4:58 │ 4 │ FUNCTION func2 : INT VAR x : BYTE; END_VAR test(x); END_FUNCTION - │ ^ Invalid type nature for generic argument. BYTE is no String. + │ ^ Invalid type nature for generic argument. BYTE is no ANY_STRING error: Invalid assignment: cannot assign 'WORD' to 'STRING' ┌─ :5:58 @@ -32,11 +32,11 @@ error: Invalid assignment: cannot assign 'WORD' to 'STRING' 5 │ FUNCTION func3 : INT VAR x : WORD; END_VAR test(x); END_FUNCTION │ ^ Invalid assignment: cannot assign 'WORD' to 'STRING' -error: Invalid type nature for generic argument. WORD is no String. +error: Invalid type nature for generic argument. WORD is no ANY_STRING ┌─ :5:58 │ 5 │ FUNCTION func3 : INT VAR x : WORD; END_VAR test(x); END_FUNCTION - │ ^ Invalid type nature for generic argument. WORD is no String. + │ ^ Invalid type nature for generic argument. WORD is no ANY_STRING error: Invalid assignment: cannot assign 'DWORD' to 'STRING' ┌─ :6:59 @@ -44,11 +44,11 @@ error: Invalid assignment: cannot assign 'DWORD' to 'STRING' 6 │ FUNCTION func4 : INT VAR x : DWORD; END_VAR test(x); END_FUNCTION │ ^ Invalid assignment: cannot assign 'DWORD' to 'STRING' -error: Invalid type nature for generic argument. DWORD is no String. +error: Invalid type nature for generic argument. DWORD is no ANY_STRING ┌─ :6:59 │ 6 │ FUNCTION func4 : INT VAR x : DWORD; END_VAR test(x); END_FUNCTION - │ ^ Invalid type nature for generic argument. DWORD is no String. + │ ^ Invalid type nature for generic argument. DWORD is no ANY_STRING error: Invalid assignment: cannot assign 'LWORD' to 'STRING' ┌─ :7:59 @@ -56,10 +56,10 @@ error: Invalid assignment: cannot assign 'LWORD' to 'STRING' 7 │ FUNCTION func5 : INT VAR x : LWORD; END_VAR test(x); END_FUNCTION │ ^ Invalid assignment: cannot assign 'LWORD' to 'STRING' -error: Invalid type nature for generic argument. LWORD is no String. +error: Invalid type nature for generic argument. LWORD is no ANY_STRING ┌─ :7:59 │ 7 │ FUNCTION func5 : INT VAR x : LWORD; END_VAR test(x); END_FUNCTION - │ ^ Invalid type nature for generic argument. LWORD is no String. + │ ^ Invalid type nature for generic argument. LWORD is no ANY_STRING diff --git a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_string_does_not_allow_chars.snap b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_string_does_not_allow_chars.snap index 9ea8bfc1de..c554f873b3 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_string_does_not_allow_chars.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_string_does_not_allow_chars.snap @@ -8,11 +8,11 @@ error: Invalid assignment: cannot assign 'CHAR' to 'STRING' 3 │ FUNCTION func1 : INT VAR x : CHAR; END_VAR test(x); END_FUNCTION │ ^ Invalid assignment: cannot assign 'CHAR' to 'STRING' -error: Invalid type nature for generic argument. CHAR is no String. +error: Invalid type nature for generic argument. CHAR is no ANY_STRING ┌─ :3:58 │ 3 │ FUNCTION func1 : INT VAR x : CHAR; END_VAR test(x); END_FUNCTION - │ ^ Invalid type nature for generic argument. CHAR is no String. + │ ^ Invalid type nature for generic argument. CHAR is no ANY_STRING error: Invalid assignment: cannot assign 'WCHAR' to 'STRING' ┌─ :4:59 @@ -20,10 +20,10 @@ error: Invalid assignment: cannot assign 'WCHAR' to 'STRING' 4 │ FUNCTION func2 : INT VAR x : WCHAR; END_VAR test(x); END_FUNCTION │ ^ Invalid assignment: cannot assign 'WCHAR' to 'STRING' -error: Invalid type nature for generic argument. WCHAR is no String. +error: Invalid type nature for generic argument. WCHAR is no ANY_STRING ┌─ :4:59 │ 4 │ FUNCTION func2 : INT VAR x : WCHAR; END_VAR test(x); END_FUNCTION - │ ^ Invalid type nature for generic argument. WCHAR is no String. + │ ^ Invalid type nature for generic argument. WCHAR is no ANY_STRING diff --git a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_string_does_not_allow_date.snap b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_string_does_not_allow_date.snap index f9a298da7b..c5a9e23f19 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_string_does_not_allow_date.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_string_does_not_allow_date.snap @@ -8,11 +8,11 @@ error: Invalid assignment: cannot assign 'DATE_AND_TIME' to 'STRING' 3 │ FUNCTION func1 : INT VAR x : DT; END_VAR test(x); END_FUNCTION │ ^ Invalid assignment: cannot assign 'DATE_AND_TIME' to 'STRING' -error: Invalid type nature for generic argument. DATE_AND_TIME is no String. +error: Invalid type nature for generic argument. DATE_AND_TIME is no ANY_STRING ┌─ :3:56 │ 3 │ FUNCTION func1 : INT VAR x : DT; END_VAR test(x); END_FUNCTION - │ ^ Invalid type nature for generic argument. DATE_AND_TIME is no String. + │ ^ Invalid type nature for generic argument. DATE_AND_TIME is no ANY_STRING error: Invalid assignment: cannot assign 'DATE_AND_TIME' to 'STRING' ┌─ :4:57 @@ -20,11 +20,11 @@ error: Invalid assignment: cannot assign 'DATE_AND_TIME' to 'STRING' 4 │ FUNCTION func2 : INT VAR x : LDT; END_VAR test(x); END_FUNCTION │ ^ Invalid assignment: cannot assign 'DATE_AND_TIME' to 'STRING' -error: Invalid type nature for generic argument. DATE_AND_TIME is no String. +error: Invalid type nature for generic argument. DATE_AND_TIME is no ANY_STRING ┌─ :4:57 │ 4 │ FUNCTION func2 : INT VAR x : LDT; END_VAR test(x); END_FUNCTION - │ ^ Invalid type nature for generic argument. DATE_AND_TIME is no String. + │ ^ Invalid type nature for generic argument. DATE_AND_TIME is no ANY_STRING error: Invalid assignment: cannot assign 'DATE' to 'STRING' ┌─ :5:58 @@ -32,11 +32,11 @@ error: Invalid assignment: cannot assign 'DATE' to 'STRING' 5 │ FUNCTION func3 : INT VAR x : DATE; END_VAR test(x); END_FUNCTION │ ^ Invalid assignment: cannot assign 'DATE' to 'STRING' -error: Invalid type nature for generic argument. DATE is no String. +error: Invalid type nature for generic argument. DATE is no ANY_STRING ┌─ :5:58 │ 5 │ FUNCTION func3 : INT VAR x : DATE; END_VAR test(x); END_FUNCTION - │ ^ Invalid type nature for generic argument. DATE is no String. + │ ^ Invalid type nature for generic argument. DATE is no ANY_STRING error: Invalid assignment: cannot assign 'TIME_OF_DAY' to 'STRING' ┌─ :6:57 @@ -44,11 +44,11 @@ error: Invalid assignment: cannot assign 'TIME_OF_DAY' to 'STRING' 6 │ FUNCTION func4 : INT VAR x : TOD; END_VAR test(x); END_FUNCTION │ ^ Invalid assignment: cannot assign 'TIME_OF_DAY' to 'STRING' -error: Invalid type nature for generic argument. TIME_OF_DAY is no String. +error: Invalid type nature for generic argument. TIME_OF_DAY is no ANY_STRING ┌─ :6:57 │ 6 │ FUNCTION func4 : INT VAR x : TOD; END_VAR test(x); END_FUNCTION - │ ^ Invalid type nature for generic argument. TIME_OF_DAY is no String. + │ ^ Invalid type nature for generic argument. TIME_OF_DAY is no ANY_STRING error: Invalid assignment: cannot assign 'TIME_OF_DAY' to 'STRING' ┌─ :7:58 @@ -56,10 +56,10 @@ error: Invalid assignment: cannot assign 'TIME_OF_DAY' to 'STRING' 7 │ FUNCTION func5 : INT VAR x : LTOD; END_VAR test(x); END_FUNCTION │ ^ Invalid assignment: cannot assign 'TIME_OF_DAY' to 'STRING' -error: Invalid type nature for generic argument. TIME_OF_DAY is no String. +error: Invalid type nature for generic argument. TIME_OF_DAY is no ANY_STRING ┌─ :7:58 │ 7 │ FUNCTION func5 : INT VAR x : LTOD; END_VAR test(x); END_FUNCTION - │ ^ Invalid type nature for generic argument. TIME_OF_DAY is no String. + │ ^ Invalid type nature for generic argument. TIME_OF_DAY is no ANY_STRING diff --git a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_string_does_not_allow_ints.snap b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_string_does_not_allow_ints.snap index 99cf46a912..a1b3699ca5 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_string_does_not_allow_ints.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_string_does_not_allow_ints.snap @@ -8,11 +8,11 @@ error: Invalid assignment: cannot assign 'USINT' to 'STRING' 4 │ FUNCTION func1 : INT VAR x : USINT; END_VAR test(x); END_FUNCTION │ ^ Invalid assignment: cannot assign 'USINT' to 'STRING' -error: Invalid type nature for generic argument. USINT is no String. +error: Invalid type nature for generic argument. USINT is no ANY_STRING ┌─ :4:59 │ 4 │ FUNCTION func1 : INT VAR x : USINT; END_VAR test(x); END_FUNCTION - │ ^ Invalid type nature for generic argument. USINT is no String. + │ ^ Invalid type nature for generic argument. USINT is no ANY_STRING error: Invalid assignment: cannot assign 'UINT' to 'STRING' ┌─ :5:58 @@ -20,11 +20,11 @@ error: Invalid assignment: cannot assign 'UINT' to 'STRING' 5 │ FUNCTION func2 : INT VAR x : UINT; END_VAR test(x); END_FUNCTION │ ^ Invalid assignment: cannot assign 'UINT' to 'STRING' -error: Invalid type nature for generic argument. UINT is no String. +error: Invalid type nature for generic argument. UINT is no ANY_STRING ┌─ :5:58 │ 5 │ FUNCTION func2 : INT VAR x : UINT; END_VAR test(x); END_FUNCTION - │ ^ Invalid type nature for generic argument. UINT is no String. + │ ^ Invalid type nature for generic argument. UINT is no ANY_STRING error: Invalid assignment: cannot assign 'UDINT' to 'STRING' ┌─ :6:59 @@ -32,11 +32,11 @@ error: Invalid assignment: cannot assign 'UDINT' to 'STRING' 6 │ FUNCTION func3 : INT VAR x : UDINT; END_VAR test(x); END_FUNCTION │ ^ Invalid assignment: cannot assign 'UDINT' to 'STRING' -error: Invalid type nature for generic argument. UDINT is no String. +error: Invalid type nature for generic argument. UDINT is no ANY_STRING ┌─ :6:59 │ 6 │ FUNCTION func3 : INT VAR x : UDINT; END_VAR test(x); END_FUNCTION - │ ^ Invalid type nature for generic argument. UDINT is no String. + │ ^ Invalid type nature for generic argument. UDINT is no ANY_STRING error: Invalid assignment: cannot assign 'ULINT' to 'STRING' ┌─ :7:59 @@ -44,11 +44,11 @@ error: Invalid assignment: cannot assign 'ULINT' to 'STRING' 7 │ FUNCTION func4 : INT VAR x : ULINT; END_VAR test(x); END_FUNCTION │ ^ Invalid assignment: cannot assign 'ULINT' to 'STRING' -error: Invalid type nature for generic argument. ULINT is no String. +error: Invalid type nature for generic argument. ULINT is no ANY_STRING ┌─ :7:59 │ 7 │ FUNCTION func4 : INT VAR x : ULINT; END_VAR test(x); END_FUNCTION - │ ^ Invalid type nature for generic argument. ULINT is no String. + │ ^ Invalid type nature for generic argument. ULINT is no ANY_STRING error: Invalid assignment: cannot assign 'SINT' to 'STRING' ┌─ :9:58 @@ -56,11 +56,11 @@ error: Invalid assignment: cannot assign 'SINT' to 'STRING' 9 │ FUNCTION func5 : INT VAR x : SINT; END_VAR test(x); END_FUNCTION │ ^ Invalid assignment: cannot assign 'SINT' to 'STRING' -error: Invalid type nature for generic argument. SINT is no String. +error: Invalid type nature for generic argument. SINT is no ANY_STRING ┌─ :9:58 │ 9 │ FUNCTION func5 : INT VAR x : SINT; END_VAR test(x); END_FUNCTION - │ ^ Invalid type nature for generic argument. SINT is no String. + │ ^ Invalid type nature for generic argument. SINT is no ANY_STRING error: Invalid assignment: cannot assign 'INT' to 'STRING' ┌─ :10:57 @@ -68,11 +68,11 @@ error: Invalid assignment: cannot assign 'INT' to 'STRING' 10 │ FUNCTION func6 : INT VAR x : INT; END_VAR test(x); END_FUNCTION │ ^ Invalid assignment: cannot assign 'INT' to 'STRING' -error: Invalid type nature for generic argument. INT is no String. +error: Invalid type nature for generic argument. INT is no ANY_STRING ┌─ :10:57 │ 10 │ FUNCTION func6 : INT VAR x : INT; END_VAR test(x); END_FUNCTION - │ ^ Invalid type nature for generic argument. INT is no String. + │ ^ Invalid type nature for generic argument. INT is no ANY_STRING error: Invalid assignment: cannot assign 'DINT' to 'STRING' ┌─ :11:58 @@ -80,11 +80,11 @@ error: Invalid assignment: cannot assign 'DINT' to 'STRING' 11 │ FUNCTION func7 : INT VAR x : DINT; END_VAR test(x); END_FUNCTION │ ^ Invalid assignment: cannot assign 'DINT' to 'STRING' -error: Invalid type nature for generic argument. DINT is no String. +error: Invalid type nature for generic argument. DINT is no ANY_STRING ┌─ :11:58 │ 11 │ FUNCTION func7 : INT VAR x : DINT; END_VAR test(x); END_FUNCTION - │ ^ Invalid type nature for generic argument. DINT is no String. + │ ^ Invalid type nature for generic argument. DINT is no ANY_STRING error: Invalid assignment: cannot assign 'LINT' to 'STRING' ┌─ :12:58 @@ -92,10 +92,10 @@ error: Invalid assignment: cannot assign 'LINT' to 'STRING' 12 │ FUNCTION func8 : INT VAR x : LINT; END_VAR test(x); END_FUNCTION │ ^ Invalid assignment: cannot assign 'LINT' to 'STRING' -error: Invalid type nature for generic argument. LINT is no String. +error: Invalid type nature for generic argument. LINT is no ANY_STRING ┌─ :12:58 │ 12 │ FUNCTION func8 : INT VAR x : LINT; END_VAR test(x); END_FUNCTION - │ ^ Invalid type nature for generic argument. LINT is no String. + │ ^ Invalid type nature for generic argument. LINT is no ANY_STRING diff --git a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_string_does_not_allow_reals.snap b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_string_does_not_allow_reals.snap index a6984ba6e8..7c6524d1e9 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_string_does_not_allow_reals.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_string_does_not_allow_reals.snap @@ -8,11 +8,11 @@ error: Invalid assignment: cannot assign 'REAL' to 'STRING' 3 │ FUNCTION func : INT VAR x : REAL; END_VAR test(x); END_FUNCTION │ ^ Invalid assignment: cannot assign 'REAL' to 'STRING' -error: Invalid type nature for generic argument. REAL is no String. +error: Invalid type nature for generic argument. REAL is no ANY_STRING ┌─ :3:57 │ 3 │ FUNCTION func : INT VAR x : REAL; END_VAR test(x); END_FUNCTION - │ ^ Invalid type nature for generic argument. REAL is no String. + │ ^ Invalid type nature for generic argument. REAL is no ANY_STRING error: Invalid assignment: cannot assign 'LREAL' to 'STRING' ┌─ :4:59 @@ -20,10 +20,10 @@ error: Invalid assignment: cannot assign 'LREAL' to 'STRING' 4 │ FUNCTION func1 : INT VAR x : LREAL; END_VAR test(x); END_FUNCTION │ ^ Invalid assignment: cannot assign 'LREAL' to 'STRING' -error: Invalid type nature for generic argument. LREAL is no String. +error: Invalid type nature for generic argument. LREAL is no ANY_STRING ┌─ :4:59 │ 4 │ FUNCTION func1 : INT VAR x : LREAL; END_VAR test(x); END_FUNCTION - │ ^ Invalid type nature for generic argument. LREAL is no String. + │ ^ Invalid type nature for generic argument. LREAL is no ANY_STRING diff --git a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_string_does_not_allow_time.snap b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_string_does_not_allow_time.snap index 1189636e09..4584777d73 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_string_does_not_allow_time.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_string_does_not_allow_time.snap @@ -8,11 +8,11 @@ error: Invalid assignment: cannot assign 'TIME' to 'STRING' 3 │ FUNCTION func1 : INT VAR x : TIME; END_VAR test(x); END_FUNCTION │ ^ Invalid assignment: cannot assign 'TIME' to 'STRING' -error: Invalid type nature for generic argument. TIME is no String. +error: Invalid type nature for generic argument. TIME is no ANY_STRING ┌─ :3:58 │ 3 │ FUNCTION func1 : INT VAR x : TIME; END_VAR test(x); END_FUNCTION - │ ^ Invalid type nature for generic argument. TIME is no String. + │ ^ Invalid type nature for generic argument. TIME is no ANY_STRING error: Invalid assignment: cannot assign 'TIME' to 'STRING' ┌─ :4:59 @@ -20,10 +20,10 @@ error: Invalid assignment: cannot assign 'TIME' to 'STRING' 4 │ FUNCTION func2 : INT VAR x : LTIME; END_VAR test(x); END_FUNCTION │ ^ Invalid assignment: cannot assign 'TIME' to 'STRING' -error: Invalid type nature for generic argument. TIME is no String. +error: Invalid type nature for generic argument. TIME is no ANY_STRING ┌─ :4:59 │ 4 │ FUNCTION func2 : INT VAR x : LTIME; END_VAR test(x); END_FUNCTION - │ ^ Invalid type nature for generic argument. TIME is no String. + │ ^ Invalid type nature for generic argument. TIME is no ANY_STRING diff --git a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_string_multiple_parameters.snap b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_string_multiple_parameters.snap index 7d29372c74..2234d436b0 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_string_multiple_parameters.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_string_multiple_parameters.snap @@ -8,11 +8,11 @@ error: Invalid assignment: cannot assign 'REAL' to 'STRING' 15 │ func(var_real, var_unsigned, var_signed, var_time, var_byte, var_str, var_char, var_date); │ ^^^^^^^^ Invalid assignment: cannot assign 'REAL' to 'STRING' -error: Invalid type nature for generic argument. REAL is no String. +error: Invalid type nature for generic argument. REAL is no ANY_STRING ┌─ :15:14 │ 15 │ func(var_real, var_unsigned, var_signed, var_time, var_byte, var_str, var_char, var_date); - │ ^^^^^^^^ Invalid type nature for generic argument. REAL is no String. + │ ^^^^^^^^ Invalid type nature for generic argument. REAL is no ANY_STRING error: Invalid assignment: cannot assign 'UDINT' to 'STRING' ┌─ :15:24 @@ -20,11 +20,11 @@ error: Invalid assignment: cannot assign 'UDINT' to 'STRING' 15 │ func(var_real, var_unsigned, var_signed, var_time, var_byte, var_str, var_char, var_date); │ ^^^^^^^^^^^^ Invalid assignment: cannot assign 'UDINT' to 'STRING' -error: Invalid type nature for generic argument. UDINT is no String. +error: Invalid type nature for generic argument. UDINT is no ANY_STRING ┌─ :15:24 │ 15 │ func(var_real, var_unsigned, var_signed, var_time, var_byte, var_str, var_char, var_date); - │ ^^^^^^^^^^^^ Invalid type nature for generic argument. UDINT is no String. + │ ^^^^^^^^^^^^ Invalid type nature for generic argument. UDINT is no ANY_STRING error: Invalid assignment: cannot assign 'DINT' to 'STRING' ┌─ :15:38 @@ -32,11 +32,11 @@ error: Invalid assignment: cannot assign 'DINT' to 'STRING' 15 │ func(var_real, var_unsigned, var_signed, var_time, var_byte, var_str, var_char, var_date); │ ^^^^^^^^^^ Invalid assignment: cannot assign 'DINT' to 'STRING' -error: Invalid type nature for generic argument. DINT is no String. +error: Invalid type nature for generic argument. DINT is no ANY_STRING ┌─ :15:38 │ 15 │ func(var_real, var_unsigned, var_signed, var_time, var_byte, var_str, var_char, var_date); - │ ^^^^^^^^^^ Invalid type nature for generic argument. DINT is no String. + │ ^^^^^^^^^^ Invalid type nature for generic argument. DINT is no ANY_STRING error: Invalid assignment: cannot assign 'TIME' to 'STRING' ┌─ :15:50 @@ -44,11 +44,11 @@ error: Invalid assignment: cannot assign 'TIME' to 'STRING' 15 │ func(var_real, var_unsigned, var_signed, var_time, var_byte, var_str, var_char, var_date); │ ^^^^^^^^ Invalid assignment: cannot assign 'TIME' to 'STRING' -error: Invalid type nature for generic argument. TIME is no String. +error: Invalid type nature for generic argument. TIME is no ANY_STRING ┌─ :15:50 │ 15 │ func(var_real, var_unsigned, var_signed, var_time, var_byte, var_str, var_char, var_date); - │ ^^^^^^^^ Invalid type nature for generic argument. TIME is no String. + │ ^^^^^^^^ Invalid type nature for generic argument. TIME is no ANY_STRING error: Invalid assignment: cannot assign 'BYTE' to 'STRING' ┌─ :15:60 @@ -56,11 +56,11 @@ error: Invalid assignment: cannot assign 'BYTE' to 'STRING' 15 │ func(var_real, var_unsigned, var_signed, var_time, var_byte, var_str, var_char, var_date); │ ^^^^^^^^ Invalid assignment: cannot assign 'BYTE' to 'STRING' -error: Invalid type nature for generic argument. BYTE is no String. +error: Invalid type nature for generic argument. BYTE is no ANY_STRING ┌─ :15:60 │ 15 │ func(var_real, var_unsigned, var_signed, var_time, var_byte, var_str, var_char, var_date); - │ ^^^^^^^^ Invalid type nature for generic argument. BYTE is no String. + │ ^^^^^^^^ Invalid type nature for generic argument. BYTE is no ANY_STRING error: Invalid assignment: cannot assign 'CHAR' to 'STRING' ┌─ :15:79 @@ -68,11 +68,11 @@ error: Invalid assignment: cannot assign 'CHAR' to 'STRING' 15 │ func(var_real, var_unsigned, var_signed, var_time, var_byte, var_str, var_char, var_date); │ ^^^^^^^^ Invalid assignment: cannot assign 'CHAR' to 'STRING' -error: Invalid type nature for generic argument. CHAR is no String. +error: Invalid type nature for generic argument. CHAR is no ANY_STRING ┌─ :15:79 │ 15 │ func(var_real, var_unsigned, var_signed, var_time, var_byte, var_str, var_char, var_date); - │ ^^^^^^^^ Invalid type nature for generic argument. CHAR is no String. + │ ^^^^^^^^ Invalid type nature for generic argument. CHAR is no ANY_STRING error: Invalid assignment: cannot assign 'DATE' to 'STRING' ┌─ :15:89 @@ -80,10 +80,10 @@ error: Invalid assignment: cannot assign 'DATE' to 'STRING' 15 │ func(var_real, var_unsigned, var_signed, var_time, var_byte, var_str, var_char, var_date); │ ^^^^^^^^ Invalid assignment: cannot assign 'DATE' to 'STRING' -error: Invalid type nature for generic argument. DATE is no String. +error: Invalid type nature for generic argument. DATE is no ANY_STRING ┌─ :15:89 │ 15 │ func(var_real, var_unsigned, var_signed, var_time, var_byte, var_str, var_char, var_date); - │ ^^^^^^^^ Invalid type nature for generic argument. DATE is no String. + │ ^^^^^^^^ Invalid type nature for generic argument. DATE is no ANY_STRING diff --git a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_unsigned_does_not_allow_bits.snap b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_unsigned_does_not_allow_bits.snap index 5876d1cc1c..e8cd132fe9 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_unsigned_does_not_allow_bits.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_unsigned_does_not_allow_bits.snap @@ -2,34 +2,34 @@ source: src/validation/tests/generic_validation_tests.rs expression: "&diagnostics" --- -error: Invalid type nature for generic argument. BOOL is no Unsigned. +error: Invalid type nature for generic argument. BOOL is no ANY_UNSIGNED ┌─ :3:58 │ 3 │ FUNCTION func1 : INT VAR x : BOOL; END_VAR test(x); END_FUNCTION - │ ^ Invalid type nature for generic argument. BOOL is no Unsigned. + │ ^ Invalid type nature for generic argument. BOOL is no ANY_UNSIGNED -error: Invalid type nature for generic argument. BYTE is no Unsigned. +error: Invalid type nature for generic argument. BYTE is no ANY_UNSIGNED ┌─ :4:58 │ 4 │ FUNCTION func2 : INT VAR x : BYTE; END_VAR test(x); END_FUNCTION - │ ^ Invalid type nature for generic argument. BYTE is no Unsigned. + │ ^ Invalid type nature for generic argument. BYTE is no ANY_UNSIGNED -error: Invalid type nature for generic argument. WORD is no Unsigned. +error: Invalid type nature for generic argument. WORD is no ANY_UNSIGNED ┌─ :5:58 │ 5 │ FUNCTION func3 : INT VAR x : WORD; END_VAR test(x); END_FUNCTION - │ ^ Invalid type nature for generic argument. WORD is no Unsigned. + │ ^ Invalid type nature for generic argument. WORD is no ANY_UNSIGNED -error: Invalid type nature for generic argument. DWORD is no Unsigned. +error: Invalid type nature for generic argument. DWORD is no ANY_UNSIGNED ┌─ :6:59 │ 6 │ FUNCTION func4 : INT VAR x : DWORD; END_VAR test(x); END_FUNCTION - │ ^ Invalid type nature for generic argument. DWORD is no Unsigned. + │ ^ Invalid type nature for generic argument. DWORD is no ANY_UNSIGNED -error: Invalid type nature for generic argument. LWORD is no Unsigned. +error: Invalid type nature for generic argument. LWORD is no ANY_UNSIGNED ┌─ :7:59 │ 7 │ FUNCTION func5 : INT VAR x : LWORD; END_VAR test(x); END_FUNCTION - │ ^ Invalid type nature for generic argument. LWORD is no Unsigned. + │ ^ Invalid type nature for generic argument. LWORD is no ANY_UNSIGNED diff --git a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_unsigned_does_not_allow_chars.snap b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_unsigned_does_not_allow_chars.snap index e281997f84..5cc838c45e 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_unsigned_does_not_allow_chars.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_unsigned_does_not_allow_chars.snap @@ -8,11 +8,11 @@ error: Invalid assignment: cannot assign 'CHAR' to 'USINT' 3 │ FUNCTION func1 : INT VAR x : CHAR; END_VAR test(x); END_FUNCTION │ ^ Invalid assignment: cannot assign 'CHAR' to 'USINT' -error: Invalid type nature for generic argument. CHAR is no Unsigned. +error: Invalid type nature for generic argument. CHAR is no ANY_UNSIGNED ┌─ :3:58 │ 3 │ FUNCTION func1 : INT VAR x : CHAR; END_VAR test(x); END_FUNCTION - │ ^ Invalid type nature for generic argument. CHAR is no Unsigned. + │ ^ Invalid type nature for generic argument. CHAR is no ANY_UNSIGNED error: Invalid assignment: cannot assign 'WCHAR' to 'USINT' ┌─ :4:59 @@ -20,10 +20,10 @@ error: Invalid assignment: cannot assign 'WCHAR' to 'USINT' 4 │ FUNCTION func2 : INT VAR x : WCHAR; END_VAR test(x); END_FUNCTION │ ^ Invalid assignment: cannot assign 'WCHAR' to 'USINT' -error: Invalid type nature for generic argument. WCHAR is no Unsigned. +error: Invalid type nature for generic argument. WCHAR is no ANY_UNSIGNED ┌─ :4:59 │ 4 │ FUNCTION func2 : INT VAR x : WCHAR; END_VAR test(x); END_FUNCTION - │ ^ Invalid type nature for generic argument. WCHAR is no Unsigned. + │ ^ Invalid type nature for generic argument. WCHAR is no ANY_UNSIGNED diff --git a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_unsigned_does_not_allow_date.snap b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_unsigned_does_not_allow_date.snap index d0abe53082..461517cfef 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_unsigned_does_not_allow_date.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_unsigned_does_not_allow_date.snap @@ -2,34 +2,34 @@ source: src/validation/tests/generic_validation_tests.rs expression: "&diagnostics" --- -error: Invalid type nature for generic argument. DATE_AND_TIME is no Unsigned. +error: Invalid type nature for generic argument. DATE_AND_TIME is no ANY_UNSIGNED ┌─ :3:56 │ 3 │ FUNCTION func1 : INT VAR x : DT; END_VAR test(x); END_FUNCTION - │ ^ Invalid type nature for generic argument. DATE_AND_TIME is no Unsigned. + │ ^ Invalid type nature for generic argument. DATE_AND_TIME is no ANY_UNSIGNED -error: Invalid type nature for generic argument. DATE_AND_TIME is no Unsigned. +error: Invalid type nature for generic argument. DATE_AND_TIME is no ANY_UNSIGNED ┌─ :4:57 │ 4 │ FUNCTION func2 : INT VAR x : LDT; END_VAR test(x); END_FUNCTION - │ ^ Invalid type nature for generic argument. DATE_AND_TIME is no Unsigned. + │ ^ Invalid type nature for generic argument. DATE_AND_TIME is no ANY_UNSIGNED -error: Invalid type nature for generic argument. DATE is no Unsigned. +error: Invalid type nature for generic argument. DATE is no ANY_UNSIGNED ┌─ :5:58 │ 5 │ FUNCTION func3 : INT VAR x : DATE; END_VAR test(x); END_FUNCTION - │ ^ Invalid type nature for generic argument. DATE is no Unsigned. + │ ^ Invalid type nature for generic argument. DATE is no ANY_UNSIGNED -error: Invalid type nature for generic argument. TIME_OF_DAY is no Unsigned. +error: Invalid type nature for generic argument. TIME_OF_DAY is no ANY_UNSIGNED ┌─ :6:57 │ 6 │ FUNCTION func4 : INT VAR x : TOD; END_VAR test(x); END_FUNCTION - │ ^ Invalid type nature for generic argument. TIME_OF_DAY is no Unsigned. + │ ^ Invalid type nature for generic argument. TIME_OF_DAY is no ANY_UNSIGNED -error: Invalid type nature for generic argument. TIME_OF_DAY is no Unsigned. +error: Invalid type nature for generic argument. TIME_OF_DAY is no ANY_UNSIGNED ┌─ :7:58 │ 7 │ FUNCTION func5 : INT VAR x : LTOD; END_VAR test(x); END_FUNCTION - │ ^ Invalid type nature for generic argument. TIME_OF_DAY is no Unsigned. + │ ^ Invalid type nature for generic argument. TIME_OF_DAY is no ANY_UNSIGNED diff --git a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_unsigned_does_not_allow_reals.snap b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_unsigned_does_not_allow_reals.snap index 3bcba293c9..796c0150ee 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_unsigned_does_not_allow_reals.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_unsigned_does_not_allow_reals.snap @@ -2,16 +2,16 @@ source: src/validation/tests/generic_validation_tests.rs expression: "&diagnostics" --- -error: Invalid type nature for generic argument. REAL is no Unsigned. +error: Invalid type nature for generic argument. REAL is no ANY_UNSIGNED ┌─ :3:57 │ 3 │ FUNCTION func : INT VAR x : REAL; END_VAR test(x); END_FUNCTION - │ ^ Invalid type nature for generic argument. REAL is no Unsigned. + │ ^ Invalid type nature for generic argument. REAL is no ANY_UNSIGNED -error: Invalid type nature for generic argument. LREAL is no Unsigned. +error: Invalid type nature for generic argument. LREAL is no ANY_UNSIGNED ┌─ :4:59 │ 4 │ FUNCTION func1 : INT VAR x : LREAL; END_VAR test(x); END_FUNCTION - │ ^ Invalid type nature for generic argument. LREAL is no Unsigned. + │ ^ Invalid type nature for generic argument. LREAL is no ANY_UNSIGNED diff --git a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_unsigned_does_not_allow_signed_ints.snap b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_unsigned_does_not_allow_signed_ints.snap index 36b40f22db..268af3b691 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_unsigned_does_not_allow_signed_ints.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_unsigned_does_not_allow_signed_ints.snap @@ -2,28 +2,28 @@ source: src/validation/tests/generic_validation_tests.rs expression: "&diagnostics" --- -error: Invalid type nature for generic argument. SINT is no Unsigned. +error: Invalid type nature for generic argument. SINT is no ANY_UNSIGNED ┌─ :3:58 │ 3 │ FUNCTION func1 : INT VAR x : SINT; END_VAR test(x); END_FUNCTION - │ ^ Invalid type nature for generic argument. SINT is no Unsigned. + │ ^ Invalid type nature for generic argument. SINT is no ANY_UNSIGNED -error: Invalid type nature for generic argument. INT is no Unsigned. +error: Invalid type nature for generic argument. INT is no ANY_UNSIGNED ┌─ :4:57 │ 4 │ FUNCTION func2 : INT VAR x : INT; END_VAR test(x); END_FUNCTION - │ ^ Invalid type nature for generic argument. INT is no Unsigned. + │ ^ Invalid type nature for generic argument. INT is no ANY_UNSIGNED -error: Invalid type nature for generic argument. DINT is no Unsigned. +error: Invalid type nature for generic argument. DINT is no ANY_UNSIGNED ┌─ :5:58 │ 5 │ FUNCTION func3 : INT VAR x : DINT; END_VAR test(x); END_FUNCTION - │ ^ Invalid type nature for generic argument. DINT is no Unsigned. + │ ^ Invalid type nature for generic argument. DINT is no ANY_UNSIGNED -error: Invalid type nature for generic argument. LINT is no Unsigned. +error: Invalid type nature for generic argument. LINT is no ANY_UNSIGNED ┌─ :6:58 │ 6 │ FUNCTION func4 : INT VAR x : LINT; END_VAR test(x); END_FUNCTION - │ ^ Invalid type nature for generic argument. LINT is no Unsigned. + │ ^ Invalid type nature for generic argument. LINT is no ANY_UNSIGNED diff --git a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_unsigned_does_not_allow_string.snap b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_unsigned_does_not_allow_string.snap index c1bc15b379..6a93df97d7 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_unsigned_does_not_allow_string.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_unsigned_does_not_allow_string.snap @@ -8,11 +8,11 @@ error: Invalid assignment: cannot assign 'STRING' to 'USINT' 3 │ FUNCTION func1 : INT VAR x : STRING; END_VAR test(x); END_FUNCTION │ ^ Invalid assignment: cannot assign 'STRING' to 'USINT' -error: Invalid type nature for generic argument. STRING is no Unsigned. +error: Invalid type nature for generic argument. STRING is no ANY_UNSIGNED ┌─ :3:61 │ 3 │ FUNCTION func1 : INT VAR x : STRING; END_VAR test(x); END_FUNCTION - │ ^ Invalid type nature for generic argument. STRING is no Unsigned. + │ ^ Invalid type nature for generic argument. STRING is no ANY_UNSIGNED error: Invalid assignment: cannot assign 'WSTRING' to 'USINT' ┌─ :4:61 @@ -20,10 +20,10 @@ error: Invalid assignment: cannot assign 'WSTRING' to 'USINT' 4 │ FUNCTION func2 : INT VAR x : WSTRING; END_VAR test(x); END_FUNCTION │ ^ Invalid assignment: cannot assign 'WSTRING' to 'USINT' -error: Invalid type nature for generic argument. WSTRING is no Unsigned. +error: Invalid type nature for generic argument. WSTRING is no ANY_UNSIGNED ┌─ :4:61 │ 4 │ FUNCTION func2 : INT VAR x : WSTRING; END_VAR test(x); END_FUNCTION - │ ^ Invalid type nature for generic argument. WSTRING is no Unsigned. + │ ^ Invalid type nature for generic argument. WSTRING is no ANY_UNSIGNED diff --git a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_unsigned_does_not_allow_time.snap b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_unsigned_does_not_allow_time.snap index f47254d309..f026ed39ad 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_unsigned_does_not_allow_time.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_unsigned_does_not_allow_time.snap @@ -2,16 +2,16 @@ source: src/validation/tests/generic_validation_tests.rs expression: "&diagnostics" --- -error: Invalid type nature for generic argument. TIME is no Unsigned. +error: Invalid type nature for generic argument. TIME is no ANY_UNSIGNED ┌─ :3:58 │ 3 │ FUNCTION func1 : INT VAR x : TIME; END_VAR test(x); END_FUNCTION - │ ^ Invalid type nature for generic argument. TIME is no Unsigned. + │ ^ Invalid type nature for generic argument. TIME is no ANY_UNSIGNED -error: Invalid type nature for generic argument. TIME is no Unsigned. +error: Invalid type nature for generic argument. TIME is no ANY_UNSIGNED ┌─ :4:59 │ 4 │ FUNCTION func2 : INT VAR x : LTIME; END_VAR test(x); END_FUNCTION - │ ^ Invalid type nature for generic argument. TIME is no Unsigned. + │ ^ Invalid type nature for generic argument. TIME is no ANY_UNSIGNED diff --git a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_unsigned_multiple_parameters.snap b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_unsigned_multiple_parameters.snap index 5b64fff636..604d52d57e 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_unsigned_multiple_parameters.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__any_unsigned_multiple_parameters.snap @@ -2,29 +2,29 @@ source: src/validation/tests/generic_validation_tests.rs expression: "&diagnostics" --- -error: Invalid type nature for generic argument. REAL is no Unsigned. +error: Invalid type nature for generic argument. REAL is no ANY_UNSIGNED ┌─ :15:14 │ 15 │ func(var_real, var_unsigned, var_signed, var_time, var_byte, var_str, var_char, var_date); - │ ^^^^^^^^ Invalid type nature for generic argument. REAL is no Unsigned. + │ ^^^^^^^^ Invalid type nature for generic argument. REAL is no ANY_UNSIGNED -error: Invalid type nature for generic argument. DINT is no Unsigned. +error: Invalid type nature for generic argument. DINT is no ANY_UNSIGNED ┌─ :15:38 │ 15 │ func(var_real, var_unsigned, var_signed, var_time, var_byte, var_str, var_char, var_date); - │ ^^^^^^^^^^ Invalid type nature for generic argument. DINT is no Unsigned. + │ ^^^^^^^^^^ Invalid type nature for generic argument. DINT is no ANY_UNSIGNED -error: Invalid type nature for generic argument. TIME is no Unsigned. +error: Invalid type nature for generic argument. TIME is no ANY_UNSIGNED ┌─ :15:50 │ 15 │ func(var_real, var_unsigned, var_signed, var_time, var_byte, var_str, var_char, var_date); - │ ^^^^^^^^ Invalid type nature for generic argument. TIME is no Unsigned. + │ ^^^^^^^^ Invalid type nature for generic argument. TIME is no ANY_UNSIGNED -error: Invalid type nature for generic argument. BYTE is no Unsigned. +error: Invalid type nature for generic argument. BYTE is no ANY_UNSIGNED ┌─ :15:60 │ 15 │ func(var_real, var_unsigned, var_signed, var_time, var_byte, var_str, var_char, var_date); - │ ^^^^^^^^ Invalid type nature for generic argument. BYTE is no Unsigned. + │ ^^^^^^^^ Invalid type nature for generic argument. BYTE is no ANY_UNSIGNED error: Invalid assignment: cannot assign 'STRING' to 'UDINT' ┌─ :15:70 @@ -32,11 +32,11 @@ error: Invalid assignment: cannot assign 'STRING' to 'UDINT' 15 │ func(var_real, var_unsigned, var_signed, var_time, var_byte, var_str, var_char, var_date); │ ^^^^^^^ Invalid assignment: cannot assign 'STRING' to 'UDINT' -error: Invalid type nature for generic argument. STRING is no Unsigned. +error: Invalid type nature for generic argument. STRING is no ANY_UNSIGNED ┌─ :15:70 │ 15 │ func(var_real, var_unsigned, var_signed, var_time, var_byte, var_str, var_char, var_date); - │ ^^^^^^^ Invalid type nature for generic argument. STRING is no Unsigned. + │ ^^^^^^^ Invalid type nature for generic argument. STRING is no ANY_UNSIGNED error: Invalid assignment: cannot assign 'CHAR' to 'UDINT' ┌─ :15:79 @@ -44,16 +44,16 @@ error: Invalid assignment: cannot assign 'CHAR' to 'UDINT' 15 │ func(var_real, var_unsigned, var_signed, var_time, var_byte, var_str, var_char, var_date); │ ^^^^^^^^ Invalid assignment: cannot assign 'CHAR' to 'UDINT' -error: Invalid type nature for generic argument. CHAR is no Unsigned. +error: Invalid type nature for generic argument. CHAR is no ANY_UNSIGNED ┌─ :15:79 │ 15 │ func(var_real, var_unsigned, var_signed, var_time, var_byte, var_str, var_char, var_date); - │ ^^^^^^^^ Invalid type nature for generic argument. CHAR is no Unsigned. + │ ^^^^^^^^ Invalid type nature for generic argument. CHAR is no ANY_UNSIGNED -error: Invalid type nature for generic argument. DATE is no Unsigned. +error: Invalid type nature for generic argument. DATE is no ANY_UNSIGNED ┌─ :15:89 │ 15 │ func(var_real, var_unsigned, var_signed, var_time, var_byte, var_str, var_char, var_date); - │ ^^^^^^^^ Invalid type nature for generic argument. DATE is no Unsigned. + │ ^^^^^^^^ Invalid type nature for generic argument. DATE is no ANY_UNSIGNED diff --git a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__non_resolved_generics_reported.snap b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__non_resolved_generics_reported.snap index 24ac4b53e5..be976fc5e8 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__non_resolved_generics_reported.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__non_resolved_generics_reported.snap @@ -2,10 +2,10 @@ source: src/validation/tests/generic_validation_tests.rs expression: "&diagnostics" --- -error: Could not resolve generic type T with nature String +error: Could not resolve generic type T with ANY_STRING ┌─ :3:31 │ 3 │ FUNCTION func : INT test(); END_FUNCTION - │ ^^^^^^^ Could not resolve generic type T with nature String + │ ^^^^^^^ Could not resolve generic type T with ANY_STRING diff --git a/src/validation/tests/snapshots/rusty__validation__tests__literals_validation_tests__literal_cast_with_non_literal.snap b/src/validation/tests/snapshots/rusty__validation__tests__literals_validation_tests__literal_cast_with_non_literal.snap index e731ba3200..163a44716d 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__literals_validation_tests__literal_cast_with_non_literal.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__literals_validation_tests__literal_cast_with_non_literal.snap @@ -2,10 +2,10 @@ source: src/validation/tests/literals_validation_tests.rs expression: "&diagnostics" --- -error: Expected literal +error: Cannot cast into [x], only elementary types are allowed ┌─ :2:13 │ 2 │ INT#[x]; - │ ^^^^^^^ Expected literal + │ ^^^^^^^ Cannot cast into [x], only elementary types are allowed diff --git a/src/validation/tests/snapshots/rusty__validation__tests__pou_validation_tests__function_has_super_class.snap b/src/validation/tests/snapshots/rusty__validation__tests__pou_validation_tests__function_has_super_class.snap index 29e436404b..990c7b1212 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__pou_validation_tests__function_has_super_class.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__pou_validation_tests__function_has_super_class.snap @@ -2,11 +2,11 @@ source: src/validation/tests/pou_validation_tests.rs expression: "&diagnostics" --- -error: A function cannot use EXTEND +error: A function cannot use `EXTEND` ┌─ :5:18 │ 5 │ FUNCTION func EXTENDS cls - │ ^^^^ A function cannot use EXTEND + │ ^^^^ A function cannot use `EXTEND` error: Function Return type missing ┌─ :5:18 diff --git a/src/validation/tests/snapshots/rusty__validation__tests__pou_validation_tests__program_has_super_class.snap b/src/validation/tests/snapshots/rusty__validation__tests__pou_validation_tests__program_has_super_class.snap index 2ed1b32923..4e788c9e72 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__pou_validation_tests__program_has_super_class.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__pou_validation_tests__program_has_super_class.snap @@ -2,10 +2,10 @@ source: src/validation/tests/pou_validation_tests.rs expression: "&diagnostics" --- -error: A program cannot use EXTEND +error: A program cannot use `EXTEND` ┌─ :5:17 │ 5 │ PROGRAM prog EXTENDS cls - │ ^^^^ A program cannot use EXTEND + │ ^^^^ A program cannot use `EXTEND` diff --git a/src/validation/tests/snapshots/rusty__validation__tests__recursive_validation_tests__arrays__one_cycle_aba_input.snap b/src/validation/tests/snapshots/rusty__validation__tests__recursive_validation_tests__arrays__one_cycle_aba_input.snap index 8cc8e82837..e65c40c93e 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__recursive_validation_tests__arrays__one_cycle_aba_input.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__recursive_validation_tests__arrays__one_cycle_aba_input.snap @@ -6,7 +6,10 @@ error: Recursive data structure `A -> B -> A` has infinite size ┌─ :2:18 │ 2 │ TYPE A : STRUCT - │ ^ Recursive data structure `A -> B -> A` has infinite size + │ ^ + │ │ + │ Recursive data structure `A -> B -> A` has infinite size + │ see also · 6 │ FUNCTION_BLOCK B │ - see also diff --git a/src/validation/tests/snapshots/rusty__validation__tests__recursive_validation_tests__arrays__one_cycle_aba_output.snap b/src/validation/tests/snapshots/rusty__validation__tests__recursive_validation_tests__arrays__one_cycle_aba_output.snap index 8cc8e82837..e65c40c93e 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__recursive_validation_tests__arrays__one_cycle_aba_output.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__recursive_validation_tests__arrays__one_cycle_aba_output.snap @@ -6,7 +6,10 @@ error: Recursive data structure `A -> B -> A` has infinite size ┌─ :2:18 │ 2 │ TYPE A : STRUCT - │ ^ Recursive data structure `A -> B -> A` has infinite size + │ ^ + │ │ + │ Recursive data structure `A -> B -> A` has infinite size + │ see also · 6 │ FUNCTION_BLOCK B │ - see also diff --git a/src/validation/tests/snapshots/rusty__validation__tests__recursive_validation_tests__arrays__one_cycle_bcb.snap b/src/validation/tests/snapshots/rusty__validation__tests__recursive_validation_tests__arrays__one_cycle_bcb.snap index fa8fe2a89b..d80864dd59 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__recursive_validation_tests__arrays__one_cycle_bcb.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__recursive_validation_tests__arrays__one_cycle_bcb.snap @@ -6,7 +6,10 @@ error: Recursive data structure `B -> C -> B` has infinite size ┌─ :6:18 │ 6 │ TYPE B : STRUCT - │ ^ Recursive data structure `B -> C -> B` has infinite size + │ ^ + │ │ + │ Recursive data structure `B -> C -> B` has infinite size + │ see also · 10 │ TYPE C : STRUCT │ - see also diff --git a/src/validation/tests/snapshots/rusty__validation__tests__recursive_validation_tests__arrays__one_cycle_with_multiple_identical_members_aba.snap b/src/validation/tests/snapshots/rusty__validation__tests__recursive_validation_tests__arrays__one_cycle_with_multiple_identical_members_aba.snap index 09cc059a87..a9af318934 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__recursive_validation_tests__arrays__one_cycle_with_multiple_identical_members_aba.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__recursive_validation_tests__arrays__one_cycle_with_multiple_identical_members_aba.snap @@ -6,7 +6,10 @@ error: Recursive data structure `A -> B -> A` has infinite size ┌─ :2:18 │ 2 │ TYPE A : STRUCT - │ ^ Recursive data structure `A -> B -> A` has infinite size + │ ^ + │ │ + │ Recursive data structure `A -> B -> A` has infinite size + │ see also · 8 │ TYPE B : STRUCT │ - see also diff --git a/src/validation/tests/snapshots/rusty__validation__tests__recursive_validation_tests__arrays__two_cycles_aa_and_aba.snap b/src/validation/tests/snapshots/rusty__validation__tests__recursive_validation_tests__arrays__two_cycles_aa_and_aba.snap index 27960e1961..cae82b9ec4 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__recursive_validation_tests__arrays__two_cycles_aa_and_aba.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__recursive_validation_tests__arrays__two_cycles_aa_and_aba.snap @@ -12,7 +12,10 @@ error: Recursive data structure `A -> B -> A` has infinite size ┌─ :2:18 │ 2 │ TYPE A : STRUCT - │ ^ Recursive data structure `A -> B -> A` has infinite size + │ ^ + │ │ + │ Recursive data structure `A -> B -> A` has infinite size + │ see also · 7 │ TYPE B : STRUCT │ - see also diff --git a/src/validation/tests/snapshots/rusty__validation__tests__recursive_validation_tests__arrays__two_cycles_with_branch_input.snap b/src/validation/tests/snapshots/rusty__validation__tests__recursive_validation_tests__arrays__two_cycles_with_branch_input.snap index 9b1d70c775..188fd2d59b 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__recursive_validation_tests__arrays__two_cycles_with_branch_input.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__recursive_validation_tests__arrays__two_cycles_with_branch_input.snap @@ -6,7 +6,10 @@ error: Recursive data structure `F -> G -> H -> I -> F` has infinite size ┌─ :22:28 │ 22 │ FUNCTION_BLOCK F - │ ^ Recursive data structure `F -> G -> H -> I -> F` has infinite size + │ ^ + │ │ + │ Recursive data structure `F -> G -> H -> I -> F` has infinite size + │ see also · 29 │ TYPE G : STRUCT │ - see also @@ -21,7 +24,10 @@ error: Recursive data structure `B -> C -> E -> F -> B` has infinite size ┌─ :8:18 │ 8 │ TYPE B : STRUCT - │ ^ Recursive data structure `B -> C -> E -> F -> B` has infinite size + │ ^ + │ │ + │ Recursive data structure `B -> C -> E -> F -> B` has infinite size + │ see also · 12 │ FUNCTION_BLOCK C │ - see also diff --git a/src/validation/tests/snapshots/rusty__validation__tests__recursive_validation_tests__functionblocks__one_cycle_aba_input.snap b/src/validation/tests/snapshots/rusty__validation__tests__recursive_validation_tests__functionblocks__one_cycle_aba_input.snap index 92e6b08c0d..c11483cfe0 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__recursive_validation_tests__functionblocks__one_cycle_aba_input.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__recursive_validation_tests__functionblocks__one_cycle_aba_input.snap @@ -6,7 +6,10 @@ error: Recursive data structure `A -> B -> A` has infinite size ┌─ :2:28 │ 2 │ FUNCTION_BLOCK A - │ ^ Recursive data structure `A -> B -> A` has infinite size + │ ^ + │ │ + │ Recursive data structure `A -> B -> A` has infinite size + │ see also · 9 │ FUNCTION_BLOCK B │ - see also diff --git a/src/validation/tests/snapshots/rusty__validation__tests__recursive_validation_tests__functionblocks__one_cycle_aba_output.snap b/src/validation/tests/snapshots/rusty__validation__tests__recursive_validation_tests__functionblocks__one_cycle_aba_output.snap index 92e6b08c0d..c11483cfe0 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__recursive_validation_tests__functionblocks__one_cycle_aba_output.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__recursive_validation_tests__functionblocks__one_cycle_aba_output.snap @@ -6,7 +6,10 @@ error: Recursive data structure `A -> B -> A` has infinite size ┌─ :2:28 │ 2 │ FUNCTION_BLOCK A - │ ^ Recursive data structure `A -> B -> A` has infinite size + │ ^ + │ │ + │ Recursive data structure `A -> B -> A` has infinite size + │ see also · 9 │ FUNCTION_BLOCK B │ - see also diff --git a/src/validation/tests/snapshots/rusty__validation__tests__recursive_validation_tests__functionblocks__one_cycle_aba_var.snap b/src/validation/tests/snapshots/rusty__validation__tests__recursive_validation_tests__functionblocks__one_cycle_aba_var.snap index 92e6b08c0d..c11483cfe0 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__recursive_validation_tests__functionblocks__one_cycle_aba_var.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__recursive_validation_tests__functionblocks__one_cycle_aba_var.snap @@ -6,7 +6,10 @@ error: Recursive data structure `A -> B -> A` has infinite size ┌─ :2:28 │ 2 │ FUNCTION_BLOCK A - │ ^ Recursive data structure `A -> B -> A` has infinite size + │ ^ + │ │ + │ Recursive data structure `A -> B -> A` has infinite size + │ see also · 9 │ FUNCTION_BLOCK B │ - see also diff --git a/src/validation/tests/snapshots/rusty__validation__tests__recursive_validation_tests__functionblocks__two_cycles_with_branch_input.snap b/src/validation/tests/snapshots/rusty__validation__tests__recursive_validation_tests__functionblocks__two_cycles_with_branch_input.snap index 3d405ada9e..77ef800d3b 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__recursive_validation_tests__functionblocks__two_cycles_with_branch_input.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__recursive_validation_tests__functionblocks__two_cycles_with_branch_input.snap @@ -6,7 +6,10 @@ error: Recursive data structure `F -> G -> H -> I -> F` has infinite size ┌─ :26:28 │ 26 │ FUNCTION_BLOCK F - │ ^ Recursive data structure `F -> G -> H -> I -> F` has infinite size + │ ^ + │ │ + │ Recursive data structure `F -> G -> H -> I -> F` has infinite size + │ see also · 33 │ FUNCTION_BLOCK G │ - see also @@ -21,7 +24,10 @@ error: Recursive data structure `B -> C -> E -> F -> B` has infinite size ┌─ :8:28 │ 8 │ FUNCTION_BLOCK B - │ ^ Recursive data structure `B -> C -> E -> F -> B` has infinite size + │ ^ + │ │ + │ Recursive data structure `B -> C -> E -> F -> B` has infinite size + │ see also · 14 │ FUNCTION_BLOCK C │ - see also diff --git a/src/validation/tests/snapshots/rusty__validation__tests__recursive_validation_tests__mixed_structs_and_functionblocks__one_cycle_aba_input.snap b/src/validation/tests/snapshots/rusty__validation__tests__recursive_validation_tests__mixed_structs_and_functionblocks__one_cycle_aba_input.snap index 8cc8e82837..e65c40c93e 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__recursive_validation_tests__mixed_structs_and_functionblocks__one_cycle_aba_input.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__recursive_validation_tests__mixed_structs_and_functionblocks__one_cycle_aba_input.snap @@ -6,7 +6,10 @@ error: Recursive data structure `A -> B -> A` has infinite size ┌─ :2:18 │ 2 │ TYPE A : STRUCT - │ ^ Recursive data structure `A -> B -> A` has infinite size + │ ^ + │ │ + │ Recursive data structure `A -> B -> A` has infinite size + │ see also · 6 │ FUNCTION_BLOCK B │ - see also diff --git a/src/validation/tests/snapshots/rusty__validation__tests__recursive_validation_tests__mixed_structs_and_functionblocks__one_cycle_aba_output.snap b/src/validation/tests/snapshots/rusty__validation__tests__recursive_validation_tests__mixed_structs_and_functionblocks__one_cycle_aba_output.snap index 8cc8e82837..e65c40c93e 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__recursive_validation_tests__mixed_structs_and_functionblocks__one_cycle_aba_output.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__recursive_validation_tests__mixed_structs_and_functionblocks__one_cycle_aba_output.snap @@ -6,7 +6,10 @@ error: Recursive data structure `A -> B -> A` has infinite size ┌─ :2:18 │ 2 │ TYPE A : STRUCT - │ ^ Recursive data structure `A -> B -> A` has infinite size + │ ^ + │ │ + │ Recursive data structure `A -> B -> A` has infinite size + │ see also · 6 │ FUNCTION_BLOCK B │ - see also diff --git a/src/validation/tests/snapshots/rusty__validation__tests__recursive_validation_tests__mixed_structs_and_functionblocks__two_cycles_with_branch_input.snap b/src/validation/tests/snapshots/rusty__validation__tests__recursive_validation_tests__mixed_structs_and_functionblocks__two_cycles_with_branch_input.snap index 9b1d70c775..188fd2d59b 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__recursive_validation_tests__mixed_structs_and_functionblocks__two_cycles_with_branch_input.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__recursive_validation_tests__mixed_structs_and_functionblocks__two_cycles_with_branch_input.snap @@ -6,7 +6,10 @@ error: Recursive data structure `F -> G -> H -> I -> F` has infinite size ┌─ :22:28 │ 22 │ FUNCTION_BLOCK F - │ ^ Recursive data structure `F -> G -> H -> I -> F` has infinite size + │ ^ + │ │ + │ Recursive data structure `F -> G -> H -> I -> F` has infinite size + │ see also · 29 │ TYPE G : STRUCT │ - see also @@ -21,7 +24,10 @@ error: Recursive data structure `B -> C -> E -> F -> B` has infinite size ┌─ :8:18 │ 8 │ TYPE B : STRUCT - │ ^ Recursive data structure `B -> C -> E -> F -> B` has infinite size + │ ^ + │ │ + │ Recursive data structure `B -> C -> E -> F -> B` has infinite size + │ see also · 12 │ FUNCTION_BLOCK C │ - see also diff --git a/src/validation/tests/snapshots/rusty__validation__tests__recursive_validation_tests__structs__one_cycle_aba.snap b/src/validation/tests/snapshots/rusty__validation__tests__recursive_validation_tests__structs__one_cycle_aba.snap index e51c1a8270..2029f87e3c 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__recursive_validation_tests__structs__one_cycle_aba.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__recursive_validation_tests__structs__one_cycle_aba.snap @@ -6,7 +6,10 @@ error: Recursive data structure `A -> B -> A` has infinite size ┌─ :2:18 │ 2 │ TYPE A : STRUCT - │ ^ Recursive data structure `A -> B -> A` has infinite size + │ ^ + │ │ + │ Recursive data structure `A -> B -> A` has infinite size + │ see also · 6 │ TYPE B : STRUCT │ - see also diff --git a/src/validation/tests/snapshots/rusty__validation__tests__recursive_validation_tests__structs__one_cycle_abca.snap b/src/validation/tests/snapshots/rusty__validation__tests__recursive_validation_tests__structs__one_cycle_abca.snap index f76b47c047..28bdb83df1 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__recursive_validation_tests__structs__one_cycle_abca.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__recursive_validation_tests__structs__one_cycle_abca.snap @@ -6,7 +6,10 @@ error: Recursive data structure `A -> B -> C -> A` has infinite size ┌─ :2:18 │ 2 │ TYPE A : STRUCT - │ ^ Recursive data structure `A -> B -> C -> A` has infinite size + │ ^ + │ │ + │ Recursive data structure `A -> B -> C -> A` has infinite size + │ see also · 6 │ TYPE B : STRUCT │ - see also diff --git a/src/validation/tests/snapshots/rusty__validation__tests__recursive_validation_tests__structs__one_cycle_bcb.snap b/src/validation/tests/snapshots/rusty__validation__tests__recursive_validation_tests__structs__one_cycle_bcb.snap index fa8fe2a89b..d80864dd59 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__recursive_validation_tests__structs__one_cycle_bcb.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__recursive_validation_tests__structs__one_cycle_bcb.snap @@ -6,7 +6,10 @@ error: Recursive data structure `B -> C -> B` has infinite size ┌─ :6:18 │ 6 │ TYPE B : STRUCT - │ ^ Recursive data structure `B -> C -> B` has infinite size + │ ^ + │ │ + │ Recursive data structure `B -> C -> B` has infinite size + │ see also · 10 │ TYPE C : STRUCT │ - see also diff --git a/src/validation/tests/snapshots/rusty__validation__tests__recursive_validation_tests__structs__one_cycle_with_multiple_identical_members_aba.snap b/src/validation/tests/snapshots/rusty__validation__tests__recursive_validation_tests__structs__one_cycle_with_multiple_identical_members_aba.snap index 09cc059a87..a9af318934 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__recursive_validation_tests__structs__one_cycle_with_multiple_identical_members_aba.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__recursive_validation_tests__structs__one_cycle_with_multiple_identical_members_aba.snap @@ -6,7 +6,10 @@ error: Recursive data structure `A -> B -> A` has infinite size ┌─ :2:18 │ 2 │ TYPE A : STRUCT - │ ^ Recursive data structure `A -> B -> A` has infinite size + │ ^ + │ │ + │ Recursive data structure `A -> B -> A` has infinite size + │ see also · 8 │ TYPE B : STRUCT │ - see also diff --git a/src/validation/tests/snapshots/rusty__validation__tests__recursive_validation_tests__structs__two_cycles_aa_and_aba.snap b/src/validation/tests/snapshots/rusty__validation__tests__recursive_validation_tests__structs__two_cycles_aa_and_aba.snap index 27960e1961..cae82b9ec4 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__recursive_validation_tests__structs__two_cycles_aa_and_aba.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__recursive_validation_tests__structs__two_cycles_aa_and_aba.snap @@ -12,7 +12,10 @@ error: Recursive data structure `A -> B -> A` has infinite size ┌─ :2:18 │ 2 │ TYPE A : STRUCT - │ ^ Recursive data structure `A -> B -> A` has infinite size + │ ^ + │ │ + │ Recursive data structure `A -> B -> A` has infinite size + │ see also · 7 │ TYPE B : STRUCT │ - see also diff --git a/src/validation/tests/snapshots/rusty__validation__tests__recursive_validation_tests__structs__two_cycles_branch_cc_and_cec.snap b/src/validation/tests/snapshots/rusty__validation__tests__recursive_validation_tests__structs__two_cycles_branch_cc_and_cec.snap index 7df694da3b..5ed2bb31de 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__recursive_validation_tests__structs__two_cycles_branch_cc_and_cec.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__recursive_validation_tests__structs__two_cycles_branch_cc_and_cec.snap @@ -12,7 +12,10 @@ error: Recursive data structure `C -> E -> C` has infinite size ┌─ :10:18 │ 10 │ TYPE C : STRUCT - │ ^ Recursive data structure `C -> E -> C` has infinite size + │ ^ + │ │ + │ Recursive data structure `C -> E -> C` has infinite size + │ see also · 15 │ TYPE E : STRUCT │ - see also diff --git a/src/validation/tests/snapshots/rusty__validation__tests__recursive_validation_tests__structs__two_cycles_with_branch.snap b/src/validation/tests/snapshots/rusty__validation__tests__recursive_validation_tests__structs__two_cycles_with_branch.snap index b91f2d2f8e..7ff9e5a350 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__recursive_validation_tests__structs__two_cycles_with_branch.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__recursive_validation_tests__structs__two_cycles_with_branch.snap @@ -6,7 +6,10 @@ error: Recursive data structure `F -> G -> H -> I -> F` has infinite size ┌─ :18:18 │ 18 │ TYPE F : STRUCT - │ ^ Recursive data structure `F -> G -> H -> I -> F` has infinite size + │ ^ + │ │ + │ Recursive data structure `F -> G -> H -> I -> F` has infinite size + │ see also · 23 │ TYPE G : STRUCT │ - see also @@ -21,7 +24,10 @@ error: Recursive data structure `B -> C -> E -> F -> B` has infinite size ┌─ :6:18 │ 6 │ TYPE B : STRUCT - │ ^ Recursive data structure `B -> C -> E -> F -> B` has infinite size + │ ^ + │ │ + │ Recursive data structure `B -> C -> E -> F -> B` has infinite size + │ see also · 10 │ TYPE C : STRUCT │ - see also diff --git a/src/validation/tests/snapshots/rusty__validation__tests__reference_resolve_tests__resolve_function_calls_and_parameters.snap b/src/validation/tests/snapshots/rusty__validation__tests__reference_resolve_tests__resolve_function_calls_and_parameters.snap index 98d0bc9eb2..06234fa74d 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__reference_resolve_tests__resolve_function_calls_and_parameters.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__reference_resolve_tests__resolve_function_calls_and_parameters.snap @@ -20,6 +20,12 @@ error: Could not resolve reference to c 7 │ foo(x := c); │ ^ Could not resolve reference to c +error: Invalid call parameters + ┌─ :8:21 + │ +8 │ foo(y := a); + │ ^^^^^^ Invalid call parameters + error: Could not resolve reference to y ┌─ :8:21 │ diff --git a/src/validation/tests/snapshots/rusty__validation__tests__statement_validation_tests__assign_too_small_type_to_pointer_result_in_an_error.snap b/src/validation/tests/snapshots/rusty__validation__tests__statement_validation_tests__assign_too_small_type_to_pointer_result_in_an_error.snap index f26f8d7f18..aacd24486f 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__statement_validation_tests__assign_too_small_type_to_pointer_result_in_an_error.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__statement_validation_tests__assign_too_small_type_to_pointer_result_in_an_error.snap @@ -2,11 +2,11 @@ source: src/validation/tests/statement_validation_tests.rs expression: "&diagnostics" --- -error: The type DWORD 32 is too small to to be stored in a Pointer +error: The type DWORD 32 is too small to be stored in a Pointer ┌─ :9:13 │ 9 │ ptr := address; //should throw error as address is too small to store full pointer - │ ^^^^^^^^^^^^^^ The type DWORD 32 is too small to to be stored in a Pointer + │ ^^^^^^^^^^^^^^ The type DWORD 32 is too small to be stored in a Pointer error: Invalid assignment: cannot assign 'DWORD' to 'REF_TO INT' ┌─ :9:13 diff --git a/src/validation/tests/snapshots/rusty__validation__tests__statement_validation_tests__assigning_to_rvalue.snap b/src/validation/tests/snapshots/rusty__validation__tests__statement_validation_tests__assigning_to_rvalue.snap index 142d61482d..1d1e0ce530 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__statement_validation_tests__assigning_to_rvalue.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__statement_validation_tests__assigning_to_rvalue.snap @@ -2,22 +2,28 @@ source: src/validation/tests/statement_validation_tests.rs expression: "&diagnostics" --- -error: Expression is not assignable +error: Expression 1 is not assignable. ┌─ :12:13 │ 12 │ 1 := 1; - │ ^ Expression is not assignable + │ ^ Expression 1 is not assignable. -error: Expression is not assignable +error: Expression 1 is not assignable. ┌─ :13:13 │ 13 │ 1 := i; - │ ^ Expression is not assignable + │ ^ Expression 1 is not assignable. + +error: Invalid call parameters + ┌─ :14:18 + │ +14 │ func(1 := 1); + │ ^^^^^^ Invalid call parameters error: Expression is not assignable ┌─ :14:18 │ 14 │ func(1 := 1); - │ ^ Expression is not assignable + │ ^^^^^^ Expression is not assignable diff --git a/src/validation/tests/snapshots/rusty__validation__tests__statement_validation_tests__bit_access_with_incorrect_operator_causes_warning.snap b/src/validation/tests/snapshots/rusty__validation__tests__statement_validation_tests__bit_access_with_incorrect_operator_causes_warning.snap index a5a87489cc..65699a7a66 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__statement_validation_tests__bit_access_with_incorrect_operator_causes_warning.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__statement_validation_tests__bit_access_with_incorrect_operator_causes_warning.snap @@ -8,10 +8,10 @@ error: Could not resolve reference to n1 12 │ Output.var1.n1 := Input.var1; // bitaccess without %X -> Warning │ ^^ Could not resolve reference to n1 -warning: If you meant to directly access a bit/byte/word/.., use %X/%B/%Wn1 instead. +note: If you meant to directly access a bit/byte/word/..., use %X/%B/%Wn1 instead. ┌─ :12:25 │ 12 │ Output.var1.n1 := Input.var1; // bitaccess without %X -> Warning - │ ^^ If you meant to directly access a bit/byte/word/.., use %X/%B/%Wn1 instead. + │ ^^ If you meant to directly access a bit/byte/word/..., use %X/%B/%Wn1 instead. diff --git a/src/validation/tests/snapshots/rusty__validation__tests__statement_validation_tests__exlicit_param_different_casing.snap b/src/validation/tests/snapshots/rusty__validation__tests__statement_validation_tests__exlicit_param_different_casing.snap new file mode 100644 index 0000000000..e123c05d92 --- /dev/null +++ b/src/validation/tests/snapshots/rusty__validation__tests__statement_validation_tests__exlicit_param_different_casing.snap @@ -0,0 +1,5 @@ +--- +source: src/validation/tests/statement_validation_tests.rs +expression: diagnostics +--- + diff --git a/src/validation/tests/snapshots/rusty__validation__tests__statement_validation_tests__exlicit_param_unknown_reference.snap b/src/validation/tests/snapshots/rusty__validation__tests__statement_validation_tests__exlicit_param_unknown_reference.snap new file mode 100644 index 0000000000..83ec266b63 --- /dev/null +++ b/src/validation/tests/snapshots/rusty__validation__tests__statement_validation_tests__exlicit_param_unknown_reference.snap @@ -0,0 +1,17 @@ +--- +source: src/validation/tests/statement_validation_tests.rs +expression: diagnostics +--- +error: Invalid call parameters + ┌─ :13:16 + │ +13 │ fb(unknown := 2); + │ ^^^^^^^^^^^^ Invalid call parameters + +error: Could not resolve reference to unknown + ┌─ :13:16 + │ +13 │ fb(unknown := 2); + │ ^^^^^^^ Could not resolve reference to unknown + + diff --git a/src/validation/tests/snapshots/rusty__validation__tests__statement_validation_tests__reference_to_reference_assignments_in_function_arguments.snap b/src/validation/tests/snapshots/rusty__validation__tests__statement_validation_tests__reference_to_reference_assignments_in_function_arguments.snap index 02f721f482..2140ecb219 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__statement_validation_tests__reference_to_reference_assignments_in_function_arguments.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__statement_validation_tests__reference_to_reference_assignments_in_function_arguments.snap @@ -2,40 +2,40 @@ source: src/validation/tests/statement_validation_tests.rs expression: "&diagnostics" --- -error: Invalid assignment: cannot assign '__POINTER_TO_INT' to 'REF_TO STRUCT_params' +warning: Pointers REF_TO STRUCT_params and __POINTER_TO_INT have different types ┌─ :47:13 │ 47 │ input1 := REF(global4), - │ ^^^^^^^^^^^^^^^^^^^^^^ Invalid assignment: cannot assign '__POINTER_TO_INT' to 'REF_TO STRUCT_params' + │ ^^^^^^^^^^^^^^^^^^^^^^ Pointers REF_TO STRUCT_params and __POINTER_TO_INT have different types -error: Invalid assignment: cannot assign '__POINTER_TO_REAL' to 'REF_TO STRUCT_params' +warning: Pointers REF_TO STRUCT_params and __POINTER_TO_REAL have different types ┌─ :48:13 │ 48 │ input2 := REF(global5), - │ ^^^^^^^^^^^^^^^^^^^^^^ Invalid assignment: cannot assign '__POINTER_TO_REAL' to 'REF_TO STRUCT_params' + │ ^^^^^^^^^^^^^^^^^^^^^^ Pointers REF_TO STRUCT_params and __POINTER_TO_REAL have different types -error: Invalid assignment: cannot assign '__POINTER_TO_STRING' to 'REF_TO STRUCT_params' +warning: Pointers REF_TO STRUCT_params and __POINTER_TO_STRING have different types ┌─ :49:13 │ 49 │ input3 := REF(global6), - │ ^^^^^^^^^^^^^^^^^^^^^^ Invalid assignment: cannot assign '__POINTER_TO_STRING' to 'REF_TO STRUCT_params' + │ ^^^^^^^^^^^^^^^^^^^^^^ Pointers REF_TO STRUCT_params and __POINTER_TO_STRING have different types -error: Invalid assignment: cannot assign '__POINTER_TO_INT' to 'REF_TO STRUCT_params' +warning: Pointers REF_TO STRUCT_params and __POINTER_TO_INT have different types ┌─ :55:13 │ 55 │ input1 := &(global4), - │ ^^^^^^^^^^^^^^^^^^^^ Invalid assignment: cannot assign '__POINTER_TO_INT' to 'REF_TO STRUCT_params' + │ ^^^^^^^^^^^^^^^^^^^^ Pointers REF_TO STRUCT_params and __POINTER_TO_INT have different types -error: Invalid assignment: cannot assign '__POINTER_TO_REAL' to 'REF_TO STRUCT_params' +warning: Pointers REF_TO STRUCT_params and __POINTER_TO_REAL have different types ┌─ :56:13 │ 56 │ input2 := &(global5), - │ ^^^^^^^^^^^^^^^^^^^^ Invalid assignment: cannot assign '__POINTER_TO_REAL' to 'REF_TO STRUCT_params' + │ ^^^^^^^^^^^^^^^^^^^^ Pointers REF_TO STRUCT_params and __POINTER_TO_REAL have different types -error: Invalid assignment: cannot assign '__POINTER_TO___global_global6' to 'REF_TO STRUCT_params' +warning: Pointers REF_TO STRUCT_params and __POINTER_TO___global_global6 have different types ┌─ :57:13 │ 57 │ input3 := &(global6), - │ ^^^^^^^^^^^^^^^^^^^^ Invalid assignment: cannot assign '__POINTER_TO___global_global6' to 'REF_TO STRUCT_params' + │ ^^^^^^^^^^^^^^^^^^^^ Pointers REF_TO STRUCT_params and __POINTER_TO___global_global6 have different types diff --git a/src/validation/tests/snapshots/rusty__validation__tests__statement_validation_tests__switch_case_duplicate_integer_non_const_var_reference.snap b/src/validation/tests/snapshots/rusty__validation__tests__statement_validation_tests__switch_case_duplicate_integer_non_const_var_reference.snap index 8df7a6e3df..31a2d2b32f 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__statement_validation_tests__switch_case_duplicate_integer_non_const_var_reference.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__statement_validation_tests__switch_case_duplicate_integer_non_const_var_reference.snap @@ -2,28 +2,28 @@ source: src/validation/tests/statement_validation_tests.rs expression: "&diagnostics" --- -error: 'x' is no const reference. Non constant variables are not supported in case conditions +error: `x` is no const reference. Non constant variables are not supported in case conditions ┌─ :14:17 │ 14 │ x: // x is no constant => error - │ ^ 'x' is no const reference. Non constant variables are not supported in case conditions + │ ^ `x` is no const reference. Non constant variables are not supported in case conditions -error: 'y' is no const reference. Non constant variables are not supported in case conditions +error: `y` is no const reference. Non constant variables are not supported in case conditions ┌─ :16:17 │ 16 │ y: // y is no constant => error - │ ^ 'y' is no const reference. Non constant variables are not supported in case conditions + │ ^ `y` is no const reference. Non constant variables are not supported in case conditions -error: 'x' is no const reference. Non constant variables are not supported in case conditions +error: `x` is no const reference. Non constant variables are not supported in case conditions ┌─ :18:17 │ 18 │ 2+x: // x is no constant => error - │ ^^^ 'x' is no const reference. Non constant variables are not supported in case conditions + │ ^^^ `x` is no const reference. Non constant variables are not supported in case conditions -error: 'x' is no const reference. Non constant variables are not supported in case conditions +error: `x` is no const reference. Non constant variables are not supported in case conditions ┌─ :22:17 │ 22 │ CONST+x: // x is no constant => error - │ ^^^^^^^ 'x' is no const reference. Non constant variables are not supported in case conditions + │ ^^^^^^^ `x` is no const reference. Non constant variables are not supported in case conditions diff --git a/src/validation/tests/snapshots/rusty__validation__tests__variable_length_array_test__builtins__builtins_called_with_invalid_index.snap b/src/validation/tests/snapshots/rusty__validation__tests__variable_length_array_test__builtins__builtins_called_with_invalid_index.snap index 612d36a31c..27f71a652d 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__variable_length_array_test__builtins__builtins_called_with_invalid_index.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__variable_length_array_test__builtins__builtins_called_with_invalid_index.snap @@ -2,40 +2,40 @@ source: src/validation/tests/variable_length_array_test.rs expression: diagnostics --- -error: Invalid type nature for generic argument. REAL is no Int. +error: Invalid type nature for generic argument. REAL is no ANY_INT ┌─ :18:30 │ 18 │ LOWER_BOUND(vla, 3.1415); // invalid - │ ^^^^^^ Invalid type nature for generic argument. REAL is no Int. + │ ^^^^^^ Invalid type nature for generic argument. REAL is no ANY_INT -error: Invalid type nature for generic argument. TIME is no Int. +error: Invalid type nature for generic argument. TIME is no ANY_INT ┌─ :19:30 │ 19 │ LOWER_BOUND(vla, TIME#3s); // invalid - │ ^^^^^^^ Invalid type nature for generic argument. TIME is no Int. + │ ^^^^^^^ Invalid type nature for generic argument. TIME is no ANY_INT -error: Index out of bounds. +error: Index out of bound ┌─ :20:13 │ 20 │ LOWER_BOUND(vla, 0); // index out of bounds - │ ^^^^^^^^^^^ Index out of bounds. + │ ^^^^^^^^^^^ Index out of bound -error: Invalid type nature for generic argument. REAL is no Int. +error: Invalid type nature for generic argument. REAL is no ANY_INT ┌─ :22:30 │ 22 │ UPPER_BOUND(vla, 3.1415); // invalid - │ ^^^^^^ Invalid type nature for generic argument. REAL is no Int. + │ ^^^^^^ Invalid type nature for generic argument. REAL is no ANY_INT -error: Invalid type nature for generic argument. TIME is no Int. +error: Invalid type nature for generic argument. TIME is no ANY_INT ┌─ :23:30 │ 23 │ UPPER_BOUND(vla, TIME#3s); // invalid - │ ^^^^^^^ Invalid type nature for generic argument. TIME is no Int. + │ ^^^^^^^ Invalid type nature for generic argument. TIME is no ANY_INT -error: Index out of bounds. +error: Index out of bound ┌─ :24:13 │ 24 │ UPPER_BOUND(vla, 0); // index out of bounds - │ ^^^^^^^^^^^ Index out of bounds. + │ ^^^^^^^^^^^ Index out of bound diff --git a/src/validation/tests/snapshots/rusty__validation__tests__variable_validation_tests__overflows__overflows_with_aliases.snap b/src/validation/tests/snapshots/rusty__validation__tests__variable_validation_tests__overflows__overflows_with_aliases.snap index ff7e700c1a..97d2183a99 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__variable_validation_tests__overflows__overflows_with_aliases.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__variable_validation_tests__overflows__overflows_with_aliases.snap @@ -2,19 +2,19 @@ source: src/validation/tests/variable_validation_tests.rs expression: diagnostics --- -error: This will overflow for type INT +warning: This will overflow for type INT ┌─ :2:36 │ 2 │ TYPE MyINT : INT := 60000; END_TYPE │ ^^^^^ This will overflow for type INT -error: This will overflow for type REAL +warning: This will overflow for type REAL ┌─ :3:36 │ 3 │ TYPE MyREAL : REAL := 3.50282347E+38; END_TYPE │ ^^^^^^^^^^^^^^ This will overflow for type REAL -error: This will overflow for type LREAL +warning: This will overflow for type LREAL ┌─ :4:36 │ 4 │ TYPE MyLREAL : LREAL := 1.8076931348623157E+308; END_TYPE diff --git a/src/validation/tests/snapshots/rusty__validation__tests__variable_validation_tests__overflows__overflows_with_array_initializer.snap b/src/validation/tests/snapshots/rusty__validation__tests__variable_validation_tests__overflows__overflows_with_array_initializer.snap index c8bf4d92c2..dfe9777605 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__variable_validation_tests__overflows__overflows_with_array_initializer.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__variable_validation_tests__overflows__overflows_with_array_initializer.snap @@ -2,7 +2,7 @@ source: src/validation/tests/variable_validation_tests.rs expression: diagnostics --- -error: This will overflow for type UINT +warning: This will overflow for type UINT ┌─ :3:46 │ 3 │ arr : ARRAY[0..5] OF UINT := [0, -1, -2, -3, -4, -5]; diff --git a/src/validation/tests/snapshots/rusty__validation__tests__variable_validation_tests__overflows__overflows_with_constants.snap b/src/validation/tests/snapshots/rusty__validation__tests__variable_validation_tests__overflows__overflows_with_constants.snap index 5bf1340851..3606e01936 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__variable_validation_tests__overflows__overflows_with_constants.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__variable_validation_tests__overflows__overflows_with_constants.snap @@ -2,7 +2,7 @@ source: src/validation/tests/variable_validation_tests.rs expression: diagnostics --- -error: This will overflow for type INT +warning: This will overflow for type INT ┌─ :3:24 │ 3 │ a : INT := 16384; // OK diff --git a/src/validation/tests/snapshots/rusty__validation__tests__variable_validation_tests__overflows__overflows_with_expressions.snap b/src/validation/tests/snapshots/rusty__validation__tests__variable_validation_tests__overflows__overflows_with_expressions.snap index 1e07e18ae3..526736e278 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__variable_validation_tests__overflows__overflows_with_expressions.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__variable_validation_tests__overflows__overflows_with_expressions.snap @@ -2,121 +2,121 @@ source: src/validation/tests/variable_validation_tests.rs expression: diagnostics --- -error: This will overflow for type SINT +warning: This will overflow for type SINT ┌─ :5:42 │ 5 │ min_sint : SINT := ((-128 * 1) * 2); // -128 │ ^^^^^^^^^^^^^ This will overflow for type SINT -error: This will overflow for type SINT +warning: This will overflow for type SINT ┌─ :6:43 │ 6 │ max_sint : SINT := ((127 * 1) * 2); // 127 │ ^^^^^^^^^^^^ This will overflow for type SINT -error: This will overflow for type USINT +warning: This will overflow for type USINT ┌─ :7:43 │ 7 │ min_usint : USINT := ((1 * 1) * -2); // 0 │ ^^^^^^^^^^^ This will overflow for type USINT -error: This will overflow for type USINT +warning: This will overflow for type USINT ┌─ :8:43 │ 8 │ max_usint : USINT := ((256 * 1) * 2); // 256 │ ^^^^^^^^^^^^ This will overflow for type USINT -error: This will overflow for type INT +warning: This will overflow for type INT ┌─ :11:41 │ 11 │ min_int : INT := ((-32_768 * 1) * 2); // -32768 │ ^^^^^^^^^^^^^^^^ This will overflow for type INT -error: This will overflow for type INT +warning: This will overflow for type INT ┌─ :12:42 │ 12 │ max_int : INT := ((32_767 * 1) * 2); // 32767 │ ^^^^^^^^^^^^^^^ This will overflow for type INT -error: This will overflow for type UINT +warning: This will overflow for type UINT ┌─ :13:42 │ 13 │ min_uint : UINT := ((1 * 1) * -2); // 0 │ ^^^^^^^^^^^ This will overflow for type UINT -error: This will overflow for type UINT +warning: This will overflow for type UINT ┌─ :14:42 │ 14 │ max_uint : UINT := ((65_536 * 1) * 2); // 65536 │ ^^^^^^^^^^^^^^^ This will overflow for type UINT -error: This will overflow for type DINT +warning: This will overflow for type DINT ┌─ :17:42 │ 17 │ min_dint : DINT := ((-2_147_483_649 * 1) * 2); // -2_147_483_648 │ ^^^^^^^^^^^^^^^^^^^^^^^ This will overflow for type DINT -error: This will overflow for type DINT +warning: This will overflow for type DINT ┌─ :18:43 │ 18 │ max_dint : DINT := (( 2_147_483_648 * 1) * 2); // 2_147_483_647 │ ^^^^^^^^^^^^^^^^^^^^^^ This will overflow for type DINT -error: This will overflow for type UDINT +warning: This will overflow for type UDINT ┌─ :19:43 │ 19 │ min_udint : UDINT := ((1 * 1) * -2); // 0 │ ^^^^^^^^^^^ This will overflow for type UDINT -error: This will overflow for type UDINT +warning: This will overflow for type UDINT ┌─ :20:43 │ 20 │ max_udint : UDINT := ((4_294_967_296 * 1) * 2); // 4_294_967_296 │ ^^^^^^^^^^^^^^^^^^^^^^ This will overflow for type UDINT -error: This will overflow for type LINT +warning: This will overflow for type LINT ┌─ :23:42 │ 23 │ min_lint : LINT := ((-9_223_372_036_854_775_808 * 1) * 2); // -9_223_372_036_854_775_808 │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ This will overflow for type LINT -error: This will overflow for type LINT +warning: This will overflow for type LINT ┌─ :24:43 │ 24 │ max_lint : LINT := (( 9_223_372_036_854_775_807 * 1) * 2); // 9_223_372_036_854_775_807 │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ This will overflow for type LINT -error: This will overflow for type ULINT +warning: This will overflow for type ULINT ┌─ :25:43 │ 25 │ min_ulint : ULINT := ((1 * 1) * -2); // 0 │ ^^^^^^^^^^^ This will overflow for type ULINT -error: This will overflow for type ULINT +warning: This will overflow for type ULINT ┌─ :26:43 │ 26 │ max_ulint : ULINT := ((18_446_744_073_709_551_615 * 1) * 2); // 18_446_744_073_709_551_615 │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ This will overflow for type ULINT -error: This will overflow for type REAL +warning: This will overflow for type REAL ┌─ :29:39 │ 29 │ min_real : REAL := ((-3.40282347E+38 * 1) * 2); // -3.40282347E+38 │ ^^^^^^^^^^^^^^^^^^^^^^^ This will overflow for type REAL -error: This will overflow for type REAL +warning: This will overflow for type REAL ┌─ :30:39 │ 30 │ max_real : REAL := (( 3.40282347E+38 * 1) * 2); // 3.40282347E+38 │ ^^^^^^^^^^^^^^^^^^^^^^^ This will overflow for type REAL -error: This will overflow for type LREAL +warning: This will overflow for type LREAL ┌─ :33:41 │ 33 │ min_lreal : LREAL := ((-1.7976931348623157E+308 * 1) * 2); // -1.7976931348623157E+308 │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ This will overflow for type LREAL -error: This will overflow for type LREAL +warning: This will overflow for type LREAL ┌─ :34:41 │ 34 │ max_lreal : LREAL := (( 1.7976931348623157E+308 * 1) * 2); // 1.7976931348623157E+308 diff --git a/src/validation/tests/snapshots/rusty__validation__tests__variable_validation_tests__overflows__overflows_with_globals.snap b/src/validation/tests/snapshots/rusty__validation__tests__variable_validation_tests__overflows__overflows_with_globals.snap index 016a72b4bd..d425ff3907 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__variable_validation_tests__overflows__overflows_with_globals.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__variable_validation_tests__overflows__overflows_with_globals.snap @@ -2,13 +2,13 @@ source: src/validation/tests/variable_validation_tests.rs expression: diagnostics --- -error: This will overflow for type INT +warning: This will overflow for type INT ┌─ :3:24 │ 3 │ a : INT := 32768; │ ^^^^^ This will overflow for type INT -error: This will overflow for type INT +warning: This will overflow for type INT ┌─ :4:24 │ 4 │ b : INT := 32767 + 1; diff --git a/src/validation/tests/snapshots/rusty__validation__tests__variable_validation_tests__overflows__overflows_with_hex.snap b/src/validation/tests/snapshots/rusty__validation__tests__variable_validation_tests__overflows__overflows_with_hex.snap index 050a07db6d..05c95853e0 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__variable_validation_tests__overflows__overflows_with_hex.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__variable_validation_tests__overflows__overflows_with_hex.snap @@ -2,7 +2,7 @@ source: src/validation/tests/variable_validation_tests.rs expression: diagnostics --- -error: This will overflow for type WORD +warning: This will overflow for type WORD ┌─ :4:30 │ 4 │ y : UINT := WORD#16#fffff; // Not OK, should have been `ffff` not `ffff_f_` diff --git a/src/validation/tests/snapshots/rusty__validation__tests__variable_validation_tests__overflows__overflows_with_literals.snap b/src/validation/tests/snapshots/rusty__validation__tests__variable_validation_tests__overflows__overflows_with_literals.snap index 66e6072599..5fe9f83b9d 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__variable_validation_tests__overflows__overflows_with_literals.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__variable_validation_tests__overflows__overflows_with_literals.snap @@ -2,121 +2,121 @@ source: src/validation/tests/variable_validation_tests.rs expression: diagnostics --- -error: This will overflow for type SINT +warning: This will overflow for type SINT ┌─ :5:40 │ 5 │ min_sint : SINT := -129; // -128 │ ^^^^ This will overflow for type SINT -error: This will overflow for type SINT +warning: This will overflow for type SINT ┌─ :6:41 │ 6 │ max_sint : SINT := 128; // 127 │ ^^^ This will overflow for type SINT -error: This will overflow for type USINT +warning: This will overflow for type USINT ┌─ :7:41 │ 7 │ min_usint : USINT := -1; // 0 │ ^^ This will overflow for type USINT -error: This will overflow for type USINT +warning: This will overflow for type USINT ┌─ :8:41 │ 8 │ max_usint : USINT := 257; // 256 │ ^^^ This will overflow for type USINT -error: This will overflow for type INT +warning: This will overflow for type INT ┌─ :11:39 │ 11 │ min_int : INT := -32_769; // -32768 │ ^^^^^^^ This will overflow for type INT -error: This will overflow for type INT +warning: This will overflow for type INT ┌─ :12:39 │ 12 │ max_int : INT := 32_768; // 32767 │ ^^^^^^ This will overflow for type INT -error: This will overflow for type UINT +warning: This will overflow for type UINT ┌─ :13:40 │ 13 │ min_uint : UINT := -1; // 0 │ ^^ This will overflow for type UINT -error: This will overflow for type UINT +warning: This will overflow for type UINT ┌─ :14:40 │ 14 │ max_uint : UINT := 65_537; // 65536 │ ^^^^^^ This will overflow for type UINT -error: This will overflow for type DINT +warning: This will overflow for type DINT ┌─ :17:40 │ 17 │ min_dint : DINT := -2_147_483_649; // -2_147_483_648 │ ^^^^^^^^^^^^^^ This will overflow for type DINT -error: This will overflow for type DINT +warning: This will overflow for type DINT ┌─ :18:41 │ 18 │ max_dint : DINT := 2_147_483_648; // 2_147_483_647 │ ^^^^^^^^^^^^^ This will overflow for type DINT -error: This will overflow for type UDINT +warning: This will overflow for type UDINT ┌─ :19:41 │ 19 │ min_udint : UDINT := -1; // 0 │ ^^ This will overflow for type UDINT -error: This will overflow for type UDINT +warning: This will overflow for type UDINT ┌─ :20:41 │ 20 │ max_udint : UDINT := 4_294_967_296; // 4_294_967_296 │ ^^^^^^^^^^^^^ This will overflow for type UDINT -error: This will overflow for type LINT +warning: This will overflow for type LINT ┌─ :23:40 │ 23 │ min_lint : LINT := -9_223_372_036_854_775_809; // -9_223_372_036_854_775_808 │ ^^^^^^^^^^^^^^^^^^^^^^^^^^ This will overflow for type LINT -error: This will overflow for type LINT +warning: This will overflow for type LINT ┌─ :24:41 │ 24 │ max_lint : LINT := 9_223_372_036_854_775_808; // 9_223_372_036_854_775_807 │ ^^^^^^^^^^^^^^^^^^^^^^^^^ This will overflow for type LINT -error: This will overflow for type ULINT +warning: This will overflow for type ULINT ┌─ :25:41 │ 25 │ min_ulint : ULINT := -1; // 0 │ ^^ This will overflow for type ULINT -error: This will overflow for type ULINT +warning: This will overflow for type ULINT ┌─ :26:41 │ 26 │ max_ulint : ULINT := 18_446_744_073_709_551_616; // 18_446_744_073_709_551_615 │ ^^^^^^^^^^^^^^^^^^^^^^^^^^ This will overflow for type ULINT -error: This will overflow for type REAL +warning: This will overflow for type REAL ┌─ :29:37 │ 29 │ min_real : REAL := -3.50282347E+38; // -3.40282347E+38 │ ^^^^^^^^^^^^^^ This will overflow for type REAL -error: This will overflow for type REAL +warning: This will overflow for type REAL ┌─ :30:37 │ 30 │ max_real : REAL := 3.50282347E+38; // 3.40282347E+38 │ ^^^^^^^^^^^^^^ This will overflow for type REAL -error: This will overflow for type LREAL +warning: This will overflow for type LREAL ┌─ :33:39 │ 33 │ min_lreal : LREAL := -1.8076931348623157E+308; // -1.7976931348623157E+308 │ ^^^^^^^^^^^^^^^^^^^^^^^ This will overflow for type LREAL -error: This will overflow for type LREAL +warning: This will overflow for type LREAL ┌─ :34:39 │ 34 │ max_lreal : LREAL := 1.8076931348623157E+308; // 1.7976931348623157E+308 diff --git a/src/validation/tests/snapshots/rusty__validation__tests__variable_validation_tests__overflows__overflows_with_non_global_constants.snap b/src/validation/tests/snapshots/rusty__validation__tests__variable_validation_tests__overflows__overflows_with_non_global_constants.snap index a3aaa4c797..0562d0845b 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__variable_validation_tests__overflows__overflows_with_non_global_constants.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__variable_validation_tests__overflows__overflows_with_non_global_constants.snap @@ -2,10 +2,10 @@ source: src/validation/tests/variable_validation_tests.rs expression: diagnostics --- -error: Unresolved constant 'c' variable: 'a' is no const reference +error: Unresolved constant `c` variable: `a` is no const reference ┌─ :5:24 │ 5 │ c : INT := a + b; // Will overflow - │ ^^^^^ Unresolved constant 'c' variable: 'a' is no const reference + │ ^^^^^ Unresolved constant `c` variable: `a` is no const reference diff --git a/src/validation/tests/snapshots/rusty__validation__tests__variable_validation_tests__overflows__overflows_with_not.snap b/src/validation/tests/snapshots/rusty__validation__tests__variable_validation_tests__overflows__overflows_with_not.snap index b90dff4b55..7363377e46 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__variable_validation_tests__overflows__overflows_with_not.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__variable_validation_tests__overflows__overflows_with_not.snap @@ -2,7 +2,7 @@ source: src/validation/tests/variable_validation_tests.rs expression: diagnostics --- -error: This will overflow for type UINT +warning: This will overflow for type UINT ┌─ :4:25 │ 4 │ y : UINT := NOT -1234; // Not OK (because of -1234) diff --git a/src/validation/tests/snapshots/rusty__validation__tests__variable_validation_tests__sized_varargs_require_type.snap b/src/validation/tests/snapshots/rusty__validation__tests__variable_validation_tests__sized_varargs_require_type.snap index b67da5750b..e30a8b54cf 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__variable_validation_tests__sized_varargs_require_type.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__variable_validation_tests__sized_varargs_require_type.snap @@ -2,10 +2,10 @@ source: src/validation/tests/variable_validation_tests.rs expression: "&diagnostics" --- -error: Missing datatype : Sized Variadics require a known datatype. +error: Missing datatype: Sized Variadics require a known datatype. ┌─ :5:27 │ 5 │ args : {sized}...; - │ ^^^ Missing datatype : Sized Variadics require a known datatype. + │ ^^^ Missing datatype: Sized Variadics require a known datatype. diff --git a/src/validation/tests/snapshots/rusty__validation__tests__variable_validation_tests__unresolvable_variables_are_reported.snap b/src/validation/tests/snapshots/rusty__validation__tests__variable_validation_tests__unresolvable_variables_are_reported.snap index eb5d88255b..a6bae808c1 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__variable_validation_tests__unresolvable_variables_are_reported.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__variable_validation_tests__unresolvable_variables_are_reported.snap @@ -2,11 +2,11 @@ source: src/validation/tests/variable_validation_tests.rs expression: "&diagnostics" --- -error: Unresolved constant 'cx' variable +error: Unresolved constant `cx` variable ┌─ :19:29 │ 19 │ cx : INT := cx; //unresolvable - │ ^^ Unresolved constant 'cx' variable + │ ^^ Unresolved constant `cx` variable error: Could not resolve reference to a ┌─ :21:30 @@ -14,10 +14,10 @@ error: Could not resolve reference to a 21 │ cai : INT := a; //unresolvable │ ^ Could not resolve reference to a -error: Unresolved constant 'cai' variable +error: Unresolved constant `cai` variable ┌─ :21:30 │ 21 │ cai : INT := a; //unresolvable - │ ^ Unresolved constant 'cai' variable + │ ^ Unresolved constant `cai` variable diff --git a/src/validation/tests/statement_validation_tests.rs b/src/validation/tests/statement_validation_tests.rs index 5b908ae3e7..a5ee7f4398 100644 --- a/src/validation/tests/statement_validation_tests.rs +++ b/src/validation/tests/statement_validation_tests.rs @@ -847,6 +847,58 @@ fn validate_call_by_ref_explicit() { assert_snapshot!(&diagnostics); } +#[test] +fn exlicit_param_unknown_reference() { + let diagnostics = parse_and_validate_buffered( + " + FUNCTION_BLOCK func + VAR_INPUT + byValInput : INT; + END_VAR + END_FUNCTION_BLOCK + + PROGRAM main + VAR + fb: func; + END_VAR + + fb(unknown := 2); + fb(byVALInput := 2); //different case but valid + fb(byValInput := 2); //valid + + END_PROGRAM + ", + ); + assert_snapshot!(diagnostics) +} + +#[test] +fn exlicit_param_different_casing() { + let diagnostics = parse_and_validate_buffered( + " + FUNCTION_BLOCK func + VAR_INPUT + IN : INT; + IN2 : INT; + END_VAR + END_FUNCTION_BLOCK + + PROGRAM main + VAR + fb: func; + END_VAR + + fb(in := 2); + fb(in := 2, IN2 := 3); + fb(IN := 2, in2 := 3); + fb(in := 2, in2 := 3); + END_PROGRAM + ", + ); + + assert_snapshot!(diagnostics) +} + #[test] fn implicit_param_downcast_in_function_call() { let diagnostics = parse_and_validate_buffered( diff --git a/src/validation/types.rs b/src/validation/types.rs index af27651df1..99c6ac4c51 100644 --- a/src/validation/types.rs +++ b/src/validation/types.rs @@ -47,21 +47,28 @@ fn validate_data_type(validator: &mut Validator, data_type: &DataType, location: match data_type { DataType::StructType { variables, .. } => { if variables.is_empty() { - validator.push_diagnostic(Diagnostic::empty_variable_block(location.clone())); + validator.push_diagnostic( + Diagnostic::error("Variable block is empty") + .with_error_code("E028") + .with_location(location.clone()), + ); } } DataType::EnumType { elements: AstNode { stmt: AstStatement::ExpressionList(expressions), .. }, .. } if expressions.is_empty() => { - validator.push_diagnostic(Diagnostic::empty_variable_block(location.clone())); - } - DataType::VarArgs { referenced_type: None, sized: true } => { - validator.push_diagnostic(Diagnostic::missing_datatype( - Some(": Sized Variadics require a known datatype."), - location.clone(), - )) + validator.push_diagnostic( + Diagnostic::error("Variable block is empty") + .with_error_code("E028") + .with_location(location.clone()), + ); } + DataType::VarArgs { referenced_type: None, sized: true } => validator.push_diagnostic( + Diagnostic::error("Missing datatype: Sized Variadics require a known datatype.") + .with_error_code("E038") + .with_location(location.clone()), + ), _ => {} } } diff --git a/src/validation/variable.rs b/src/validation/variable.rs index 85f499906d..080146d44b 100644 --- a/src/validation/variable.rs +++ b/src/validation/variable.rs @@ -33,7 +33,11 @@ fn validate_variable_block(validator: &mut Validator, block: &VariableBlock) { if block.constant && !matches!(block.variable_block_type, VariableBlockType::Global | VariableBlockType::Local) { - validator.push_diagnostic(Diagnostic::invalid_constant_block(block.location.clone())) + validator.push_diagnostic( + Diagnostic::error("This variable block does not support the CONSTANT modifier") + .with_error_code("E034") + .with_location(block.location.clone()), + ) } } @@ -52,25 +56,31 @@ pub fn visit_variable( /// - InOut within Function-Block fn validate_vla(validator: &mut Validator, pou: Option<&Pou>, block: &VariableBlock, variable: &Variable) { let Some(pou) = pou else { + if matches!(block.variable_block_type, VariableBlockType::Global) { - validator.push_diagnostic(Diagnostic::invalid_vla_container( - "VLAs can not be defined as global variables".to_string(), - variable.location.clone(), - )) + validator.push_diagnostic(Diagnostic::error("VLAs can not be defined as global variables") + .with_error_code("E044") + .with_location( variable.location.clone()) + ) } return; }; match (&pou.pou_type, block.variable_block_type) { - (PouType::Function, VariableBlockType::Input(ArgumentProperty::ByVal)) => { - validator.push_diagnostic(Diagnostic::vla_by_val_warning(variable.location.clone())) - } - - (PouType::Program, _) => validator.push_diagnostic(Diagnostic::invalid_vla_container( - "Variable Length Arrays are not allowed to be defined inside a Program".to_string(), - variable.location.clone(), - )), + (PouType::Function, VariableBlockType::Input(ArgumentProperty::ByVal)) => validator.push_diagnostic( + Diagnostic::warning( + "Variable Length Arrays are always by-ref, even when declared in a by-value block", + ) + .with_error_code("E047") + .with_location(variable.location.clone()), + ), + + (PouType::Program, _) => validator.push_diagnostic( + Diagnostic::error("Variable Length Arrays are not allowed to be defined inside a Program") + .with_error_code("E044") + .with_location(variable.location.clone()), + ), ( PouType::Function | PouType::Method { .. }, @@ -80,13 +90,14 @@ fn validate_vla(validator: &mut Validator, pou: Option<&Pou>, block: &VariableBl ) | (PouType::FunctionBlock, VariableBlockType::InOut) => (), - _ => validator.push_diagnostic(Diagnostic::invalid_vla_container( - format!( + _ => validator.push_diagnostic( + Diagnostic::error(format!( "Variable Length Arrays are not allowed to be defined as {} variables inside a {}", block.variable_block_type, pou.pou_type - ), - variable.location.clone(), - )), + )) + .with_error_code("E044") + .with_location(variable.location.clone()), + ), } } @@ -113,25 +124,29 @@ fn validate_variable( .and_then(|initial_id| context.index.get_const_expressions().find_const_expression(&initial_id)) { Some(ConstExpression::Unresolvable { reason, statement }) if reason.is_misc() => { - validator.push_diagnostic(Diagnostic::unresolved_constant( - variable.name.as_str(), - Some(reason.get_reason()), - statement.get_location(), - )); + validator.push_diagnostic( + Diagnostic::error(format!( + "Unresolved constant `{}` variable: {}", + variable.name.as_str(), + reason.get_reason() + )) + .with_error_code("E033") + .with_location(statement.get_location()), + ); } Some(ConstExpression::Unresolved { statement, .. }) => { - validator.push_diagnostic(Diagnostic::unresolved_constant( - variable.name.as_str(), - None, - statement.get_location(), - )); + validator.push_diagnostic( + Diagnostic::error(format!("Unresolved constant `{}` variable", variable.name.as_str(),)) + .with_error_code("E033") + .with_location(statement.get_location()), + ); } None if v_entry.is_constant() => { - validator.push_diagnostic(Diagnostic::unresolved_constant( - variable.name.as_str(), - None, - variable.location.clone(), - )); + validator.push_diagnostic( + Diagnostic::error(format!("Unresolved constant `{}` variable", variable.name.as_str(),)) + .with_error_code("E033") + .with_location(variable.location.clone()), + ); } _ => { if let Some(rhs) = variable.initializer.as_ref() { @@ -152,8 +167,14 @@ fn validate_variable( // check if we declared a constant fb-instance or class-instance if v_entry.is_constant() && data_type_is_fb_or_class_instance(v_entry.get_type_name(), context.index) { - validator - .push_diagnostic(Diagnostic::invalid_constant(v_entry.get_name(), variable.location.clone())); + validator.push_diagnostic( + Diagnostic::error(format!( + "Invalid constant {} - Functionblock- and Class-instances cannot be delcared constant", + v_entry.get_name() + )) + .with_error_code("E035") + .with_location(variable.location.clone()), + ); } } } diff --git a/tests/correctness/arithmetic_functions/multiplication.rs b/tests/correctness/arithmetic_functions/multiplication.rs index 9e22ce2db6..eefb5c2370 100644 --- a/tests/correctness/arithmetic_functions/multiplication.rs +++ b/tests/correctness/arithmetic_functions/multiplication.rs @@ -14,7 +14,7 @@ fn mul_with_ints() { END_FUNCTION "#; - let expected = 1 * 2 * 3 * 4 * 1000 * 5; + let expected = 2 * 3 * 4 * 1000 * 5; let res: i64 = compile_and_run_no_params(prog.to_string()); assert_eq!(expected, res); } diff --git a/tests/correctness/comparison_functions/equal.rs b/tests/correctness/comparison_functions/equal.rs index f255fcdab7..668b47d9cb 100644 --- a/tests/correctness/comparison_functions/equal.rs +++ b/tests/correctness/comparison_functions/equal.rs @@ -17,7 +17,7 @@ fn builtin_eq_with_ints_monotonic() { let mut main = MainType::default(); let res: bool = compile_and_run(prog.to_string(), &mut main); - assert_eq!(res, true); + assert!(res); } #[test] @@ -37,7 +37,7 @@ fn builtin_eq_with_ints() { let mut main = MainType::default(); let res: bool = compile_and_run(prog.to_string(), &mut main); - assert_eq!(res, false); + assert!(!res); } #[test] @@ -57,7 +57,7 @@ fn builtin_eq_with_floats_monotonic() { let mut main = MainType::default(); let res: bool = compile_and_run(prog.to_string(), &mut main); - assert_eq!(res, true); + assert!(res); } #[test] @@ -77,7 +77,7 @@ fn builtin_eq_with_floats() { let mut main = MainType::default(); let res: bool = compile_and_run(prog.to_string(), &mut main); - assert_eq!(res, false); + assert!(!res); } #[test] @@ -98,5 +98,5 @@ fn builtin_eq_with_mixed_ints_and_floats() { let mut main = MainType::default(); let res: bool = compile_and_run(prog.to_string(), &mut main); - assert_eq!(res, false); + assert!(!res); } diff --git a/tests/correctness/comparison_functions/greater_than.rs b/tests/correctness/comparison_functions/greater_than.rs index 040a6cb71c..b9ac5a6a61 100644 --- a/tests/correctness/comparison_functions/greater_than.rs +++ b/tests/correctness/comparison_functions/greater_than.rs @@ -17,7 +17,7 @@ fn builtin_gt_with_ints_descending() { let mut main = MainType::default(); let res: bool = compile_and_run(prog.to_string(), &mut main); - assert_eq!(res, true); + assert!(res); } #[test] @@ -37,7 +37,7 @@ fn builtin_gt_with_ints() { let mut main = MainType::default(); let res: bool = compile_and_run(prog.to_string(), &mut main); - assert_eq!(res, false); + assert!(!res); } #[test] @@ -57,7 +57,7 @@ fn builtin_gt_with_floats_descending() { let mut main = MainType::default(); let res: bool = compile_and_run(prog.to_string(), &mut main); - assert_eq!(res, true); + assert!(res); } #[test] @@ -77,7 +77,7 @@ fn builtin_gt_with_floats() { let mut main = MainType::default(); let res: bool = compile_and_run(prog.to_string(), &mut main); - assert_eq!(res, false); + assert!(!res); } #[test] @@ -98,5 +98,5 @@ fn builtin_gt_with_mixed_ints_and_floats() { let mut main = MainType::default(); let res: bool = compile_and_run(prog.to_string(), &mut main); - assert_eq!(res, true); + assert!(res); } diff --git a/tests/correctness/comparison_functions/greater_than_or_equal.rs b/tests/correctness/comparison_functions/greater_than_or_equal.rs index 6033a9bd57..8c008c3456 100644 --- a/tests/correctness/comparison_functions/greater_than_or_equal.rs +++ b/tests/correctness/comparison_functions/greater_than_or_equal.rs @@ -17,7 +17,7 @@ fn builtin_ge_with_ints_monotonic() { let mut main = MainType::default(); let res: bool = compile_and_run(prog.to_string(), &mut main); - assert_eq!(res, true); + assert!(res); } #[test] @@ -37,7 +37,7 @@ fn builtin_ge_with_ints() { let mut main = MainType::default(); let res: bool = compile_and_run(prog.to_string(), &mut main); - assert_eq!(res, false); + assert!(!res); } #[test] @@ -57,7 +57,7 @@ fn builtin_ge_with_floats_monotonic() { let mut main = MainType::default(); let res: bool = compile_and_run(prog.to_string(), &mut main); - assert_eq!(res, true); + assert!(res); } #[test] @@ -77,7 +77,7 @@ fn builtin_ge_with_floats() { let mut main = MainType::default(); let res: bool = compile_and_run(prog.to_string(), &mut main); - assert_eq!(res, false); + assert!(!res); } #[test] @@ -98,5 +98,5 @@ fn builtin_ge_with_mixed_ints_and_floats() { let mut main = MainType::default(); let res: bool = compile_and_run(prog.to_string(), &mut main); - assert_eq!(res, true); + assert!(res); } diff --git a/tests/correctness/comparison_functions/less_than.rs b/tests/correctness/comparison_functions/less_than.rs index f09b86baec..7dbac04617 100644 --- a/tests/correctness/comparison_functions/less_than.rs +++ b/tests/correctness/comparison_functions/less_than.rs @@ -17,7 +17,7 @@ fn builtin_lt_with_ints_monotonic() { let mut main = MainType::default(); let res: bool = compile_and_run(prog.to_string(), &mut main); - assert_eq!(res, false); + assert!(!res); } #[test] @@ -37,7 +37,7 @@ fn builtin_lt_with_ints() { let mut main = MainType::default(); let res: bool = compile_and_run(prog.to_string(), &mut main); - assert_eq!(res, false); + assert!(!res); } #[test] @@ -57,7 +57,7 @@ fn builtin_lt_with_floats_monotonic() { let mut main = MainType::default(); let res: bool = compile_and_run(prog.to_string(), &mut main); - assert_eq!(res, false); + assert!(!res); } #[test] @@ -77,7 +77,7 @@ fn builtin_lt_with_floats() { let mut main = MainType::default(); let res: bool = compile_and_run(prog.to_string(), &mut main); - assert_eq!(res, false); + assert!(!res); } #[test] @@ -98,5 +98,5 @@ fn builtin_lt_with_mixed_ints_and_floats() { let mut main = MainType::default(); let res: bool = compile_and_run(prog.to_string(), &mut main); - assert_eq!(res, false); + assert!(!res); } diff --git a/tests/correctness/comparison_functions/less_than_or_equal.rs b/tests/correctness/comparison_functions/less_than_or_equal.rs index c9b2af6e4a..5bc1743ad2 100644 --- a/tests/correctness/comparison_functions/less_than_or_equal.rs +++ b/tests/correctness/comparison_functions/less_than_or_equal.rs @@ -17,7 +17,7 @@ fn builtin_le_with_ints_monotonic() { let mut main = MainType::default(); let res: bool = compile_and_run(prog.to_string(), &mut main); - assert_eq!(res, true); + assert!(res); } #[test] @@ -37,7 +37,7 @@ fn builtin_le_with_ints() { let mut main = MainType::default(); let res: bool = compile_and_run(prog.to_string(), &mut main); - assert_eq!(res, false); + assert!(!res); } #[test] @@ -57,7 +57,7 @@ fn builtin_le_with_floats_monotonic() { let mut main = MainType::default(); let res: bool = compile_and_run(prog.to_string(), &mut main); - assert_eq!(res, true); + assert!(res); } #[test] @@ -77,7 +77,7 @@ fn builtin_le_with_floats() { let mut main = MainType::default(); let res: bool = compile_and_run(prog.to_string(), &mut main); - assert_eq!(res, false); + assert!(!res); } #[test] @@ -98,5 +98,5 @@ fn builtin_le_with_mixed_ints_and_floats() { let mut main = MainType::default(); let res: bool = compile_and_run(prog.to_string(), &mut main); - assert_eq!(res, false); + assert!(!res); } diff --git a/tests/correctness/comparison_functions/not_equal.rs b/tests/correctness/comparison_functions/not_equal.rs index bf9b243f1a..c1459eace7 100644 --- a/tests/correctness/comparison_functions/not_equal.rs +++ b/tests/correctness/comparison_functions/not_equal.rs @@ -17,7 +17,7 @@ fn builtin_ne_with_ints_monotonic() { let mut main = MainType::default(); let res: bool = compile_and_run(prog.to_string(), &mut main); - assert_eq!(res, false); + assert!(!res); } #[test] @@ -37,7 +37,7 @@ fn builtin_ne_with_ints() { let mut main = MainType::default(); let res: bool = compile_and_run(prog.to_string(), &mut main); - assert_eq!(res, true); + assert!(res); } #[test] @@ -57,7 +57,7 @@ fn builtin_ne_with_floats_monotonic() { let mut main = MainType::default(); let res: bool = compile_and_run(prog.to_string(), &mut main); - assert_eq!(res, false); + assert!(!res); } #[test] @@ -77,7 +77,7 @@ fn builtin_ne_with_floats() { let mut main = MainType::default(); let res: bool = compile_and_run(prog.to_string(), &mut main); - assert_eq!(res, true); + assert!(res); } #[test] @@ -98,5 +98,5 @@ fn builtin_ne_with_mixed_ints_and_floats() { let mut main = MainType::default(); let res: bool = compile_and_run(prog.to_string(), &mut main); - assert_eq!(res, true); + assert!(res); } diff --git a/tests/integration/cfc.rs b/tests/integration/cfc.rs index 0caea6745d..da4d1fc5bd 100644 --- a/tests/integration/cfc.rs +++ b/tests/integration/cfc.rs @@ -307,7 +307,7 @@ mod ir { #[test] // TODO: Transfer this test to `codegen/tests/debug_tests/cfc.rs` once `test_utils.rs` has been refactored fn conditional_return_debug() { - let declaration = "FUNCTION foo VAR_INPUT val : DINT; END_VAR"; + let declaration = "FUNCTION foo : DINT VAR_INPUT val : DINT; END_VAR"; let content = SPou::init("foo", "function", declaration).with_fbd(vec![ // IF val = 1 THEN RETURN &SInVariable::id(2).with_expression("val = 5"), diff --git a/tests/integration/cfc/validation_tests.rs b/tests/integration/cfc/validation_tests.rs index 312d7ceabb..0b7f2d5b05 100644 --- a/tests/integration/cfc/validation_tests.rs +++ b/tests/integration/cfc/validation_tests.rs @@ -15,7 +15,7 @@ fn duplicate_label_validation() { let mut diagnostician = Diagnostician::buffered(); diagnostician.register_file(".cfc".to_string(), "".into()); let (ctxt, project) = parse_and_annotate("plc", vec![cfc_file]).unwrap(); - project.validate(&ctxt, &mut diagnostician).unwrap(); + project.validate(&ctxt, &mut diagnostician).expect_err("Expecting a validation problem"); assert_snapshot!(diagnostician.buffer().unwrap()) } diff --git a/tests/integration/linking.rs b/tests/integration/linking.rs index 606ce774a1..bd0d42fe6b 100644 --- a/tests/integration/linking.rs +++ b/tests/integration/linking.rs @@ -134,11 +134,7 @@ fn link_missing_file() { match res { Err(err) => { - assert!(err - .into_diagnostic() - .unwrap() - .get_message() - .contains("Compilation aborted due to previous errors")); + assert!(err.to_string().contains("Compilation aborted due to previous errors")); } _ => panic!("Expected link failure"), } diff --git a/tests/integration/snapshots/tests__integration__cfc__ir__conditional_return_debug.snap b/tests/integration/snapshots/tests__integration__cfc__ir__conditional_return_debug.snap index b3fe2cfa4c..aaeb884ce6 100644 --- a/tests/integration/snapshots/tests__integration__cfc__ir__conditional_return_debug.snap +++ b/tests/integration/snapshots/tests__integration__cfc__ir__conditional_return_debug.snap @@ -2,21 +2,26 @@ source: tests/integration/cfc.rs expression: output_file_content_without_headers --- -define void @foo(i32 %0) !dbg !3 { +define i32 @foo(i32 %0) !dbg !3 { entry: + %foo = alloca i32, align 4, !dbg !8 %val = alloca i32, align 4, !dbg !8 call void @llvm.dbg.declare(metadata i32* %val, metadata !9, metadata !DIExpression()), !dbg !10 store i32 %0, i32* %val, align 4, !dbg !8 - %load_val = load i32, i32* %val, align 4, !dbg !11 - %tmpVar = icmp eq i32 %load_val, 5, !dbg !11 - br i1 %tmpVar, label %then_block, label %else_block, !dbg !11 + call void @llvm.dbg.declare(metadata i32* %foo, metadata !11, metadata !DIExpression()), !dbg !12 + store i32 0, i32* %foo, align 4, !dbg !8 + %load_val = load i32, i32* %val, align 4, !dbg !13 + %tmpVar = icmp eq i32 %load_val, 5, !dbg !13 + br i1 %tmpVar, label %then_block, label %else_block, !dbg !13 then_block: ; preds = %entry - ret void, !dbg !8 + %foo_ret = load i32, i32* %foo, align 4, !dbg !8 + ret i32 %foo_ret, !dbg !8 else_block: ; preds = %entry - store i32 10, i32* %val, align 4, !dbg !12 - ret void, !dbg !12 + store i32 10, i32* %val, align 4, !dbg !14 + %foo_ret1 = load i32, i32* %foo, align 4, !dbg !14 + ret i32 %foo_ret1, !dbg !14 } ; Function Attrs: nofree nosync nounwind readnone speculatable willreturn @@ -37,6 +42,8 @@ attributes #0 = { nofree nosync nounwind readnone speculatable willreturn } !7 = !{} !8 = !DILocation(line: 3, scope: !3) !9 = !DILocalVariable(name: "val", scope: !3, file: !2, line: 1, type: !6) -!10 = !DILocation(line: 1, column: 23, scope: !3) -!11 = !DILocation(line: 2, scope: !3) -!12 = !DILocation(line: 5, scope: !3) +!10 = !DILocation(line: 1, column: 30, scope: !3) +!11 = !DILocalVariable(name: "foo", scope: !3, file: !2, line: 1, type: !6, align: 32) +!12 = !DILocation(line: 1, column: 9, scope: !3) +!13 = !DILocation(line: 2, scope: !3) +!14 = !DILocation(line: 5, scope: !3) From 7e2e61af0b08fb19c6bae9345441d22811c93c55 Mon Sep 17 00:00:00 2001 From: Ghaith Hachem Date: Wed, 31 Jan 2024 10:57:15 +0100 Subject: [PATCH 27/33] feat: embed the plc json into the source (#1079) The PLC Json schema is now part of the source. It can be printed using plc config schema --- compiler/plc_driver/src/cli.rs | 31 +++++++++++++++++++- compiler/plc_driver/src/lib.rs | 17 +++++++++++ compiler/plc_project/src/build_config.rs | 36 ++---------------------- 3 files changed, 49 insertions(+), 35 deletions(-) diff --git a/compiler/plc_driver/src/cli.rs b/compiler/plc_driver/src/cli.rs index 9c6676bf68..8d2f31febb 100644 --- a/compiler/plc_driver/src/cli.rs +++ b/compiler/plc_driver/src/cli.rs @@ -196,11 +196,33 @@ pub enum SubCommands { )] build_config: Option, }, + + /// Prints out various configuration options + Config { + #[clap( + name = "config-format", + group = "config", + default_value = "json", + help = "Format of the configuration file, if supported" + )] + format: ConfigFormat, + + #[clap(subcommand)] + option: ConfigOption, + }, +} + +#[derive(Copy, Clone, PartialEq, Eq, Debug, Subcommand)] +pub enum ConfigOption { + #[clap(help = "Prints the plc.json schema used for validation")] + Schema, } impl SubCommands { pub fn get_build_configuration(&self) -> Option<&str> { - let (SubCommands::Build { build_config, .. } | SubCommands::Check { build_config }) = self; + let (SubCommands::Build { build_config, .. } | SubCommands::Check { build_config }) = self else { + return None; + }; build_config.as_deref() } } @@ -319,6 +341,13 @@ impl CompileParameters { _ => None, } } + + pub fn get_config_options(&self) -> Option<(ConfigOption, ConfigFormat)> { + let Some(SubCommands::Config { format, option }) = &self.commands else { + return None + }; + Some((*option, *format)) + } } #[cfg(test)] diff --git a/compiler/plc_driver/src/lib.rs b/compiler/plc_driver/src/lib.rs index 13914421eb..8d1ec68602 100644 --- a/compiler/plc_driver/src/lib.rs +++ b/compiler/plc_driver/src/lib.rs @@ -122,6 +122,9 @@ impl Display for CompileError { pub fn compile + AsRef + Debug>(args: &[T]) -> Result<()> { //Parse the arguments let compile_parameters = CompileParameters::parse(args)?; + if let Some((options, format)) = compile_parameters.get_config_options() { + return print_config_options(options, format); + } let project = get_project(&compile_parameters)?; let output_format = compile_parameters.output_format().unwrap_or_else(|| project.get_output_format()); let location = project.get_location().map(|it| it.to_path_buf()); @@ -205,6 +208,20 @@ pub fn compile + AsRef + Debug>(args: &[T]) -> Result<()> { Ok(()) } +fn print_config_options( + option: cli::ConfigOption, + _format: plc::ConfigFormat, +) -> std::result::Result<(), anyhow::Error> { + match option { + cli::ConfigOption::Schema => { + let schema = include_str!("../../plc_project/schema/plc-json.schema"); + println!("{schema}"); + } + }; + + Ok(()) +} + /// Parses and annotates a given project. Can be used in tests or api calls pub fn parse_and_annotate( name: &str, diff --git a/compiler/plc_project/src/build_config.rs b/compiler/plc_project/src/build_config.rs index 63c0a1ee9f..fd7a7dacf0 100644 --- a/compiler/plc_project/src/build_config.rs +++ b/compiler/plc_project/src/build_config.rs @@ -84,41 +84,9 @@ impl ProjectConfig { Ok(project) } - fn get_schema() -> Result { - let current_exe_dir = - std::env::current_exe()?.parent().map(|it| it.to_path_buf()).unwrap_or_default(); - let schema_dir = current_exe_dir.join("schema"); - #[cfg(feature = "integration")] - //Fallback to the build location - let schema_dir = if !&schema_dir.exists() { - let project_dir: PathBuf = env!("CARGO_MANIFEST_DIR").into(); - project_dir.join("schema") - } else { - schema_dir - }; - let path = schema_dir.join("plc-json.schema"); - if !path.exists() { - Err(std::io::Error::new( - std::io::ErrorKind::NotFound, - format!("{}: File not found", path.to_string_lossy()), - ) - .into()) - } else { - Ok(path) - } - } - fn validate(&self) -> Result<()> { - let schema_path = match Self::get_schema() { - Ok(path) => path, - Err(error) => { - eprintln!("Could not find schema, validation skipped. Original error: {error:?}"); - //Skip validation but do not fail - return Ok(()); - } - }; - let schema = fs::read_to_string(schema_path).map_err(Diagnostic::from)?; - let schema_obj = serde_json::from_str(&schema).expect("A valid schema"); + let schema = include_str!("../schema/plc-json.schema"); + let schema_obj = serde_json::from_str(schema).expect("A valid schema"); let compiled = JSONSchema::compile(&schema_obj).expect("A valid schema"); let instance = json!(self); compiled.validate(&instance).map_err(|errors| { From 61113916740667de8bee5e08e56b9be59db09082 Mon Sep 17 00:00:00 2001 From: Michael <78988079+mhasel@users.noreply.github.com> Date: Fri, 2 Feb 2024 10:36:39 +0100 Subject: [PATCH 28/33] fix(validation): fix false-positive unresolved generic symbol validation for formal parameters (#1066) * fix(validation): fix false-positive unresolved generic symbol validation for formal parameters * remove unreferenced snapshots --- src/validation/statement.rs | 4 +++ .../tests/generic_validation_tests.rs | 30 +++++++++++++++++++ ...s__generic_call_with_formal_parameter.snap | 29 ++++++++++++++++++ 3 files changed, 63 insertions(+) create mode 100644 src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__generic_call_with_formal_parameter.snap diff --git a/src/validation/statement.rs b/src/validation/statement.rs index 7445fa8ba9..77a34e4576 100644 --- a/src/validation/statement.rs +++ b/src/validation/statement.rs @@ -1189,6 +1189,10 @@ fn validate_type_nature( { if let DataTypeInformation::Generic { generic_symbol, nature, .. } = type_hint.get_type_information() { + // we might be validating an identifier of a formal parameter assignment (FOO(x := 0)) + if let AstStatement::Identifier(_) = statement.get_stmt() { + return; + } validator.push_diagnostic( Diagnostic::error(format!("Could not resolve generic type {generic_symbol} with {nature}")) .with_error_code("E064") diff --git a/src/validation/tests/generic_validation_tests.rs b/src/validation/tests/generic_validation_tests.rs index 4c26cc74e6..1be22f3c99 100644 --- a/src/validation/tests/generic_validation_tests.rs +++ b/src/validation/tests/generic_validation_tests.rs @@ -1599,3 +1599,33 @@ fn any_date_multiple_parameters() { let diagnostics = parse_and_validate_buffered(src); assert_snapshot!(&diagnostics); } + +#[test] +fn generic_call_with_formal_parameter() { + let src = " + FUNCTION FOO < T: ANY_NUM >: T + VAR_INPUT + x: T; + END_VAR + END_FUNCTION + + FUNCTION FOO__DINT: DINT + VAR_INPUT + x: DINT; + END_VAR + FOO__DINT := x + 0; + END_FUNCTION + + FUNCTION main: DINT + VAR + myLocalNumber: DINT := 2; + END_VAR + myLocalNumber := FOO(x := myLocalNumber); // okay + myLocalNumber := FOO(y := 0); // unresolved reference + myLocalNumber := FOO(x := 'INVALID TYPE NATURE'); // invalid type nature + END_FUNCTION +"; + + let diagnostics = parse_and_validate_buffered(src); + insta::assert_snapshot!(diagnostics); +} diff --git a/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__generic_call_with_formal_parameter.snap b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__generic_call_with_formal_parameter.snap new file mode 100644 index 0000000000..3117cf5b16 --- /dev/null +++ b/src/validation/tests/snapshots/rusty__validation__tests__generic_validation_tests__generic_call_with_formal_parameter.snap @@ -0,0 +1,29 @@ +--- +source: src/validation/tests/generic_validation_tests.rs +expression: diagnostics +--- +error: Invalid call parameters + ┌─ :20:30 + │ +20 │ myLocalNumber := FOO(y := 0); // unresolved reference + │ ^^^^^^ Invalid call parameters + +error: Could not resolve reference to y + ┌─ :20:30 + │ +20 │ myLocalNumber := FOO(y := 0); // unresolved reference + │ ^ Could not resolve reference to y + +error: Invalid type nature for generic argument. __STRING_19 is no ANY_NUMBER + ┌─ :21:35 + │ +21 │ myLocalNumber := FOO(x := 'INVALID TYPE NATURE'); // invalid type nature + │ ^^^^^^^^^^^^^^^^^^^^^ Invalid type nature for generic argument. __STRING_19 is no ANY_NUMBER + +error: Invalid assignment: cannot assign 'STRING' to 'USINT' + ┌─ :21:30 + │ +21 │ myLocalNumber := FOO(x := 'INVALID TYPE NATURE'); // invalid type nature + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^ Invalid assignment: cannot assign 'STRING' to 'USINT' + + From eeb0bab239cead6430061cb4099638c57eef457d Mon Sep 17 00:00:00 2001 From: Michael <78988079+mhasel@users.noreply.github.com> Date: Wed, 7 Feb 2024 13:52:22 +0100 Subject: [PATCH 29/33] fix(debugging): don't create debug info for external functions/add LLVM-version-appropriate DI-metadata (#1072) * fix(debugging): don't create debug info for external functions * fix: debug info version, add separate args for overrides --- compiler/plc_driver/src/cli.rs | 98 +++++++++++- compiler/plc_driver/src/lib.rs | 2 +- compiler/plc_driver/src/tests/multi_files.rs | 8 +- ...n_different_locations_with_debug_info.snap | 72 +++++---- ...files__multiple_files_with_debug_info.snap | 72 +++++---- src/codegen/debug.rs | 36 +++-- src/codegen/tests/debug_tests.rs | 17 ++ .../tests/debug_tests/expression_debugging.rs | 4 +- ...ate_return_value_variable_in_function.snap | 55 +++---- ...g__assignment_statement_have_location.snap | 39 ++--- ...ging__case_conditions_location_marked.snap | 65 ++++---- ...bugging__exit_statement_have_location.snap | 49 +++--- ..._is_not_added_as_external_subroutine.snap} | 23 +-- ...gging__for_conditions_location_marked.snap | 123 ++++++++------- ...bugging__function_calls_have_location.snap | 39 ++--- ...on_calls_in_expressions_have_location.snap | 43 ++--- ...ugging__if_conditions_location_marked.snap | 67 ++++---- ...g__implementation_added_as_subroutine.snap | 59 +++---- ...g__nested_function_calls_get_location.snap | 53 ++++--- ...callable_expressions_have_no_location.snap | 39 ++--- ...on_function_pous_have_struct_as_param.snap | 55 +++---- ...ng__repeat_conditions_location_marked.snap | 67 ++++---- ...gging__return_statement_have_location.snap | 41 ++--- ...temp_variables_in_pous_added_as_local.snap | 149 +++++++++--------- ...out_inout_in_function_added_as_params.snap | 61 +++---- ...ing__while_conditions_location_marked.snap | 61 +++---- ...__debug_tests__dwarf_version_override.snap | 22 +++ ...tests__debug_tests__global_alias_type.snap | 9 +- ..._global_var_array_added_to_debug_info.snap | 9 +- ...lobal_var_byteseq_added_to_debug_info.snap | 9 +- ...__global_var_enum_added_to_debug_info.snap | 9 +- ..._global_var_float_added_to_debug_info.snap | 9 +- ...s__global_var_int_added_to_debug_info.snap | 9 +- ...var_nested_struct_added_to_debug_info.snap | 9 +- ...lobal_var_pointer_added_to_debug_info.snap | 9 +- ...global_var_string_added_to_debug_info.snap | 11 +- ...global_var_struct_added_to_debug_info.snap | 9 +- src/lib.rs | 6 +- src/test_utils.rs | 6 +- ...__integration__cfc__ir__actions_debug.snap | 89 +++++------ ...on__cfc__ir__conditional_return_debug.snap | 63 ++++---- ...sts__integration__cfc__ir__jump_debug.snap | 45 +++--- ...tegration__cfc__ir__sink_source_debug.snap | 35 ++-- 43 files changed, 964 insertions(+), 791 deletions(-) rename src/codegen/tests/debug_tests/snapshots/{rusty__codegen__tests__debug_tests__expression_debugging__external_impl_added_as_external_subroutine.snap => rusty__codegen__tests__debug_tests__expression_debugging__external_impl_is_not_added_as_external_subroutine.snap} (51%) create mode 100644 src/codegen/tests/snapshots/rusty__codegen__tests__debug_tests__dwarf_version_override.snap diff --git a/compiler/plc_driver/src/cli.rs b/compiler/plc_driver/src/cli.rs index 8d2f31febb..9746c10297 100644 --- a/compiler/plc_driver/src/cli.rs +++ b/compiler/plc_driver/src/cli.rs @@ -15,6 +15,7 @@ pub type ParameterError = clap::Error; )] #[clap(propagate_version = true)] #[clap(subcommand_negates_reqs = true)] +#[clap(subcommand_precedence_over_arg = true)] pub struct CompileParameters { #[clap(short, long, global = true, name = "output-file", help = "Write output to ")] pub output: Option, @@ -140,6 +141,32 @@ pub struct CompileParameters { )] pub generate_varinfo: bool, + #[clap( + name = "gdwarf", + long, + help = "Generate source-level debug information with the specified dwarf version", + value_name = "dwarf version", + global = true, + group = "dbg", + conflicts_with = "debug", + max_values = 1, + possible_values = &["2", "3", "4", "5"], + )] + pub gdwarf_version: Option, + + #[clap( + name = "gdwarf-variables", + long, + help = "Generate debug information for global variables with the specified dwarf version", + value_name = "dwarf version", + global = true, + group = "dbg", + conflicts_with = "debug-variables", + max_values = 1, + possible_values = &["2", "3", "4", "5"], + )] + pub gdwarf_varinfo_version: Option, + #[clap( name = "threads", long, @@ -274,12 +301,19 @@ impl CompileParameters { pub fn debug_level(&self) -> DebugLevel { if self.generate_debug { - DebugLevel::Full - } else if self.generate_varinfo { - DebugLevel::VariablesOnly - } else { - DebugLevel::None + return DebugLevel::Full(plc::DEFAULT_DWARF_VERSION); + } + if self.generate_varinfo { + return DebugLevel::VariablesOnly(plc::DEFAULT_DWARF_VERSION); + } + if let Some(version) = self.gdwarf_version { + return DebugLevel::Full(version); + } + if let Some(version) = self.gdwarf_varinfo_version { + return DebugLevel::VariablesOnly(version); } + + DebugLevel::None } // convert the scattered bools from structopt into an enum @@ -762,4 +796,58 @@ mod cli_tests { .to_string() ) } + + #[test] + fn test_gdwarf_and_debug_mutually_exclusive() { + assert!(CompileParameters::parse(vec_of_strings!("input.st", "--debug", "--gdwarf", "2")).is_err()); + assert!(CompileParameters::parse(vec_of_strings!("input.st", "-g", "--gdwarf", "4")).is_err()); + assert!(CompileParameters::parse(vec_of_strings!( + "input.st", + "--debug-variables", + "--gdwarf-variables", + "3" + )) + .is_err()); + } + + #[test] + fn test_dwarf_version_override() { + let parameters = CompileParameters::parse(vec_of_strings!("input.st", "--gdwarf", "2")).unwrap(); + assert_eq!(parameters.gdwarf_version, Some(2)); + + let parameters = CompileParameters::parse(vec_of_strings!("input.st", "--gdwarf", "3")).unwrap(); + assert_eq!(parameters.gdwarf_version, Some(3)); + + let parameters = + CompileParameters::parse(vec_of_strings!("input.st", "--gdwarf-variables", "4")).unwrap(); + assert_eq!(parameters.gdwarf_varinfo_version, Some(4)); + } + + #[test] + fn invalid_dwarf_version() { + let error = CompileParameters::parse(vec_of_strings!("input.st", "--gdwarf", "1")).unwrap_err(); + assert_eq!(error.kind(), ErrorKind::InvalidValue); + let inner = &error.info; + assert_eq!(inner[1], "1"); + + let error = + CompileParameters::parse(vec_of_strings!("input.st", "--gdwarf-variables", "99")).unwrap_err(); + assert_eq!(error.kind(), ErrorKind::InvalidValue); + let inner = &error.info; + assert_eq!(inner[1], "99"); + + let error = CompileParameters::parse(vec_of_strings!("input.st", "--gdwarf", "abc")).unwrap_err(); + assert_eq!(error.kind(), ErrorKind::InvalidValue); + let inner = &error.info; + assert_eq!(inner[1], "abc"); + } + + #[test] + fn dwarf_version_override_arg_requries_value() { + let error = CompileParameters::parse(vec_of_strings!("input.st", "--gdwarf")).unwrap_err(); + assert_eq!(error.kind(), ErrorKind::EmptyValue); + + let error = CompileParameters::parse(vec_of_strings!("input.st", "--gdwarf-variables")).unwrap_err(); + assert_eq!(error.kind(), ErrorKind::EmptyValue); + } } diff --git a/compiler/plc_driver/src/lib.rs b/compiler/plc_driver/src/lib.rs index 8d1ec68602..f81ba52053 100644 --- a/compiler/plc_driver/src/lib.rs +++ b/compiler/plc_driver/src/lib.rs @@ -263,7 +263,7 @@ fn generate_to_string_internal( let context = CodegenContext::create(); let mut options = CompileOptions::default(); if debug { - options.debug_level = DebugLevel::Full; + options.debug_level = DebugLevel::Full(plc::DEFAULT_DWARF_VERSION); } let module = project.generate_single_module(&context, &options)?; diff --git a/compiler/plc_driver/src/tests/multi_files.rs b/compiler/plc_driver/src/tests/multi_files.rs index d90b02d637..2455f062fe 100644 --- a/compiler/plc_driver/src/tests/multi_files.rs +++ b/compiler/plc_driver/src/tests/multi_files.rs @@ -69,7 +69,9 @@ fn multiple_files_with_debug_info() { "file2.st", ); //When the are generated - let results = compile_with_root(vec![src1, src2], vec![], "root", DebugLevel::Full).unwrap(); + let results = + compile_with_root(vec![src1, src2], vec![], "root", DebugLevel::Full(plc::DEFAULT_DWARF_VERSION)) + .unwrap(); assert_eq!(results.len(), 2); //The datatypes do not conflics //The functions are defined correctly @@ -106,7 +108,9 @@ fn multiple_files_in_different_locations_with_debug_info() { "lib/file2.st", ); //When the are generated - let results = compile_with_root(vec![src1, src2], vec![], "root", DebugLevel::Full).unwrap(); + let results = + compile_with_root(vec![src1, src2], vec![], "root", DebugLevel::Full(plc::DEFAULT_DWARF_VERSION)) + .unwrap(); assert_eq!(results.len(), 2); //The datatypes do not conflics //The functions are defined correctly diff --git a/compiler/plc_driver/src/tests/snapshots/plc_driver__tests__multi_files__multiple_files_in_different_locations_with_debug_info.snap b/compiler/plc_driver/src/tests/snapshots/plc_driver__tests__multi_files__multiple_files_in_different_locations_with_debug_info.snap index 5b48d40e67..1a4de63ab3 100644 --- a/compiler/plc_driver/src/tests/snapshots/plc_driver__tests__multi_files__multiple_files_in_different_locations_with_debug_info.snap +++ b/compiler/plc_driver/src/tests/snapshots/plc_driver__tests__multi_files__multiple_files_in_different_locations_with_debug_info.snap @@ -9,25 +9,25 @@ source_filename = "app/file1.st" @mainProg_instance = external global %mainProg, !dbg !0 -define i16 @main() !dbg !9 { +define i16 @main() !dbg !10 { entry: - %main = alloca i16, align 2, !dbg !13 - call void @llvm.dbg.declare(metadata i16* %main, metadata !14, metadata !DIExpression()), !dbg !16 - store i16 0, i16* %main, align 2, !dbg !13 - call void @mainProg(%mainProg* @mainProg_instance), !dbg !13 - %main_ret = load i16, i16* %main, align 2, !dbg !13 - ret i16 %main_ret, !dbg !13 + %main = alloca i16, align 2, !dbg !14 + call void @llvm.dbg.declare(metadata i16* %main, metadata !15, metadata !DIExpression()), !dbg !17 + store i16 0, i16* %main, align 2, !dbg !14 + call void @mainProg(%mainProg* @mainProg_instance), !dbg !14 + %main_ret = load i16, i16* %main, align 2, !dbg !14 + ret i16 %main_ret, !dbg !14 } -declare !dbg !17 void @mainProg(%mainProg*) +declare !dbg !18 void @mainProg(%mainProg*) ; Function Attrs: nofree nosync nounwind readnone speculatable willreturn declare void @llvm.dbg.declare(metadata, metadata, metadata) #0 attributes #0 = { nofree nosync nounwind readnone speculatable willreturn } -!llvm.module.flags = !{!5} -!llvm.dbg.cu = !{!6} +!llvm.module.flags = !{!5, !6} +!llvm.dbg.cu = !{!7} !0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression()) !1 = distinct !DIGlobalVariable(name: "mainProg", scope: !2, file: !2, line: 2, type: !3, isLocal: false, isDefinition: true) @@ -35,18 +35,19 @@ attributes #0 = { nofree nosync nounwind readnone speculatable willreturn } !3 = !DICompositeType(tag: DW_TAG_structure_type, name: "mainProg", scope: !2, file: !2, line: 2, align: 64, flags: DIFlagPublic, elements: !4, identifier: "mainProg") !4 = !{} !5 = !{i32 2, !"Dwarf Version", i32 5} -!6 = distinct !DICompileUnit(language: DW_LANG_C, file: !7, producer: "RuSTy Structured text Compiler", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, globals: !8, splitDebugInlining: false) -!7 = !DIFile(filename: "app/file1.st", directory: "root") -!8 = !{!0} -!9 = distinct !DISubprogram(name: "main", linkageName: "main", scope: !10, file: !10, line: 2, type: !11, scopeLine: 10, flags: DIFlagPublic, spFlags: DISPFlagDefinition, unit: !6, retainedNodes: !4) -!10 = !DIFile(filename: "file1.st", directory: "app") -!11 = !DISubroutineType(flags: DIFlagPublic, types: !12) -!12 = !{null} -!13 = !DILocation(line: 10, column: 4, scope: !9) -!14 = !DILocalVariable(name: "main", scope: !9, file: !10, line: 2, type: !15, align: 16) -!15 = !DIBasicType(name: "INT", size: 16, encoding: DW_ATE_signed, flags: DIFlagPublic) -!16 = !DILocation(line: 2, column: 13, scope: !9) -!17 = distinct !DISubprogram(name: "mainProg", linkageName: "mainProg", scope: !2, file: !2, line: 2, type: !11, scopeLine: 5, flags: DIFlagPublic, spFlags: DISPFlagDefinition, unit: !6, retainedNodes: !4) +!6 = !{i32 2, !"Debug Info Version", i32 3} +!7 = distinct !DICompileUnit(language: DW_LANG_C, file: !8, producer: "RuSTy Structured text Compiler", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, globals: !9, splitDebugInlining: false) +!8 = !DIFile(filename: "app/file1.st", directory: "root") +!9 = !{!0} +!10 = distinct !DISubprogram(name: "main", linkageName: "main", scope: !11, file: !11, line: 2, type: !12, scopeLine: 10, flags: DIFlagPublic, spFlags: DISPFlagDefinition, unit: !7, retainedNodes: !4) +!11 = !DIFile(filename: "file1.st", directory: "app") +!12 = !DISubroutineType(flags: DIFlagPublic, types: !13) +!13 = !{null} +!14 = !DILocation(line: 10, column: 4, scope: !10) +!15 = !DILocalVariable(name: "main", scope: !10, file: !11, line: 2, type: !16, align: 16) +!16 = !DIBasicType(name: "INT", size: 16, encoding: DW_ATE_signed, flags: DIFlagPublic) +!17 = !DILocation(line: 2, column: 13, scope: !10) +!18 = distinct !DISubprogram(name: "mainProg", linkageName: "mainProg", scope: !2, file: !2, line: 2, type: !12, scopeLine: 5, flags: DIFlagPublic, spFlags: DISPFlagDefinition, unit: !7, retainedNodes: !4) ; ModuleID = 'lib/file2.st' source_filename = "lib/file2.st" @@ -55,10 +56,10 @@ source_filename = "lib/file2.st" @mainProg_instance = global %mainProg zeroinitializer, !dbg !0 -define void @mainProg(%mainProg* %0) !dbg !9 { +define void @mainProg(%mainProg* %0) !dbg !10 { entry: - call void @llvm.dbg.declare(metadata %mainProg* %0, metadata !12, metadata !DIExpression()), !dbg !13 - ret void, !dbg !13 + call void @llvm.dbg.declare(metadata %mainProg* %0, metadata !13, metadata !DIExpression()), !dbg !14 + ret void, !dbg !14 } ; Function Attrs: nofree nosync nounwind readnone speculatable willreturn @@ -66,8 +67,8 @@ declare void @llvm.dbg.declare(metadata, metadata, metadata) #0 attributes #0 = { nofree nosync nounwind readnone speculatable willreturn } -!llvm.module.flags = !{!5} -!llvm.dbg.cu = !{!6} +!llvm.module.flags = !{!5, !6} +!llvm.dbg.cu = !{!7} !0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression()) !1 = distinct !DIGlobalVariable(name: "mainProg", scope: !2, file: !2, line: 2, type: !3, isLocal: false, isDefinition: true) @@ -75,12 +76,13 @@ attributes #0 = { nofree nosync nounwind readnone speculatable willreturn } !3 = !DICompositeType(tag: DW_TAG_structure_type, name: "mainProg", scope: !2, file: !2, line: 2, align: 64, flags: DIFlagPublic, elements: !4, identifier: "mainProg") !4 = !{} !5 = !{i32 2, !"Dwarf Version", i32 5} -!6 = distinct !DICompileUnit(language: DW_LANG_C, file: !7, producer: "RuSTy Structured text Compiler", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, globals: !8, splitDebugInlining: false) -!7 = !DIFile(filename: "lib/file2.st", directory: "root") -!8 = !{!0} -!9 = distinct !DISubprogram(name: "mainProg", linkageName: "mainProg", scope: !2, file: !2, line: 2, type: !10, scopeLine: 5, flags: DIFlagPublic, spFlags: DISPFlagDefinition, unit: !6, retainedNodes: !4) -!10 = !DISubroutineType(flags: DIFlagPublic, types: !11) -!11 = !{null} -!12 = !DILocalVariable(name: "mainProg", scope: !9, file: !2, line: 2, type: !3) -!13 = !DILocation(line: 5, column: 4, scope: !9) +!6 = !{i32 2, !"Debug Info Version", i32 3} +!7 = distinct !DICompileUnit(language: DW_LANG_C, file: !8, producer: "RuSTy Structured text Compiler", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, globals: !9, splitDebugInlining: false) +!8 = !DIFile(filename: "lib/file2.st", directory: "root") +!9 = !{!0} +!10 = distinct !DISubprogram(name: "mainProg", linkageName: "mainProg", scope: !2, file: !2, line: 2, type: !11, scopeLine: 5, flags: DIFlagPublic, spFlags: DISPFlagDefinition, unit: !7, retainedNodes: !4) +!11 = !DISubroutineType(flags: DIFlagPublic, types: !12) +!12 = !{null} +!13 = !DILocalVariable(name: "mainProg", scope: !10, file: !2, line: 2, type: !3) +!14 = !DILocation(line: 5, column: 4, scope: !10) diff --git a/compiler/plc_driver/src/tests/snapshots/plc_driver__tests__multi_files__multiple_files_with_debug_info.snap b/compiler/plc_driver/src/tests/snapshots/plc_driver__tests__multi_files__multiple_files_with_debug_info.snap index 02e55ee3ba..03e8b69b94 100644 --- a/compiler/plc_driver/src/tests/snapshots/plc_driver__tests__multi_files__multiple_files_with_debug_info.snap +++ b/compiler/plc_driver/src/tests/snapshots/plc_driver__tests__multi_files__multiple_files_with_debug_info.snap @@ -9,25 +9,25 @@ source_filename = "file1.st" @mainProg_instance = external global %mainProg, !dbg !0 -define i16 @main() !dbg !9 { +define i16 @main() !dbg !10 { entry: - %main = alloca i16, align 2, !dbg !13 - call void @llvm.dbg.declare(metadata i16* %main, metadata !14, metadata !DIExpression()), !dbg !16 - store i16 0, i16* %main, align 2, !dbg !13 - call void @mainProg(%mainProg* @mainProg_instance), !dbg !13 - %main_ret = load i16, i16* %main, align 2, !dbg !13 - ret i16 %main_ret, !dbg !13 + %main = alloca i16, align 2, !dbg !14 + call void @llvm.dbg.declare(metadata i16* %main, metadata !15, metadata !DIExpression()), !dbg !17 + store i16 0, i16* %main, align 2, !dbg !14 + call void @mainProg(%mainProg* @mainProg_instance), !dbg !14 + %main_ret = load i16, i16* %main, align 2, !dbg !14 + ret i16 %main_ret, !dbg !14 } -declare !dbg !17 void @mainProg(%mainProg*) +declare !dbg !18 void @mainProg(%mainProg*) ; Function Attrs: nofree nosync nounwind readnone speculatable willreturn declare void @llvm.dbg.declare(metadata, metadata, metadata) #0 attributes #0 = { nofree nosync nounwind readnone speculatable willreturn } -!llvm.module.flags = !{!5} -!llvm.dbg.cu = !{!6} +!llvm.module.flags = !{!5, !6} +!llvm.dbg.cu = !{!7} !0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression()) !1 = distinct !DIGlobalVariable(name: "mainProg", scope: !2, file: !2, line: 2, type: !3, isLocal: false, isDefinition: true) @@ -35,18 +35,19 @@ attributes #0 = { nofree nosync nounwind readnone speculatable willreturn } !3 = !DICompositeType(tag: DW_TAG_structure_type, name: "mainProg", scope: !2, file: !2, line: 2, align: 64, flags: DIFlagPublic, elements: !4, identifier: "mainProg") !4 = !{} !5 = !{i32 2, !"Dwarf Version", i32 5} -!6 = distinct !DICompileUnit(language: DW_LANG_C, file: !7, producer: "RuSTy Structured text Compiler", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, globals: !8, splitDebugInlining: false) -!7 = !DIFile(filename: "file1.st", directory: "root") -!8 = !{!0} -!9 = distinct !DISubprogram(name: "main", linkageName: "main", scope: !10, file: !10, line: 2, type: !11, scopeLine: 10, flags: DIFlagPublic, spFlags: DISPFlagDefinition, unit: !6, retainedNodes: !4) -!10 = !DIFile(filename: "file1.st", directory: "") -!11 = !DISubroutineType(flags: DIFlagPublic, types: !12) -!12 = !{null} -!13 = !DILocation(line: 10, column: 4, scope: !9) -!14 = !DILocalVariable(name: "main", scope: !9, file: !10, line: 2, type: !15, align: 16) -!15 = !DIBasicType(name: "INT", size: 16, encoding: DW_ATE_signed, flags: DIFlagPublic) -!16 = !DILocation(line: 2, column: 13, scope: !9) -!17 = distinct !DISubprogram(name: "mainProg", linkageName: "mainProg", scope: !2, file: !2, line: 2, type: !11, scopeLine: 5, flags: DIFlagPublic, spFlags: DISPFlagDefinition, unit: !6, retainedNodes: !4) +!6 = !{i32 2, !"Debug Info Version", i32 3} +!7 = distinct !DICompileUnit(language: DW_LANG_C, file: !8, producer: "RuSTy Structured text Compiler", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, globals: !9, splitDebugInlining: false) +!8 = !DIFile(filename: "file1.st", directory: "root") +!9 = !{!0} +!10 = distinct !DISubprogram(name: "main", linkageName: "main", scope: !11, file: !11, line: 2, type: !12, scopeLine: 10, flags: DIFlagPublic, spFlags: DISPFlagDefinition, unit: !7, retainedNodes: !4) +!11 = !DIFile(filename: "file1.st", directory: "") +!12 = !DISubroutineType(flags: DIFlagPublic, types: !13) +!13 = !{null} +!14 = !DILocation(line: 10, column: 4, scope: !10) +!15 = !DILocalVariable(name: "main", scope: !10, file: !11, line: 2, type: !16, align: 16) +!16 = !DIBasicType(name: "INT", size: 16, encoding: DW_ATE_signed, flags: DIFlagPublic) +!17 = !DILocation(line: 2, column: 13, scope: !10) +!18 = distinct !DISubprogram(name: "mainProg", linkageName: "mainProg", scope: !2, file: !2, line: 2, type: !12, scopeLine: 5, flags: DIFlagPublic, spFlags: DISPFlagDefinition, unit: !7, retainedNodes: !4) ; ModuleID = 'file2.st' source_filename = "file2.st" @@ -55,10 +56,10 @@ source_filename = "file2.st" @mainProg_instance = global %mainProg zeroinitializer, !dbg !0 -define void @mainProg(%mainProg* %0) !dbg !9 { +define void @mainProg(%mainProg* %0) !dbg !10 { entry: - call void @llvm.dbg.declare(metadata %mainProg* %0, metadata !12, metadata !DIExpression()), !dbg !13 - ret void, !dbg !13 + call void @llvm.dbg.declare(metadata %mainProg* %0, metadata !13, metadata !DIExpression()), !dbg !14 + ret void, !dbg !14 } ; Function Attrs: nofree nosync nounwind readnone speculatable willreturn @@ -66,8 +67,8 @@ declare void @llvm.dbg.declare(metadata, metadata, metadata) #0 attributes #0 = { nofree nosync nounwind readnone speculatable willreturn } -!llvm.module.flags = !{!5} -!llvm.dbg.cu = !{!6} +!llvm.module.flags = !{!5, !6} +!llvm.dbg.cu = !{!7} !0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression()) !1 = distinct !DIGlobalVariable(name: "mainProg", scope: !2, file: !2, line: 2, type: !3, isLocal: false, isDefinition: true) @@ -75,12 +76,13 @@ attributes #0 = { nofree nosync nounwind readnone speculatable willreturn } !3 = !DICompositeType(tag: DW_TAG_structure_type, name: "mainProg", scope: !2, file: !2, line: 2, align: 64, flags: DIFlagPublic, elements: !4, identifier: "mainProg") !4 = !{} !5 = !{i32 2, !"Dwarf Version", i32 5} -!6 = distinct !DICompileUnit(language: DW_LANG_C, file: !7, producer: "RuSTy Structured text Compiler", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, globals: !8, splitDebugInlining: false) -!7 = !DIFile(filename: "file2.st", directory: "root") -!8 = !{!0} -!9 = distinct !DISubprogram(name: "mainProg", linkageName: "mainProg", scope: !2, file: !2, line: 2, type: !10, scopeLine: 5, flags: DIFlagPublic, spFlags: DISPFlagDefinition, unit: !6, retainedNodes: !4) -!10 = !DISubroutineType(flags: DIFlagPublic, types: !11) -!11 = !{null} -!12 = !DILocalVariable(name: "mainProg", scope: !9, file: !2, line: 2, type: !3) -!13 = !DILocation(line: 5, column: 4, scope: !9) +!6 = !{i32 2, !"Debug Info Version", i32 3} +!7 = distinct !DICompileUnit(language: DW_LANG_C, file: !8, producer: "RuSTy Structured text Compiler", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, globals: !9, splitDebugInlining: false) +!8 = !DIFile(filename: "file2.st", directory: "root") +!9 = !{!0} +!10 = distinct !DISubprogram(name: "mainProg", linkageName: "mainProg", scope: !2, file: !2, line: 2, type: !11, scopeLine: 5, flags: DIFlagPublic, spFlags: DISPFlagDefinition, unit: !7, retainedNodes: !4) +!11 = !DISubroutineType(flags: DIFlagPublic, types: !12) +!12 = !{null} +!13 = !DILocalVariable(name: "mainProg", scope: !10, file: !2, line: 2, type: !3) +!14 = !DILocation(line: 5, column: 4, scope: !10) diff --git a/src/codegen/debug.rs b/src/codegen/debug.rs index 3618e8325d..defc8d1047 100644 --- a/src/codegen/debug.rs +++ b/src/codegen/debug.rs @@ -36,19 +36,10 @@ enum DebugEncoding { DW_ATE_UTF = 0x10, } -impl From for DebugLevel { - fn from(kind: DWARFEmissionKind) -> Self { - match kind { - DWARFEmissionKind::Full => DebugLevel::Full, - _ => DebugLevel::None, - } - } -} - impl From for DWARFEmissionKind { fn from(level: DebugLevel) -> Self { match level { - DebugLevel::Full | DebugLevel::VariablesOnly => DWARFEmissionKind::Full, + DebugLevel::Full(_) | DebugLevel::VariablesOnly(_) => DWARFEmissionKind::Full, _ => DWARFEmissionKind::None, } } @@ -178,15 +169,29 @@ impl<'ink> DebugBuilderEnum<'ink> { optimization: OptimizationLevel, debug_level: DebugLevel, ) -> Self { - let dwarf_version: BasicMetadataValueEnum<'ink> = context.i32_type().const_int(5, false).into(); match debug_level { DebugLevel::None => DebugBuilderEnum::None, - DebugLevel::VariablesOnly | DebugLevel::Full => { + DebugLevel::VariablesOnly(version) | DebugLevel::Full(version) => { + let dwarf_version: BasicMetadataValueEnum<'ink> = + context.i32_type().const_int(version as u64, false).into(); module.add_metadata_flag( "Dwarf Version", inkwell::module::FlagBehavior::Warning, context.metadata_node(&[dwarf_version]), ); + // `LLVMParseIRInContext` expects "Debug Info Version" metadata, with the specified version + // matching the LLVM version or otherwise it will emit a warning and strip DI from the IR. + // These metadata flags are not mutually exclusive. + let dwarf_version: BasicMetadataValueEnum<'ink> = context + .i32_type() + .const_int(inkwell::debug_info::debug_metadata_version() as u64, false) + .into(); + module.add_metadata_flag( + "Debug Info Version", + inkwell::module::FlagBehavior::Warning, + context.metadata_node(&[dwarf_version]), + ); + let path = Path::new(module.get_source_file_name().to_str().unwrap_or("")); let root = root.unwrap_or_else(|| Path::new("")); let filename = path.strip_prefix(root).unwrap_or(path).to_str().unwrap_or_default(); @@ -218,8 +223,8 @@ impl<'ink> DebugBuilderEnum<'ink> { files: Default::default(), }; match debug_level { - DebugLevel::VariablesOnly => DebugBuilderEnum::VariablesOnly(dbg_obj), - DebugLevel::Full => DebugBuilderEnum::Full(dbg_obj), + DebugLevel::VariablesOnly(_) => DebugBuilderEnum::VariablesOnly(dbg_obj), + DebugLevel::Full(_) => DebugBuilderEnum::Full(dbg_obj), _ => unreachable!("Only variables or full debug can reach this"), } } @@ -612,6 +617,9 @@ impl<'ink> Debug<'ink> for DebugBuilder<'ink> { parameter_types: &[&'idx DataType], implementation_start: usize, ) { + if matches!(pou.get_linkage(), LinkageType::External) { + return; + } let subprogram = self.create_function(pou, return_type, parameter_types, implementation_start); func.set_subprogram(subprogram); //Create function parameters diff --git a/src/codegen/tests/debug_tests.rs b/src/codegen/tests/debug_tests.rs index 8d67b0e472..a11ce06075 100644 --- a/src/codegen/tests/debug_tests.rs +++ b/src/codegen/tests/debug_tests.rs @@ -3,6 +3,7 @@ use insta::assert_snapshot; mod expression_debugging; use crate::test_utils::tests::codegen_with_debug as codegen; +use crate::test_utils::tests::codegen_with_debug_version; #[test] fn test_global_var_int_added_to_debug_info() { let codegen = codegen( @@ -169,3 +170,19 @@ fn test_global_alias_type() { assert_snapshot!(codegen) } + +#[test] +fn test_dwarf_version_override() { + let codegen = codegen_with_debug_version( + r#" + TYPE myInt : DINT; END_TYPE + + VAR_GLOBAL + gInt : myInt; + END_VAR + "#, + 4, + ); + + assert_snapshot!(codegen) +} diff --git a/src/codegen/tests/debug_tests/expression_debugging.rs b/src/codegen/tests/debug_tests/expression_debugging.rs index 14a7e9b5ce..4a7fedb426 100644 --- a/src/codegen/tests/debug_tests/expression_debugging.rs +++ b/src/codegen/tests/debug_tests/expression_debugging.rs @@ -21,7 +21,7 @@ fn implementation_added_as_subroutine() { } #[test] -fn external_impl_added_as_external_subroutine() { +fn external_impl_is_not_added_as_external_subroutine() { //GIVEN 3 external POUs //When compiling for debug let result = codegen_with_debug( @@ -34,7 +34,7 @@ fn external_impl_added_as_external_subroutine() { END_FUNCTION_BLOCK ", ); - //The POUs has a subroutine entry in the debug info + //The POUs don't have a subroutine entry in the debug info assert_snapshot!(result); } diff --git a/src/codegen/tests/debug_tests/snapshots/rusty__codegen__tests__debug_tests__expression_debugging__aggregate_return_value_variable_in_function.snap b/src/codegen/tests/debug_tests/snapshots/rusty__codegen__tests__debug_tests__expression_debugging__aggregate_return_value_variable_in_function.snap index 78271a5fbb..a992507dbb 100644 --- a/src/codegen/tests/debug_tests/snapshots/rusty__codegen__tests__debug_tests__expression_debugging__aggregate_return_value_variable_in_function.snap +++ b/src/codegen/tests/debug_tests/snapshots/rusty__codegen__tests__debug_tests__expression_debugging__aggregate_return_value_variable_in_function.snap @@ -7,18 +7,18 @@ source_filename = "main" @utf08_literal_0 = private unnamed_addr constant [6 x i8] c"hello\00" -define void @myFunc([81 x i8]* %0) !dbg !3 { +define void @myFunc([81 x i8]* %0) !dbg !4 { entry: - %myFunc = alloca [81 x i8]*, align 8, !dbg !7 - store [81 x i8]* %0, [81 x i8]** %myFunc, align 8, !dbg !7 - call void @llvm.dbg.declare(metadata [81 x i8]** %myFunc, metadata !8, metadata !DIExpression()), !dbg !14 - %deref = load [81 x i8]*, [81 x i8]** %myFunc, align 8, !dbg !7 - %1 = bitcast [81 x i8]* %deref to i8*, !dbg !7 - call void @llvm.memset.p0i8.i64(i8* align 1 %1, i8 0, i64 ptrtoint ([81 x i8]* getelementptr ([81 x i8], [81 x i8]* null, i32 1) to i64), i1 false), !dbg !7 - %deref1 = load [81 x i8]*, [81 x i8]** %myFunc, align 8, !dbg !7 - %2 = bitcast [81 x i8]* %deref1 to i8*, !dbg !7 - call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 1 %2, i8* align 1 getelementptr inbounds ([6 x i8], [6 x i8]* @utf08_literal_0, i32 0, i32 0), i32 6, i1 false), !dbg !7 - ret void, !dbg !7 + %myFunc = alloca [81 x i8]*, align 8, !dbg !8 + store [81 x i8]* %0, [81 x i8]** %myFunc, align 8, !dbg !8 + call void @llvm.dbg.declare(metadata [81 x i8]** %myFunc, metadata !9, metadata !DIExpression()), !dbg !15 + %deref = load [81 x i8]*, [81 x i8]** %myFunc, align 8, !dbg !8 + %1 = bitcast [81 x i8]* %deref to i8*, !dbg !8 + call void @llvm.memset.p0i8.i64(i8* align 1 %1, i8 0, i64 ptrtoint ([81 x i8]* getelementptr ([81 x i8], [81 x i8]* null, i32 1) to i64), i1 false), !dbg !8 + %deref1 = load [81 x i8]*, [81 x i8]** %myFunc, align 8, !dbg !8 + %2 = bitcast [81 x i8]* %deref1 to i8*, !dbg !8 + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 1 %2, i8* align 1 getelementptr inbounds ([6 x i8], [6 x i8]* @utf08_literal_0, i32 0, i32 0), i32 6, i1 false), !dbg !8 + ret void, !dbg !8 } ; Function Attrs: nofree nosync nounwind readnone speculatable willreturn @@ -34,22 +34,23 @@ attributes #0 = { nofree nosync nounwind readnone speculatable willreturn } attributes #1 = { argmemonly nofree nounwind willreturn writeonly } attributes #2 = { argmemonly nofree nounwind willreturn } -!llvm.module.flags = !{!0} -!llvm.dbg.cu = !{!1} +!llvm.module.flags = !{!0, !1} +!llvm.dbg.cu = !{!2} !0 = !{i32 2, !"Dwarf Version", i32 5} -!1 = distinct !DICompileUnit(language: DW_LANG_C, file: !2, producer: "RuSTy Structured text Compiler", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, splitDebugInlining: false) -!2 = !DIFile(filename: "main", directory: "src") -!3 = distinct !DISubprogram(name: "myFunc", linkageName: "myFunc", scope: !2, file: !2, line: 2, type: !4, scopeLine: 3, flags: DIFlagPublic, spFlags: DISPFlagDefinition, unit: !1, retainedNodes: !6) -!4 = !DISubroutineType(flags: DIFlagPublic, types: !5) -!5 = !{null} -!6 = !{} -!7 = !DILocation(line: 3, column: 12, scope: !3) -!8 = !DILocalVariable(name: "myFunc", scope: !3, file: !2, line: 2, type: !9) -!9 = !DIDerivedType(tag: DW_TAG_pointer_type, name: "__ref_to_STRING", baseType: !10, size: 64, align: 64, dwarfAddressSpace: 1) -!10 = !DICompositeType(tag: DW_TAG_array_type, baseType: !11, size: 80, align: 64, elements: !12) -!11 = !DIBasicType(name: "char", size: 8, encoding: DW_ATE_UTF, flags: DIFlagPublic) -!12 = !{!13} -!13 = !DISubrange(count: 80, lowerBound: 0) -!14 = !DILocation(line: 2, column: 17, scope: !3) +!1 = !{i32 2, !"Debug Info Version", i32 3} +!2 = distinct !DICompileUnit(language: DW_LANG_C, file: !3, producer: "RuSTy Structured text Compiler", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, splitDebugInlining: false) +!3 = !DIFile(filename: "main", directory: "src") +!4 = distinct !DISubprogram(name: "myFunc", linkageName: "myFunc", scope: !3, file: !3, line: 2, type: !5, scopeLine: 3, flags: DIFlagPublic, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !7) +!5 = !DISubroutineType(flags: DIFlagPublic, types: !6) +!6 = !{null} +!7 = !{} +!8 = !DILocation(line: 3, column: 12, scope: !4) +!9 = !DILocalVariable(name: "myFunc", scope: !4, file: !3, line: 2, type: !10) +!10 = !DIDerivedType(tag: DW_TAG_pointer_type, name: "__ref_to_STRING", baseType: !11, size: 64, align: 64, dwarfAddressSpace: 1) +!11 = !DICompositeType(tag: DW_TAG_array_type, baseType: !12, size: 80, align: 64, elements: !13) +!12 = !DIBasicType(name: "char", size: 8, encoding: DW_ATE_UTF, flags: DIFlagPublic) +!13 = !{!14} +!14 = !DISubrange(count: 80, lowerBound: 0) +!15 = !DILocation(line: 2, column: 17, scope: !4) diff --git a/src/codegen/tests/debug_tests/snapshots/rusty__codegen__tests__debug_tests__expression_debugging__assignment_statement_have_location.snap b/src/codegen/tests/debug_tests/snapshots/rusty__codegen__tests__debug_tests__expression_debugging__assignment_statement_have_location.snap index f9b768950f..e6d7a640d5 100644 --- a/src/codegen/tests/debug_tests/snapshots/rusty__codegen__tests__debug_tests__expression_debugging__assignment_statement_have_location.snap +++ b/src/codegen/tests/debug_tests/snapshots/rusty__codegen__tests__debug_tests__expression_debugging__assignment_statement_have_location.snap @@ -5,14 +5,14 @@ expression: result ; ModuleID = 'main' source_filename = "main" -define i32 @myFunc() !dbg !3 { +define i32 @myFunc() !dbg !4 { entry: - %myFunc = alloca i32, align 4, !dbg !7 - call void @llvm.dbg.declare(metadata i32* %myFunc, metadata !8, metadata !DIExpression()), !dbg !10 - store i32 0, i32* %myFunc, align 4, !dbg !7 - store i32 3, i32* %myFunc, align 4, !dbg !7 - %myFunc_ret = load i32, i32* %myFunc, align 4, !dbg !7 - ret i32 %myFunc_ret, !dbg !7 + %myFunc = alloca i32, align 4, !dbg !8 + call void @llvm.dbg.declare(metadata i32* %myFunc, metadata !9, metadata !DIExpression()), !dbg !11 + store i32 0, i32* %myFunc, align 4, !dbg !8 + store i32 3, i32* %myFunc, align 4, !dbg !8 + %myFunc_ret = load i32, i32* %myFunc, align 4, !dbg !8 + ret i32 %myFunc_ret, !dbg !8 } ; Function Attrs: nofree nosync nounwind readnone speculatable willreturn @@ -20,18 +20,19 @@ declare void @llvm.dbg.declare(metadata, metadata, metadata) #0 attributes #0 = { nofree nosync nounwind readnone speculatable willreturn } -!llvm.module.flags = !{!0} -!llvm.dbg.cu = !{!1} +!llvm.module.flags = !{!0, !1} +!llvm.dbg.cu = !{!2} !0 = !{i32 2, !"Dwarf Version", i32 5} -!1 = distinct !DICompileUnit(language: DW_LANG_C, file: !2, producer: "RuSTy Structured text Compiler", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, splitDebugInlining: false) -!2 = !DIFile(filename: "main", directory: "src") -!3 = distinct !DISubprogram(name: "myFunc", linkageName: "myFunc", scope: !2, file: !2, line: 2, type: !4, scopeLine: 3, flags: DIFlagPublic, spFlags: DISPFlagDefinition, unit: !1, retainedNodes: !6) -!4 = !DISubroutineType(flags: DIFlagPublic, types: !5) -!5 = !{null} -!6 = !{} -!7 = !DILocation(line: 3, column: 12, scope: !3) -!8 = !DILocalVariable(name: "myFunc", scope: !3, file: !2, line: 2, type: !9, align: 32) -!9 = !DIBasicType(name: "DINT", size: 32, encoding: DW_ATE_signed, flags: DIFlagPublic) -!10 = !DILocation(line: 2, column: 17, scope: !3) +!1 = !{i32 2, !"Debug Info Version", i32 3} +!2 = distinct !DICompileUnit(language: DW_LANG_C, file: !3, producer: "RuSTy Structured text Compiler", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, splitDebugInlining: false) +!3 = !DIFile(filename: "main", directory: "src") +!4 = distinct !DISubprogram(name: "myFunc", linkageName: "myFunc", scope: !3, file: !3, line: 2, type: !5, scopeLine: 3, flags: DIFlagPublic, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !7) +!5 = !DISubroutineType(flags: DIFlagPublic, types: !6) +!6 = !{null} +!7 = !{} +!8 = !DILocation(line: 3, column: 12, scope: !4) +!9 = !DILocalVariable(name: "myFunc", scope: !4, file: !3, line: 2, type: !10, align: 32) +!10 = !DIBasicType(name: "DINT", size: 32, encoding: DW_ATE_signed, flags: DIFlagPublic) +!11 = !DILocation(line: 2, column: 17, scope: !4) diff --git a/src/codegen/tests/debug_tests/snapshots/rusty__codegen__tests__debug_tests__expression_debugging__case_conditions_location_marked.snap b/src/codegen/tests/debug_tests/snapshots/rusty__codegen__tests__debug_tests__expression_debugging__case_conditions_location_marked.snap index ded315b2b3..42831b2c31 100644 --- a/src/codegen/tests/debug_tests/snapshots/rusty__codegen__tests__debug_tests__expression_debugging__case_conditions_location_marked.snap +++ b/src/codegen/tests/debug_tests/snapshots/rusty__codegen__tests__debug_tests__expression_debugging__case_conditions_location_marked.snap @@ -5,33 +5,33 @@ expression: result ; ModuleID = 'main' source_filename = "main" -define i32 @myFunc() !dbg !3 { +define i32 @myFunc() !dbg !4 { entry: - %myFunc = alloca i32, align 4, !dbg !7 - call void @llvm.dbg.declare(metadata i32* %myFunc, metadata !8, metadata !DIExpression()), !dbg !10 - store i32 0, i32* %myFunc, align 4, !dbg !7 - %load_myFunc = load i32, i32* %myFunc, align 4, !dbg !11 + %myFunc = alloca i32, align 4, !dbg !8 + call void @llvm.dbg.declare(metadata i32* %myFunc, metadata !9, metadata !DIExpression()), !dbg !11 + store i32 0, i32* %myFunc, align 4, !dbg !8 + %load_myFunc = load i32, i32* %myFunc, align 4, !dbg !12 switch i32 %load_myFunc, label %else [ i32 1, label %case i32 2, label %case1 - ], !dbg !12 + ], !dbg !13 case: ; preds = %entry - store i32 1, i32* %myFunc, align 4, !dbg !13 - br label %continue, !dbg !13 - -case1: ; preds = %entry store i32 1, i32* %myFunc, align 4, !dbg !14 br label %continue, !dbg !14 +case1: ; preds = %entry + store i32 1, i32* %myFunc, align 4, !dbg !15 + br label %continue, !dbg !15 + else: ; preds = %entry - store i32 1, i32* %myFunc, align 4, !dbg !12 - br label %continue, !dbg !12 + store i32 1, i32* %myFunc, align 4, !dbg !13 + br label %continue, !dbg !13 continue: ; preds = %else, %case1, %case - store i32 1, i32* %myFunc, align 4, !dbg !15 - %myFunc_ret = load i32, i32* %myFunc, align 4, !dbg !15 - ret i32 %myFunc_ret, !dbg !15 + store i32 1, i32* %myFunc, align 4, !dbg !16 + %myFunc_ret = load i32, i32* %myFunc, align 4, !dbg !16 + ret i32 %myFunc_ret, !dbg !16 } ; Function Attrs: nofree nosync nounwind readnone speculatable willreturn @@ -39,23 +39,24 @@ declare void @llvm.dbg.declare(metadata, metadata, metadata) #0 attributes #0 = { nofree nosync nounwind readnone speculatable willreturn } -!llvm.module.flags = !{!0} -!llvm.dbg.cu = !{!1} +!llvm.module.flags = !{!0, !1} +!llvm.dbg.cu = !{!2} !0 = !{i32 2, !"Dwarf Version", i32 5} -!1 = distinct !DICompileUnit(language: DW_LANG_C, file: !2, producer: "RuSTy Structured text Compiler", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, splitDebugInlining: false) -!2 = !DIFile(filename: "main", directory: "src") -!3 = distinct !DISubprogram(name: "myFunc", linkageName: "myFunc", scope: !2, file: !2, line: 2, type: !4, scopeLine: 3, flags: DIFlagPublic, spFlags: DISPFlagDefinition, unit: !1, retainedNodes: !6) -!4 = !DISubroutineType(flags: DIFlagPublic, types: !5) -!5 = !{null} -!6 = !{} -!7 = !DILocation(line: 3, column: 12, scope: !3) -!8 = !DILocalVariable(name: "myFunc", scope: !3, file: !2, line: 2, type: !9, align: 32) -!9 = !DIBasicType(name: "DINT", size: 32, encoding: DW_ATE_signed, flags: DIFlagPublic) -!10 = !DILocation(line: 2, column: 17, scope: !3) -!11 = !DILocation(line: 3, column: 17, scope: !3) -!12 = !DILocation(line: 9, column: 16, scope: !3) -!13 = !DILocation(line: 5, column: 16, scope: !3) -!14 = !DILocation(line: 7, column: 16, scope: !3) -!15 = !DILocation(line: 11, column: 12, scope: !3) +!1 = !{i32 2, !"Debug Info Version", i32 3} +!2 = distinct !DICompileUnit(language: DW_LANG_C, file: !3, producer: "RuSTy Structured text Compiler", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, splitDebugInlining: false) +!3 = !DIFile(filename: "main", directory: "src") +!4 = distinct !DISubprogram(name: "myFunc", linkageName: "myFunc", scope: !3, file: !3, line: 2, type: !5, scopeLine: 3, flags: DIFlagPublic, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !7) +!5 = !DISubroutineType(flags: DIFlagPublic, types: !6) +!6 = !{null} +!7 = !{} +!8 = !DILocation(line: 3, column: 12, scope: !4) +!9 = !DILocalVariable(name: "myFunc", scope: !4, file: !3, line: 2, type: !10, align: 32) +!10 = !DIBasicType(name: "DINT", size: 32, encoding: DW_ATE_signed, flags: DIFlagPublic) +!11 = !DILocation(line: 2, column: 17, scope: !4) +!12 = !DILocation(line: 3, column: 17, scope: !4) +!13 = !DILocation(line: 9, column: 16, scope: !4) +!14 = !DILocation(line: 5, column: 16, scope: !4) +!15 = !DILocation(line: 7, column: 16, scope: !4) +!16 = !DILocation(line: 11, column: 12, scope: !4) diff --git a/src/codegen/tests/debug_tests/snapshots/rusty__codegen__tests__debug_tests__expression_debugging__exit_statement_have_location.snap b/src/codegen/tests/debug_tests/snapshots/rusty__codegen__tests__debug_tests__expression_debugging__exit_statement_have_location.snap index 9b8e9adc58..ee72fc56d7 100644 --- a/src/codegen/tests/debug_tests/snapshots/rusty__codegen__tests__debug_tests__expression_debugging__exit_statement_have_location.snap +++ b/src/codegen/tests/debug_tests/snapshots/rusty__codegen__tests__debug_tests__expression_debugging__exit_statement_have_location.snap @@ -5,23 +5,23 @@ expression: result ; ModuleID = 'main' source_filename = "main" -define i32 @myFunc() !dbg !3 { +define i32 @myFunc() !dbg !4 { entry: - %myFunc = alloca i32, align 4, !dbg !7 - call void @llvm.dbg.declare(metadata i32* %myFunc, metadata !8, metadata !DIExpression()), !dbg !10 - store i32 0, i32* %myFunc, align 4, !dbg !7 - br label %condition_check, !dbg !11 + %myFunc = alloca i32, align 4, !dbg !8 + call void @llvm.dbg.declare(metadata i32* %myFunc, metadata !9, metadata !DIExpression()), !dbg !11 + store i32 0, i32* %myFunc, align 4, !dbg !8 + br label %condition_check, !dbg !12 condition_check: ; preds = %entry, %while_body - br i1 true, label %while_body, label %continue, !dbg !11 + br i1 true, label %while_body, label %continue, !dbg !12 while_body: ; preds = %condition_check - br label %condition_check, !dbg !11 + br label %condition_check, !dbg !12 continue: ; preds = %condition_check - store i32 1, i32* %myFunc, align 4, !dbg !12 - %myFunc_ret = load i32, i32* %myFunc, align 4, !dbg !12 - ret i32 %myFunc_ret, !dbg !12 + store i32 1, i32* %myFunc, align 4, !dbg !13 + %myFunc_ret = load i32, i32* %myFunc, align 4, !dbg !13 + ret i32 %myFunc_ret, !dbg !13 } ; Function Attrs: nofree nosync nounwind readnone speculatable willreturn @@ -29,20 +29,21 @@ declare void @llvm.dbg.declare(metadata, metadata, metadata) #0 attributes #0 = { nofree nosync nounwind readnone speculatable willreturn } -!llvm.module.flags = !{!0} -!llvm.dbg.cu = !{!1} +!llvm.module.flags = !{!0, !1} +!llvm.dbg.cu = !{!2} !0 = !{i32 2, !"Dwarf Version", i32 5} -!1 = distinct !DICompileUnit(language: DW_LANG_C, file: !2, producer: "RuSTy Structured text Compiler", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, splitDebugInlining: false) -!2 = !DIFile(filename: "main", directory: "src") -!3 = distinct !DISubprogram(name: "myFunc", linkageName: "myFunc", scope: !2, file: !2, line: 2, type: !4, scopeLine: 3, flags: DIFlagPublic, spFlags: DISPFlagDefinition, unit: !1, retainedNodes: !6) -!4 = !DISubroutineType(flags: DIFlagPublic, types: !5) -!5 = !{null} -!6 = !{} -!7 = !DILocation(line: 3, column: 12, scope: !3) -!8 = !DILocalVariable(name: "myFunc", scope: !3, file: !2, line: 2, type: !9, align: 32) -!9 = !DIBasicType(name: "DINT", size: 32, encoding: DW_ATE_signed, flags: DIFlagPublic) -!10 = !DILocation(line: 2, column: 17, scope: !3) -!11 = !DILocation(line: 3, column: 18, scope: !3) -!12 = !DILocation(line: 6, column: 12, scope: !3) +!1 = !{i32 2, !"Debug Info Version", i32 3} +!2 = distinct !DICompileUnit(language: DW_LANG_C, file: !3, producer: "RuSTy Structured text Compiler", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, splitDebugInlining: false) +!3 = !DIFile(filename: "main", directory: "src") +!4 = distinct !DISubprogram(name: "myFunc", linkageName: "myFunc", scope: !3, file: !3, line: 2, type: !5, scopeLine: 3, flags: DIFlagPublic, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !7) +!5 = !DISubroutineType(flags: DIFlagPublic, types: !6) +!6 = !{null} +!7 = !{} +!8 = !DILocation(line: 3, column: 12, scope: !4) +!9 = !DILocalVariable(name: "myFunc", scope: !4, file: !3, line: 2, type: !10, align: 32) +!10 = !DIBasicType(name: "DINT", size: 32, encoding: DW_ATE_signed, flags: DIFlagPublic) +!11 = !DILocation(line: 2, column: 17, scope: !4) +!12 = !DILocation(line: 3, column: 18, scope: !4) +!13 = !DILocation(line: 6, column: 12, scope: !4) diff --git a/src/codegen/tests/debug_tests/snapshots/rusty__codegen__tests__debug_tests__expression_debugging__external_impl_added_as_external_subroutine.snap b/src/codegen/tests/debug_tests/snapshots/rusty__codegen__tests__debug_tests__expression_debugging__external_impl_is_not_added_as_external_subroutine.snap similarity index 51% rename from src/codegen/tests/debug_tests/snapshots/rusty__codegen__tests__debug_tests__expression_debugging__external_impl_added_as_external_subroutine.snap rename to src/codegen/tests/debug_tests/snapshots/rusty__codegen__tests__debug_tests__expression_debugging__external_impl_is_not_added_as_external_subroutine.snap index da2551e8e1..c0d7de781b 100644 --- a/src/codegen/tests/debug_tests/snapshots/rusty__codegen__tests__debug_tests__expression_debugging__external_impl_added_as_external_subroutine.snap +++ b/src/codegen/tests/debug_tests/snapshots/rusty__codegen__tests__debug_tests__expression_debugging__external_impl_is_not_added_as_external_subroutine.snap @@ -11,14 +11,14 @@ source_filename = "main" @myPrg_instance = external global %myPrg, !dbg !0 @__myFb__init = unnamed_addr constant %myFb zeroinitializer, !dbg !5 -declare !dbg !11 i32 @myFunc() +declare i32 @myFunc() -declare !dbg !15 void @myPrg(%myPrg*) +declare void @myPrg(%myPrg*) -declare !dbg !17 void @myFb(%myFb*) +declare void @myFb(%myFb*) -!llvm.module.flags = !{!8} -!llvm.dbg.cu = !{!9} +!llvm.module.flags = !{!8, !9} +!llvm.dbg.cu = !{!10} !0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression()) !1 = distinct !DIGlobalVariable(name: "myPrg", scope: !2, file: !2, line: 4, type: !3, isLocal: false, isDefinition: true) @@ -29,14 +29,7 @@ declare !dbg !17 void @myFb(%myFb*) !6 = distinct !DIGlobalVariable(name: "__myFb__init", scope: !2, file: !2, line: 6, type: !7, isLocal: false, isDefinition: true) !7 = !DICompositeType(tag: DW_TAG_structure_type, name: "myFb", scope: !2, file: !2, line: 6, align: 64, flags: DIFlagPublic, elements: !4, identifier: "myFb") !8 = !{i32 2, !"Dwarf Version", i32 5} -!9 = distinct !DICompileUnit(language: DW_LANG_C, file: !2, producer: "RuSTy Structured text Compiler", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, globals: !10, splitDebugInlining: false) -!10 = !{!0, !5} -!11 = !DISubprogram(name: "myFunc", linkageName: "myFunc", scope: !2, file: !2, line: 2, type: !12, scopeLine: 3, flags: DIFlagPublic, spFlags: 0, retainedNodes: !14) -!12 = !DISubroutineType(flags: DIFlagPublic, types: !13) -!13 = !{null} -!14 = !{} -!15 = !DISubprogram(name: "myPrg", linkageName: "myPrg", scope: !2, file: !2, line: 4, type: !12, scopeLine: 5, flags: DIFlagPublic, spFlags: 0, retainedNodes: !16) -!16 = !{} -!17 = !DISubprogram(name: "myFb", linkageName: "myFb", scope: !2, file: !2, line: 6, type: !12, scopeLine: 7, flags: DIFlagPublic, spFlags: 0, retainedNodes: !18) -!18 = !{} +!9 = !{i32 2, !"Debug Info Version", i32 3} +!10 = distinct !DICompileUnit(language: DW_LANG_C, file: !2, producer: "RuSTy Structured text Compiler", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, globals: !11, splitDebugInlining: false) +!11 = !{!0, !5} diff --git a/src/codegen/tests/debug_tests/snapshots/rusty__codegen__tests__debug_tests__expression_debugging__for_conditions_location_marked.snap b/src/codegen/tests/debug_tests/snapshots/rusty__codegen__tests__debug_tests__expression_debugging__for_conditions_location_marked.snap index ff2b56a26c..ee99845615 100644 --- a/src/codegen/tests/debug_tests/snapshots/rusty__codegen__tests__debug_tests__expression_debugging__for_conditions_location_marked.snap +++ b/src/codegen/tests/debug_tests/snapshots/rusty__codegen__tests__debug_tests__expression_debugging__for_conditions_location_marked.snap @@ -5,73 +5,73 @@ expression: result ; ModuleID = 'main' source_filename = "main" -define i32 @myFunc() !dbg !3 { +define i32 @myFunc() !dbg !4 { entry: - %myFunc = alloca i32, align 4, !dbg !7 - call void @llvm.dbg.declare(metadata i32* %myFunc, metadata !8, metadata !DIExpression()), !dbg !10 - store i32 0, i32* %myFunc, align 4, !dbg !7 - store i32 1, i32* %myFunc, align 4, !dbg !11 - br label %condition_check, !dbg !11 + %myFunc = alloca i32, align 4, !dbg !8 + call void @llvm.dbg.declare(metadata i32* %myFunc, metadata !9, metadata !DIExpression()), !dbg !11 + store i32 0, i32* %myFunc, align 4, !dbg !8 + store i32 1, i32* %myFunc, align 4, !dbg !12 + br label %condition_check, !dbg !12 condition_check: ; preds = %increment, %entry - %load_myFunc = load i32, i32* %myFunc, align 4, !dbg !11 - %load_myFunc1 = load i32, i32* %myFunc, align 4, !dbg !11 - %tmpVar = icmp sle i32 %load_myFunc1, 20, !dbg !11 - %0 = zext i1 %tmpVar to i8, !dbg !11 - %1 = icmp ne i8 %0, 0, !dbg !11 - br i1 %1, label %2, label %5, !dbg !11 + %load_myFunc = load i32, i32* %myFunc, align 4, !dbg !12 + %load_myFunc1 = load i32, i32* %myFunc, align 4, !dbg !12 + %tmpVar = icmp sle i32 %load_myFunc1, 20, !dbg !12 + %0 = zext i1 %tmpVar to i8, !dbg !12 + %1 = icmp ne i8 %0, 0, !dbg !12 + br i1 %1, label %2, label %5, !dbg !12 for_body: ; preds = %12 - store i32 1, i32* %myFunc, align 4, !dbg !12 - br label %increment, !dbg !12 + store i32 1, i32* %myFunc, align 4, !dbg !13 + br label %increment, !dbg !13 increment: ; preds = %for_body - %tmpVar8 = add i32 %load_myFunc, 2, !dbg !13 - store i32 %tmpVar8, i32* %myFunc, align 4, !dbg !13 - br label %condition_check, !dbg !13 + %tmpVar8 = add i32 %load_myFunc, 2, !dbg !14 + store i32 %tmpVar8, i32* %myFunc, align 4, !dbg !14 + br label %condition_check, !dbg !14 continue: ; preds = %12 - %myFunc_ret = load i32, i32* %myFunc, align 4, !dbg !13 - ret i32 %myFunc_ret, !dbg !13 + %myFunc_ret = load i32, i32* %myFunc, align 4, !dbg !14 + ret i32 %myFunc_ret, !dbg !14 2: ; preds = %condition_check - %load_myFunc2 = load i32, i32* %myFunc, align 4, !dbg !11 - %tmpVar3 = icmp sge i32 %load_myFunc2, 1, !dbg !11 - %3 = zext i1 %tmpVar3 to i8, !dbg !11 - %4 = icmp ne i8 %3, 0, !dbg !11 - br label %5, !dbg !11 + %load_myFunc2 = load i32, i32* %myFunc, align 4, !dbg !12 + %tmpVar3 = icmp sge i32 %load_myFunc2, 1, !dbg !12 + %3 = zext i1 %tmpVar3 to i8, !dbg !12 + %4 = icmp ne i8 %3, 0, !dbg !12 + br label %5, !dbg !12 5: ; preds = %2, %condition_check - %6 = phi i1 [ %1, %condition_check ], [ %4, %2 ], !dbg !11 - %7 = zext i1 %6 to i8, !dbg !11 - %8 = icmp ne i8 %7, 0, !dbg !11 - br i1 %8, label %12, label %9, !dbg !11 + %6 = phi i1 [ %1, %condition_check ], [ %4, %2 ], !dbg !12 + %7 = zext i1 %6 to i8, !dbg !12 + %8 = icmp ne i8 %7, 0, !dbg !12 + br i1 %8, label %12, label %9, !dbg !12 9: ; preds = %5 - %load_myFunc4 = load i32, i32* %myFunc, align 4, !dbg !11 - %tmpVar5 = icmp sge i32 %load_myFunc4, 20, !dbg !11 - %10 = zext i1 %tmpVar5 to i8, !dbg !11 - %11 = icmp ne i8 %10, 0, !dbg !11 - br i1 %11, label %16, label %19, !dbg !11 + %load_myFunc4 = load i32, i32* %myFunc, align 4, !dbg !12 + %tmpVar5 = icmp sge i32 %load_myFunc4, 20, !dbg !12 + %10 = zext i1 %tmpVar5 to i8, !dbg !12 + %11 = icmp ne i8 %10, 0, !dbg !12 + br i1 %11, label %16, label %19, !dbg !12 12: ; preds = %19, %5 - %13 = phi i1 [ %8, %5 ], [ %22, %19 ], !dbg !11 - %14 = zext i1 %13 to i8, !dbg !11 - %15 = icmp ne i8 %14, 0, !dbg !11 - br i1 %15, label %for_body, label %continue, !dbg !11 + %13 = phi i1 [ %8, %5 ], [ %22, %19 ], !dbg !12 + %14 = zext i1 %13 to i8, !dbg !12 + %15 = icmp ne i8 %14, 0, !dbg !12 + br i1 %15, label %for_body, label %continue, !dbg !12 16: ; preds = %9 - %load_myFunc6 = load i32, i32* %myFunc, align 4, !dbg !11 - %tmpVar7 = icmp sle i32 %load_myFunc6, 1, !dbg !11 - %17 = zext i1 %tmpVar7 to i8, !dbg !11 - %18 = icmp ne i8 %17, 0, !dbg !11 - br label %19, !dbg !11 + %load_myFunc6 = load i32, i32* %myFunc, align 4, !dbg !12 + %tmpVar7 = icmp sle i32 %load_myFunc6, 1, !dbg !12 + %17 = zext i1 %tmpVar7 to i8, !dbg !12 + %18 = icmp ne i8 %17, 0, !dbg !12 + br label %19, !dbg !12 19: ; preds = %16, %9 - %20 = phi i1 [ %11, %9 ], [ %18, %16 ], !dbg !11 - %21 = zext i1 %20 to i8, !dbg !11 - %22 = icmp ne i8 %21, 0, !dbg !11 - br label %12, !dbg !11 + %20 = phi i1 [ %11, %9 ], [ %18, %16 ], !dbg !12 + %21 = zext i1 %20 to i8, !dbg !12 + %22 = icmp ne i8 %21, 0, !dbg !12 + br label %12, !dbg !12 } ; Function Attrs: nofree nosync nounwind readnone speculatable willreturn @@ -79,21 +79,22 @@ declare void @llvm.dbg.declare(metadata, metadata, metadata) #0 attributes #0 = { nofree nosync nounwind readnone speculatable willreturn } -!llvm.module.flags = !{!0} -!llvm.dbg.cu = !{!1} +!llvm.module.flags = !{!0, !1} +!llvm.dbg.cu = !{!2} !0 = !{i32 2, !"Dwarf Version", i32 5} -!1 = distinct !DICompileUnit(language: DW_LANG_C, file: !2, producer: "RuSTy Structured text Compiler", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, splitDebugInlining: false) -!2 = !DIFile(filename: "main", directory: "src") -!3 = distinct !DISubprogram(name: "myFunc", linkageName: "myFunc", scope: !2, file: !2, line: 2, type: !4, scopeLine: 3, flags: DIFlagPublic, spFlags: DISPFlagDefinition, unit: !1, retainedNodes: !6) -!4 = !DISubroutineType(flags: DIFlagPublic, types: !5) -!5 = !{null} -!6 = !{} -!7 = !DILocation(line: 3, column: 12, scope: !3) -!8 = !DILocalVariable(name: "myFunc", scope: !3, file: !2, line: 2, type: !9, align: 32) -!9 = !DIBasicType(name: "DINT", size: 32, encoding: DW_ATE_signed, flags: DIFlagPublic) -!10 = !DILocation(line: 2, column: 17, scope: !3) -!11 = !DILocation(line: 3, column: 16, scope: !3) -!12 = !DILocation(line: 4, column: 16, scope: !3) -!13 = !DILocation(line: 3, column: 37, scope: !3) +!1 = !{i32 2, !"Debug Info Version", i32 3} +!2 = distinct !DICompileUnit(language: DW_LANG_C, file: !3, producer: "RuSTy Structured text Compiler", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, splitDebugInlining: false) +!3 = !DIFile(filename: "main", directory: "src") +!4 = distinct !DISubprogram(name: "myFunc", linkageName: "myFunc", scope: !3, file: !3, line: 2, type: !5, scopeLine: 3, flags: DIFlagPublic, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !7) +!5 = !DISubroutineType(flags: DIFlagPublic, types: !6) +!6 = !{null} +!7 = !{} +!8 = !DILocation(line: 3, column: 12, scope: !4) +!9 = !DILocalVariable(name: "myFunc", scope: !4, file: !3, line: 2, type: !10, align: 32) +!10 = !DIBasicType(name: "DINT", size: 32, encoding: DW_ATE_signed, flags: DIFlagPublic) +!11 = !DILocation(line: 2, column: 17, scope: !4) +!12 = !DILocation(line: 3, column: 16, scope: !4) +!13 = !DILocation(line: 4, column: 16, scope: !4) +!14 = !DILocation(line: 3, column: 37, scope: !4) diff --git a/src/codegen/tests/debug_tests/snapshots/rusty__codegen__tests__debug_tests__expression_debugging__function_calls_have_location.snap b/src/codegen/tests/debug_tests/snapshots/rusty__codegen__tests__debug_tests__expression_debugging__function_calls_have_location.snap index 13e8480161..d44923da57 100644 --- a/src/codegen/tests/debug_tests/snapshots/rusty__codegen__tests__debug_tests__expression_debugging__function_calls_have_location.snap +++ b/src/codegen/tests/debug_tests/snapshots/rusty__codegen__tests__debug_tests__expression_debugging__function_calls_have_location.snap @@ -5,14 +5,14 @@ expression: result ; ModuleID = 'main' source_filename = "main" -define i32 @myFunc() !dbg !3 { +define i32 @myFunc() !dbg !4 { entry: - %myFunc = alloca i32, align 4, !dbg !7 - call void @llvm.dbg.declare(metadata i32* %myFunc, metadata !8, metadata !DIExpression()), !dbg !10 - store i32 0, i32* %myFunc, align 4, !dbg !7 - %call = call i32 @myFunc(), !dbg !7 - %myFunc_ret = load i32, i32* %myFunc, align 4, !dbg !7 - ret i32 %myFunc_ret, !dbg !7 + %myFunc = alloca i32, align 4, !dbg !8 + call void @llvm.dbg.declare(metadata i32* %myFunc, metadata !9, metadata !DIExpression()), !dbg !11 + store i32 0, i32* %myFunc, align 4, !dbg !8 + %call = call i32 @myFunc(), !dbg !8 + %myFunc_ret = load i32, i32* %myFunc, align 4, !dbg !8 + ret i32 %myFunc_ret, !dbg !8 } ; Function Attrs: nofree nosync nounwind readnone speculatable willreturn @@ -20,18 +20,19 @@ declare void @llvm.dbg.declare(metadata, metadata, metadata) #0 attributes #0 = { nofree nosync nounwind readnone speculatable willreturn } -!llvm.module.flags = !{!0} -!llvm.dbg.cu = !{!1} +!llvm.module.flags = !{!0, !1} +!llvm.dbg.cu = !{!2} !0 = !{i32 2, !"Dwarf Version", i32 5} -!1 = distinct !DICompileUnit(language: DW_LANG_C, file: !2, producer: "RuSTy Structured text Compiler", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, splitDebugInlining: false) -!2 = !DIFile(filename: "main", directory: "src") -!3 = distinct !DISubprogram(name: "myFunc", linkageName: "myFunc", scope: !2, file: !2, line: 2, type: !4, scopeLine: 3, flags: DIFlagPublic, spFlags: DISPFlagDefinition, unit: !1, retainedNodes: !6) -!4 = !DISubroutineType(flags: DIFlagPublic, types: !5) -!5 = !{null} -!6 = !{} -!7 = !DILocation(line: 3, column: 12, scope: !3) -!8 = !DILocalVariable(name: "myFunc", scope: !3, file: !2, line: 2, type: !9, align: 32) -!9 = !DIBasicType(name: "DINT", size: 32, encoding: DW_ATE_signed, flags: DIFlagPublic) -!10 = !DILocation(line: 2, column: 17, scope: !3) +!1 = !{i32 2, !"Debug Info Version", i32 3} +!2 = distinct !DICompileUnit(language: DW_LANG_C, file: !3, producer: "RuSTy Structured text Compiler", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, splitDebugInlining: false) +!3 = !DIFile(filename: "main", directory: "src") +!4 = distinct !DISubprogram(name: "myFunc", linkageName: "myFunc", scope: !3, file: !3, line: 2, type: !5, scopeLine: 3, flags: DIFlagPublic, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !7) +!5 = !DISubroutineType(flags: DIFlagPublic, types: !6) +!6 = !{null} +!7 = !{} +!8 = !DILocation(line: 3, column: 12, scope: !4) +!9 = !DILocalVariable(name: "myFunc", scope: !4, file: !3, line: 2, type: !10, align: 32) +!10 = !DIBasicType(name: "DINT", size: 32, encoding: DW_ATE_signed, flags: DIFlagPublic) +!11 = !DILocation(line: 2, column: 17, scope: !4) diff --git a/src/codegen/tests/debug_tests/snapshots/rusty__codegen__tests__debug_tests__expression_debugging__function_calls_in_expressions_have_location.snap b/src/codegen/tests/debug_tests/snapshots/rusty__codegen__tests__debug_tests__expression_debugging__function_calls_in_expressions_have_location.snap index 2ba610e434..7d7f35da9d 100644 --- a/src/codegen/tests/debug_tests/snapshots/rusty__codegen__tests__debug_tests__expression_debugging__function_calls_in_expressions_have_location.snap +++ b/src/codegen/tests/debug_tests/snapshots/rusty__codegen__tests__debug_tests__expression_debugging__function_calls_in_expressions_have_location.snap @@ -5,15 +5,15 @@ expression: result ; ModuleID = 'main' source_filename = "main" -define i32 @myFunc() !dbg !3 { +define i32 @myFunc() !dbg !4 { entry: - %myFunc = alloca i32, align 4, !dbg !7 - call void @llvm.dbg.declare(metadata i32* %myFunc, metadata !8, metadata !DIExpression()), !dbg !10 - store i32 0, i32* %myFunc, align 4, !dbg !7 - %call = call i32 @myFunc(), !dbg !11 - %tmpVar = add i32 1, %call, !dbg !11 - %myFunc_ret = load i32, i32* %myFunc, align 4, !dbg !11 - ret i32 %myFunc_ret, !dbg !11 + %myFunc = alloca i32, align 4, !dbg !8 + call void @llvm.dbg.declare(metadata i32* %myFunc, metadata !9, metadata !DIExpression()), !dbg !11 + store i32 0, i32* %myFunc, align 4, !dbg !8 + %call = call i32 @myFunc(), !dbg !12 + %tmpVar = add i32 1, %call, !dbg !12 + %myFunc_ret = load i32, i32* %myFunc, align 4, !dbg !12 + ret i32 %myFunc_ret, !dbg !12 } ; Function Attrs: nofree nosync nounwind readnone speculatable willreturn @@ -21,19 +21,20 @@ declare void @llvm.dbg.declare(metadata, metadata, metadata) #0 attributes #0 = { nofree nosync nounwind readnone speculatable willreturn } -!llvm.module.flags = !{!0} -!llvm.dbg.cu = !{!1} +!llvm.module.flags = !{!0, !1} +!llvm.dbg.cu = !{!2} !0 = !{i32 2, !"Dwarf Version", i32 5} -!1 = distinct !DICompileUnit(language: DW_LANG_C, file: !2, producer: "RuSTy Structured text Compiler", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, splitDebugInlining: false) -!2 = !DIFile(filename: "main", directory: "src") -!3 = distinct !DISubprogram(name: "myFunc", linkageName: "myFunc", scope: !2, file: !2, line: 2, type: !4, scopeLine: 3, flags: DIFlagPublic, spFlags: DISPFlagDefinition, unit: !1, retainedNodes: !6) -!4 = !DISubroutineType(flags: DIFlagPublic, types: !5) -!5 = !{null} -!6 = !{} -!7 = !DILocation(line: 3, column: 12, scope: !3) -!8 = !DILocalVariable(name: "myFunc", scope: !3, file: !2, line: 2, type: !9, align: 32) -!9 = !DIBasicType(name: "DINT", size: 32, encoding: DW_ATE_signed, flags: DIFlagPublic) -!10 = !DILocation(line: 2, column: 17, scope: !3) -!11 = !DILocation(line: 3, column: 16, scope: !3) +!1 = !{i32 2, !"Debug Info Version", i32 3} +!2 = distinct !DICompileUnit(language: DW_LANG_C, file: !3, producer: "RuSTy Structured text Compiler", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, splitDebugInlining: false) +!3 = !DIFile(filename: "main", directory: "src") +!4 = distinct !DISubprogram(name: "myFunc", linkageName: "myFunc", scope: !3, file: !3, line: 2, type: !5, scopeLine: 3, flags: DIFlagPublic, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !7) +!5 = !DISubroutineType(flags: DIFlagPublic, types: !6) +!6 = !{null} +!7 = !{} +!8 = !DILocation(line: 3, column: 12, scope: !4) +!9 = !DILocalVariable(name: "myFunc", scope: !4, file: !3, line: 2, type: !10, align: 32) +!10 = !DIBasicType(name: "DINT", size: 32, encoding: DW_ATE_signed, flags: DIFlagPublic) +!11 = !DILocation(line: 2, column: 17, scope: !4) +!12 = !DILocation(line: 3, column: 16, scope: !4) diff --git a/src/codegen/tests/debug_tests/snapshots/rusty__codegen__tests__debug_tests__expression_debugging__if_conditions_location_marked.snap b/src/codegen/tests/debug_tests/snapshots/rusty__codegen__tests__debug_tests__expression_debugging__if_conditions_location_marked.snap index 7af350bba1..fa841ecb2b 100644 --- a/src/codegen/tests/debug_tests/snapshots/rusty__codegen__tests__debug_tests__expression_debugging__if_conditions_location_marked.snap +++ b/src/codegen/tests/debug_tests/snapshots/rusty__codegen__tests__debug_tests__expression_debugging__if_conditions_location_marked.snap @@ -5,32 +5,32 @@ expression: result ; ModuleID = 'main' source_filename = "main" -define i32 @myFunc() !dbg !3 { +define i32 @myFunc() !dbg !4 { entry: - %myFunc = alloca i32, align 4, !dbg !7 - call void @llvm.dbg.declare(metadata i32* %myFunc, metadata !8, metadata !DIExpression()), !dbg !10 - store i32 0, i32* %myFunc, align 4, !dbg !7 - br i1 true, label %condition_body, label %branch, !dbg !11 + %myFunc = alloca i32, align 4, !dbg !8 + call void @llvm.dbg.declare(metadata i32* %myFunc, metadata !9, metadata !DIExpression()), !dbg !11 + store i32 0, i32* %myFunc, align 4, !dbg !8 + br i1 true, label %condition_body, label %branch, !dbg !12 condition_body: ; preds = %entry - store i32 1, i32* %myFunc, align 4, !dbg !12 - br label %continue, !dbg !12 + store i32 1, i32* %myFunc, align 4, !dbg !13 + br label %continue, !dbg !13 branch: ; preds = %entry - br i1 false, label %condition_body1, label %else, !dbg !13 + br i1 false, label %condition_body1, label %else, !dbg !14 condition_body1: ; preds = %branch - store i32 1, i32* %myFunc, align 4, !dbg !14 - br label %continue, !dbg !14 - -else: ; preds = %branch store i32 1, i32* %myFunc, align 4, !dbg !15 br label %continue, !dbg !15 -continue: ; preds = %else, %condition_body1, %condition_body +else: ; preds = %branch store i32 1, i32* %myFunc, align 4, !dbg !16 - %myFunc_ret = load i32, i32* %myFunc, align 4, !dbg !16 - ret i32 %myFunc_ret, !dbg !16 + br label %continue, !dbg !16 + +continue: ; preds = %else, %condition_body1, %condition_body + store i32 1, i32* %myFunc, align 4, !dbg !17 + %myFunc_ret = load i32, i32* %myFunc, align 4, !dbg !17 + ret i32 %myFunc_ret, !dbg !17 } ; Function Attrs: nofree nosync nounwind readnone speculatable willreturn @@ -38,24 +38,25 @@ declare void @llvm.dbg.declare(metadata, metadata, metadata) #0 attributes #0 = { nofree nosync nounwind readnone speculatable willreturn } -!llvm.module.flags = !{!0} -!llvm.dbg.cu = !{!1} +!llvm.module.flags = !{!0, !1} +!llvm.dbg.cu = !{!2} !0 = !{i32 2, !"Dwarf Version", i32 5} -!1 = distinct !DICompileUnit(language: DW_LANG_C, file: !2, producer: "RuSTy Structured text Compiler", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, splitDebugInlining: false) -!2 = !DIFile(filename: "main", directory: "src") -!3 = distinct !DISubprogram(name: "myFunc", linkageName: "myFunc", scope: !2, file: !2, line: 2, type: !4, scopeLine: 3, flags: DIFlagPublic, spFlags: DISPFlagDefinition, unit: !1, retainedNodes: !6) -!4 = !DISubroutineType(flags: DIFlagPublic, types: !5) -!5 = !{null} -!6 = !{} -!7 = !DILocation(line: 3, column: 12, scope: !3) -!8 = !DILocalVariable(name: "myFunc", scope: !3, file: !2, line: 2, type: !9, align: 32) -!9 = !DIBasicType(name: "DINT", size: 32, encoding: DW_ATE_signed, flags: DIFlagPublic) -!10 = !DILocation(line: 2, column: 17, scope: !3) -!11 = !DILocation(line: 3, column: 15, scope: !3) -!12 = !DILocation(line: 4, column: 16, scope: !3) -!13 = !DILocation(line: 5, column: 18, scope: !3) -!14 = !DILocation(line: 6, column: 16, scope: !3) -!15 = !DILocation(line: 8, column: 16, scope: !3) -!16 = !DILocation(line: 10, column: 12, scope: !3) +!1 = !{i32 2, !"Debug Info Version", i32 3} +!2 = distinct !DICompileUnit(language: DW_LANG_C, file: !3, producer: "RuSTy Structured text Compiler", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, splitDebugInlining: false) +!3 = !DIFile(filename: "main", directory: "src") +!4 = distinct !DISubprogram(name: "myFunc", linkageName: "myFunc", scope: !3, file: !3, line: 2, type: !5, scopeLine: 3, flags: DIFlagPublic, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !7) +!5 = !DISubroutineType(flags: DIFlagPublic, types: !6) +!6 = !{null} +!7 = !{} +!8 = !DILocation(line: 3, column: 12, scope: !4) +!9 = !DILocalVariable(name: "myFunc", scope: !4, file: !3, line: 2, type: !10, align: 32) +!10 = !DIBasicType(name: "DINT", size: 32, encoding: DW_ATE_signed, flags: DIFlagPublic) +!11 = !DILocation(line: 2, column: 17, scope: !4) +!12 = !DILocation(line: 3, column: 15, scope: !4) +!13 = !DILocation(line: 4, column: 16, scope: !4) +!14 = !DILocation(line: 5, column: 18, scope: !4) +!15 = !DILocation(line: 6, column: 16, scope: !4) +!16 = !DILocation(line: 8, column: 16, scope: !4) +!17 = !DILocation(line: 10, column: 12, scope: !4) diff --git a/src/codegen/tests/debug_tests/snapshots/rusty__codegen__tests__debug_tests__expression_debugging__implementation_added_as_subroutine.snap b/src/codegen/tests/debug_tests/snapshots/rusty__codegen__tests__debug_tests__expression_debugging__implementation_added_as_subroutine.snap index 29c07f8099..360b51f756 100644 --- a/src/codegen/tests/debug_tests/snapshots/rusty__codegen__tests__debug_tests__expression_debugging__implementation_added_as_subroutine.snap +++ b/src/codegen/tests/debug_tests/snapshots/rusty__codegen__tests__debug_tests__expression_debugging__implementation_added_as_subroutine.snap @@ -11,25 +11,25 @@ source_filename = "main" @myPrg_instance = global %myPrg zeroinitializer, !dbg !0 @__myFb__init = unnamed_addr constant %myFb zeroinitializer, !dbg !5 -define i32 @myFunc() !dbg !11 { +define i32 @myFunc() !dbg !12 { entry: - %myFunc = alloca i32, align 4, !dbg !14 - call void @llvm.dbg.declare(metadata i32* %myFunc, metadata !15, metadata !DIExpression()), !dbg !17 - store i32 0, i32* %myFunc, align 4, !dbg !14 - %myFunc_ret = load i32, i32* %myFunc, align 4, !dbg !14 - ret i32 %myFunc_ret, !dbg !14 + %myFunc = alloca i32, align 4, !dbg !15 + call void @llvm.dbg.declare(metadata i32* %myFunc, metadata !16, metadata !DIExpression()), !dbg !18 + store i32 0, i32* %myFunc, align 4, !dbg !15 + %myFunc_ret = load i32, i32* %myFunc, align 4, !dbg !15 + ret i32 %myFunc_ret, !dbg !15 } -define void @myPrg(%myPrg* %0) !dbg !18 { +define void @myPrg(%myPrg* %0) !dbg !19 { entry: - call void @llvm.dbg.declare(metadata %myPrg* %0, metadata !19, metadata !DIExpression()), !dbg !20 - ret void, !dbg !20 + call void @llvm.dbg.declare(metadata %myPrg* %0, metadata !20, metadata !DIExpression()), !dbg !21 + ret void, !dbg !21 } -define void @myFb(%myFb* %0) !dbg !21 { +define void @myFb(%myFb* %0) !dbg !22 { entry: - call void @llvm.dbg.declare(metadata %myFb* %0, metadata !22, metadata !DIExpression()), !dbg !23 - ret void, !dbg !23 + call void @llvm.dbg.declare(metadata %myFb* %0, metadata !23, metadata !DIExpression()), !dbg !24 + ret void, !dbg !24 } ; Function Attrs: nofree nosync nounwind readnone speculatable willreturn @@ -37,8 +37,8 @@ declare void @llvm.dbg.declare(metadata, metadata, metadata) #0 attributes #0 = { nofree nosync nounwind readnone speculatable willreturn } -!llvm.module.flags = !{!8} -!llvm.dbg.cu = !{!9} +!llvm.module.flags = !{!8, !9} +!llvm.dbg.cu = !{!10} !0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression()) !1 = distinct !DIGlobalVariable(name: "myPrg", scope: !2, file: !2, line: 4, type: !3, isLocal: false, isDefinition: true) @@ -49,19 +49,20 @@ attributes #0 = { nofree nosync nounwind readnone speculatable willreturn } !6 = distinct !DIGlobalVariable(name: "__myFb__init", scope: !2, file: !2, line: 6, type: !7, isLocal: false, isDefinition: true) !7 = !DICompositeType(tag: DW_TAG_structure_type, name: "myFb", scope: !2, file: !2, line: 6, align: 64, flags: DIFlagPublic, elements: !4, identifier: "myFb") !8 = !{i32 2, !"Dwarf Version", i32 5} -!9 = distinct !DICompileUnit(language: DW_LANG_C, file: !2, producer: "RuSTy Structured text Compiler", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, globals: !10, splitDebugInlining: false) -!10 = !{!0, !5} -!11 = distinct !DISubprogram(name: "myFunc", linkageName: "myFunc", scope: !2, file: !2, line: 2, type: !12, scopeLine: 3, flags: DIFlagPublic, spFlags: DISPFlagDefinition, unit: !9, retainedNodes: !4) -!12 = !DISubroutineType(flags: DIFlagPublic, types: !13) -!13 = !{null} -!14 = !DILocation(line: 3, column: 8, scope: !11) -!15 = !DILocalVariable(name: "myFunc", scope: !11, file: !2, line: 2, type: !16, align: 32) -!16 = !DIBasicType(name: "DINT", size: 32, encoding: DW_ATE_signed, flags: DIFlagPublic) -!17 = !DILocation(line: 2, column: 17, scope: !11) -!18 = distinct !DISubprogram(name: "myPrg", linkageName: "myPrg", scope: !2, file: !2, line: 4, type: !12, scopeLine: 5, flags: DIFlagPublic, spFlags: DISPFlagDefinition, unit: !9, retainedNodes: !4) -!19 = !DILocalVariable(name: "myPrg", scope: !18, file: !2, line: 4, type: !3) -!20 = !DILocation(line: 5, column: 8, scope: !18) -!21 = distinct !DISubprogram(name: "myFb", linkageName: "myFb", scope: !2, file: !2, line: 6, type: !12, scopeLine: 7, flags: DIFlagPublic, spFlags: DISPFlagDefinition, unit: !9, retainedNodes: !4) -!22 = !DILocalVariable(name: "myFb", scope: !21, file: !2, line: 6, type: !7) -!23 = !DILocation(line: 7, column: 8, scope: !21) +!9 = !{i32 2, !"Debug Info Version", i32 3} +!10 = distinct !DICompileUnit(language: DW_LANG_C, file: !2, producer: "RuSTy Structured text Compiler", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, globals: !11, splitDebugInlining: false) +!11 = !{!0, !5} +!12 = distinct !DISubprogram(name: "myFunc", linkageName: "myFunc", scope: !2, file: !2, line: 2, type: !13, scopeLine: 3, flags: DIFlagPublic, spFlags: DISPFlagDefinition, unit: !10, retainedNodes: !4) +!13 = !DISubroutineType(flags: DIFlagPublic, types: !14) +!14 = !{null} +!15 = !DILocation(line: 3, column: 8, scope: !12) +!16 = !DILocalVariable(name: "myFunc", scope: !12, file: !2, line: 2, type: !17, align: 32) +!17 = !DIBasicType(name: "DINT", size: 32, encoding: DW_ATE_signed, flags: DIFlagPublic) +!18 = !DILocation(line: 2, column: 17, scope: !12) +!19 = distinct !DISubprogram(name: "myPrg", linkageName: "myPrg", scope: !2, file: !2, line: 4, type: !13, scopeLine: 5, flags: DIFlagPublic, spFlags: DISPFlagDefinition, unit: !10, retainedNodes: !4) +!20 = !DILocalVariable(name: "myPrg", scope: !19, file: !2, line: 4, type: !3) +!21 = !DILocation(line: 5, column: 8, scope: !19) +!22 = distinct !DISubprogram(name: "myFb", linkageName: "myFb", scope: !2, file: !2, line: 6, type: !13, scopeLine: 7, flags: DIFlagPublic, spFlags: DISPFlagDefinition, unit: !10, retainedNodes: !4) +!23 = !DILocalVariable(name: "myFb", scope: !22, file: !2, line: 6, type: !7) +!24 = !DILocation(line: 7, column: 8, scope: !22) diff --git a/src/codegen/tests/debug_tests/snapshots/rusty__codegen__tests__debug_tests__expression_debugging__nested_function_calls_get_location.snap b/src/codegen/tests/debug_tests/snapshots/rusty__codegen__tests__debug_tests__expression_debugging__nested_function_calls_get_location.snap index 2ab45bb4a4..06ddad4ef9 100644 --- a/src/codegen/tests/debug_tests/snapshots/rusty__codegen__tests__debug_tests__expression_debugging__nested_function_calls_get_location.snap +++ b/src/codegen/tests/debug_tests/snapshots/rusty__codegen__tests__debug_tests__expression_debugging__nested_function_calls_get_location.snap @@ -5,18 +5,18 @@ expression: result ; ModuleID = 'main' source_filename = "main" -define i32 @myFunc(i32 %0) !dbg !3 { +define i32 @myFunc(i32 %0) !dbg !4 { entry: - %myFunc = alloca i32, align 4, !dbg !8 - %x = alloca i32, align 4, !dbg !8 - call void @llvm.dbg.declare(metadata i32* %x, metadata !9, metadata !DIExpression()), !dbg !10 - store i32 %0, i32* %x, align 4, !dbg !8 - call void @llvm.dbg.declare(metadata i32* %myFunc, metadata !11, metadata !DIExpression()), !dbg !12 - store i32 0, i32* %myFunc, align 4, !dbg !8 - %call = call i32 @myFunc(i32 1), !dbg !13 - %call1 = call i32 @myFunc(i32 %call), !dbg !8 - %myFunc_ret = load i32, i32* %myFunc, align 4, !dbg !8 - ret i32 %myFunc_ret, !dbg !8 + %myFunc = alloca i32, align 4, !dbg !9 + %x = alloca i32, align 4, !dbg !9 + call void @llvm.dbg.declare(metadata i32* %x, metadata !10, metadata !DIExpression()), !dbg !11 + store i32 %0, i32* %x, align 4, !dbg !9 + call void @llvm.dbg.declare(metadata i32* %myFunc, metadata !12, metadata !DIExpression()), !dbg !13 + store i32 0, i32* %myFunc, align 4, !dbg !9 + %call = call i32 @myFunc(i32 1), !dbg !14 + %call1 = call i32 @myFunc(i32 %call), !dbg !9 + %myFunc_ret = load i32, i32* %myFunc, align 4, !dbg !9 + ret i32 %myFunc_ret, !dbg !9 } ; Function Attrs: nofree nosync nounwind readnone speculatable willreturn @@ -24,21 +24,22 @@ declare void @llvm.dbg.declare(metadata, metadata, metadata) #0 attributes #0 = { nofree nosync nounwind readnone speculatable willreturn } -!llvm.module.flags = !{!0} -!llvm.dbg.cu = !{!1} +!llvm.module.flags = !{!0, !1} +!llvm.dbg.cu = !{!2} !0 = !{i32 2, !"Dwarf Version", i32 5} -!1 = distinct !DICompileUnit(language: DW_LANG_C, file: !2, producer: "RuSTy Structured text Compiler", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, splitDebugInlining: false) -!2 = !DIFile(filename: "main", directory: "src") -!3 = distinct !DISubprogram(name: "myFunc", linkageName: "myFunc", scope: !2, file: !2, line: 2, type: !4, scopeLine: 4, flags: DIFlagPublic, spFlags: DISPFlagDefinition, unit: !1, retainedNodes: !7) -!4 = !DISubroutineType(flags: DIFlagPublic, types: !5) -!5 = !{null, !6} -!6 = !DIBasicType(name: "DINT", size: 32, encoding: DW_ATE_signed, flags: DIFlagPublic) -!7 = !{} -!8 = !DILocation(line: 4, column: 12, scope: !3) -!9 = !DILocalVariable(name: "x", scope: !3, file: !2, line: 3, type: !6) -!10 = !DILocation(line: 3, column: 18, scope: !3) -!11 = !DILocalVariable(name: "myFunc", scope: !3, file: !2, line: 2, type: !6, align: 32) -!12 = !DILocation(line: 2, column: 17, scope: !3) -!13 = !DILocation(line: 4, column: 19, scope: !3) +!1 = !{i32 2, !"Debug Info Version", i32 3} +!2 = distinct !DICompileUnit(language: DW_LANG_C, file: !3, producer: "RuSTy Structured text Compiler", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, splitDebugInlining: false) +!3 = !DIFile(filename: "main", directory: "src") +!4 = distinct !DISubprogram(name: "myFunc", linkageName: "myFunc", scope: !3, file: !3, line: 2, type: !5, scopeLine: 4, flags: DIFlagPublic, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !8) +!5 = !DISubroutineType(flags: DIFlagPublic, types: !6) +!6 = !{null, !7} +!7 = !DIBasicType(name: "DINT", size: 32, encoding: DW_ATE_signed, flags: DIFlagPublic) +!8 = !{} +!9 = !DILocation(line: 4, column: 12, scope: !4) +!10 = !DILocalVariable(name: "x", scope: !4, file: !3, line: 3, type: !7) +!11 = !DILocation(line: 3, column: 18, scope: !4) +!12 = !DILocalVariable(name: "myFunc", scope: !4, file: !3, line: 2, type: !7, align: 32) +!13 = !DILocation(line: 2, column: 17, scope: !4) +!14 = !DILocation(line: 4, column: 19, scope: !4) diff --git a/src/codegen/tests/debug_tests/snapshots/rusty__codegen__tests__debug_tests__expression_debugging__non_callable_expressions_have_no_location.snap b/src/codegen/tests/debug_tests/snapshots/rusty__codegen__tests__debug_tests__expression_debugging__non_callable_expressions_have_no_location.snap index 354e05211c..6407892c53 100644 --- a/src/codegen/tests/debug_tests/snapshots/rusty__codegen__tests__debug_tests__expression_debugging__non_callable_expressions_have_no_location.snap +++ b/src/codegen/tests/debug_tests/snapshots/rusty__codegen__tests__debug_tests__expression_debugging__non_callable_expressions_have_no_location.snap @@ -5,14 +5,14 @@ expression: result ; ModuleID = 'main' source_filename = "main" -define i32 @myFunc() !dbg !3 { +define i32 @myFunc() !dbg !4 { entry: - %myFunc = alloca i32, align 4, !dbg !7 - call void @llvm.dbg.declare(metadata i32* %myFunc, metadata !8, metadata !DIExpression()), !dbg !10 - store i32 0, i32* %myFunc, align 4, !dbg !7 - %load_myFunc = load i32, i32* %myFunc, align 4, !dbg !7 - %myFunc_ret = load i32, i32* %myFunc, align 4, !dbg !7 - ret i32 %myFunc_ret, !dbg !7 + %myFunc = alloca i32, align 4, !dbg !8 + call void @llvm.dbg.declare(metadata i32* %myFunc, metadata !9, metadata !DIExpression()), !dbg !11 + store i32 0, i32* %myFunc, align 4, !dbg !8 + %load_myFunc = load i32, i32* %myFunc, align 4, !dbg !8 + %myFunc_ret = load i32, i32* %myFunc, align 4, !dbg !8 + ret i32 %myFunc_ret, !dbg !8 } ; Function Attrs: nofree nosync nounwind readnone speculatable willreturn @@ -20,18 +20,19 @@ declare void @llvm.dbg.declare(metadata, metadata, metadata) #0 attributes #0 = { nofree nosync nounwind readnone speculatable willreturn } -!llvm.module.flags = !{!0} -!llvm.dbg.cu = !{!1} +!llvm.module.flags = !{!0, !1} +!llvm.dbg.cu = !{!2} !0 = !{i32 2, !"Dwarf Version", i32 5} -!1 = distinct !DICompileUnit(language: DW_LANG_C, file: !2, producer: "RuSTy Structured text Compiler", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, splitDebugInlining: false) -!2 = !DIFile(filename: "main", directory: "src") -!3 = distinct !DISubprogram(name: "myFunc", linkageName: "myFunc", scope: !2, file: !2, line: 2, type: !4, scopeLine: 3, flags: DIFlagPublic, spFlags: DISPFlagDefinition, unit: !1, retainedNodes: !6) -!4 = !DISubroutineType(flags: DIFlagPublic, types: !5) -!5 = !{null} -!6 = !{} -!7 = !DILocation(line: 3, column: 12, scope: !3) -!8 = !DILocalVariable(name: "myFunc", scope: !3, file: !2, line: 2, type: !9, align: 32) -!9 = !DIBasicType(name: "DINT", size: 32, encoding: DW_ATE_signed, flags: DIFlagPublic) -!10 = !DILocation(line: 2, column: 17, scope: !3) +!1 = !{i32 2, !"Debug Info Version", i32 3} +!2 = distinct !DICompileUnit(language: DW_LANG_C, file: !3, producer: "RuSTy Structured text Compiler", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, splitDebugInlining: false) +!3 = !DIFile(filename: "main", directory: "src") +!4 = distinct !DISubprogram(name: "myFunc", linkageName: "myFunc", scope: !3, file: !3, line: 2, type: !5, scopeLine: 3, flags: DIFlagPublic, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !7) +!5 = !DISubroutineType(flags: DIFlagPublic, types: !6) +!6 = !{null} +!7 = !{} +!8 = !DILocation(line: 3, column: 12, scope: !4) +!9 = !DILocalVariable(name: "myFunc", scope: !4, file: !3, line: 2, type: !10, align: 32) +!10 = !DIBasicType(name: "DINT", size: 32, encoding: DW_ATE_signed, flags: DIFlagPublic) +!11 = !DILocation(line: 2, column: 17, scope: !4) diff --git a/src/codegen/tests/debug_tests/snapshots/rusty__codegen__tests__debug_tests__expression_debugging__non_function_pous_have_struct_as_param.snap b/src/codegen/tests/debug_tests/snapshots/rusty__codegen__tests__debug_tests__expression_debugging__non_function_pous_have_struct_as_param.snap index 9e35ae7b1c..80d137fc14 100644 --- a/src/codegen/tests/debug_tests/snapshots/rusty__codegen__tests__debug_tests__expression_debugging__non_function_pous_have_struct_as_param.snap +++ b/src/codegen/tests/debug_tests/snapshots/rusty__codegen__tests__debug_tests__expression_debugging__non_function_pous_have_struct_as_param.snap @@ -11,24 +11,24 @@ source_filename = "main" @myProg_instance = global %myProg zeroinitializer, !dbg !0 @__fb__init = unnamed_addr constant %fb zeroinitializer, !dbg !7 -define void @myProg(%myProg* %0) !dbg !15 { +define void @myProg(%myProg* %0) !dbg !16 { entry: - call void @llvm.dbg.declare(metadata %myProg* %0, metadata !19, metadata !DIExpression()), !dbg !20 - %x = getelementptr inbounds %myProg, %myProg* %0, i32 0, i32 0, !dbg !20 - %load_x = load i32, i32* %x, align 4, !dbg !20 - %tmpVar = add i32 %load_x, 2, !dbg !20 - store i32 %tmpVar, i32* %x, align 4, !dbg !20 - ret void, !dbg !20 + call void @llvm.dbg.declare(metadata %myProg* %0, metadata !20, metadata !DIExpression()), !dbg !21 + %x = getelementptr inbounds %myProg, %myProg* %0, i32 0, i32 0, !dbg !21 + %load_x = load i32, i32* %x, align 4, !dbg !21 + %tmpVar = add i32 %load_x, 2, !dbg !21 + store i32 %tmpVar, i32* %x, align 4, !dbg !21 + ret void, !dbg !21 } -define void @fb(%fb* %0) !dbg !21 { +define void @fb(%fb* %0) !dbg !22 { entry: - call void @llvm.dbg.declare(metadata %fb* %0, metadata !22, metadata !DIExpression()), !dbg !23 - %x = getelementptr inbounds %fb, %fb* %0, i32 0, i32 0, !dbg !23 - %load_x = load i32, i32* %x, align 4, !dbg !23 - %tmpVar = add i32 %load_x, 2, !dbg !23 - store i32 %tmpVar, i32* %x, align 4, !dbg !23 - ret void, !dbg !23 + call void @llvm.dbg.declare(metadata %fb* %0, metadata !23, metadata !DIExpression()), !dbg !24 + %x = getelementptr inbounds %fb, %fb* %0, i32 0, i32 0, !dbg !24 + %load_x = load i32, i32* %x, align 4, !dbg !24 + %tmpVar = add i32 %load_x, 2, !dbg !24 + store i32 %tmpVar, i32* %x, align 4, !dbg !24 + ret void, !dbg !24 } ; Function Attrs: nofree nosync nounwind readnone speculatable willreturn @@ -36,8 +36,8 @@ declare void @llvm.dbg.declare(metadata, metadata, metadata) #0 attributes #0 = { nofree nosync nounwind readnone speculatable willreturn } -!llvm.module.flags = !{!12} -!llvm.dbg.cu = !{!13} +!llvm.module.flags = !{!12, !13} +!llvm.dbg.cu = !{!14} !0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression()) !1 = distinct !DIGlobalVariable(name: "myProg", scope: !2, file: !2, line: 2, type: !3, isLocal: false, isDefinition: true) @@ -52,15 +52,16 @@ attributes #0 = { nofree nosync nounwind readnone speculatable willreturn } !10 = !{!11} !11 = !DIDerivedType(tag: DW_TAG_member, name: "x", scope: !2, file: !2, line: 11, baseType: !6, size: 32, align: 32, flags: DIFlagPublic) !12 = !{i32 2, !"Dwarf Version", i32 5} -!13 = distinct !DICompileUnit(language: DW_LANG_C, file: !2, producer: "RuSTy Structured text Compiler", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, globals: !14, splitDebugInlining: false) -!14 = !{!0, !7} -!15 = distinct !DISubprogram(name: "myProg", linkageName: "myProg", scope: !2, file: !2, line: 2, type: !16, scopeLine: 6, flags: DIFlagPublic, spFlags: DISPFlagDefinition, unit: !13, retainedNodes: !18) -!16 = !DISubroutineType(flags: DIFlagPublic, types: !17) -!17 = !{null, !6} -!18 = !{} -!19 = !DILocalVariable(name: "myProg", scope: !15, file: !2, line: 2, type: !3) -!20 = !DILocation(line: 6, column: 12, scope: !15) -!21 = distinct !DISubprogram(name: "fb", linkageName: "fb", scope: !2, file: !2, line: 9, type: !16, scopeLine: 13, flags: DIFlagPublic, spFlags: DISPFlagDefinition, unit: !13, retainedNodes: !18) -!22 = !DILocalVariable(name: "fb", scope: !21, file: !2, line: 9, type: !9) -!23 = !DILocation(line: 13, column: 12, scope: !21) +!13 = !{i32 2, !"Debug Info Version", i32 3} +!14 = distinct !DICompileUnit(language: DW_LANG_C, file: !2, producer: "RuSTy Structured text Compiler", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, globals: !15, splitDebugInlining: false) +!15 = !{!0, !7} +!16 = distinct !DISubprogram(name: "myProg", linkageName: "myProg", scope: !2, file: !2, line: 2, type: !17, scopeLine: 6, flags: DIFlagPublic, spFlags: DISPFlagDefinition, unit: !14, retainedNodes: !19) +!17 = !DISubroutineType(flags: DIFlagPublic, types: !18) +!18 = !{null, !6} +!19 = !{} +!20 = !DILocalVariable(name: "myProg", scope: !16, file: !2, line: 2, type: !3) +!21 = !DILocation(line: 6, column: 12, scope: !16) +!22 = distinct !DISubprogram(name: "fb", linkageName: "fb", scope: !2, file: !2, line: 9, type: !17, scopeLine: 13, flags: DIFlagPublic, spFlags: DISPFlagDefinition, unit: !14, retainedNodes: !19) +!23 = !DILocalVariable(name: "fb", scope: !22, file: !2, line: 9, type: !9) +!24 = !DILocation(line: 13, column: 12, scope: !22) diff --git a/src/codegen/tests/debug_tests/snapshots/rusty__codegen__tests__debug_tests__expression_debugging__repeat_conditions_location_marked.snap b/src/codegen/tests/debug_tests/snapshots/rusty__codegen__tests__debug_tests__expression_debugging__repeat_conditions_location_marked.snap index 9f92bd5c61..371943333e 100644 --- a/src/codegen/tests/debug_tests/snapshots/rusty__codegen__tests__debug_tests__expression_debugging__repeat_conditions_location_marked.snap +++ b/src/codegen/tests/debug_tests/snapshots/rusty__codegen__tests__debug_tests__expression_debugging__repeat_conditions_location_marked.snap @@ -5,31 +5,31 @@ expression: result ; ModuleID = 'main' source_filename = "main" -define i32 @myFunc() !dbg !3 { +define i32 @myFunc() !dbg !4 { entry: - %myFunc = alloca i32, align 4, !dbg !7 - call void @llvm.dbg.declare(metadata i32* %myFunc, metadata !8, metadata !DIExpression()), !dbg !10 - store i32 0, i32* %myFunc, align 4, !dbg !7 - br label %while_body, !dbg !11 + %myFunc = alloca i32, align 4, !dbg !8 + call void @llvm.dbg.declare(metadata i32* %myFunc, metadata !9, metadata !DIExpression()), !dbg !11 + store i32 0, i32* %myFunc, align 4, !dbg !8 + br label %while_body, !dbg !12 condition_check: ; preds = %while_body - %load_myFunc = load i32, i32* %myFunc, align 4, !dbg !12 - %tmpVar = icmp sgt i32 %load_myFunc, 10, !dbg !12 - %0 = zext i1 %tmpVar to i8, !dbg !12 - %1 = icmp ne i8 %0, 0, !dbg !12 - %tmpVar1 = xor i1 %1, true, !dbg !12 - %2 = zext i1 %tmpVar1 to i8, !dbg !12 - %3 = icmp ne i8 %2, 0, !dbg !12 - br i1 %3, label %while_body, label %continue, !dbg !12 + %load_myFunc = load i32, i32* %myFunc, align 4, !dbg !13 + %tmpVar = icmp sgt i32 %load_myFunc, 10, !dbg !13 + %0 = zext i1 %tmpVar to i8, !dbg !13 + %1 = icmp ne i8 %0, 0, !dbg !13 + %tmpVar1 = xor i1 %1, true, !dbg !13 + %2 = zext i1 %tmpVar1 to i8, !dbg !13 + %3 = icmp ne i8 %2, 0, !dbg !13 + br i1 %3, label %while_body, label %continue, !dbg !13 while_body: ; preds = %entry, %condition_check - store i32 1, i32* %myFunc, align 4, !dbg !11 - br label %condition_check, !dbg !11 + store i32 1, i32* %myFunc, align 4, !dbg !12 + br label %condition_check, !dbg !12 continue: ; preds = %condition_check - store i32 1, i32* %myFunc, align 4, !dbg !13 - %myFunc_ret = load i32, i32* %myFunc, align 4, !dbg !13 - ret i32 %myFunc_ret, !dbg !13 + store i32 1, i32* %myFunc, align 4, !dbg !14 + %myFunc_ret = load i32, i32* %myFunc, align 4, !dbg !14 + ret i32 %myFunc_ret, !dbg !14 } ; Function Attrs: nofree nosync nounwind readnone speculatable willreturn @@ -37,21 +37,22 @@ declare void @llvm.dbg.declare(metadata, metadata, metadata) #0 attributes #0 = { nofree nosync nounwind readnone speculatable willreturn } -!llvm.module.flags = !{!0} -!llvm.dbg.cu = !{!1} +!llvm.module.flags = !{!0, !1} +!llvm.dbg.cu = !{!2} !0 = !{i32 2, !"Dwarf Version", i32 5} -!1 = distinct !DICompileUnit(language: DW_LANG_C, file: !2, producer: "RuSTy Structured text Compiler", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, splitDebugInlining: false) -!2 = !DIFile(filename: "main", directory: "src") -!3 = distinct !DISubprogram(name: "myFunc", linkageName: "myFunc", scope: !2, file: !2, line: 2, type: !4, scopeLine: 3, flags: DIFlagPublic, spFlags: DISPFlagDefinition, unit: !1, retainedNodes: !6) -!4 = !DISubroutineType(flags: DIFlagPublic, types: !5) -!5 = !{null} -!6 = !{} -!7 = !DILocation(line: 3, column: 12, scope: !3) -!8 = !DILocalVariable(name: "myFunc", scope: !3, file: !2, line: 2, type: !9, align: 32) -!9 = !DIBasicType(name: "DINT", size: 32, encoding: DW_ATE_signed, flags: DIFlagPublic) -!10 = !DILocation(line: 2, column: 17, scope: !3) -!11 = !DILocation(line: 4, column: 16, scope: !3) -!12 = !DILocation(line: 5, column: 18, scope: !3) -!13 = !DILocation(line: 6, column: 12, scope: !3) +!1 = !{i32 2, !"Debug Info Version", i32 3} +!2 = distinct !DICompileUnit(language: DW_LANG_C, file: !3, producer: "RuSTy Structured text Compiler", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, splitDebugInlining: false) +!3 = !DIFile(filename: "main", directory: "src") +!4 = distinct !DISubprogram(name: "myFunc", linkageName: "myFunc", scope: !3, file: !3, line: 2, type: !5, scopeLine: 3, flags: DIFlagPublic, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !7) +!5 = !DISubroutineType(flags: DIFlagPublic, types: !6) +!6 = !{null} +!7 = !{} +!8 = !DILocation(line: 3, column: 12, scope: !4) +!9 = !DILocalVariable(name: "myFunc", scope: !4, file: !3, line: 2, type: !10, align: 32) +!10 = !DIBasicType(name: "DINT", size: 32, encoding: DW_ATE_signed, flags: DIFlagPublic) +!11 = !DILocation(line: 2, column: 17, scope: !4) +!12 = !DILocation(line: 4, column: 16, scope: !4) +!13 = !DILocation(line: 5, column: 18, scope: !4) +!14 = !DILocation(line: 6, column: 12, scope: !4) diff --git a/src/codegen/tests/debug_tests/snapshots/rusty__codegen__tests__debug_tests__expression_debugging__return_statement_have_location.snap b/src/codegen/tests/debug_tests/snapshots/rusty__codegen__tests__debug_tests__expression_debugging__return_statement_have_location.snap index 5a2f476a2e..1f5eb71b2a 100644 --- a/src/codegen/tests/debug_tests/snapshots/rusty__codegen__tests__debug_tests__expression_debugging__return_statement_have_location.snap +++ b/src/codegen/tests/debug_tests/snapshots/rusty__codegen__tests__debug_tests__expression_debugging__return_statement_have_location.snap @@ -5,17 +5,17 @@ expression: result ; ModuleID = 'main' source_filename = "main" -define i32 @myFunc() !dbg !3 { +define i32 @myFunc() !dbg !4 { entry: - %myFunc = alloca i32, align 4, !dbg !7 - call void @llvm.dbg.declare(metadata i32* %myFunc, metadata !8, metadata !DIExpression()), !dbg !10 - store i32 0, i32* %myFunc, align 4, !dbg !7 - %myFunc_ret = load i32, i32* %myFunc, align 4, !dbg !7 - ret i32 %myFunc_ret, !dbg !7 + %myFunc = alloca i32, align 4, !dbg !8 + call void @llvm.dbg.declare(metadata i32* %myFunc, metadata !9, metadata !DIExpression()), !dbg !11 + store i32 0, i32* %myFunc, align 4, !dbg !8 + %myFunc_ret = load i32, i32* %myFunc, align 4, !dbg !8 + ret i32 %myFunc_ret, !dbg !8 buffer_block: ; No predecessors! - %myFunc_ret1 = load i32, i32* %myFunc, align 4, !dbg !7 - ret i32 %myFunc_ret1, !dbg !7 + %myFunc_ret1 = load i32, i32* %myFunc, align 4, !dbg !8 + ret i32 %myFunc_ret1, !dbg !8 } ; Function Attrs: nofree nosync nounwind readnone speculatable willreturn @@ -23,18 +23,19 @@ declare void @llvm.dbg.declare(metadata, metadata, metadata) #0 attributes #0 = { nofree nosync nounwind readnone speculatable willreturn } -!llvm.module.flags = !{!0} -!llvm.dbg.cu = !{!1} +!llvm.module.flags = !{!0, !1} +!llvm.dbg.cu = !{!2} !0 = !{i32 2, !"Dwarf Version", i32 5} -!1 = distinct !DICompileUnit(language: DW_LANG_C, file: !2, producer: "RuSTy Structured text Compiler", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, splitDebugInlining: false) -!2 = !DIFile(filename: "main", directory: "src") -!3 = distinct !DISubprogram(name: "myFunc", linkageName: "myFunc", scope: !2, file: !2, line: 2, type: !4, scopeLine: 3, flags: DIFlagPublic, spFlags: DISPFlagDefinition, unit: !1, retainedNodes: !6) -!4 = !DISubroutineType(flags: DIFlagPublic, types: !5) -!5 = !{null} -!6 = !{} -!7 = !DILocation(line: 3, column: 12, scope: !3) -!8 = !DILocalVariable(name: "myFunc", scope: !3, file: !2, line: 2, type: !9, align: 32) -!9 = !DIBasicType(name: "DINT", size: 32, encoding: DW_ATE_signed, flags: DIFlagPublic) -!10 = !DILocation(line: 2, column: 17, scope: !3) +!1 = !{i32 2, !"Debug Info Version", i32 3} +!2 = distinct !DICompileUnit(language: DW_LANG_C, file: !3, producer: "RuSTy Structured text Compiler", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, splitDebugInlining: false) +!3 = !DIFile(filename: "main", directory: "src") +!4 = distinct !DISubprogram(name: "myFunc", linkageName: "myFunc", scope: !3, file: !3, line: 2, type: !5, scopeLine: 3, flags: DIFlagPublic, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !7) +!5 = !DISubroutineType(flags: DIFlagPublic, types: !6) +!6 = !{null} +!7 = !{} +!8 = !DILocation(line: 3, column: 12, scope: !4) +!9 = !DILocalVariable(name: "myFunc", scope: !4, file: !3, line: 2, type: !10, align: 32) +!10 = !DIBasicType(name: "DINT", size: 32, encoding: DW_ATE_signed, flags: DIFlagPublic) +!11 = !DILocation(line: 2, column: 17, scope: !4) diff --git a/src/codegen/tests/debug_tests/snapshots/rusty__codegen__tests__debug_tests__expression_debugging__var_and_vartemp_variables_in_pous_added_as_local.snap b/src/codegen/tests/debug_tests/snapshots/rusty__codegen__tests__debug_tests__expression_debugging__var_and_vartemp_variables_in_pous_added_as_local.snap index e1b3ddbd56..555fa80120 100644 --- a/src/codegen/tests/debug_tests/snapshots/rusty__codegen__tests__debug_tests__expression_debugging__var_and_vartemp_variables_in_pous_added_as_local.snap +++ b/src/codegen/tests/debug_tests/snapshots/rusty__codegen__tests__debug_tests__expression_debugging__var_and_vartemp_variables_in_pous_added_as_local.snap @@ -11,52 +11,52 @@ source_filename = "main" @myPrg_instance = global %myPrg zeroinitializer, !dbg !0 @__myFb__init = unnamed_addr constant %myFb zeroinitializer, !dbg !9 -define i32 @myFunc() !dbg !19 { +define i32 @myFunc() !dbg !20 { entry: - %myFunc = alloca i32, align 4, !dbg !23 - %a = alloca i32, align 4, !dbg !23 - %b = alloca i32, align 4, !dbg !23 - %c = alloca i32, align 4, !dbg !23 - call void @llvm.dbg.declare(metadata i32* %a, metadata !24, metadata !DIExpression()), !dbg !25 - store i32 0, i32* %a, align 4, !dbg !23 - call void @llvm.dbg.declare(metadata i32* %b, metadata !26, metadata !DIExpression()), !dbg !27 - store i32 0, i32* %b, align 4, !dbg !23 - call void @llvm.dbg.declare(metadata i32* %c, metadata !28, metadata !DIExpression()), !dbg !29 - store i32 0, i32* %c, align 4, !dbg !23 - call void @llvm.dbg.declare(metadata i32* %myFunc, metadata !30, metadata !DIExpression()), !dbg !31 - store i32 0, i32* %myFunc, align 4, !dbg !23 - %myFunc_ret = load i32, i32* %myFunc, align 4, !dbg !23 - ret i32 %myFunc_ret, !dbg !23 + %myFunc = alloca i32, align 4, !dbg !24 + %a = alloca i32, align 4, !dbg !24 + %b = alloca i32, align 4, !dbg !24 + %c = alloca i32, align 4, !dbg !24 + call void @llvm.dbg.declare(metadata i32* %a, metadata !25, metadata !DIExpression()), !dbg !26 + store i32 0, i32* %a, align 4, !dbg !24 + call void @llvm.dbg.declare(metadata i32* %b, metadata !27, metadata !DIExpression()), !dbg !28 + store i32 0, i32* %b, align 4, !dbg !24 + call void @llvm.dbg.declare(metadata i32* %c, metadata !29, metadata !DIExpression()), !dbg !30 + store i32 0, i32* %c, align 4, !dbg !24 + call void @llvm.dbg.declare(metadata i32* %myFunc, metadata !31, metadata !DIExpression()), !dbg !32 + store i32 0, i32* %myFunc, align 4, !dbg !24 + %myFunc_ret = load i32, i32* %myFunc, align 4, !dbg !24 + ret i32 %myFunc_ret, !dbg !24 } -define void @myPrg(%myPrg* %0) !dbg !32 { +define void @myPrg(%myPrg* %0) !dbg !33 { entry: - call void @llvm.dbg.declare(metadata %myPrg* %0, metadata !33, metadata !DIExpression()), !dbg !34 - %a = alloca i32, align 4, !dbg !34 - %b = alloca i32, align 4, !dbg !34 - %c = alloca i32, align 4, !dbg !34 - call void @llvm.dbg.declare(metadata i32* %a, metadata !35, metadata !DIExpression()), !dbg !36 - store i32 0, i32* %a, align 4, !dbg !34 - call void @llvm.dbg.declare(metadata i32* %b, metadata !37, metadata !DIExpression()), !dbg !38 - store i32 0, i32* %b, align 4, !dbg !34 - call void @llvm.dbg.declare(metadata i32* %c, metadata !39, metadata !DIExpression()), !dbg !40 - store i32 0, i32* %c, align 4, !dbg !34 - ret void, !dbg !34 + call void @llvm.dbg.declare(metadata %myPrg* %0, metadata !34, metadata !DIExpression()), !dbg !35 + %a = alloca i32, align 4, !dbg !35 + %b = alloca i32, align 4, !dbg !35 + %c = alloca i32, align 4, !dbg !35 + call void @llvm.dbg.declare(metadata i32* %a, metadata !36, metadata !DIExpression()), !dbg !37 + store i32 0, i32* %a, align 4, !dbg !35 + call void @llvm.dbg.declare(metadata i32* %b, metadata !38, metadata !DIExpression()), !dbg !39 + store i32 0, i32* %b, align 4, !dbg !35 + call void @llvm.dbg.declare(metadata i32* %c, metadata !40, metadata !DIExpression()), !dbg !41 + store i32 0, i32* %c, align 4, !dbg !35 + ret void, !dbg !35 } -define void @myFb(%myFb* %0) !dbg !41 { +define void @myFb(%myFb* %0) !dbg !42 { entry: - call void @llvm.dbg.declare(metadata %myFb* %0, metadata !42, metadata !DIExpression()), !dbg !43 - %a = alloca i32, align 4, !dbg !43 - %b = alloca i32, align 4, !dbg !43 - %c = alloca i32, align 4, !dbg !43 - call void @llvm.dbg.declare(metadata i32* %a, metadata !44, metadata !DIExpression()), !dbg !45 - store i32 0, i32* %a, align 4, !dbg !43 - call void @llvm.dbg.declare(metadata i32* %b, metadata !46, metadata !DIExpression()), !dbg !47 - store i32 0, i32* %b, align 4, !dbg !43 - call void @llvm.dbg.declare(metadata i32* %c, metadata !48, metadata !DIExpression()), !dbg !49 - store i32 0, i32* %c, align 4, !dbg !43 - ret void, !dbg !43 + call void @llvm.dbg.declare(metadata %myFb* %0, metadata !43, metadata !DIExpression()), !dbg !44 + %a = alloca i32, align 4, !dbg !44 + %b = alloca i32, align 4, !dbg !44 + %c = alloca i32, align 4, !dbg !44 + call void @llvm.dbg.declare(metadata i32* %a, metadata !45, metadata !DIExpression()), !dbg !46 + store i32 0, i32* %a, align 4, !dbg !44 + call void @llvm.dbg.declare(metadata i32* %b, metadata !47, metadata !DIExpression()), !dbg !48 + store i32 0, i32* %b, align 4, !dbg !44 + call void @llvm.dbg.declare(metadata i32* %c, metadata !49, metadata !DIExpression()), !dbg !50 + store i32 0, i32* %c, align 4, !dbg !44 + ret void, !dbg !44 } ; Function Attrs: nofree nosync nounwind readnone speculatable willreturn @@ -64,8 +64,8 @@ declare void @llvm.dbg.declare(metadata, metadata, metadata) #0 attributes #0 = { nofree nosync nounwind readnone speculatable willreturn } -!llvm.module.flags = !{!16} -!llvm.dbg.cu = !{!17} +!llvm.module.flags = !{!16, !17} +!llvm.dbg.cu = !{!18} !0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression()) !1 = distinct !DIGlobalVariable(name: "myPrg", scope: !2, file: !2, line: 5, type: !3, isLocal: false, isDefinition: true) @@ -84,37 +84,38 @@ attributes #0 = { nofree nosync nounwind readnone speculatable willreturn } !14 = !DIDerivedType(tag: DW_TAG_member, name: "b", scope: !2, file: !2, line: 9, baseType: !6, size: 32, align: 32, offset: 32, flags: DIFlagPublic) !15 = !DIDerivedType(tag: DW_TAG_member, name: "c", scope: !2, file: !2, line: 9, baseType: !6, size: 32, align: 32, offset: 64, flags: DIFlagPublic) !16 = !{i32 2, !"Dwarf Version", i32 5} -!17 = distinct !DICompileUnit(language: DW_LANG_C, file: !2, producer: "RuSTy Structured text Compiler", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, globals: !18, splitDebugInlining: false) -!18 = !{!0, !9} -!19 = distinct !DISubprogram(name: "myFunc", linkageName: "myFunc", scope: !2, file: !2, line: 2, type: !20, scopeLine: 4, flags: DIFlagPublic, spFlags: DISPFlagDefinition, unit: !17, retainedNodes: !22) -!20 = !DISubroutineType(flags: DIFlagPublic, types: !21) -!21 = !{null} -!22 = !{} -!23 = !DILocation(line: 4, column: 8, scope: !19) -!24 = !DILocalVariable(name: "a", scope: !19, file: !2, line: 3, type: !6, align: 32) -!25 = !DILocation(line: 3, column: 12, scope: !19) -!26 = !DILocalVariable(name: "b", scope: !19, file: !2, line: 3, type: !6, align: 32) -!27 = !DILocation(line: 3, column: 14, scope: !19) -!28 = !DILocalVariable(name: "c", scope: !19, file: !2, line: 3, type: !6, align: 32) -!29 = !DILocation(line: 3, column: 16, scope: !19) -!30 = !DILocalVariable(name: "myFunc", scope: !19, file: !2, line: 2, type: !6, align: 32) -!31 = !DILocation(line: 2, column: 17, scope: !19) -!32 = distinct !DISubprogram(name: "myPrg", linkageName: "myPrg", scope: !2, file: !2, line: 5, type: !20, scopeLine: 7, flags: DIFlagPublic, spFlags: DISPFlagDefinition, unit: !17, retainedNodes: !22) -!33 = !DILocalVariable(name: "myPrg", scope: !32, file: !2, line: 5, type: !3) -!34 = !DILocation(line: 7, column: 8, scope: !32) -!35 = !DILocalVariable(name: "a", scope: !32, file: !2, line: 6, type: !6, align: 32) -!36 = !DILocation(line: 6, column: 17, scope: !32) -!37 = !DILocalVariable(name: "b", scope: !32, file: !2, line: 6, type: !6, align: 32) -!38 = !DILocation(line: 6, column: 19, scope: !32) -!39 = !DILocalVariable(name: "c", scope: !32, file: !2, line: 6, type: !6, align: 32) -!40 = !DILocation(line: 6, column: 21, scope: !32) -!41 = distinct !DISubprogram(name: "myFb", linkageName: "myFb", scope: !2, file: !2, line: 8, type: !20, scopeLine: 10, flags: DIFlagPublic, spFlags: DISPFlagDefinition, unit: !17, retainedNodes: !22) -!42 = !DILocalVariable(name: "myFb", scope: !41, file: !2, line: 8, type: !11) -!43 = !DILocation(line: 10, column: 8, scope: !41) -!44 = !DILocalVariable(name: "a", scope: !41, file: !2, line: 9, type: !6, align: 32) -!45 = !DILocation(line: 9, column: 17, scope: !41) -!46 = !DILocalVariable(name: "b", scope: !41, file: !2, line: 9, type: !6, align: 32) -!47 = !DILocation(line: 9, column: 19, scope: !41) -!48 = !DILocalVariable(name: "c", scope: !41, file: !2, line: 9, type: !6, align: 32) -!49 = !DILocation(line: 9, column: 21, scope: !41) +!17 = !{i32 2, !"Debug Info Version", i32 3} +!18 = distinct !DICompileUnit(language: DW_LANG_C, file: !2, producer: "RuSTy Structured text Compiler", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, globals: !19, splitDebugInlining: false) +!19 = !{!0, !9} +!20 = distinct !DISubprogram(name: "myFunc", linkageName: "myFunc", scope: !2, file: !2, line: 2, type: !21, scopeLine: 4, flags: DIFlagPublic, spFlags: DISPFlagDefinition, unit: !18, retainedNodes: !23) +!21 = !DISubroutineType(flags: DIFlagPublic, types: !22) +!22 = !{null} +!23 = !{} +!24 = !DILocation(line: 4, column: 8, scope: !20) +!25 = !DILocalVariable(name: "a", scope: !20, file: !2, line: 3, type: !6, align: 32) +!26 = !DILocation(line: 3, column: 12, scope: !20) +!27 = !DILocalVariable(name: "b", scope: !20, file: !2, line: 3, type: !6, align: 32) +!28 = !DILocation(line: 3, column: 14, scope: !20) +!29 = !DILocalVariable(name: "c", scope: !20, file: !2, line: 3, type: !6, align: 32) +!30 = !DILocation(line: 3, column: 16, scope: !20) +!31 = !DILocalVariable(name: "myFunc", scope: !20, file: !2, line: 2, type: !6, align: 32) +!32 = !DILocation(line: 2, column: 17, scope: !20) +!33 = distinct !DISubprogram(name: "myPrg", linkageName: "myPrg", scope: !2, file: !2, line: 5, type: !21, scopeLine: 7, flags: DIFlagPublic, spFlags: DISPFlagDefinition, unit: !18, retainedNodes: !23) +!34 = !DILocalVariable(name: "myPrg", scope: !33, file: !2, line: 5, type: !3) +!35 = !DILocation(line: 7, column: 8, scope: !33) +!36 = !DILocalVariable(name: "a", scope: !33, file: !2, line: 6, type: !6, align: 32) +!37 = !DILocation(line: 6, column: 17, scope: !33) +!38 = !DILocalVariable(name: "b", scope: !33, file: !2, line: 6, type: !6, align: 32) +!39 = !DILocation(line: 6, column: 19, scope: !33) +!40 = !DILocalVariable(name: "c", scope: !33, file: !2, line: 6, type: !6, align: 32) +!41 = !DILocation(line: 6, column: 21, scope: !33) +!42 = distinct !DISubprogram(name: "myFb", linkageName: "myFb", scope: !2, file: !2, line: 8, type: !21, scopeLine: 10, flags: DIFlagPublic, spFlags: DISPFlagDefinition, unit: !18, retainedNodes: !23) +!43 = !DILocalVariable(name: "myFb", scope: !42, file: !2, line: 8, type: !11) +!44 = !DILocation(line: 10, column: 8, scope: !42) +!45 = !DILocalVariable(name: "a", scope: !42, file: !2, line: 9, type: !6, align: 32) +!46 = !DILocation(line: 9, column: 17, scope: !42) +!47 = !DILocalVariable(name: "b", scope: !42, file: !2, line: 9, type: !6, align: 32) +!48 = !DILocation(line: 9, column: 19, scope: !42) +!49 = !DILocalVariable(name: "c", scope: !42, file: !2, line: 9, type: !6, align: 32) +!50 = !DILocation(line: 9, column: 21, scope: !42) diff --git a/src/codegen/tests/debug_tests/snapshots/rusty__codegen__tests__debug_tests__expression_debugging__var_in_out_inout_in_function_added_as_params.snap b/src/codegen/tests/debug_tests/snapshots/rusty__codegen__tests__debug_tests__expression_debugging__var_in_out_inout_in_function_added_as_params.snap index 5e84a8b06b..e56cf55013 100644 --- a/src/codegen/tests/debug_tests/snapshots/rusty__codegen__tests__debug_tests__expression_debugging__var_in_out_inout_in_function_added_as_params.snap +++ b/src/codegen/tests/debug_tests/snapshots/rusty__codegen__tests__debug_tests__expression_debugging__var_in_out_inout_in_function_added_as_params.snap @@ -5,21 +5,21 @@ expression: result ; ModuleID = 'main' source_filename = "main" -define i32 @myFunc(i16* %0) !dbg !3 { +define i32 @myFunc(i16* %0) !dbg !4 { entry: - %myFunc = alloca i32, align 4, !dbg !9 - %x = alloca i16*, align 8, !dbg !9 - call void @llvm.dbg.declare(metadata i16** %x, metadata !10, metadata !DIExpression()), !dbg !11 - store i16* %0, i16** %x, align 8, !dbg !9 - call void @llvm.dbg.declare(metadata i32* %myFunc, metadata !12, metadata !DIExpression()), !dbg !14 - store i32 0, i32* %myFunc, align 4, !dbg !9 - %deref = load i16*, i16** %x, align 8, !dbg !9 - %load_x = load i16, i16* %deref, align 2, !dbg !9 - %1 = sext i16 %load_x to i32, !dbg !9 - %tmpVar = add i32 %1, 2, !dbg !9 - store i32 %tmpVar, i32* %myFunc, align 4, !dbg !9 - %myFunc_ret = load i32, i32* %myFunc, align 4, !dbg !9 - ret i32 %myFunc_ret, !dbg !9 + %myFunc = alloca i32, align 4, !dbg !10 + %x = alloca i16*, align 8, !dbg !10 + call void @llvm.dbg.declare(metadata i16** %x, metadata !11, metadata !DIExpression()), !dbg !12 + store i16* %0, i16** %x, align 8, !dbg !10 + call void @llvm.dbg.declare(metadata i32* %myFunc, metadata !13, metadata !DIExpression()), !dbg !15 + store i32 0, i32* %myFunc, align 4, !dbg !10 + %deref = load i16*, i16** %x, align 8, !dbg !10 + %load_x = load i16, i16* %deref, align 2, !dbg !10 + %1 = sext i16 %load_x to i32, !dbg !10 + %tmpVar = add i32 %1, 2, !dbg !10 + store i32 %tmpVar, i32* %myFunc, align 4, !dbg !10 + %myFunc_ret = load i32, i32* %myFunc, align 4, !dbg !10 + ret i32 %myFunc_ret, !dbg !10 } ; Function Attrs: nofree nosync nounwind readnone speculatable willreturn @@ -27,22 +27,23 @@ declare void @llvm.dbg.declare(metadata, metadata, metadata) #0 attributes #0 = { nofree nosync nounwind readnone speculatable willreturn } -!llvm.module.flags = !{!0} -!llvm.dbg.cu = !{!1} +!llvm.module.flags = !{!0, !1} +!llvm.dbg.cu = !{!2} !0 = !{i32 2, !"Dwarf Version", i32 5} -!1 = distinct !DICompileUnit(language: DW_LANG_C, file: !2, producer: "RuSTy Structured text Compiler", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, splitDebugInlining: false) -!2 = !DIFile(filename: "main", directory: "src") -!3 = distinct !DISubprogram(name: "myFunc", linkageName: "myFunc", scope: !2, file: !2, line: 2, type: !4, scopeLine: 6, flags: DIFlagPublic, spFlags: DISPFlagDefinition, unit: !1, retainedNodes: !8) -!4 = !DISubroutineType(flags: DIFlagPublic, types: !5) -!5 = !{null, !6} -!6 = !DIDerivedType(tag: DW_TAG_pointer_type, name: "__auto_pointer_to_INT", baseType: !7, size: 64, align: 64, dwarfAddressSpace: 1) -!7 = !DIBasicType(name: "INT", size: 16, encoding: DW_ATE_signed, flags: DIFlagPublic) -!8 = !{} -!9 = !DILocation(line: 6, column: 12, scope: !3) -!10 = !DILocalVariable(name: "x", scope: !3, file: !2, line: 4, type: !6) -!11 = !DILocation(line: 4, column: 12, scope: !3) -!12 = !DILocalVariable(name: "myFunc", scope: !3, file: !2, line: 2, type: !13, align: 32) -!13 = !DIBasicType(name: "DINT", size: 32, encoding: DW_ATE_signed, flags: DIFlagPublic) -!14 = !DILocation(line: 2, column: 17, scope: !3) +!1 = !{i32 2, !"Debug Info Version", i32 3} +!2 = distinct !DICompileUnit(language: DW_LANG_C, file: !3, producer: "RuSTy Structured text Compiler", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, splitDebugInlining: false) +!3 = !DIFile(filename: "main", directory: "src") +!4 = distinct !DISubprogram(name: "myFunc", linkageName: "myFunc", scope: !3, file: !3, line: 2, type: !5, scopeLine: 6, flags: DIFlagPublic, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !9) +!5 = !DISubroutineType(flags: DIFlagPublic, types: !6) +!6 = !{null, !7} +!7 = !DIDerivedType(tag: DW_TAG_pointer_type, name: "__auto_pointer_to_INT", baseType: !8, size: 64, align: 64, dwarfAddressSpace: 1) +!8 = !DIBasicType(name: "INT", size: 16, encoding: DW_ATE_signed, flags: DIFlagPublic) +!9 = !{} +!10 = !DILocation(line: 6, column: 12, scope: !4) +!11 = !DILocalVariable(name: "x", scope: !4, file: !3, line: 4, type: !7) +!12 = !DILocation(line: 4, column: 12, scope: !4) +!13 = !DILocalVariable(name: "myFunc", scope: !4, file: !3, line: 2, type: !14, align: 32) +!14 = !DIBasicType(name: "DINT", size: 32, encoding: DW_ATE_signed, flags: DIFlagPublic) +!15 = !DILocation(line: 2, column: 17, scope: !4) diff --git a/src/codegen/tests/debug_tests/snapshots/rusty__codegen__tests__debug_tests__expression_debugging__while_conditions_location_marked.snap b/src/codegen/tests/debug_tests/snapshots/rusty__codegen__tests__debug_tests__expression_debugging__while_conditions_location_marked.snap index 210e5d113c..382cf40c25 100644 --- a/src/codegen/tests/debug_tests/snapshots/rusty__codegen__tests__debug_tests__expression_debugging__while_conditions_location_marked.snap +++ b/src/codegen/tests/debug_tests/snapshots/rusty__codegen__tests__debug_tests__expression_debugging__while_conditions_location_marked.snap @@ -5,28 +5,28 @@ expression: result ; ModuleID = 'main' source_filename = "main" -define i32 @myFunc() !dbg !3 { +define i32 @myFunc() !dbg !4 { entry: - %myFunc = alloca i32, align 4, !dbg !7 - call void @llvm.dbg.declare(metadata i32* %myFunc, metadata !8, metadata !DIExpression()), !dbg !10 - store i32 0, i32* %myFunc, align 4, !dbg !7 - br label %condition_check, !dbg !11 + %myFunc = alloca i32, align 4, !dbg !8 + call void @llvm.dbg.declare(metadata i32* %myFunc, metadata !9, metadata !DIExpression()), !dbg !11 + store i32 0, i32* %myFunc, align 4, !dbg !8 + br label %condition_check, !dbg !12 condition_check: ; preds = %entry, %while_body - %load_myFunc = load i32, i32* %myFunc, align 4, !dbg !12 - %tmpVar = icmp sgt i32 %load_myFunc, 1, !dbg !12 - %0 = zext i1 %tmpVar to i8, !dbg !12 - %1 = icmp ne i8 %0, 0, !dbg !12 - br i1 %1, label %while_body, label %continue, !dbg !12 + %load_myFunc = load i32, i32* %myFunc, align 4, !dbg !13 + %tmpVar = icmp sgt i32 %load_myFunc, 1, !dbg !13 + %0 = zext i1 %tmpVar to i8, !dbg !13 + %1 = icmp ne i8 %0, 0, !dbg !13 + br i1 %1, label %while_body, label %continue, !dbg !13 while_body: ; preds = %condition_check - store i32 1, i32* %myFunc, align 4, !dbg !11 - br label %condition_check, !dbg !11 + store i32 1, i32* %myFunc, align 4, !dbg !12 + br label %condition_check, !dbg !12 continue: ; preds = %condition_check - store i32 1, i32* %myFunc, align 4, !dbg !13 - %myFunc_ret = load i32, i32* %myFunc, align 4, !dbg !13 - ret i32 %myFunc_ret, !dbg !13 + store i32 1, i32* %myFunc, align 4, !dbg !14 + %myFunc_ret = load i32, i32* %myFunc, align 4, !dbg !14 + ret i32 %myFunc_ret, !dbg !14 } ; Function Attrs: nofree nosync nounwind readnone speculatable willreturn @@ -34,21 +34,22 @@ declare void @llvm.dbg.declare(metadata, metadata, metadata) #0 attributes #0 = { nofree nosync nounwind readnone speculatable willreturn } -!llvm.module.flags = !{!0} -!llvm.dbg.cu = !{!1} +!llvm.module.flags = !{!0, !1} +!llvm.dbg.cu = !{!2} !0 = !{i32 2, !"Dwarf Version", i32 5} -!1 = distinct !DICompileUnit(language: DW_LANG_C, file: !2, producer: "RuSTy Structured text Compiler", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, splitDebugInlining: false) -!2 = !DIFile(filename: "main", directory: "src") -!3 = distinct !DISubprogram(name: "myFunc", linkageName: "myFunc", scope: !2, file: !2, line: 2, type: !4, scopeLine: 3, flags: DIFlagPublic, spFlags: DISPFlagDefinition, unit: !1, retainedNodes: !6) -!4 = !DISubroutineType(flags: DIFlagPublic, types: !5) -!5 = !{null} -!6 = !{} -!7 = !DILocation(line: 3, column: 12, scope: !3) -!8 = !DILocalVariable(name: "myFunc", scope: !3, file: !2, line: 2, type: !9, align: 32) -!9 = !DIBasicType(name: "DINT", size: 32, encoding: DW_ATE_signed, flags: DIFlagPublic) -!10 = !DILocation(line: 2, column: 17, scope: !3) -!11 = !DILocation(line: 4, column: 16, scope: !3) -!12 = !DILocation(line: 3, column: 18, scope: !3) -!13 = !DILocation(line: 6, column: 12, scope: !3) +!1 = !{i32 2, !"Debug Info Version", i32 3} +!2 = distinct !DICompileUnit(language: DW_LANG_C, file: !3, producer: "RuSTy Structured text Compiler", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, splitDebugInlining: false) +!3 = !DIFile(filename: "main", directory: "src") +!4 = distinct !DISubprogram(name: "myFunc", linkageName: "myFunc", scope: !3, file: !3, line: 2, type: !5, scopeLine: 3, flags: DIFlagPublic, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !7) +!5 = !DISubroutineType(flags: DIFlagPublic, types: !6) +!6 = !{null} +!7 = !{} +!8 = !DILocation(line: 3, column: 12, scope: !4) +!9 = !DILocalVariable(name: "myFunc", scope: !4, file: !3, line: 2, type: !10, align: 32) +!10 = !DIBasicType(name: "DINT", size: 32, encoding: DW_ATE_signed, flags: DIFlagPublic) +!11 = !DILocation(line: 2, column: 17, scope: !4) +!12 = !DILocation(line: 4, column: 16, scope: !4) +!13 = !DILocation(line: 3, column: 18, scope: !4) +!14 = !DILocation(line: 6, column: 12, scope: !4) diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__debug_tests__dwarf_version_override.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__debug_tests__dwarf_version_override.snap new file mode 100644 index 0000000000..97f35d7d5a --- /dev/null +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__debug_tests__dwarf_version_override.snap @@ -0,0 +1,22 @@ +--- +source: src/codegen/tests/debug_tests.rs +expression: codegen +--- +; ModuleID = 'main' +source_filename = "main" + +@gInt = global i32 0, !dbg !0 + +!llvm.module.flags = !{!5, !6} +!llvm.dbg.cu = !{!7} + +!0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression()) +!1 = distinct !DIGlobalVariable(name: "gInt", scope: !2, file: !2, line: 5, type: !3, isLocal: false, isDefinition: true) +!2 = !DIFile(filename: "main", directory: "src") +!3 = !DIDerivedType(tag: DW_TAG_typedef, name: "myInt", scope: !2, file: !2, line: 2, baseType: !4, align: 32) +!4 = !DIBasicType(name: "DINT", size: 32, encoding: DW_ATE_signed, flags: DIFlagPublic) +!5 = !{i32 2, !"Dwarf Version", i32 4} +!6 = !{i32 2, !"Debug Info Version", i32 3} +!7 = distinct !DICompileUnit(language: DW_LANG_C, file: !2, producer: "RuSTy Structured text Compiler", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, globals: !8, splitDebugInlining: false) +!8 = !{!0} + diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__debug_tests__global_alias_type.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__debug_tests__global_alias_type.snap index 2c0e3da4b7..f768c755d4 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__debug_tests__global_alias_type.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__debug_tests__global_alias_type.snap @@ -7,8 +7,8 @@ source_filename = "main" @gInt = global i32 0, !dbg !0 -!llvm.module.flags = !{!5} -!llvm.dbg.cu = !{!6} +!llvm.module.flags = !{!5, !6} +!llvm.dbg.cu = !{!7} !0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression()) !1 = distinct !DIGlobalVariable(name: "gInt", scope: !2, file: !2, line: 5, type: !3, isLocal: false, isDefinition: true) @@ -16,6 +16,7 @@ source_filename = "main" !3 = !DIDerivedType(tag: DW_TAG_typedef, name: "myInt", scope: !2, file: !2, line: 2, baseType: !4, align: 32) !4 = !DIBasicType(name: "DINT", size: 32, encoding: DW_ATE_signed, flags: DIFlagPublic) !5 = !{i32 2, !"Dwarf Version", i32 5} -!6 = distinct !DICompileUnit(language: DW_LANG_C, file: !2, producer: "RuSTy Structured text Compiler", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, globals: !7, splitDebugInlining: false) -!7 = !{!0} +!6 = !{i32 2, !"Debug Info Version", i32 3} +!7 = distinct !DICompileUnit(language: DW_LANG_C, file: !2, producer: "RuSTy Structured text Compiler", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, globals: !8, splitDebugInlining: false) +!8 = !{!0} diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__debug_tests__global_var_array_added_to_debug_info.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__debug_tests__global_var_array_added_to_debug_info.snap index 37f44808e7..0076eb9783 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__debug_tests__global_var_array_added_to_debug_info.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__debug_tests__global_var_array_added_to_debug_info.snap @@ -9,8 +9,8 @@ source_filename = "main" @b = global [110 x i32] zeroinitializer, !dbg !7 @c = global [11 x [10 x i32]] zeroinitializer, !dbg !12 -!llvm.module.flags = !{!17} -!llvm.dbg.cu = !{!18} +!llvm.module.flags = !{!17, !18} +!llvm.dbg.cu = !{!19} !0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression()) !1 = distinct !DIGlobalVariable(name: "a", scope: !2, file: !2, line: 3, type: !3, isLocal: false, isDefinition: true) @@ -30,6 +30,7 @@ source_filename = "main" !15 = !DICompositeType(tag: DW_TAG_array_type, baseType: !4, size: 320, align: 64, elements: !16) !16 = !{!11} !17 = !{i32 2, !"Dwarf Version", i32 5} -!18 = distinct !DICompileUnit(language: DW_LANG_C, file: !2, producer: "RuSTy Structured text Compiler", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, globals: !19, splitDebugInlining: false) -!19 = !{!0, !7, !12} +!18 = !{i32 2, !"Debug Info Version", i32 3} +!19 = distinct !DICompileUnit(language: DW_LANG_C, file: !2, producer: "RuSTy Structured text Compiler", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, globals: !20, splitDebugInlining: false) +!20 = !{!0, !7, !12} diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__debug_tests__global_var_byteseq_added_to_debug_info.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__debug_tests__global_var_byteseq_added_to_debug_info.snap index 82dbb2fed5..c3bcfd9c53 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__debug_tests__global_var_byteseq_added_to_debug_info.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__debug_tests__global_var_byteseq_added_to_debug_info.snap @@ -11,8 +11,8 @@ source_filename = "main" @d = global i32 0, !dbg !10 @e = global i64 0, !dbg !13 -!llvm.module.flags = !{!16} -!llvm.dbg.cu = !{!17} +!llvm.module.flags = !{!16, !17} +!llvm.dbg.cu = !{!18} !0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression()) !1 = distinct !DIGlobalVariable(name: "a", scope: !2, file: !2, line: 3, type: !3, isLocal: false, isDefinition: true) @@ -31,6 +31,7 @@ source_filename = "main" !14 = distinct !DIGlobalVariable(name: "e", scope: !2, file: !2, line: 7, type: !15, isLocal: false, isDefinition: true) !15 = !DIBasicType(name: "LWORD", size: 64, encoding: DW_ATE_unsigned, flags: DIFlagPublic) !16 = !{i32 2, !"Dwarf Version", i32 5} -!17 = distinct !DICompileUnit(language: DW_LANG_C, file: !2, producer: "RuSTy Structured text Compiler", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, globals: !18, splitDebugInlining: false) -!18 = !{!0, !4, !7, !10, !13} +!17 = !{i32 2, !"Debug Info Version", i32 3} +!18 = distinct !DICompileUnit(language: DW_LANG_C, file: !2, producer: "RuSTy Structured text Compiler", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, globals: !19, splitDebugInlining: false) +!19 = !{!0, !4, !7, !10, !13} diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__debug_tests__global_var_enum_added_to_debug_info.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__debug_tests__global_var_enum_added_to_debug_info.snap index 9827a45f7e..ddc9cc3c7a 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__debug_tests__global_var_enum_added_to_debug_info.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__debug_tests__global_var_enum_added_to_debug_info.snap @@ -16,8 +16,8 @@ source_filename = "main" @b.2 = unnamed_addr constant i64 1, !dbg !23 @c.3 = unnamed_addr constant i64 2, !dbg !25 -!llvm.module.flags = !{!27} -!llvm.dbg.cu = !{!28} +!llvm.module.flags = !{!27, !28} +!llvm.dbg.cu = !{!29} !0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression()) !1 = distinct !DIGlobalVariable(name: "en3", scope: !2, file: !2, line: 5, type: !3, isLocal: false, isDefinition: true) @@ -47,6 +47,7 @@ source_filename = "main" !25 = !DIGlobalVariableExpression(var: !26, expr: !DIExpression()) !26 = distinct !DIGlobalVariable(name: "__global_en3.c", scope: !2, file: !2, line: 5, type: !3, isLocal: false, isDefinition: true) !27 = !{i32 2, !"Dwarf Version", i32 5} -!28 = distinct !DICompileUnit(language: DW_LANG_C, file: !2, producer: "RuSTy Structured text Compiler", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, globals: !29, splitDebugInlining: false) -!29 = !{!0, !5, !9, !11, !13, !17, !19, !21, !23, !25} +!28 = !{i32 2, !"Debug Info Version", i32 3} +!29 = distinct !DICompileUnit(language: DW_LANG_C, file: !2, producer: "RuSTy Structured text Compiler", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, globals: !30, splitDebugInlining: false) +!30 = !{!0, !5, !9, !11, !13, !17, !19, !21, !23, !25} diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__debug_tests__global_var_float_added_to_debug_info.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__debug_tests__global_var_float_added_to_debug_info.snap index f4723b832d..3072a3a70e 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__debug_tests__global_var_float_added_to_debug_info.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__debug_tests__global_var_float_added_to_debug_info.snap @@ -8,8 +8,8 @@ source_filename = "main" @a = global float 0.000000e+00, !dbg !0 @b = global double 0.000000e+00, !dbg !4 -!llvm.module.flags = !{!7} -!llvm.dbg.cu = !{!8} +!llvm.module.flags = !{!7, !8} +!llvm.dbg.cu = !{!9} !0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression()) !1 = distinct !DIGlobalVariable(name: "a", scope: !2, file: !2, line: 3, type: !3, isLocal: false, isDefinition: true) @@ -19,6 +19,7 @@ source_filename = "main" !5 = distinct !DIGlobalVariable(name: "b", scope: !2, file: !2, line: 4, type: !6, isLocal: false, isDefinition: true) !6 = !DIBasicType(name: "LREAL", size: 64, encoding: DW_ATE_float, flags: DIFlagPublic) !7 = !{i32 2, !"Dwarf Version", i32 5} -!8 = distinct !DICompileUnit(language: DW_LANG_C, file: !2, producer: "RuSTy Structured text Compiler", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, globals: !9, splitDebugInlining: false) -!9 = !{!0, !4} +!8 = !{i32 2, !"Debug Info Version", i32 3} +!9 = distinct !DICompileUnit(language: DW_LANG_C, file: !2, producer: "RuSTy Structured text Compiler", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, globals: !10, splitDebugInlining: false) +!10 = !{!0, !4} diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__debug_tests__global_var_int_added_to_debug_info.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__debug_tests__global_var_int_added_to_debug_info.snap index 74154e5ed8..ef994f3a9e 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__debug_tests__global_var_int_added_to_debug_info.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__debug_tests__global_var_int_added_to_debug_info.snap @@ -14,8 +14,8 @@ source_filename = "main" @g = global i64 0, !dbg !19 @h = global i64 0, !dbg !22 -!llvm.module.flags = !{!25} -!llvm.dbg.cu = !{!26} +!llvm.module.flags = !{!25, !26} +!llvm.dbg.cu = !{!27} !0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression()) !1 = distinct !DIGlobalVariable(name: "a", scope: !2, file: !2, line: 3, type: !3, isLocal: false, isDefinition: true) @@ -43,6 +43,7 @@ source_filename = "main" !23 = distinct !DIGlobalVariable(name: "h", scope: !2, file: !2, line: 10, type: !24, isLocal: false, isDefinition: true) !24 = !DIBasicType(name: "ULINT", size: 64, encoding: DW_ATE_unsigned, flags: DIFlagPublic) !25 = !{i32 2, !"Dwarf Version", i32 5} -!26 = distinct !DICompileUnit(language: DW_LANG_C, file: !2, producer: "RuSTy Structured text Compiler", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, globals: !27, splitDebugInlining: false) -!27 = !{!0, !4, !7, !10, !13, !16, !19, !22} +!26 = !{i32 2, !"Debug Info Version", i32 3} +!27 = distinct !DICompileUnit(language: DW_LANG_C, file: !2, producer: "RuSTy Structured text Compiler", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, globals: !28, splitDebugInlining: false) +!28 = !{!0, !4, !7, !10, !13, !16, !19, !22} diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__debug_tests__global_var_nested_struct_added_to_debug_info.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__debug_tests__global_var_nested_struct_added_to_debug_info.snap index ab61d12603..77a450c403 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__debug_tests__global_var_nested_struct_added_to_debug_info.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__debug_tests__global_var_nested_struct_added_to_debug_info.snap @@ -12,8 +12,8 @@ source_filename = "main" @__myStruct__init = unnamed_addr constant %myStruct zeroinitializer, !dbg !13 @__myStruct2__init = unnamed_addr constant %myStruct2 zeroinitializer, !dbg !15 -!llvm.module.flags = !{!17} -!llvm.dbg.cu = !{!18} +!llvm.module.flags = !{!17, !18} +!llvm.dbg.cu = !{!19} !0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression()) !1 = distinct !DIGlobalVariable(name: "gStruct", scope: !2, file: !2, line: 15, type: !3, isLocal: false, isDefinition: true) @@ -33,6 +33,7 @@ source_filename = "main" !15 = !DIGlobalVariableExpression(var: !16, expr: !DIExpression()) !16 = distinct !DIGlobalVariable(name: "__myStruct2__init", scope: !2, file: !2, line: 8, type: !8, isLocal: false, isDefinition: true) !17 = !{i32 2, !"Dwarf Version", i32 5} -!18 = distinct !DICompileUnit(language: DW_LANG_C, file: !2, producer: "RuSTy Structured text Compiler", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, globals: !19, splitDebugInlining: false) -!19 = !{!0, !13, !15} +!18 = !{i32 2, !"Debug Info Version", i32 3} +!19 = distinct !DICompileUnit(language: DW_LANG_C, file: !2, producer: "RuSTy Structured text Compiler", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, globals: !20, splitDebugInlining: false) +!20 = !{!0, !13, !15} diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__debug_tests__global_var_pointer_added_to_debug_info.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__debug_tests__global_var_pointer_added_to_debug_info.snap index 8c8be5a06d..627648ab04 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__debug_tests__global_var_pointer_added_to_debug_info.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__debug_tests__global_var_pointer_added_to_debug_info.snap @@ -7,8 +7,8 @@ source_filename = "main" @a = global i32* null, !dbg !0 -!llvm.module.flags = !{!5} -!llvm.dbg.cu = !{!6} +!llvm.module.flags = !{!5, !6} +!llvm.dbg.cu = !{!7} !0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression()) !1 = distinct !DIGlobalVariable(name: "a", scope: !2, file: !2, line: 3, type: !3, isLocal: false, isDefinition: true) @@ -16,6 +16,7 @@ source_filename = "main" !3 = !DIDerivedType(tag: DW_TAG_pointer_type, name: "__global_a", baseType: !4, size: 64, align: 64, dwarfAddressSpace: 1) !4 = !DIBasicType(name: "DINT", size: 32, encoding: DW_ATE_signed, flags: DIFlagPublic) !5 = !{i32 2, !"Dwarf Version", i32 5} -!6 = distinct !DICompileUnit(language: DW_LANG_C, file: !2, producer: "RuSTy Structured text Compiler", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, globals: !7, splitDebugInlining: false) -!7 = !{!0} +!6 = !{i32 2, !"Debug Info Version", i32 3} +!7 = distinct !DICompileUnit(language: DW_LANG_C, file: !2, producer: "RuSTy Structured text Compiler", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, globals: !8, splitDebugInlining: false) +!8 = !{!0} diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__debug_tests__global_var_string_added_to_debug_info.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__debug_tests__global_var_string_added_to_debug_info.snap index 38c1ae5baa..b5624c5172 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__debug_tests__global_var_string_added_to_debug_info.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__debug_tests__global_var_string_added_to_debug_info.snap @@ -1,6 +1,6 @@ --- source: src/codegen/tests/debug_tests.rs -expression: codegen.0 +expression: codegen --- ; ModuleID = 'main' source_filename = "main" @@ -8,8 +8,8 @@ source_filename = "main" @a = global [81 x i8] zeroinitializer, !dbg !0 @b = global [81 x i16] zeroinitializer, !dbg !7 -!llvm.module.flags = !{!11} -!llvm.dbg.cu = !{!12} +!llvm.module.flags = !{!11, !12} +!llvm.dbg.cu = !{!13} !0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression()) !1 = distinct !DIGlobalVariable(name: "a", scope: !2, file: !2, line: 3, type: !3, isLocal: false, isDefinition: true) @@ -23,6 +23,7 @@ source_filename = "main" !9 = !DICompositeType(tag: DW_TAG_array_type, baseType: !10, size: 160, align: 64, elements: !5) !10 = !DIBasicType(name: "wchar", size: 16, encoding: DW_ATE_UTF, flags: DIFlagPublic) !11 = !{i32 2, !"Dwarf Version", i32 5} -!12 = distinct !DICompileUnit(language: DW_LANG_C, file: !2, producer: "RuSTy Structured text Compiler", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, globals: !13, splitDebugInlining: false) -!13 = !{!0, !7} +!12 = !{i32 2, !"Debug Info Version", i32 3} +!13 = distinct !DICompileUnit(language: DW_LANG_C, file: !2, producer: "RuSTy Structured text Compiler", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, globals: !14, splitDebugInlining: false) +!14 = !{!0, !7} diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__debug_tests__global_var_struct_added_to_debug_info.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__debug_tests__global_var_struct_added_to_debug_info.snap index 35f252c4fc..fd3ac61817 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__debug_tests__global_var_struct_added_to_debug_info.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__debug_tests__global_var_struct_added_to_debug_info.snap @@ -11,8 +11,8 @@ source_filename = "main" @__myStruct__init = unnamed_addr constant %myStruct zeroinitializer, !dbg !13 @b = global [11 x %myStruct] zeroinitializer, !dbg !15 -!llvm.module.flags = !{!18} -!llvm.dbg.cu = !{!19} +!llvm.module.flags = !{!18, !19} +!llvm.dbg.cu = !{!20} !0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression()) !1 = distinct !DIGlobalVariable(name: "gStruct", scope: !2, file: !2, line: 11, type: !3, isLocal: false, isDefinition: true) @@ -33,6 +33,7 @@ source_filename = "main" !16 = distinct !DIGlobalVariable(name: "b", scope: !2, file: !2, line: 12, type: !17, isLocal: false, isDefinition: true) !17 = !DICompositeType(tag: DW_TAG_array_type, baseType: !3, size: 5280, align: 64, elements: !11) !18 = !{i32 2, !"Dwarf Version", i32 5} -!19 = distinct !DICompileUnit(language: DW_LANG_C, file: !2, producer: "RuSTy Structured text Compiler", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, globals: !20, splitDebugInlining: false) -!20 = !{!0, !13, !15} +!19 = !{i32 2, !"Debug Info Version", i32 3} +!20 = distinct !DICompileUnit(language: DW_LANG_C, file: !2, producer: "RuSTy Structured text Compiler", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, globals: !21, splitDebugInlining: false) +!21 = !{!0, !13, !15} diff --git a/src/lib.rs b/src/lib.rs index 73b711487b..1092512aae 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -48,6 +48,8 @@ pub mod typesystem; pub mod validation; extern crate shell_words; +pub const DEFAULT_DWARF_VERSION: usize = 5; + #[derive(Serialize, Debug, Clone, PartialEq, Eq)] pub enum Target { System, @@ -170,8 +172,8 @@ pub enum OptimizationLevel { pub enum DebugLevel { #[default] None, - VariablesOnly, - Full, + VariablesOnly(usize), + Full(usize), } impl From for inkwell::OptimizationLevel { diff --git a/src/test_utils.rs b/src/test_utils.rs index a5464d8d37..f7631b06c5 100644 --- a/src/test_utils.rs +++ b/src/test_utils.rs @@ -182,7 +182,11 @@ pub mod tests { } pub fn codegen_with_debug(src: &str) -> String { - codegen_debug_without_unwrap(src, DebugLevel::Full).unwrap() + codegen_debug_without_unwrap(src, DebugLevel::Full(crate::DEFAULT_DWARF_VERSION)).unwrap() + } + + pub fn codegen_with_debug_version(src: &str, dwarf_version: usize) -> String { + codegen_debug_without_unwrap(src, DebugLevel::Full(dwarf_version)).unwrap() } pub fn codegen(src: &str) -> String { diff --git a/tests/integration/snapshots/tests__integration__cfc__ir__actions_debug.snap b/tests/integration/snapshots/tests__integration__cfc__ir__actions_debug.snap index 81edf2590d..099b546475 100644 --- a/tests/integration/snapshots/tests__integration__cfc__ir__actions_debug.snap +++ b/tests/integration/snapshots/tests__integration__cfc__ir__actions_debug.snap @@ -6,37 +6,37 @@ expression: output_file_content_without_headers @main_instance = global %main zeroinitializer, !dbg !0 -define void @main(%main* %0) !dbg !11 { +define void @main(%main* %0) !dbg !12 { entry: - call void @llvm.dbg.declare(metadata %main* %0, metadata !15, metadata !DIExpression()), !dbg !16 - %a = getelementptr inbounds %main, %main* %0, i32 0, i32 0, !dbg !17 - %b = getelementptr inbounds %main, %main* %0, i32 0, i32 1, !dbg !17 - store i32 0, i32* %a, align 4, !dbg !18 - call void @main.newAction(%main* %0), !dbg !16 - call void @main.newAction2(%main* %0), !dbg !19 - ret void, !dbg !19 + call void @llvm.dbg.declare(metadata %main* %0, metadata !16, metadata !DIExpression()), !dbg !17 + %a = getelementptr inbounds %main, %main* %0, i32 0, i32 0, !dbg !18 + %b = getelementptr inbounds %main, %main* %0, i32 0, i32 1, !dbg !18 + store i32 0, i32* %a, align 4, !dbg !19 + call void @main.newAction(%main* %0), !dbg !17 + call void @main.newAction2(%main* %0), !dbg !20 + ret void, !dbg !20 } -define void @main.newAction(%main* %0) !dbg !20 { +define void @main.newAction(%main* %0) !dbg !21 { entry: - call void @llvm.dbg.declare(metadata %main* %0, metadata !15, metadata !DIExpression()), !dbg !21 - %a = getelementptr inbounds %main, %main* %0, i32 0, i32 0, !dbg !22 - %b = getelementptr inbounds %main, %main* %0, i32 0, i32 1, !dbg !22 - %load_a = load i32, i32* %a, align 4, !dbg !21 - %tmpVar = add i32 %load_a, 1, !dbg !21 - store i32 %tmpVar, i32* %a, align 4, !dbg !21 - ret void, !dbg !21 + call void @llvm.dbg.declare(metadata %main* %0, metadata !16, metadata !DIExpression()), !dbg !22 + %a = getelementptr inbounds %main, %main* %0, i32 0, i32 0, !dbg !23 + %b = getelementptr inbounds %main, %main* %0, i32 0, i32 1, !dbg !23 + %load_a = load i32, i32* %a, align 4, !dbg !22 + %tmpVar = add i32 %load_a, 1, !dbg !22 + store i32 %tmpVar, i32* %a, align 4, !dbg !22 + ret void, !dbg !22 } -define void @main.newAction2(%main* %0) !dbg !23 { +define void @main.newAction2(%main* %0) !dbg !24 { entry: - call void @llvm.dbg.declare(metadata %main* %0, metadata !15, metadata !DIExpression()), !dbg !24 - %a = getelementptr inbounds %main, %main* %0, i32 0, i32 0, !dbg !25 - %b = getelementptr inbounds %main, %main* %0, i32 0, i32 1, !dbg !25 - %load_b = load i32, i32* %b, align 4, !dbg !26 - %tmpVar = add i32 %load_b, 2, !dbg !26 - store i32 %tmpVar, i32* %b, align 4, !dbg !26 - ret void, !dbg !26 + call void @llvm.dbg.declare(metadata %main* %0, metadata !16, metadata !DIExpression()), !dbg !25 + %a = getelementptr inbounds %main, %main* %0, i32 0, i32 0, !dbg !26 + %b = getelementptr inbounds %main, %main* %0, i32 0, i32 1, !dbg !26 + %load_b = load i32, i32* %b, align 4, !dbg !27 + %tmpVar = add i32 %load_b, 2, !dbg !27 + store i32 %tmpVar, i32* %b, align 4, !dbg !27 + ret void, !dbg !27 } ; Function Attrs: nofree nosync nounwind readnone speculatable willreturn @@ -44,8 +44,8 @@ declare void @llvm.dbg.declare(metadata, metadata, metadata) #0 attributes #0 = { nofree nosync nounwind readnone speculatable willreturn } -!llvm.module.flags = !{!8} -!llvm.dbg.cu = !{!9} +!llvm.module.flags = !{!8, !9} +!llvm.dbg.cu = !{!10} !0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression()) !1 = distinct !DIGlobalVariable(name: "main", scope: !2, file: !2, line: 1, type: !3, isLocal: false, isDefinition: true) @@ -56,21 +56,22 @@ attributes #0 = { nofree nosync nounwind readnone speculatable willreturn } !6 = !DIBasicType(name: "DINT", size: 32, encoding: DW_ATE_signed, flags: DIFlagPublic) !7 = !DIDerivedType(tag: DW_TAG_member, name: "b", scope: !2, file: !2, line: 1, baseType: !6, size: 32, align: 32, offset: 32, flags: DIFlagPublic) !8 = !{i32 2, !"Dwarf Version", i32 5} -!9 = distinct !DICompileUnit(language: DW_LANG_C, file: !2, producer: "RuSTy Structured text Compiler", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, globals: !10, splitDebugInlining: false) -!10 = !{!0} -!11 = distinct !DISubprogram(name: "main", linkageName: "main", scope: !2, file: !2, line: 1, type: !12, scopeLine: 1, flags: DIFlagPublic, spFlags: DISPFlagDefinition, unit: !9, retainedNodes: !14) -!12 = !DISubroutineType(flags: DIFlagPublic, types: !13) -!13 = !{null} -!14 = !{} -!15 = !DILocalVariable(name: "main", scope: !11, file: !2, line: 1, type: !3) -!16 = !DILocation(line: 1, scope: !11) -!17 = !DILocation(line: 0, scope: !11) -!18 = !DILocation(line: 3, scope: !11) -!19 = !DILocation(line: 2, scope: !11) -!20 = distinct !DISubprogram(name: "main.newAction", linkageName: "main.newAction", scope: !2, file: !2, type: !12, scopeLine: 1, flags: DIFlagPublic, spFlags: DISPFlagDefinition, unit: !9, retainedNodes: !14) -!21 = !DILocation(line: 1, scope: !20) -!22 = !DILocation(line: 0, scope: !20) -!23 = distinct !DISubprogram(name: "main.newAction2", linkageName: "main.newAction2", scope: !2, file: !2, type: !12, scopeLine: 1, flags: DIFlagPublic, spFlags: DISPFlagDefinition, unit: !9, retainedNodes: !14) -!24 = !DILocation(line: 1, scope: !23) -!25 = !DILocation(line: 0, scope: !23) -!26 = !DILocation(line: 2, scope: !23) +!9 = !{i32 2, !"Debug Info Version", i32 3} +!10 = distinct !DICompileUnit(language: DW_LANG_C, file: !2, producer: "RuSTy Structured text Compiler", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, globals: !11, splitDebugInlining: false) +!11 = !{!0} +!12 = distinct !DISubprogram(name: "main", linkageName: "main", scope: !2, file: !2, line: 1, type: !13, scopeLine: 1, flags: DIFlagPublic, spFlags: DISPFlagDefinition, unit: !10, retainedNodes: !15) +!13 = !DISubroutineType(flags: DIFlagPublic, types: !14) +!14 = !{null} +!15 = !{} +!16 = !DILocalVariable(name: "main", scope: !12, file: !2, line: 1, type: !3) +!17 = !DILocation(line: 1, scope: !12) +!18 = !DILocation(line: 0, scope: !12) +!19 = !DILocation(line: 3, scope: !12) +!20 = !DILocation(line: 2, scope: !12) +!21 = distinct !DISubprogram(name: "main.newAction", linkageName: "main.newAction", scope: !2, file: !2, type: !13, scopeLine: 1, flags: DIFlagPublic, spFlags: DISPFlagDefinition, unit: !10, retainedNodes: !15) +!22 = !DILocation(line: 1, scope: !21) +!23 = !DILocation(line: 0, scope: !21) +!24 = distinct !DISubprogram(name: "main.newAction2", linkageName: "main.newAction2", scope: !2, file: !2, type: !13, scopeLine: 1, flags: DIFlagPublic, spFlags: DISPFlagDefinition, unit: !10, retainedNodes: !15) +!25 = !DILocation(line: 1, scope: !24) +!26 = !DILocation(line: 0, scope: !24) +!27 = !DILocation(line: 2, scope: !24) diff --git a/tests/integration/snapshots/tests__integration__cfc__ir__conditional_return_debug.snap b/tests/integration/snapshots/tests__integration__cfc__ir__conditional_return_debug.snap index aaeb884ce6..7bca5852a2 100644 --- a/tests/integration/snapshots/tests__integration__cfc__ir__conditional_return_debug.snap +++ b/tests/integration/snapshots/tests__integration__cfc__ir__conditional_return_debug.snap @@ -2,26 +2,26 @@ source: tests/integration/cfc.rs expression: output_file_content_without_headers --- -define i32 @foo(i32 %0) !dbg !3 { +define i32 @foo(i32 %0) !dbg !4 { entry: - %foo = alloca i32, align 4, !dbg !8 - %val = alloca i32, align 4, !dbg !8 - call void @llvm.dbg.declare(metadata i32* %val, metadata !9, metadata !DIExpression()), !dbg !10 - store i32 %0, i32* %val, align 4, !dbg !8 - call void @llvm.dbg.declare(metadata i32* %foo, metadata !11, metadata !DIExpression()), !dbg !12 - store i32 0, i32* %foo, align 4, !dbg !8 - %load_val = load i32, i32* %val, align 4, !dbg !13 - %tmpVar = icmp eq i32 %load_val, 5, !dbg !13 - br i1 %tmpVar, label %then_block, label %else_block, !dbg !13 + %foo = alloca i32, align 4, !dbg !9 + %val = alloca i32, align 4, !dbg !9 + call void @llvm.dbg.declare(metadata i32* %val, metadata !10, metadata !DIExpression()), !dbg !11 + store i32 %0, i32* %val, align 4, !dbg !9 + call void @llvm.dbg.declare(metadata i32* %foo, metadata !12, metadata !DIExpression()), !dbg !13 + store i32 0, i32* %foo, align 4, !dbg !9 + %load_val = load i32, i32* %val, align 4, !dbg !14 + %tmpVar = icmp eq i32 %load_val, 5, !dbg !14 + br i1 %tmpVar, label %then_block, label %else_block, !dbg !14 then_block: ; preds = %entry - %foo_ret = load i32, i32* %foo, align 4, !dbg !8 - ret i32 %foo_ret, !dbg !8 + %foo_ret = load i32, i32* %foo, align 4, !dbg !9 + ret i32 %foo_ret, !dbg !9 else_block: ; preds = %entry - store i32 10, i32* %val, align 4, !dbg !14 - %foo_ret1 = load i32, i32* %foo, align 4, !dbg !14 - ret i32 %foo_ret1, !dbg !14 + store i32 10, i32* %val, align 4, !dbg !15 + %foo_ret1 = load i32, i32* %foo, align 4, !dbg !15 + ret i32 %foo_ret1, !dbg !15 } ; Function Attrs: nofree nosync nounwind readnone speculatable willreturn @@ -29,21 +29,22 @@ declare void @llvm.dbg.declare(metadata, metadata, metadata) #0 attributes #0 = { nofree nosync nounwind readnone speculatable willreturn } -!llvm.module.flags = !{!0} -!llvm.dbg.cu = !{!1} +!llvm.module.flags = !{!0, !1} +!llvm.dbg.cu = !{!2} !0 = !{i32 2, !"Dwarf Version", i32 5} -!1 = distinct !DICompileUnit(language: DW_LANG_C, file: !2, producer: "RuSTy Structured text Compiler", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, splitDebugInlining: false) -!2 = !DIFile(filename: ".cfc", directory: "") -!3 = distinct !DISubprogram(name: "foo", linkageName: "foo", scope: !2, file: !2, line: 1, type: !4, scopeLine: 4, flags: DIFlagPublic, spFlags: DISPFlagDefinition, unit: !1, retainedNodes: !7) -!4 = !DISubroutineType(flags: DIFlagPublic, types: !5) -!5 = !{null, !6} -!6 = !DIBasicType(name: "DINT", size: 32, encoding: DW_ATE_signed, flags: DIFlagPublic) -!7 = !{} -!8 = !DILocation(line: 3, scope: !3) -!9 = !DILocalVariable(name: "val", scope: !3, file: !2, line: 1, type: !6) -!10 = !DILocation(line: 1, column: 30, scope: !3) -!11 = !DILocalVariable(name: "foo", scope: !3, file: !2, line: 1, type: !6, align: 32) -!12 = !DILocation(line: 1, column: 9, scope: !3) -!13 = !DILocation(line: 2, scope: !3) -!14 = !DILocation(line: 5, scope: !3) +!1 = !{i32 2, !"Debug Info Version", i32 3} +!2 = distinct !DICompileUnit(language: DW_LANG_C, file: !3, producer: "RuSTy Structured text Compiler", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, splitDebugInlining: false) +!3 = !DIFile(filename: ".cfc", directory: "") +!4 = distinct !DISubprogram(name: "foo", linkageName: "foo", scope: !3, file: !3, line: 1, type: !5, scopeLine: 4, flags: DIFlagPublic, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !8) +!5 = !DISubroutineType(flags: DIFlagPublic, types: !6) +!6 = !{null, !7} +!7 = !DIBasicType(name: "DINT", size: 32, encoding: DW_ATE_signed, flags: DIFlagPublic) +!8 = !{} +!9 = !DILocation(line: 3, scope: !4) +!10 = !DILocalVariable(name: "val", scope: !4, file: !3, line: 1, type: !7) +!11 = !DILocation(line: 1, column: 30, scope: !4) +!12 = !DILocalVariable(name: "foo", scope: !4, file: !3, line: 1, type: !7, align: 32) +!13 = !DILocation(line: 1, column: 9, scope: !4) +!14 = !DILocation(line: 2, scope: !4) +!15 = !DILocation(line: 5, scope: !4) diff --git a/tests/integration/snapshots/tests__integration__cfc__ir__jump_debug.snap b/tests/integration/snapshots/tests__integration__cfc__ir__jump_debug.snap index 06b43172da..07376c0a96 100644 --- a/tests/integration/snapshots/tests__integration__cfc__ir__jump_debug.snap +++ b/tests/integration/snapshots/tests__integration__cfc__ir__jump_debug.snap @@ -6,20 +6,20 @@ expression: output_file_content_without_headers @foo_instance = global %foo zeroinitializer, !dbg !0 -define void @foo(%foo* %0) !dbg !10 { +define void @foo(%foo* %0) !dbg !11 { entry: - call void @llvm.dbg.declare(metadata %foo* %0, metadata !14, metadata !DIExpression()), !dbg !15 - %val = getelementptr inbounds %foo, %foo* %0, i32 0, i32 0, !dbg !16 - br label %lbl, !dbg !16 + call void @llvm.dbg.declare(metadata %foo* %0, metadata !15, metadata !DIExpression()), !dbg !16 + %val = getelementptr inbounds %foo, %foo* %0, i32 0, i32 0, !dbg !17 + br label %lbl, !dbg !17 lbl: ; preds = %lbl, %entry - %load_val = load i32, i32* %val, align 4, !dbg !15 - %tmpVar = icmp eq i32 %load_val, 0, !dbg !15 - br i1 %tmpVar, label %lbl, label %else_block, !dbg !17 + %load_val = load i32, i32* %val, align 4, !dbg !16 + %tmpVar = icmp eq i32 %load_val, 0, !dbg !16 + br i1 %tmpVar, label %lbl, label %else_block, !dbg !18 else_block: ; preds = %lbl - store i32 1, i32* %val, align 4, !dbg !18 - ret void, !dbg !18 + store i32 1, i32* %val, align 4, !dbg !19 + ret void, !dbg !19 } ; Function Attrs: nofree nosync nounwind readnone speculatable willreturn @@ -27,8 +27,8 @@ declare void @llvm.dbg.declare(metadata, metadata, metadata) #0 attributes #0 = { nofree nosync nounwind readnone speculatable willreturn } -!llvm.module.flags = !{!7} -!llvm.dbg.cu = !{!8} +!llvm.module.flags = !{!7, !8} +!llvm.dbg.cu = !{!9} !0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression()) !1 = distinct !DIGlobalVariable(name: "foo", scope: !2, file: !2, line: 1, type: !3, isLocal: false, isDefinition: true) @@ -38,14 +38,15 @@ attributes #0 = { nofree nosync nounwind readnone speculatable willreturn } !5 = !DIDerivedType(tag: DW_TAG_member, name: "val", scope: !2, file: !2, line: 1, baseType: !6, size: 32, align: 32, flags: DIFlagPublic) !6 = !DIBasicType(name: "DINT", size: 32, encoding: DW_ATE_signed, flags: DIFlagPublic) !7 = !{i32 2, !"Dwarf Version", i32 5} -!8 = distinct !DICompileUnit(language: DW_LANG_C, file: !2, producer: "RuSTy Structured text Compiler", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, globals: !9, splitDebugInlining: false) -!9 = !{!0} -!10 = distinct !DISubprogram(name: "foo", linkageName: "foo", scope: !2, file: !2, line: 1, type: !11, scopeLine: 3, flags: DIFlagPublic, spFlags: DISPFlagDefinition, unit: !8, retainedNodes: !13) -!11 = !DISubroutineType(flags: DIFlagPublic, types: !12) -!12 = !{null} -!13 = !{} -!14 = !DILocalVariable(name: "foo", scope: !10, file: !2, line: 1, type: !3) -!15 = !DILocation(line: 1, scope: !10) -!16 = !DILocation(line: 2, scope: !10) -!17 = !DILocation(line: 3, scope: !10) -!18 = !DILocation(line: 4, scope: !10) +!8 = !{i32 2, !"Debug Info Version", i32 3} +!9 = distinct !DICompileUnit(language: DW_LANG_C, file: !2, producer: "RuSTy Structured text Compiler", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, globals: !10, splitDebugInlining: false) +!10 = !{!0} +!11 = distinct !DISubprogram(name: "foo", linkageName: "foo", scope: !2, file: !2, line: 1, type: !12, scopeLine: 3, flags: DIFlagPublic, spFlags: DISPFlagDefinition, unit: !9, retainedNodes: !14) +!12 = !DISubroutineType(flags: DIFlagPublic, types: !13) +!13 = !{null} +!14 = !{} +!15 = !DILocalVariable(name: "foo", scope: !11, file: !2, line: 1, type: !3) +!16 = !DILocation(line: 1, scope: !11) +!17 = !DILocation(line: 2, scope: !11) +!18 = !DILocation(line: 3, scope: !11) +!19 = !DILocation(line: 4, scope: !11) diff --git a/tests/integration/snapshots/tests__integration__cfc__ir__sink_source_debug.snap b/tests/integration/snapshots/tests__integration__cfc__ir__sink_source_debug.snap index 51bd832702..3e542dd24a 100644 --- a/tests/integration/snapshots/tests__integration__cfc__ir__sink_source_debug.snap +++ b/tests/integration/snapshots/tests__integration__cfc__ir__sink_source_debug.snap @@ -6,12 +6,12 @@ expression: output_file_content_without_headers @main_instance = global %main zeroinitializer, !dbg !0 -define void @main(%main* %0) !dbg !10 { +define void @main(%main* %0) !dbg !11 { entry: - call void @llvm.dbg.declare(metadata %main* %0, metadata !14, metadata !DIExpression()), !dbg !15 - %x = getelementptr inbounds %main, %main* %0, i32 0, i32 0, !dbg !16 - store i32 5, i32* %x, align 4, !dbg !17 - ret void, !dbg !17 + call void @llvm.dbg.declare(metadata %main* %0, metadata !15, metadata !DIExpression()), !dbg !16 + %x = getelementptr inbounds %main, %main* %0, i32 0, i32 0, !dbg !17 + store i32 5, i32* %x, align 4, !dbg !18 + ret void, !dbg !18 } ; Function Attrs: nofree nosync nounwind readnone speculatable willreturn @@ -19,8 +19,8 @@ declare void @llvm.dbg.declare(metadata, metadata, metadata) #0 attributes #0 = { nofree nosync nounwind readnone speculatable willreturn } -!llvm.module.flags = !{!7} -!llvm.dbg.cu = !{!8} +!llvm.module.flags = !{!7, !8} +!llvm.dbg.cu = !{!9} !0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression()) !1 = distinct !DIGlobalVariable(name: "main", scope: !2, file: !2, line: 1, type: !3, isLocal: false, isDefinition: true) @@ -30,13 +30,14 @@ attributes #0 = { nofree nosync nounwind readnone speculatable willreturn } !5 = !DIDerivedType(tag: DW_TAG_member, name: "x", scope: !2, file: !2, line: 1, baseType: !6, size: 32, align: 32, flags: DIFlagPublic) !6 = !DIBasicType(name: "DINT", size: 32, encoding: DW_ATE_signed, flags: DIFlagPublic) !7 = !{i32 2, !"Dwarf Version", i32 5} -!8 = distinct !DICompileUnit(language: DW_LANG_C, file: !2, producer: "RuSTy Structured text Compiler", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, globals: !9, splitDebugInlining: false) -!9 = !{!0} -!10 = distinct !DISubprogram(name: "main", linkageName: "main", scope: !2, file: !2, line: 1, type: !11, scopeLine: 1, flags: DIFlagPublic, spFlags: DISPFlagDefinition, unit: !8, retainedNodes: !13) -!11 = !DISubroutineType(flags: DIFlagPublic, types: !12) -!12 = !{null} -!13 = !{} -!14 = !DILocalVariable(name: "main", scope: !10, file: !2, line: 1, type: !3) -!15 = !DILocation(line: 1, scope: !10) -!16 = !DILocation(line: 0, scope: !10) -!17 = !DILocation(line: 4, scope: !10) +!8 = !{i32 2, !"Debug Info Version", i32 3} +!9 = distinct !DICompileUnit(language: DW_LANG_C, file: !2, producer: "RuSTy Structured text Compiler", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, globals: !10, splitDebugInlining: false) +!10 = !{!0} +!11 = distinct !DISubprogram(name: "main", linkageName: "main", scope: !2, file: !2, line: 1, type: !12, scopeLine: 1, flags: DIFlagPublic, spFlags: DISPFlagDefinition, unit: !9, retainedNodes: !14) +!12 = !DISubroutineType(flags: DIFlagPublic, types: !13) +!13 = !{null} +!14 = !{} +!15 = !DILocalVariable(name: "main", scope: !11, file: !2, line: 1, type: !3) +!16 = !DILocation(line: 1, scope: !11) +!17 = !DILocation(line: 0, scope: !11) +!18 = !DILocation(line: 4, scope: !11) From fdd22b4360f38e5bfccac41872bcc06a6fa7cc87 Mon Sep 17 00:00:00 2001 From: Ghaith Hachem Date: Fri, 9 Feb 2024 07:13:53 +0100 Subject: [PATCH 30/33] ci: run clippy with rust 1.75 (#1085) * ci: run clippy with rust 1.75 * Fix bitaccess test where true != true because of bitshift --- compiler/plc_diagnostics/src/diagnostics.rs | 2 +- compiler/plc_driver/src/cli.rs | 4 +--- compiler/plc_driver/src/lib.rs | 2 +- compiler/plc_xml/src/model/interface.rs | 2 +- compiler/plc_xml/src/xml_parser/control.rs | 13 +++++++++---- compiler/plc_xml/src/xml_parser/tests.rs | 4 ++-- libs/stdlib/src/date_time_extra_functions.rs | 4 ++-- src/builtins.rs | 16 ++++++++-------- src/codegen/debug.rs | 1 + src/codegen/generators/expression_generator.rs | 6 +++--- src/codegen/generators/statement_generator.rs | 2 +- src/index.rs | 9 +++------ src/index/symbol.rs | 2 +- src/index/tests/index_tests.rs | 6 +++--- src/resolver.rs | 2 +- src/resolver/const_evaluator.rs | 2 +- src/validation/variable.rs | 8 ++++---- tests/correctness/bitaccess.rs | 12 ++++++------ 18 files changed, 49 insertions(+), 48 deletions(-) diff --git a/compiler/plc_diagnostics/src/diagnostics.rs b/compiler/plc_diagnostics/src/diagnostics.rs index 5ed1afe340..f4a517a442 100644 --- a/compiler/plc_diagnostics/src/diagnostics.rs +++ b/compiler/plc_diagnostics/src/diagnostics.rs @@ -330,7 +330,7 @@ impl Diagnostic { impl PartialOrd for Diagnostic { fn partial_cmp(&self, other: &Self) -> Option { - self.severity.partial_cmp(&other.severity) + Some(self.cmp(other)) } } diff --git a/compiler/plc_driver/src/cli.rs b/compiler/plc_driver/src/cli.rs index 9746c10297..89f758d049 100644 --- a/compiler/plc_driver/src/cli.rs +++ b/compiler/plc_driver/src/cli.rs @@ -377,9 +377,7 @@ impl CompileParameters { } pub fn get_config_options(&self) -> Option<(ConfigOption, ConfigFormat)> { - let Some(SubCommands::Config { format, option }) = &self.commands else { - return None - }; + let Some(SubCommands::Config { format, option }) = &self.commands else { return None }; Some((*option, *format)) } } diff --git a/compiler/plc_driver/src/lib.rs b/compiler/plc_driver/src/lib.rs index f81ba52053..9bae1b56a6 100644 --- a/compiler/plc_driver/src/lib.rs +++ b/compiler/plc_driver/src/lib.rs @@ -364,7 +364,7 @@ fn get_project(compile_parameters: &CompileParameters) -> Result Option<&str> { - let Some(ref data) = self.add_data else { return None }; + let data = self.add_data.as_ref()?; Some(&data.content) } diff --git a/compiler/plc_xml/src/xml_parser/control.rs b/compiler/plc_xml/src/xml_parser/control.rs index ad3a4eef71..a32c181f5b 100644 --- a/compiler/plc_xml/src/xml_parser/control.rs +++ b/compiler/plc_xml/src/xml_parser/control.rs @@ -26,14 +26,19 @@ fn get_connection( let Some(ref_local_id) = control.ref_local_id else { let location = session.range_factory.create_block_location(control.local_id, control.execution_order_id); - return Err(Diagnostic::error("Control statement has no connection").with_error_code("E081").with_location(location)); + return Err(Diagnostic::error("Control statement has no connection") + .with_error_code("E081") + .with_location(location)); }; let Some(node) = index.get(&ref_local_id) else { let location = session.range_factory.create_block_location(ref_local_id, None); - return Err(Diagnostic::error(format!("Node {} is referencing a non-existing element with ID {ref_local_id}",control.local_id)) - .with_error_code("E082") - .with_location(location)); + return Err(Diagnostic::error(format!( + "Node {} is referencing a non-existing element with ID {ref_local_id}", + control.local_id + )) + .with_error_code("E082") + .with_location(location)); }; match node { diff --git a/compiler/plc_xml/src/xml_parser/tests.rs b/compiler/plc_xml/src/xml_parser/tests.rs index dbeda9ea1d..60a0a13359 100644 --- a/compiler/plc_xml/src/xml_parser/tests.rs +++ b/compiler/plc_xml/src/xml_parser/tests.rs @@ -319,7 +319,7 @@ fn ast_generates_locations() { &SInVariable::id(5).with_expression("1"), ]); - let source_code = SourceCode::new(&content.serialize(), ".cfc"); + let source_code = SourceCode::new(content.serialize(), ".cfc"); let (units, diagnostics) = xml_parser::parse(&source_code, LinkageType::Internal, IdProvider::default()); let impl1 = &units.implementations[0]; //Deconstruct assignment and get locations @@ -366,7 +366,7 @@ fn ast_diagnostic_locations() { &SOutVariable::id(2).with_execution_id(0).with_expression("a").connect(1), // "a" isn't declared anywhere, hence the error ]); - let source_code = SourceCode::new(&content.serialize(), ".cfc"); + let source_code = SourceCode::new(content.serialize(), ".cfc"); let (units, diagnostics) = xml_parser::parse(&source_code, LinkageType::Internal, IdProvider::default()); let impl1 = &units.implementations[0]; assert_debug_snapshot!(impl1); diff --git a/libs/stdlib/src/date_time_extra_functions.rs b/libs/stdlib/src/date_time_extra_functions.rs index 423152cefb..ebfc504cfe 100644 --- a/libs/stdlib/src/date_time_extra_functions.rs +++ b/libs/stdlib/src/date_time_extra_functions.rs @@ -239,7 +239,7 @@ pub extern "C" fn SPLIT_DATE__UDINT(in1: i64, out1: &mut u32, out2: &mut u32, ou pub extern "C" fn SPLIT_DATE__LINT(in1: i64, out1: &mut i64, out2: &mut i64, out3: &mut i64) -> i16 { let date = chrono::Utc.timestamp_nanos(in1).date_naive(); // if year does not fit in target data type -> panic - *out1 = date.year().try_into().unwrap(); + *out1 = date.year().into(); *out2 = date.month() as i64; *out3 = date.day() as i64; @@ -516,7 +516,7 @@ pub extern "C" fn SPLIT_DT__LINT( ) -> i16 { let dt = chrono::Utc.timestamp_nanos(in1); // if year does not fit in target data type -> panic - *out1 = dt.year().try_into().unwrap(); + *out1 = dt.year().into(); *out2 = dt.month() as i64; *out3 = dt.day() as i64; *out4 = dt.hour() as i64; diff --git a/src/builtins.rs b/src/builtins.rs index 9ea1f232be..7d0e32ac01 100644 --- a/src/builtins.rs +++ b/src/builtins.rs @@ -73,7 +73,7 @@ lazy_static! { let Some(params) = parameters else { return; }; // Get the input and annotate it with a pointer type let input = flatten_expression_list(params); - let Some(input) = input.get(0) else { return; }; + let Some(input) = input.first() else { return; }; let input_type = annotator.annotation_map .get_type_or_void(input, annotator.index) .get_type_information() @@ -136,13 +136,13 @@ lazy_static! { let context = llvm.context; let builder = &llvm.builder; - let function_context = generator.get_function_context(params.get(0).expect("Param 0 exists"))?; + let function_context = generator.get_function_context(params.first().expect("Param 0 exists"))?; let insert_block = builder.get_insert_block().expect("Builder should have a block at this point"); //Generate an access from the first param if let (&[k], params) = params.split_at(1) { //Create a temp var - let result_type = params.get(0) + let result_type = params.first() .ok_or_else(|| Diagnostic::codegen_error("Invalid signature for MUX", location)) .and_then(|it| generator.get_type_hint_info_for(it)) .and_then(|it| generator.llvm_index.get_associated_type(it.get_name()))?; @@ -642,7 +642,7 @@ fn annotate_comparison_function( ) }) .collect::>(); - let Some(new_statement) = comparisons.get(0) else { + let Some(new_statement) = comparisons.first() else { // no windows => less than 2 parameters, caught during validation return; }; @@ -688,7 +688,7 @@ fn annotate_arithmetic_function( let find_biggest_param_type_name = |annotator: &TypeAnnotator| { let mut bigger = annotator .annotation_map - .get_type_or_void(params_flattened.get(0).expect("must have this parameter"), annotator.index); + .get_type_or_void(params_flattened.first().expect("must have this parameter"), annotator.index); for param in params_flattened.iter().skip(1) { let right_type = annotator.annotation_map.get_type_or_void(param, annotator.index); @@ -702,7 +702,7 @@ fn annotate_arithmetic_function( // create nested AstStatement::BinaryExpression for each parameter, such that // ADD(a, b, c, d) ends up as (((a + b) + c) + d) - let left = (*params_flattened.get(0).expect("Must exist")).clone(); + let left = (*params_flattened.first().expect("Must exist")).clone(); let new_statement = params_flattened.into_iter().skip(1).fold(left, |left, right| { AstFactory::create_binary_expression(left, operation, right.clone(), ctx.id_provider.next_id()) }); @@ -722,7 +722,7 @@ fn annotate_variable_length_array_bound_function( return; }; let params = ast::flatten_expression_list(parameters); - let Some(vla) = params.get(0) else { + let Some(vla) = params.first() else { // caught during validation return; }; @@ -762,7 +762,7 @@ fn validate_variable_length_array_bound_function( )); } - match (params.get(0), params.get(1)) { + match (params.first(), params.get(1)) { (Some(vla), Some(idx)) => { let idx_type = annotations.get_type_or_void(idx, index); diff --git a/src/codegen/debug.rs b/src/codegen/debug.rs index defc8d1047..e4c2c2df34 100644 --- a/src/codegen/debug.rs +++ b/src/codegen/debug.rs @@ -411,6 +411,7 @@ impl<'ink> DebugBuilder<'ink> { inner_type.into(), size.bits().into(), alignment.bits(), + #[allow(clippy::single_range_in_vec_init)] &[(0..(length - 1))], ); self.register_concrete_type(name, DebugType::Composite(array_type)); diff --git a/src/codegen/generators/expression_generator.rs b/src/codegen/generators/expression_generator.rs index 6693b9705c..44f7b6bdac 100644 --- a/src/codegen/generators/expression_generator.rs +++ b/src/codegen/generators/expression_generator.rs @@ -2393,13 +2393,13 @@ impl<'ink, 'b> ExpressionCodeGenerator<'ink, 'b> { // relatively straightforward for single-dimensional arrays, but is quite costly (O(n²)) for multi-dimensional arrays let access_statements = access.get_as_list(); let accessor = if access_statements.len() == 1 { - let Some(stmt) = access_statements.get(0) else { + let Some(stmt) = access_statements.first() else { unreachable!("Must have exactly 1 access statement") }; let access_value = self.generate_expression(stmt).map_err(|_| ())?; // if start offset is not 0, adjust the access value accordingly - let Some(start_offset) = index_offsets.get(0).map(|(start, _)| *start) else { + let Some(start_offset) = index_offsets.first().map(|(start, _)| *start) else { unreachable!("VLA must have information about dimension offsets") }; self.create_llvm_int_binary_expression(&Operator::Minus, access_value, start_offset.into()) @@ -2581,7 +2581,7 @@ pub fn get_implicit_call_parameter<'a>( //TODO: use global context to get an expression slice Diagnostic::error("Expression is not assignable") .with_error_code("E050") - .with_location(param_statement.get_location()) + .with_location(param_statement.get_location()), ); }; let loc = declared_parameters diff --git a/src/codegen/generators/statement_generator.rs b/src/codegen/generators/statement_generator.rs index 6b0ed52bd5..b8adab2d88 100644 --- a/src/codegen/generators/statement_generator.rs +++ b/src/codegen/generators/statement_generator.rs @@ -323,7 +323,7 @@ impl<'a, 'b> StatementCodeGenerator<'a, 'b> { ) } else { //TODO: using the global context we could get a slice here - Err(Diagnostic::error(&format!("{element:?} not a direct access")) + Err(Diagnostic::error(format!("{element:?} not a direct access")) .with_error_code("E055") .with_location(element.get_location())) }?; diff --git a/src/index.rs b/src/index.rs index a64a5f2a72..5eb395d974 100644 --- a/src/index.rs +++ b/src/index.rs @@ -1115,13 +1115,10 @@ impl Index { segments .iter() .skip(1) - .fold(Some((segments[0], init)), |accum, current| match accum { - Some((_, Some(context))) => { - Some((*current, self.find_member(&context.data_type_name, current))) - } + .try_fold((segments[0], init), |accum, current| match accum { + (_, Some(context)) => Some((*current, self.find_member(&context.data_type_name, current))), // The variable could be in a block that has no global variable (Function block) - Some((name, None)) => Some((*current, self.find_member(name, current))), - None => Some((*current, self.find_global_variable(current))), + (name, None) => Some((*current, self.find_member(name, current))), }) .and_then(|(_, it)| it) } diff --git a/src/index/symbol.rs b/src/index/symbol.rs index 9591670332..e4558d5052 100644 --- a/src/index/symbol.rs +++ b/src/index/symbol.rs @@ -28,7 +28,7 @@ where where Q: Hash + Equivalent, { - self.get_all(key).and_then(|it| it.get(0)) + self.get_all(key).and_then(|it| it.first()) } /// returns all elements associated with the given key or None if diff --git a/src/index/tests/index_tests.rs b/src/index/tests/index_tests.rs index fdcdc3fa95..b9dc72dc62 100644 --- a/src/index/tests/index_tests.rs +++ b/src/index/tests/index_tests.rs @@ -1530,7 +1530,7 @@ fn pou_duplicates_are_indexed() { //THEN I expect both PouIndexEntries let pous = index.get_pous().values().filter(|it| it.get_name().eq("foo")).collect::>(); - let foo1 = pous.get(0).unwrap(); + let foo1 = pous.first().unwrap(); assert_eq!(foo1.get_name(), "foo"); let foo2 = pous.get(1).unwrap(); @@ -1566,7 +1566,7 @@ fn type_duplicates_are_indexed() { //THEN I expect all 3 DataTypes let types = index.get_types().values().filter(|it| it.get_name().eq("MyStruct")).collect::>(); - let mystruct1 = types.get(0).unwrap(); + let mystruct1 = types.first().unwrap(); assert_eq!(mystruct1.get_name(), "MyStruct"); let mystruct2 = types.get(1).unwrap(); @@ -1595,7 +1595,7 @@ fn global_variables_duplicates_are_indexed() { //THEN I expect both globals let globals = index.get_globals().values().filter(|it| it.get_name().eq("x")).collect::>(); - let x1 = globals.get(0).unwrap(); + let x1 = globals.first().unwrap(); assert_eq!(x1.get_name(), "x"); assert_eq!(x1.get_type_name(), "INT"); diff --git a/src/resolver.rs b/src/resolver.rs index 82fe52b63e..5e6e153d2b 100644 --- a/src/resolver.rs +++ b/src/resolver.rs @@ -1685,7 +1685,7 @@ impl<'i> TypeAnnotator<'i> { if let DataTypeInformation::Pointer { inner_type_name, .. } = &self .index .get_effective_type_or_void_by_name( - members.get(0).expect("internal VLA struct ALWAYS has this member").get_type_name(), + members.first().expect("internal VLA struct ALWAYS has this member").get_type_name(), ) .get_type_information() { diff --git a/src/resolver/const_evaluator.rs b/src/resolver/const_evaluator.rs index cfda5b1bcf..799f87b294 100644 --- a/src/resolver/const_evaluator.rs +++ b/src/resolver/const_evaluator.rs @@ -191,7 +191,7 @@ fn get_default_initializer( Some(AstFactory::create_literal(AstLiteral::new_integer(0), location.clone(), id)) } DataTypeInformation::Enum { name, elements, .. } => elements - .get(0) + .first() .and_then(|default_enum| index.find_enum_element(name, default_enum)) .and_then(|enum_element| enum_element.initial_value) .and_then(|initial_val| { diff --git a/src/validation/variable.rs b/src/validation/variable.rs index 080146d44b..97e3561d9a 100644 --- a/src/validation/variable.rs +++ b/src/validation/variable.rs @@ -56,11 +56,11 @@ pub fn visit_variable( /// - InOut within Function-Block fn validate_vla(validator: &mut Validator, pou: Option<&Pou>, block: &VariableBlock, variable: &Variable) { let Some(pou) = pou else { - if matches!(block.variable_block_type, VariableBlockType::Global) { - validator.push_diagnostic(Diagnostic::error("VLAs can not be defined as global variables") - .with_error_code("E044") - .with_location( variable.location.clone()) + validator.push_diagnostic( + Diagnostic::error("VLAs can not be defined as global variables") + .with_error_code("E044") + .with_location(variable.location.clone()), ) } diff --git a/tests/correctness/bitaccess.rs b/tests/correctness/bitaccess.rs index 25bb6c581f..1aa369c637 100644 --- a/tests/correctness/bitaccess.rs +++ b/tests/correctness/bitaccess.rs @@ -9,8 +9,8 @@ use pretty_assertions::assert_eq; struct MainType { variable: u64, access_var: i16, - bit_target: bool, - bit_target2: bool, + bit_target: u8, //bool + bit_target2: u8, //bool byte_target: u8, word_target: u16, dword_target: u32, @@ -125,11 +125,11 @@ fn bitaccess_test() { MainType { variable: 0xAB_CD_EF_12_34_56_78_90, access_var: 0, - bit_target: true, + bit_target: 1, + bit_target2: 85, //variable >> 32 >> 16 >> 8 >> 1 = 85 byte_target: 0xAB, word_target: 0xAB_CD, dword_target: 0xAB_CD_EF_12, - bit_target2: true, } ) } @@ -168,11 +168,11 @@ fn bitaccess_with_var_test() { MainType { variable: 0xAB_CD_EF_12_34_56_78_90, access_var: 1, - bit_target: true, + bit_target: 1, + bit_target2: 85, //variable >> 32 >> 16 >> 8 >> 1 = 85 byte_target: 0xAB, word_target: 0xAB_CD, dword_target: 0xAB_CD_EF_12, - bit_target2: true, } ) } From 4aa3aec4ff5a79d898a51b229f2a633ea96a4474 Mon Sep 17 00:00:00 2001 From: Volkan Date: Fri, 9 Feb 2024 07:58:23 +0100 Subject: [PATCH 31/33] fix(linker): Avoid filename clashes when linking (#1086) Append .o extension to end of file name instead of replacing previous extension --- compiler/plc_driver/src/pipelines.rs | 10 +++++----- tests/integration/data/linking/consts.dt | 0 tests/integration/data/linking/consts.st | 3 +++ tests/integration/linking.rs | 12 ++++++++++++ 4 files changed, 20 insertions(+), 5 deletions(-) create mode 100644 tests/integration/data/linking/consts.dt diff --git a/compiler/plc_driver/src/pipelines.rs b/compiler/plc_driver/src/pipelines.rs index fb4414192f..c1e9b40489 100644 --- a/compiler/plc_driver/src/pipelines.rs +++ b/compiler/plc_driver/src/pipelines.rs @@ -312,7 +312,7 @@ impl AnnotatedProject { let current_dir = env::current_dir()?; let current_dir = compile_options.root.as_deref().unwrap_or(¤t_dir); let unit_location = PathBuf::from(&unit.file_name); - let unit_location = std::fs::canonicalize(unit_location)?; + let unit_location = fs::canonicalize(unit_location)?; let output_name = if unit_location.starts_with(current_dir) { unit_location.strip_prefix(current_dir).map_err(|it| { Diagnostic::error(format!( @@ -329,9 +329,9 @@ impl AnnotatedProject { }; let output_name = match compile_options.output_format { - FormatOption::IR => output_name.with_extension("ll"), - FormatOption::Bitcode => output_name.with_extension("bc"), - _ => output_name.with_extension("o"), + FormatOption::IR => format!("{}.ll", output_name.to_string_lossy()), + FormatOption::Bitcode => format!("{}.bc", output_name.to_string_lossy()), + _ => format!("{}.o", output_name.to_string_lossy()), }; let context = CodegenContext::create(); //Create a build location for the generated object files @@ -340,7 +340,7 @@ impl AnnotatedProject { module .persist( Some(&compile_directory), - &output_name.to_string_lossy(), + &output_name, compile_options.output_format, target, compile_options.optimization, diff --git a/tests/integration/data/linking/consts.dt b/tests/integration/data/linking/consts.dt new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/integration/data/linking/consts.st b/tests/integration/data/linking/consts.st index 17e9c05522..d0e500449e 100644 --- a/tests/integration/data/linking/consts.st +++ b/tests/integration/data/linking/consts.st @@ -1,3 +1,6 @@ VAR_GLOBAL CONSTANT myValue : BOOL := TRUE; END_VAR + +FUNCTION main : DINT +END_FUNCTION diff --git a/tests/integration/linking.rs b/tests/integration/linking.rs index bd0d42fe6b..fd8e5cd3e4 100644 --- a/tests/integration/linking.rs +++ b/tests/integration/linking.rs @@ -225,3 +225,15 @@ fn link_files_with_same_name() { //Delete it fs::remove_file(&out1).unwrap(); } + +#[test] +fn link_files_with_same_name_but_different_extension() { + let file1 = get_test_file("linking/consts.st"); + let file2 = get_test_file("linking/consts.dt"); + + // We want to make sure that generating object files for two or more files with the same name but different + // extensions works. Previously this would fail because both `const.st` and `const.dt` would persist to a + // `const.o` file, which causes linking issues and more specifically "duplicate symbol" errors. Hence we only + // check whether the compilation resulted in some Ok value here. + assert!(compile(&["plc", file1.as_str(), file2.as_str(), "--target", TARGET.unwrap()]).is_ok()); +} From 2b0057894e64d1b26bdf09b5090a9f5232e72aae Mon Sep 17 00:00:00 2001 From: Volkan Date: Wed, 14 Feb 2024 10:31:41 +0100 Subject: [PATCH 32/33] fix(codegen): Don't fail if a const value can not be found (#1067) Hotfix for one of our internal projects; also mimics the behaviour of rusty before the AST reference refactor --- .../generators/expression_generator.rs | 17 +++++--- src/codegen/tests/code_gen_tests.rs | 40 +++++++++++++++++++ .../tests/codegen_error_messages_tests.rs | 9 ++--- ...gation_of_struct_fields_on_assignment.snap | 24 +++++++++++ ...ts__recursive_initial_constant_values.snap | 8 ++-- 5 files changed, 83 insertions(+), 15 deletions(-) create mode 100644 src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__constant_propagation_of_struct_fields_on_assignment.snap diff --git a/src/codegen/generators/expression_generator.rs b/src/codegen/generators/expression_generator.rs index 44f7b6bdac..fb89dd92fc 100644 --- a/src/codegen/generators/expression_generator.rs +++ b/src/codegen/generators/expression_generator.rs @@ -200,10 +200,15 @@ impl<'ink, 'b> ExpressionCodeGenerator<'ink, 'b> { }) = self.annotations.get(expression) { if !self.index.get_type_information_or_void(resulting_type).is_aggregate() { - // constant propagation - return self.generate_constant_expression(qualified_name, expression); + match self.generate_constant_expression(qualified_name, expression) { + // We return here if constant propagation worked + Ok(expr) => return Ok(expr), + // ...and fall-back to generating the expression further down if it didn't + Err(why) => log::info!("{why}"), + } } } + // generate the expression match expression.get_stmt() { AstStatement::ReferenceExpr(data) => { @@ -266,10 +271,10 @@ impl<'ink, 'b> ExpressionCodeGenerator<'ink, 'b> { self.index.get_const_expressions().get_resolved_constant_statement(&constant_variable) }) .ok_or_else(|| { - Diagnostic::codegen_error( - format!("Cannot propagate constant value for '{qualified_name:}'").as_str(), - expression.get_location(), - ) + // We'll _probably_ land here because we're dealing with aggregate types, see also + // https://github.com/PLC-lang/rusty/issues/288 + let message = format!("Cannot propagate constant value for '{qualified_name:}'"); + Diagnostic::codegen_error(message, expression.get_location()) })?; // generate the resulting constant-expression (which should be a Value, no ptr-reference) diff --git a/src/codegen/tests/code_gen_tests.rs b/src/codegen/tests/code_gen_tests.rs index c33f22b07d..76572cc1f5 100644 --- a/src/codegen/tests/code_gen_tests.rs +++ b/src/codegen/tests/code_gen_tests.rs @@ -3004,6 +3004,46 @@ fn constant_expression_in_function_blocks_are_propagated() { insta::assert_snapshot!(result); } +#[test] +fn constant_propagation_of_struct_fields_on_assignment() { + let result = codegen( + " + TYPE STRUCT1 : STRUCT + value : DINT; + END_STRUCT END_TYPE + + VAR_GLOBAL CONSTANT + MyStruct : STRUCT1 := (value := 99); + END_VAR + + FUNCTION main : DINT + VAR + local_value : DINT; + END_VAR + + local_value := MyStruct.value; + END_FUNCTION + ", + ); + + // The snapshot of the given IR is currently not 100% correct because `MyStruct.value` isn't + // constant-propagated and instead the value requires a `load` instruction. The underlying issue + // is due to getting a qualified name of `STRUCT1.value` instead of `MyStruct.value` in `generate_expression_value` + // and `generate_constant_expression`. + // + // TL;DR: If this IR changes from + // ``` + // %load_value = load i32, i32* getelementptr inbounds (%STRUCT1, %STRUCT1* @MyStruct, i32 0, i32 0), align 4␊ + // store i32 %load_value, i32* %local_value, align 4␊ + // ``` + // to something along + // ``` + // store i32 %load_value, 99, ... + // ``` + // then you've probably fixed https://github.com/PLC-lang/rusty/issues/288 + insta::assert_snapshot!(result); +} + #[test] fn date_and_time_addition_in_var_output() { //GIVEN a date and time and a time addition on output variables diff --git a/src/codegen/tests/codegen_error_messages_tests.rs b/src/codegen/tests/codegen_error_messages_tests.rs index 39b6395e77..800146ceb7 100644 --- a/src/codegen/tests/codegen_error_messages_tests.rs +++ b/src/codegen/tests/codegen_error_messages_tests.rs @@ -212,13 +212,10 @@ fn recursive_initial_constant_values() { b : INT := a; END_VAR "#, - ); + ) + .unwrap_err(); - if let Err(msg) = result { - assert_snapshot!(msg) - } else { - panic!("expected code-gen error but got none") - } + assert_snapshot!(result) } #[test] diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__constant_propagation_of_struct_fields_on_assignment.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__constant_propagation_of_struct_fields_on_assignment.snap new file mode 100644 index 0000000000..775c8c3201 --- /dev/null +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__constant_propagation_of_struct_fields_on_assignment.snap @@ -0,0 +1,24 @@ +--- +source: src/codegen/tests/code_gen_tests.rs +expression: result +--- +; ModuleID = 'main' +source_filename = "main" + +%STRUCT1 = type { i32 } + +@MyStruct = unnamed_addr constant %STRUCT1 { i32 99 } +@__STRUCT1__init = unnamed_addr constant %STRUCT1 zeroinitializer + +define i32 @main() { +entry: + %main = alloca i32, align 4 + %local_value = alloca i32, align 4 + store i32 0, i32* %local_value, align 4 + store i32 0, i32* %main, align 4 + %load_value = load i32, i32* getelementptr inbounds (%STRUCT1, %STRUCT1* @MyStruct, i32 0, i32 0), align 4 + store i32 %load_value, i32* %local_value, align 4 + %main_ret = load i32, i32* %main, align 4 + ret i32 %main_ret +} + diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__codegen_error_messages_tests__recursive_initial_constant_values.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__codegen_error_messages_tests__recursive_initial_constant_values.snap index f4a4856dec..4a488876e5 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__codegen_error_messages_tests__recursive_initial_constant_values.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__codegen_error_messages_tests__recursive_initial_constant_values.snap @@ -1,11 +1,13 @@ --- source: src/codegen/tests/codegen_error_messages_tests.rs -expression: msg +expression: result --- -error: Cannot propagate constant value for 'b' +error: Cannot generate literal initializer for `a`. + +error: Could not resolve reference to b ┌─ :3:24 │ 3 │ a : INT := b; - │ ^ Cannot propagate constant value for 'b' + │ ^ Could not resolve reference to b From f58a57f9782e9c19f5e7cb9303058bdfbc73b86c Mon Sep 17 00:00:00 2001 From: Ghaith Hachem Date: Wed, 21 Feb 2024 10:25:45 +0100 Subject: [PATCH 33/33] fix: linking and Include folders now work again (#1102) * fix: library paths are not passed to the linker With the driver/pipeline refactor we didn't pass the correct paths to the linker, we now pass them correctly. * Fix relative paths --- book/src/using_rusty.md | 4 +- compiler/plc_driver/src/lib.rs | 157 ++++++++++++++++----------- compiler/plc_driver/src/pipelines.rs | 73 ++++++++----- compiler/plc_driver/src/runner.rs | 2 +- compiler/plc_driver/src/tests.rs | 2 +- compiler/plc_project/src/project.rs | 20 +++- compiler/plc_source/src/lib.rs | 4 +- src/linker.rs | 149 +++++++++++++++++-------- tests/integration/data/linking/lib.o | 1 + tests/integration/linking.rs | 27 ++++- 10 files changed, 291 insertions(+), 148 deletions(-) create mode 100644 tests/integration/data/linking/lib.o diff --git a/book/src/using_rusty.md b/book/src/using_rusty.md index 7ea9ca0b9a..a744508225 100644 --- a/book/src/using_rusty.md +++ b/book/src/using_rusty.md @@ -83,8 +83,8 @@ plc hello_world.st -o hello_world --linker=cc Please note that RuSTy will attempt to link the generated object file by default to generate an executable if you didn't specify something else (option `-c`). - The `--linker=cc` flag tells RuSTy that it should link with the system's compiler driver instead of the built in linker. This provides support to create executables. -- Additional libraries can be linked using the `-l` flag, additial library pathes can be added with `-L` -- You add library search pathes by providing additional `-L /path/...` options. By default, this will be the current directory. +- Additional libraries can be linked using the `-l` flag, additional library paths can be added with `-L` +- You add library search paths by providing additional `-L /path/...` options. By default, this will be the current directory. - The linker will prefer a dynamically linked library if available, and revert to a static one otherwise. ### Building for separate targets diff --git a/compiler/plc_driver/src/lib.rs b/compiler/plc_driver/src/lib.rs index 9bae1b56a6..25f0fc4d6c 100644 --- a/compiler/plc_driver/src/lib.rs +++ b/compiler/plc_driver/src/lib.rs @@ -19,7 +19,8 @@ use std::{ use cli::{CompileParameters, ParameterError}; use pipelines::AnnotatedProject; use plc::{ - codegen::CodegenContext, output::FormatOption, DebugLevel, ErrorFormat, OptimizationLevel, Threads, + codegen::CodegenContext, linker::LinkerType, output::FormatOption, DebugLevel, ErrorFormat, + OptimizationLevel, Target, Threads, }; use plc_diagnostics::{diagnostician::Diagnostician, diagnostics::Diagnostic}; @@ -52,6 +53,7 @@ pub struct CompileOptions { pub optimization: OptimizationLevel, pub error_format: ErrorFormat, pub debug_level: DebugLevel, + pub single_module: bool, } impl Default for CompileOptions { @@ -64,6 +66,7 @@ impl Default for CompileOptions { optimization: OptimizationLevel::None, error_format: ErrorFormat::None, debug_level: DebugLevel::None, + single_module: false, } } } @@ -71,9 +74,10 @@ impl Default for CompileOptions { #[derive(Clone, Default, Debug)] pub struct LinkOptions { pub libraries: Vec, - pub library_pathes: Vec, + pub library_paths: Vec, pub format: FormatOption, - pub linker: Option, + pub linker: LinkerType, + pub lib_location: Option, } #[derive(Debug)] @@ -119,12 +123,19 @@ impl Display for CompileError { } } -pub fn compile + AsRef + Debug>(args: &[T]) -> Result<()> { - //Parse the arguments +pub struct CompilationContext { + pub compile_parameters: CompileParameters, + pub project: Project, + pub diagnostician: Diagnostician, + pub compile_options: CompileOptions, + pub link_options: LinkOptions, +} + +pub fn get_compilation_context + AsRef + Debug>( + args: &[T], +) -> Result { let compile_parameters = CompileParameters::parse(args)?; - if let Some((options, format)) = compile_parameters.get_config_options() { - return print_config_options(options, format); - } + //Create the project that will be compiled let project = get_project(&compile_parameters)?; let output_format = compile_parameters.output_format().unwrap_or_else(|| project.get_output_format()); let location = project.get_location().map(|it| it.to_path_buf()); @@ -142,12 +153,52 @@ pub fn compile + AsRef + Debug>(args: &[T]) -> Result<()> { log::debug!("LIB_LOCATION={}", location.to_string_lossy()); env::set_var("LIB_LOCATION", location); } - let mut diagnostician = match compile_parameters.error_format { + let diagnostician = match compile_parameters.error_format { ErrorFormat::Rich => Diagnostician::default(), ErrorFormat::Clang => Diagnostician::clang_format_diagnostician(), ErrorFormat::None => Diagnostician::null_diagnostician(), }; + let compile_options = CompileOptions { + root: location, + build_location: compile_parameters.get_build_location(), + output: project.get_output_name(), + output_format, + optimization: compile_parameters.optimization, + error_format: compile_parameters.error_format, + debug_level: compile_parameters.debug_level(), + single_module: compile_parameters.single_module, + }; + + let libraries = + project.get_libraries().iter().map(LibraryInformation::get_link_name).map(str::to_string).collect(); + let mut library_paths: Vec = project + .get_libraries() + .iter() + .filter_map(LibraryInformation::get_path) + .map(Path::to_path_buf) + .collect(); + + library_paths.extend_from_slice(project.get_library_paths()); + + let link_options = LinkOptions { + libraries, + library_paths, + format: output_format, + linker: compile_parameters.linker.as_deref().into(), + lib_location, + }; + + Ok(CompilationContext { compile_parameters, project, diagnostician, compile_options, link_options }) +} + +pub fn compile_with_options(compile_options: CompilationContext) -> Result<()> { + let CompilationContext { compile_parameters, project, mut diagnostician, compile_options, link_options } = + compile_options; + if let Some((options, format)) = compile_parameters.get_config_options() { + return print_config_options(options, format); + } + //Set the global thread count let thread_pool = rayon::ThreadPoolBuilder::new(); let global_pool = if let Some(Threads::Fix(threads)) = compile_parameters.threads { @@ -178,25 +229,23 @@ pub fn compile + AsRef + Debug>(args: &[T]) -> Result<()> { )?; // 1 : Parse, 2. Index and 3. Resolve / Annotate - let annotated_project = pipelines::ParsedProject::parse(&ctxt, &project, &mut diagnostician)? + let annotated_project = pipelines::ParsedProject::parse(&ctxt, project, &mut diagnostician)? .index(ctxt.provider()) .annotate(ctxt.provider()); // 4 : Validate annotated_project.validate(&ctxt, &mut diagnostician)?; + if let Some((location, format)) = + compile_parameters.hardware_config.as_ref().zip(compile_parameters.config_format()) + { + annotated_project.generate_hardware_information(format, location)?; + } + // 5 : Codegen if !compile_parameters.is_check() { - let res = generate( - location, - compile_parameters, - project, - output_format, - annotated_project, - build_location, - lib_location, - ) - .map_err(|err| Diagnostic::codegen_error(err.get_message(), err.get_location())); + let res = generate(&compile_options, &link_options, compile_parameters.target, annotated_project) + .map_err(|err| Diagnostic::codegen_error(err.get_message(), err.get_location())); if let Err(res) = res { diagnostician.handle(&[res]); return Err(Diagnostic::error("Compilation aborted due to previous errors") @@ -204,10 +253,15 @@ pub fn compile + AsRef + Debug>(args: &[T]) -> Result<()> { .into()); } } - Ok(()) } +pub fn compile + AsRef + Debug>(args: &[T]) -> Result<()> { + //Parse the arguments + let compile_context = get_compilation_context(args)?; + compile_with_options(compile_context) +} + fn print_config_options( option: cli::ConfigOption, _format: plc::ConfigFormat, @@ -226,12 +280,12 @@ fn print_config_options( pub fn parse_and_annotate( name: &str, src: Vec, -) -> Result<(GlobalContext, AnnotatedProject), Diagnostic> { +) -> Result<(GlobalContext, AnnotatedProject), Diagnostic> { // Parse the source to ast let project = Project::new(name.to_string()).with_sources(src); let ctxt = GlobalContext::new().with_source(project.get_sources(), None)?; let mut diagnostician = Diagnostician::default(); - let parsed = pipelines::ParsedProject::parse(&ctxt, &project, &mut diagnostician)?; + let parsed = pipelines::ParsedProject::parse(&ctxt, project, &mut diagnostician)?; // Create an index, add builtins then resolve let provider = ctxt.provider(); @@ -271,61 +325,31 @@ fn generate_to_string_internal( } fn generate( - location: Option, - compile_parameters: CompileParameters, - project: Project, - output_format: FormatOption, - annotated_project: AnnotatedProject, - build_location: Option, - lib_location: Option, + compile_options: &CompileOptions, + linker_options: &LinkOptions, + targets: Vec, + annotated_project: AnnotatedProject, ) -> Result<(), Diagnostic> { - let compile_options = CompileOptions { - root: location, - build_location: compile_parameters.get_build_location(), - output: project.get_output_name(), - output_format, - optimization: compile_parameters.optimization, - error_format: compile_parameters.error_format, - debug_level: compile_parameters.debug_level(), - }; - let res = if compile_parameters.single_module { + let res = if compile_options.single_module { log::info!("Using single module mode"); - annotated_project.codegen_single_module(compile_options, &compile_parameters.target)? + annotated_project.codegen_single_module(compile_options, &targets)? } else { - annotated_project.codegen(compile_options, &compile_parameters.target)? - }; - let libraries = - project.get_libraries().iter().map(LibraryInformation::get_link_name).map(str::to_string).collect(); - let library_pathes = project - .get_libraries() - .iter() - .filter_map(LibraryInformation::get_path) - .map(Path::to_path_buf) - .collect(); - let linker_options = LinkOptions { - libraries, - library_pathes, - format: output_format, - linker: compile_parameters.linker.to_owned(), + annotated_project.codegen(compile_options, &targets)? }; + let project = annotated_project.get_project(); let output_name = project.get_output_name(); res.into_par_iter() .map(|res| { res.link( project.get_objects(), - build_location.as_deref(), - lib_location.as_deref(), + compile_options.build_location.as_deref(), + linker_options.lib_location.as_deref(), &output_name, linker_options.clone(), ) }) .collect::, _>>()?; - if let Some((location, format)) = - compile_parameters.hardware_config.as_ref().zip(compile_parameters.config_format()) - { - annotated_project.generate_hardware_information(format, location)?; - } - if let Some(lib_location) = lib_location { + if let Some(lib_location) = &linker_options.lib_location { for library in project.get_libraries().iter().filter(|it| it.should_copy()).map(|it| it.get_compiled_lib()) { @@ -370,8 +394,9 @@ fn get_project(compile_parameters: &CompileParameters) -> Result); +pub struct ParsedProject { + project: Project, + units: Vec, +} -impl ParsedProject { +impl ParsedProject { /// Parses a giving project, transforming it to a `ParsedProject` /// Reports parsing diagnostics such as Syntax error on the fly - pub fn parse( + pub fn parse( ctxt: &GlobalContext, - project: &Project, + project: Project, diagnostician: &mut Diagnostician, ) -> Result { //TODO in parallel @@ -88,13 +91,13 @@ impl ParsedProject { .collect::, Diagnostic>>()?; units.extend(lib_includes); - Ok(ParsedProject(units)) + Ok(ParsedProject { project, units }) } /// Creates an index out of a pased project. The index could then be used to query datatypes - pub fn index(self, id_provider: IdProvider) -> IndexedProject { + pub fn index(self, id_provider: IdProvider) -> IndexedProject { let indexed_units = self - .0 + .units .into_par_iter() .map(|mut unit| { //Preprocess @@ -121,20 +124,24 @@ impl ParsedProject { let builtins = plc::builtins::parse_built_ins(id_provider); global_index.import(plc::index::visitor::visit(&builtins)); - IndexedProject { units, index: global_index } + IndexedProject { project: ParsedProject { project: self.project, units }, index: global_index } + } + + pub fn get_project(&self) -> &Project { + &self.project } } ///A project that has also been indexed -/// Units inside an index project could be resolved and annotated -pub struct IndexedProject { - units: Vec, +/// Units inside an index project are ready be resolved and annotated +pub struct IndexedProject { + project: ParsedProject, index: Index, } -impl IndexedProject { +impl IndexedProject { /// Creates annotations on the project in order to facilitate codegen and validation - pub fn annotate(self, mut id_provider: IdProvider) -> AnnotatedProject { + pub fn annotate(self, mut id_provider: IdProvider) -> AnnotatedProject { //Resolve constants //TODO: Not sure what we are currently doing with unresolvables let (mut full_index, _unresolvables) = plc::resolver::const_evaluator::evaluate_constants(self.index); @@ -143,6 +150,7 @@ impl IndexedProject { let mut all_annotations = AnnotationMapImpl::default(); let result = self + .project .units .into_par_iter() .map(|unit| { @@ -161,18 +169,35 @@ impl IndexedProject { let annotations = AstAnnotations::new(all_annotations, id_provider.next_id()); - AnnotatedProject { units: annotated_units, index: full_index, annotations } + AnnotatedProject { + project: self.project.project, + units: annotated_units, + index: full_index, + annotations, + } + } + + fn get_parsed_project(&self) -> &ParsedProject { + &self.project + } + + pub fn get_project(&self) -> &Project { + self.get_parsed_project().get_project() } } /// A project that has been annotated with information about different types and used units -pub struct AnnotatedProject { +pub struct AnnotatedProject { + pub project: Project, pub units: Vec<(CompilationUnit, IndexSet, StringLiterals)>, pub index: Index, pub annotations: AstAnnotations, } -impl AnnotatedProject { +impl AnnotatedProject { + pub fn get_project(&self) -> &Project { + &self.project + } /// Validates the project, reports any new diagnostics on the fly pub fn validate( &self, @@ -262,7 +287,7 @@ impl AnnotatedProject { pub fn codegen_single_module<'ctx>( &'ctx self, - compile_options: CompileOptions, + compile_options: &CompileOptions, targets: &'ctx [Target], ) -> Result, Diagnostic> { let compile_directory = compile_options.build_location.clone().unwrap_or_else(|| { @@ -272,7 +297,7 @@ impl AnnotatedProject { ensure_compile_dirs(targets, &compile_directory)?; let context = CodegenContext::create(); //Create a build location for the generated object files let targets = if targets.is_empty() { &[Target::System] } else { targets }; - let module = self.generate_single_module(&context, &compile_options)?.unwrap(); + let module = self.generate_single_module(&context, compile_options)?.unwrap(); let mut result = vec![]; for target in targets { let obj: Object = module @@ -293,7 +318,7 @@ impl AnnotatedProject { pub fn codegen<'ctx>( &'ctx self, - compile_options: CompileOptions, + compile_options: &CompileOptions, targets: &'ctx [Target], ) -> Result, Diagnostic> { let compile_directory = compile_options.build_location.clone().unwrap_or_else(|| { @@ -336,7 +361,7 @@ impl AnnotatedProject { let context = CodegenContext::create(); //Create a build location for the generated object files let module = - self.generate_module(&context, &compile_options, unit, dependencies, literals)?; + self.generate_module(&context, compile_options, unit, dependencies, literals)?; module .persist( Some(&compile_directory), @@ -451,17 +476,15 @@ impl GeneratedProject { _ => { // Only initialize a linker if we need to use it let target_triple = self.target.get_target_triple(); - let mut linker = plc::linker::Linker::new( - &target_triple.as_str().to_string_lossy(), - link_options.linker.as_deref(), - )?; + let mut linker = + plc::linker::Linker::new(&target_triple.as_str().to_string_lossy(), link_options.linker)?; for obj in &self.objects { linker.add_obj(&obj.get_path().to_string_lossy()); } for obj in objects { linker.add_obj(&obj.get_path().to_string_lossy()); } - for lib_path in &link_options.library_pathes { + for lib_path in &link_options.library_paths { linker.add_lib_path(&lib_path.to_string_lossy()); } for lib in &link_options.libraries { diff --git a/compiler/plc_driver/src/runner.rs b/compiler/plc_driver/src/runner.rs index f0710c2c21..b3ceb89f7c 100644 --- a/compiler/plc_driver/src/runner.rs +++ b/compiler/plc_driver/src/runner.rs @@ -28,7 +28,7 @@ pub fn compile(context: &CodegenContext, source: T) -> GeneratedM let project = Project::new("TestProject".to_string()).with_sources(source); let ctxt = GlobalContext::new().with_source(project.get_sources(), None).unwrap(); let mut diagnostician = Diagnostician::null_diagnostician(); - let parsed_project = ParsedProject::parse(&ctxt, &project, &mut diagnostician).unwrap(); + let parsed_project = ParsedProject::parse(&ctxt, project, &mut diagnostician).unwrap(); let indexed_project = parsed_project.index(ctxt.provider()); let annotated_project = indexed_project.annotate(ctxt.provider()); let compile_options = CompileOptions { diff --git a/compiler/plc_driver/src/tests.rs b/compiler/plc_driver/src/tests.rs index 58bc54949f..222bd33d0e 100644 --- a/compiler/plc_driver/src/tests.rs +++ b/compiler/plc_driver/src/tests.rs @@ -48,7 +48,7 @@ where optimization: plc::OptimizationLevel::None, ..Default::default() }; - pipelines::ParsedProject::parse(&ctxt, &project, &mut diagnostician)? + pipelines::ParsedProject::parse(&ctxt, project, &mut diagnostician)? //Index .index(ctxt.provider()) //Resolve diff --git a/compiler/plc_project/src/project.rs b/compiler/plc_project/src/project.rs index 4a24c73a93..e40ae98d9f 100644 --- a/compiler/plc_project/src/project.rs +++ b/compiler/plc_project/src/project.rs @@ -77,6 +77,8 @@ pub struct Project { objects: Vec, /// Libraries included in the project configuration libraries: Vec>, + /// Additional library paths to consider + library_paths: Vec, /// Output format format: FormatOption, /// Output Name @@ -169,10 +171,11 @@ impl Project { output: project_config.output, includes: vec![], objects: vec![], + library_paths: vec![], }) } - pub fn with_file_pathes(self, files: Vec) -> Self { + pub fn with_file_paths(self, files: Vec) -> Self { let mut proj = self; let files = resolve_file_paths(proj.get_location(), files).unwrap(); for file in files { @@ -186,12 +189,18 @@ impl Project { proj } - pub fn with_include_pathes(self, files: Vec) -> Self { + pub fn with_include_paths(self, files: Vec) -> Self { let mut proj = self; proj.includes = resolve_file_paths(proj.get_location(), files).unwrap(); proj } + pub fn with_library_paths(self, paths: Vec) -> Self { + let mut proj = self; + proj.library_paths.extend(resolve_file_paths(proj.get_location(), paths).unwrap()); + proj + } + pub fn with_format(self, format: FormatOption) -> Self { let mut proj = self; proj.format = format; @@ -203,6 +212,10 @@ impl Project { proj.output = output.or(proj.output); proj } + + pub fn get_library_paths(&self) -> &[PathBuf] { + &self.library_paths + } } impl Project { @@ -214,6 +227,7 @@ impl Project { includes: vec![], objects: vec![], libraries: vec![], + library_paths: vec![], format: FormatOption::default(), output: None, } @@ -285,6 +299,8 @@ impl Project { fn resolve_file_paths(location: Option<&Path>, inputs: Vec) -> Result> { let mut sources = Vec::new(); + //Ensure we are working with a directory + let location = location.and_then(|it| if it.is_file() { it.parent() } else { Some(it) }); for input in &inputs { let input = location.map(|it| it.join(input)).unwrap_or(input.to_path_buf()); let path = &input.to_string_lossy(); diff --git a/compiler/plc_source/src/lib.rs b/compiler/plc_source/src/lib.rs index 936c757111..cb7fba1c3e 100644 --- a/compiler/plc_source/src/lib.rs +++ b/compiler/plc_source/src/lib.rs @@ -23,7 +23,7 @@ pub enum SourceType { /// SourceContainers offer source-code to be compiled via the load_source function. /// Furthermore it offers a location-String used when reporting diagnostics. -pub trait SourceContainer { +pub trait SourceContainer: Sync { /// loads and returns the SourceEntry that contains the SourceCode and the path it was loaded from fn load_source(&self, encoding: Option<&'static Encoding>) -> Result; /// returns the location of this source-container. Used when reporting diagnostics. @@ -88,7 +88,7 @@ impl SourceCodeFactory for &str { } } -impl> SourceContainer for T { +impl + Sync> SourceContainer for T { fn load_source(&self, encoding: Option<&'static Encoding>) -> Result { let source_type = self.get_type(); if matches!(source_type, SourceType::Text | SourceType::Xml) { diff --git a/src/linker.rs b/src/linker.rs index 4ece1cf0de..26d1aa661f 100644 --- a/src/linker.rs +++ b/src/linker.rs @@ -10,21 +10,38 @@ use std::{ process::Command, }; +use std::sync::{Arc, Mutex}; + pub struct Linker { errors: Vec, linker: Box, } +#[derive(Clone, Default, Debug)] +pub enum LinkerType { + #[default] + Internal, + External(String), + Test(MockLinker), +} + +impl From> for LinkerType { + fn from(value: Option<&str>) -> Self { + match value { + None => LinkerType::Internal, + Some(linker) => LinkerType::External(linker.to_string()), + } + } +} + impl Linker { - pub fn new(target: &str, linker: Option<&str>) -> Result { + pub fn new(target: &str, linker: LinkerType) -> Result { Ok(Linker { errors: Vec::default(), linker: match linker { - Some(linker) => Box::new(CcLinker::new(linker)), - // TODO: Linker for Windows is missing, see also: // https://github.com/PLC-lang/rusty/pull/702/files#r1052446296 - None => { + LinkerType::Internal => { let [platform, target_os] = target.split('-').collect::>()[1..=2] else { return Err(LinkerError::Target(target.into())); }; @@ -38,6 +55,8 @@ impl Linker { _ => Box::new(LdLinker::new()), } } + LinkerType::External(linker) => Box::new(CcLinker::new(&linker)), + LinkerType::Test(linker) => Box::new(linker), }, }) } @@ -115,15 +134,21 @@ impl CcLinker { } impl LinkerInterface for CcLinker { - fn args(&mut self) -> &mut Vec { - &mut self.args + fn add_arg(&mut self, value: String) { + self.args.push(value) + } + + fn get_build_command(&self) -> Result { + let linker_location = which(&self.linker) + .map_err(|e| LinkerError::Link(format!("{e} for linker: {}", &self.linker)))?; + Ok(format!("{} {}", linker_location.to_string_lossy(), self.args.join(" "))) } fn finalize(&mut self) -> Result<(), LinkerError> { let linker_location = which(&self.linker) .map_err(|e| LinkerError::Link(format!("{e} for linker: {}", &self.linker)))?; - log::debug!("Linker command : {} {}", linker_location.to_string_lossy(), self.args.join(" ")); + log::debug!("Linker command : {}", self.get_build_command()?); let status = Command::new(linker_location).args(&self.args).status()?; if status.success() { @@ -145,51 +170,76 @@ impl LdLinker { } impl LinkerInterface for LdLinker { - fn args(&mut self) -> &mut Vec { - &mut self.args + fn add_arg(&mut self, value: String) { + self.args.push(value) + } + + fn get_build_command(&self) -> Result { + Ok(format!("ld.lld {}", self.args.join(" "))) } fn finalize(&mut self) -> Result<(), LinkerError> { - log::debug!("Linker arguments : {}", self.args.join(" ")); + log::debug!("Linker arguments : {}", self.get_build_command()?); lld_rs::link(lld_rs::LldFlavor::Elf, &self.args).ok().map_err(LinkerError::Link) } } +#[derive(Clone, Debug)] +pub struct MockLinker { + pub args: Arc>>, +} + +impl LinkerInterface for MockLinker { + fn add_arg(&mut self, value: String) { + self.args.lock().unwrap().push(value) + } + + fn get_build_command(&self) -> Result { + Ok(format!("ld.lld {}", self.args.lock()?.join(" "))) + } + + fn finalize(&mut self) -> Result<(), LinkerError> { + println!("Test Executing build command {}", self.get_build_command()?); + Ok(()) + } +} + trait LinkerInterface { - fn args(&mut self) -> &mut Vec; + fn add_arg(&mut self, value: String); + fn get_build_command(&self) -> Result; fn finalize(&mut self) -> Result<(), LinkerError>; fn add_obj(&mut self, path: &str) { - self.args().push(path.into()); + self.add_arg(path.into()); } fn add_lib_path(&mut self, path: &str) { - self.args().push(format!("-L{path}")); + self.add_arg(format!("-L{path}")); } fn add_lib(&mut self, path: &str) { - self.args().push(format!("-l{path}")); + self.add_arg(format!("-l{path}")); } fn add_sysroot(&mut self, path: &str) { - self.args().push(format!("--sysroot={path}")); + self.add_arg(format!("--sysroot={path}")); } fn build_shared_object(&mut self, path: &str) { - self.args().push("--shared".into()); - self.args().push("-o".into()); - self.args().push(path.into()); + self.add_arg("--shared".into()); + self.add_arg("-o".into()); + self.add_arg(path.into()); } fn build_exectuable(&mut self, path: &str) { - self.args().push("-o".into()); - self.args().push(path.into()); + self.add_arg("-o".into()); + self.add_arg(path.into()); } fn build_relocatable(&mut self, path: &str) { - self.args().push("-r".into()); // equivalent to --relocatable - self.args().push("-o".into()); - self.args().push(path.into()); + self.add_arg("-r".into()); // equivalent to --relocatable + self.add_arg("-o".into()); + self.add_arg(path.into()); } } @@ -230,31 +280,36 @@ impl From for LinkerError { } } -#[test] -fn windows_target_triple_should_result_in_error() { - for target in &[ - "x86_64-pc-windows-gnu", - "x86_64-pc-win32-gnu", - "x86_64-windows-gnu", - "x86_64-win32-gnu", - "aarch64-pc-windows-gnu", - "aarch64-pc-win32-gnu", - "aarch64-windows-gnu", - "aarch64-win32-gnu", - "i686-pc-windows-gnu", - "i686-pc-win32-gnu", - "i686-windows-gnu", - "i686-win32-gnu", - ] { - assert!(Linker::new(target, None).is_err()); +#[cfg(test)] +mod test { + use crate::linker::{Linker, LinkerType}; + + #[test] + fn windows_target_triple_should_result_in_error() { + for target in &[ + "x86_64-pc-windows-gnu", + "x86_64-pc-win32-gnu", + "x86_64-windows-gnu", + "x86_64-win32-gnu", + "aarch64-pc-windows-gnu", + "aarch64-pc-win32-gnu", + "aarch64-windows-gnu", + "aarch64-win32-gnu", + "i686-pc-windows-gnu", + "i686-pc-win32-gnu", + "i686-windows-gnu", + "i686-win32-gnu", + ] { + assert!(Linker::new(target, LinkerType::Internal).is_err()); + } } -} -#[test] -fn non_windows_target_triple_should_result_in_ok() { - for target in - &["x86_64-linux-gnu", "x86_64-pc-linux-gnu", "x86_64-unknown-linux-gnu", "aarch64-apple-darwin"] - { - assert!(Linker::new(target, None).is_ok()); + #[test] + fn non_windows_target_triple_should_result_in_ok() { + for target in + &["x86_64-linux-gnu", "x86_64-pc-linux-gnu", "x86_64-unknown-linux-gnu", "aarch64-apple-darwin"] + { + assert!(Linker::new(target, LinkerType::Internal).is_ok()); + } } } diff --git a/tests/integration/data/linking/lib.o b/tests/integration/data/linking/lib.o new file mode 100644 index 0000000000..3959f7bc5d --- /dev/null +++ b/tests/integration/data/linking/lib.o @@ -0,0 +1 @@ +THIS FILE JUST HAS THE .O extenstion to be used in the test, do not delete diff --git a/tests/integration/linking.rs b/tests/integration/linking.rs index fd8e5cd3e4..7e08fc301b 100644 --- a/tests/integration/linking.rs +++ b/tests/integration/linking.rs @@ -1,7 +1,12 @@ -use std::{env, fs}; +use std::{ + env::{self, current_dir}, + fs, + sync::{Arc, Mutex}, +}; use crate::get_test_file; -use driver::compile; +use driver::{compile, compile_with_options, get_compilation_context}; +use rusty::linker::{LinkerType, MockLinker}; static TARGET: Option<&str> = Some("x86_64-linux-gnu"); @@ -237,3 +242,21 @@ fn link_files_with_same_name_but_different_extension() { // check whether the compilation resulted in some Ok value here. assert!(compile(&["plc", file1.as_str(), file2.as_str(), "--target", TARGET.unwrap()]).is_ok()); } + +#[test] +fn link_with_library_path() { + let file1 = get_test_file("linking/lib.o"); + let dir = current_dir().unwrap(); + + let mut compile_context = + get_compilation_context(&["plc", file1.as_str(), "-ltest", "-L", &dir.to_string_lossy()]).unwrap(); + //Change the linker + let vec: Vec = vec![]; + let vec = Arc::new(Mutex::new(vec)); + let test_linker = MockLinker { args: vec.clone() }; + compile_context.link_options.linker = LinkerType::Test(test_linker); + compile_with_options(compile_context).unwrap(); + assert!(vec.lock().unwrap().as_slice().contains(&"-L.".to_string())); + assert!(vec.lock().unwrap().contains(&"-ltest".to_string())); + assert!(vec.lock().unwrap().contains(&format!("-L{}", dir.to_string_lossy()))); +}