dmd/compiler/test/fail_compilation/fail20730b.d
Nick Treleaven 8974bb128d
Fix Bugzilla 24707 - error message has bad parameter attribute order (#16791)
* Fix Bugzilla 24707 - error message has bad attribute order

* Fix tests

* Fix & split error test into 2 lines
2024-08-19 14:29:23 +03:00

46 lines
1,022 B
D

/*
REQUIRED_ARGS: -verrors=spec -o-
TEST_OUTPUT:
---
(spec:1) fail_compilation/fail20730b.d-mixin-43(43): Error: C style cast illegal, use `cast(int)mod`
fail_compilation/fail20730b.d(26): Error: template `atomicOp` is not callable using argument types `!("+=")(shared(uint), int)`
fail_compilation/fail20730b.d(41): Candidate is: `atomicOp(string op, T, V1)(ref shared T val, V1 mod)`
with `op = "+=",
T = uint,
V1 = int`
must satisfy the following constraint:
` __traits(compiles, mixin("(int)mod"))`
---
*/
void test20730()
{
auto f = File().byLine;
}
struct File
{
shared uint refs;
this(this)
{
atomicOp!"+="(refs, 1);
}
struct ByLineImpl(Char)
{
File file;
char[] line;
}
auto byLine()
{
return ByLineImpl!char();
}
}
T atomicOp(string op, T, V1)(ref shared T val, V1 mod)
// C-style cast causes raises a parser error whilst gagged.
if (__traits(compiles, mixin("(int)mod")))
{
return val;
}