Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add test-cases for const/immutable diagnostics. Use MODtoBuffer for output.
- Loading branch information
1 parent
68ab986
commit 7aaa509
Showing
8 changed files
with
89 additions
and
15 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
/* | ||
TEST_OUTPUT: | ||
--- | ||
fail_compilation/diag8777a.d(3): Error: constructor diag8777a.Foo.this missing initializer for immutable field bar | ||
--- | ||
*/ | ||
|
||
#line 1 | ||
class Foo { | ||
immutable int[5] bar; | ||
this() {} | ||
} |
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,12 @@ | ||
/* | ||
TEST_OUTPUT: | ||
--- | ||
fail_compilation/diag8777b.d(3): Error: constructor diag8777b.Foo.this missing initializer for const field bar | ||
--- | ||
*/ | ||
|
||
#line 1 | ||
class Foo { | ||
const int[5] bar; | ||
this() {} | ||
} |
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,13 @@ | ||
/* | ||
TEST_OUTPUT: | ||
--- | ||
fail_compilation/diag8777c.d(4): Error: cannot modify const expression x | ||
--- | ||
*/ | ||
|
||
#line 1 | ||
void test() | ||
{ | ||
const int x; | ||
x = 1; | ||
} |
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,13 @@ | ||
/* | ||
TEST_OUTPUT: | ||
--- | ||
fail_compilation/diag8777d.d(4): Error: cannot modify immutable expression x | ||
--- | ||
*/ | ||
|
||
#line 1 | ||
void test() | ||
{ | ||
immutable int x; | ||
x = 1; | ||
} |
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,14 @@ | ||
/* | ||
TEST_OUTPUT: | ||
--- | ||
fail_compilation/diag8777e.d(5): Error: cannot remove key from immutable associative array hash | ||
--- | ||
*/ | ||
|
||
#line 1 | ||
immutable(int[int]) hash; | ||
|
||
void main() | ||
{ | ||
hash.remove(1); | ||
} |
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,14 @@ | ||
/* | ||
TEST_OUTPUT: | ||
--- | ||
fail_compilation/diag8777f.d(5): Error: cannot remove key from const associative array hash | ||
--- | ||
*/ | ||
|
||
#line 1 | ||
const(int[int]) hash; | ||
|
||
void main() | ||
{ | ||
hash.remove(1); | ||
} |