-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix const variable reassign reporting bug (#703)
- Loading branch information
1 parent
70ef9af
commit ea8a6cc
Showing
7 changed files
with
140 additions
and
55 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
3 changes: 3 additions & 0 deletions
3
test/test-files/typechecker/variables/error-reassign-const-ref-var/exception.out
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
77 changes: 76 additions & 1 deletion
77
test/test-files/typechecker/variables/error-reassign-const-var/exception.out
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 |
---|---|---|
@@ -1,5 +1,80 @@ | ||
[Error|Compiler]: | ||
Unresolved soft errors: There are unresolved errors. Please fix them and recompile. | ||
|
||
[Error|Semantic] ./source.spice:3:5: | ||
Cannot re-assign constant variable: Trying to assign value to an immutable variable of type int | ||
|
||
3 i = 1234; | ||
^^^^^^^^ | ||
^^^^^^^^ | ||
|
||
[Error|Semantic] ./source.spice:4:5: | ||
Cannot re-assign constant variable: Trying to assign value to an immutable variable of type int | ||
|
||
4 i++; | ||
^^^ | ||
|
||
[Error|Semantic] ./source.spice:5:5: | ||
Cannot re-assign constant variable: Trying to assign value to an immutable variable of type int | ||
|
||
5 i--; | ||
^^^ | ||
|
||
[Error|Semantic] ./source.spice:6:5: | ||
Cannot re-assign constant variable: Trying to assign value to an immutable variable of type int | ||
|
||
6 ++i; | ||
^^^ | ||
|
||
[Error|Semantic] ./source.spice:7:5: | ||
Cannot re-assign constant variable: Trying to assign value to an immutable variable of type int | ||
|
||
7 --i; | ||
^^^ | ||
|
||
[Error|Semantic] ./source.spice:8:5: | ||
Cannot re-assign constant variable: Trying to assign value to an immutable variable of type int | ||
|
||
8 i += 2; | ||
^^^^^^ | ||
|
||
[Error|Semantic] ./source.spice:9:5: | ||
Cannot re-assign constant variable: Trying to assign value to an immutable variable of type int | ||
|
||
9 i -= 2; | ||
^^^^^^ | ||
|
||
[Error|Semantic] ./source.spice:10:5: | ||
Cannot re-assign constant variable: Trying to assign value to an immutable variable of type int | ||
|
||
10 i *= 2; | ||
^^^^^^ | ||
|
||
[Error|Semantic] ./source.spice:11:5: | ||
Cannot re-assign constant variable: Trying to assign value to an immutable variable of type int | ||
|
||
11 i /= 2; | ||
^^^^^^ | ||
|
||
[Error|Semantic] ./source.spice:12:5: | ||
Cannot re-assign constant variable: Trying to assign value to an immutable variable of type int | ||
|
||
12 i %= 2; | ||
^^^^^^ | ||
|
||
[Error|Semantic] ./source.spice:13:5: | ||
Cannot re-assign constant variable: Trying to assign value to an immutable variable of type int | ||
|
||
13 i ^= 3; | ||
^^^^^^ | ||
|
||
[Error|Semantic] ./source.spice:14:5: | ||
Cannot re-assign constant variable: Trying to assign value to an immutable variable of type int | ||
|
||
14 i <<= 2; | ||
^^^^^^^ | ||
|
||
[Error|Semantic] ./source.spice:15:5: | ||
Cannot re-assign constant variable: Trying to assign value to an immutable variable of type int | ||
|
||
15 i >>= 2; | ||
^^^^^^^ |
12 changes: 12 additions & 0 deletions
12
test/test-files/typechecker/variables/error-reassign-const-var/source.spice
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 |
---|---|---|
@@ -1,4 +1,16 @@ | ||
f<int> main() { | ||
const int i = 123; | ||
i = 1234; | ||
i++; | ||
i--; | ||
++i; | ||
--i; | ||
i += 2; | ||
i -= 2; | ||
i *= 2; | ||
i /= 2; | ||
i %= 2; | ||
i ^= 3; | ||
i <<= 2; | ||
i >>= 2; | ||
} |