Skip to content

Commit 7f42a83

Browse files
authored
Merge pull request #2513 from n8sh/fix-getFunctionAttributes-example
Fix __traits(getFunctionAttributes) example merged-on-behalf-of: Nicholas Wilson <thewilsonator@users.noreply.github.com>
2 parents 4fd7517 + bc333b0 commit 7f42a83

File tree

1 file changed

+18
-3
lines changed

1 file changed

+18
-3
lines changed

spec/traits.dd

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -735,26 +735,41 @@ $(SPEC_RUNNABLE_EXAMPLE_COMPILE
735735
---
736736
int sum(int x, int y) pure nothrow { return x + y; }
737737

738-
// prints ("pure", "nothrow", "@system")
739738
pragma(msg, __traits(getFunctionAttributes, sum));
740739

741740
struct S
742741
{
743742
void test() const @system { }
744743
}
745744

746-
// prints ("const", "@system")
747745
pragma(msg, __traits(getFunctionAttributes, S.test));
746+
747+
void main(){}
748748
---
749+
)
750+
751+
Prints:
752+
753+
$(CONSOLE
754+
tuple("pure", "nothrow", "@system")
755+
tuple("const", "@system")
749756
)
750757

751758
$(P Note that some attributes can be inferred. For example:)
752759

753760
$(SPEC_RUNNABLE_EXAMPLE_COMPILE
754761
---
755-
// prints ("pure", "nothrow", "@nogc", "@trusted")
756762
pragma(msg, __traits(getFunctionAttributes, (int x) @trusted { return x * 2; }));
763+
764+
void main(){}
757765
---
766+
)
767+
768+
Prints:
769+
770+
$(CONSOLE
771+
tuple("pure", "nothrow", "@nogc", "@trusted")
772+
)
758773
)
759774
)
760775

0 commit comments

Comments
 (0)