File tree Expand file tree Collapse file tree 3 files changed +15
-0
lines changed
Expand file tree Collapse file tree 3 files changed +15
-0
lines changed Original file line number Diff line number Diff line change @@ -34,6 +34,7 @@ enum class TokenKind : char {
3434 KwWhile,
3535 KwReturn,
3636 KwStruct,
37+ KwPrintf,
3738
3839 Eof = singleCharTokens[0 ],
3940 Lpar = singleCharTokens[1 ],
Original file line number Diff line number Diff line change @@ -666,6 +666,10 @@ Sema::resolveFunctionDecl(const FunctionDecl &function) {
666666 if (!function.params .empty ())
667667 return report (function.location ,
668668 " 'main' function is expected to take no arguments" );
669+ } else if (function.identifier == " printf" ) {
670+ return report (function.location ,
671+ " 'printf' is a reserved function name and cannot be used for "
672+ " user-defined functions" );
669673 }
670674
671675 std::vector<std::unique_ptr<ResolvedParamDecl>> resolvedParams;
Original file line number Diff line number Diff line change 1+ // RUN: compiler %s -res-dump 2>&1 | filecheck %s
2+
3+ // CHECK: [[# @LINE + 1 ]]:1: error: 'printf' is a reserved function name and cannot be used for user-defined functions
4+ fn printf(): number {
5+ return 12345;
6+ }
7+
8+ fn main(): void {
9+ println(printf());
10+ }
You can’t perform that action at this time.
0 commit comments