mirror of
https://github.com/dlang/dmd.git
synced 2025-04-26 21:21:48 +03:00
44 lines
929 B
D
44 lines
929 B
D
/*
|
|
TEST_OUTPUT:
|
|
---
|
|
fail_compilation/diag8777.d(12): Error: constructor `diag8777.Foo1.this` missing initializer for immutable field `x`
|
|
fail_compilation/diag8777.d(12): Error: constructor `diag8777.Foo1.this` missing initializer for const field `y`
|
|
---
|
|
*/
|
|
class Foo1
|
|
{
|
|
immutable int[5] x;
|
|
const int[5] y;
|
|
this() {}
|
|
}
|
|
|
|
/*
|
|
TEST_OUTPUT:
|
|
---
|
|
fail_compilation/diag8777.d(25): Error: cannot modify `immutable` expression `x`
|
|
fail_compilation/diag8777.d(28): Error: cannot modify `const` expression `y`
|
|
---
|
|
*/
|
|
void test2()
|
|
{
|
|
immutable int x;
|
|
x = 1;
|
|
|
|
const int y;
|
|
y = 1;
|
|
}
|
|
|
|
/*
|
|
TEST_OUTPUT:
|
|
---
|
|
fail_compilation/diag8777.d(42): Error: cannot remove key from `immutable` associative array `hashx`
|
|
fail_compilation/diag8777.d(43): Error: cannot remove key from `const` associative array `hashy`
|
|
---
|
|
*/
|
|
immutable(int[int]) hashx;
|
|
const(int[int]) hashy;
|
|
void test3()
|
|
{
|
|
hashx.remove(1);
|
|
hashy.remove(1);
|
|
}
|