forked from PLC-lang/rusty
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(validation): Don't suggest brackets for call statements when deal…
…ing with arrays (PLC-lang#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.
- Loading branch information
Showing
6 changed files
with
106 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
...hots/rusty__validation__tests__array_validation_test__array_assignment_function_call.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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' | ||
┌─ <internal>: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 | ||
┌─ <internal>: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 | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters