Skip to content

Commit f5a60fb

Browse files
authored
[spec] Show static assert is identifier example (#3533)
* [spec] Show static assert `is` identifier example * Specify `is` must be used in the first argument * Avoid using .stringof
1 parent 2942eb0 commit f5a60fb

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

spec/expression.dd

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2799,7 +2799,8 @@ $(H4 $(LNAME2 is-identifier, Identifier Forms))
27992799
$(P *Identifier* is declared to be an alias of the resulting
28002800
type if the condition is satisfied. The *Identifier* forms
28012801
can only be used if the $(I IsExpression) appears in a
2802-
$(GLINK2 version, StaticIfCondition) or $(GLINK2 version, StaticAssert).
2802+
$(GLINK2 version, StaticIfCondition) or the first argument of a
2803+
$(GLINK2 version, StaticAssert).
28032804
)
28042805

28052806
$(H5 $(LNAME2 is-type-identifier, $(D is $(LPAREN)) $(I Type) $(I Identifier) $(D $(RPAREN))))
@@ -2810,9 +2811,19 @@ $(H4 $(LNAME2 is-identifier, Identifier Forms))
28102811
is declared to be an alias of $(I Type).
28112812
)
28122813

2814+
$(SPEC_RUNNABLE_EXAMPLE_COMPILE
2815+
---
2816+
struct S
2817+
{
2818+
int i, j;
2819+
}
2820+
static assert(is(typeof(S.i) T) && T.sizeof == 4);
2821+
---
2822+
)
28132823
$(SPEC_RUNNABLE_EXAMPLE_COMPILE
28142824
-------------
28152825
alias Bar = short;
2826+
28162827
void foo()
28172828
{
28182829
static if (is(Bar T))

0 commit comments

Comments
 (0)