You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Calling a keyword-named function or method fails in Rust, C++ and Python: the declaration is escaped (r#match, delete_, lambda_) but the call is not #361
#330 and #347 escape a keyword-named function where it is declared. A CallExpression still writes its Callee verbatim, so every call to that function names something that no longer exists, or is a keyword.
Declarations are escaped: PythonGenerator.cs (def {EscapeIdentifier(...)}), RustGenerator.cs, CppGenerator.cs.
The input is a SourceFile with a free function kw(int a) -> int { return a; } and a function caller() -> int { return kw(1); }, with the call built as new CallExpression(kw):
Target (kw)
Generated
Result
Rust (match)
pub fn r#match(a: i32) ... / return match(1);
rustc: expected one of '.', '?', '{', or an operator
C++ (delete)
int delete_(int a) / return delete(1);
g++: type 'int' argument given to 'delete', expected pointer
Python (lambda)
def lambda_(a: int) / return lambda(1)
SyntaxError: invalid syntax
Method calls behave the same way:
Rust: a Holder method loop, called as new CallExpression(new VariableReference("self"), "loop"), generates pub fn r#loop(&mut self) and self.loop().
C++: a method named delete generates int delete_() and .delete().
ReservedWordIdentifierTests does not catch this, because its drivers hand-escape the calls (holder.r#type(), holder.default_()). No generated code in that test calls a keyword-named function.
Suggested fix / acceptance criteria
Escape the callee when it resolves to a function or method declared in the document. DeclaredFunction(call.Callee) and DeclaredMethod(StaticType(receiver), call.Callee) already do the resolution (StandardLanguageGenerator).
Leave all other callees verbatim. Callee is deliberately text, so names like std::sqrt, or C++'s sizeof and static_cast<int>, must not become sizeof_.
Cover both the base path and Rust's unsafe { (*p).callee() } path.
Extend ReservedWordIdentifierTests so the generated code itself calls a keyword-named free function and method, and compile or run that output with rustc, g++ and python.
Related: #106. This issue is a gap in the targets #106 records as done (Rust, C++, Python). It is not part of the remaining Go, JavaScript, C and C# work.
Priority: Medium. A call to any keyword-named function or method fails to compile in Rust and C++ and raises SyntaxError in Python, even though the declaration is already escaped. Only documents that use keyword names are affected.
Area: Call generation: LanguageGeneratorBase.GenerateCallExpression (:895) and Rust's pointer-receiver path. Resolve the callee through DeclaredFunction / DeclaredMethod and escape it only when it resolves to a declaration.
Activity
matt-edmondson commentedon Oct 30, 2026
Triage
SyntaxErrorin Python, even though the declaration is already escaped. Only documents that use keyword names are affected.LanguageGeneratorBase.GenerateCallExpression(:895) and Rust's pointer-receiver path. Resolve the callee throughDeclaredFunction/DeclaredMethodand escape it only when it resolves to a declaration.fn type(...)(Rust) /int default()(C++) that fails to compile #106 (a gap in targets Identifiers that are target-language keywords are emitted verbatim: a property named Type or Default generatesfn type(...)(Rust) /int default()(C++) that fails to compile #106 records as done). The test gap is inReservedWordIdentifierTests, which hand-escapes the calls.Generated by Claude Code