Skip to content

Commit 0723b37

Browse files
ntreldlang-bot
authored andcommitted
[trivial] Improve module scope operator example
Make example runnable.
1 parent c022f8d commit 0723b37

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

spec/module.dd

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -489,17 +489,18 @@ $(H2 $(LNAME2 module_scope_operators, Module Scope Operator))
489489
$(P A leading dot (`.`) causes the
490490
identifier to be looked up in the module scope.)
491491

492+
$(SPEC_RUNNABLE_EXAMPLE_RUN
492493
---------
493-
int x;
494+
const int x = 1;
494495

495-
int foo(int x)
496+
void main()
496497
{
497-
if (y)
498-
return x; // returns foo.x, not global x
499-
else
500-
return .x; // returns global x
498+
int x = 5;
499+
assert(x == 5); // main.x, not global x
500+
assert(.x == 1); // global x
501501
}
502502
---------
503+
)
503504

504505

505506
$(H2 $(LNAME2 staticorder, Static Construction and Destruction))

0 commit comments

Comments
 (0)