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
str/list/dict/bool parameters generate C++ without <string>/<vector>/<map>, C# without System.Collections.Generic, and C without <stdbool.h>, so none compile #334
The generators translate the AST's portable type names into library types:
C++ (CppGenerator.cs L45-L64): str → std::string, list → std::vector, dict → std::map, object → std::any.
C# (CSharpGenerator.cs L1502-L1525): list → List, dict → Dictionary.
C (CGenerator.cs L94-L112): bool stays bool, which C99 provides only through <stdbool.h>.
There is already a mechanism for adding the imports generated output needs: RequiredImports (LanguageGeneratorBase.cs L624, used at L710). The generators don't use it for these types:
C++ adds <vector>/<string> only when an entry point takes arguments (CppGenerator.cs L154-L172). It never adds them for a mapped parameter, field or return type.
C adds only <math.h> (CGenerator.cs L183-L190).
C# does not override RequiredImports at all.
Rust avoids the problem by spelling std::collections::HashMap and std::any::Any in full. Go and Python map these names to builtins.
Input: a SourceFile containing int count(str label, list<int> sizes, dict<str, int> names, bool ready) { return 0; }
Target
Output
Result
C++
int count(std::string label, std::vector<int> sizes, std::map<std::string, int> names, bool ready)
g++ -std=c++20: 'string'/'vector'/'map' is not a member of 'std'
C#
public static int count(string label, List<int> sizes, Dictionary<string, int> names, bool ready)
dotnet build: CS0246 for List<> and Dictionary<,>
C
int count(const char* label, int* sizes, void* names, bool ready)
gcc -std=c99: unknown type name 'bool'
Rust, Go, Python
valid
The existing C compile tests pass only because they add <stdbool.h> by hand (CGeneratedSourceCompilesTests.cs L267).
Suggested fix / acceptance criteria
C++ RequiredImports yields <string>, <vector>, <map> and <any> whenever a type spelled in the file maps to one of them.
C RequiredImports yields <stdbool.h> when bool is used.
C# either:
fully qualifies the types (global::System.Collections.Generic.List<…>, as Rust does), which also works when the generation root is not a SourceFile; or
adds a RequiredImports override.
Compile tests in C++, C# and C cover a function using these types, with no imports supplied by the caller.
There is precedent for the generator adding the imports its own spellings need: #147 and #278.
Priority: High. A function using the AST's basic portable types (str, list, dict, bool) produces output that doesn't compile in C++, C# or C. The failure is loud, but it affects the most common types in three targets, and the existing C compile tests hide it by adding <stdbool.h> by hand.
Area / suggested assignee:RequiredImports overrides in CppGenerator.cs, CGenerator.cs and CSharpGenerator.cs (base at LanguageGeneratorBase.cs L624/L710). Owner: @matt-edmondson
Next step: add the imports via RequiredImports for C++ and C; for C#, prefer full global:: qualification so it also works when the generation root isn't a SourceFile. Remove the hand-added <stdbool.h> from CGeneratedSourceCompilesTests.cs L267 so the tests actually guard this.
Activity
matt-edmondson commentedon Oct 20, 2026
Triage
str,list,dict,bool) produces output that doesn't compile in C++, C# or C. The failure is loud, but it affects the most common types in three targets, and the existing C compile tests hide it by adding<stdbool.h>by hand.RequiredImportsoverrides inCppGenerator.cs,CGenerator.csandCSharpGenerator.cs(base atLanguageGeneratorBase.csL624/L710). Owner: @matt-edmondson%in a property accessor or entry point emitsmath.fmod/math.Mod/fmodwithout the import (Python NameError, Go "undefined: math") #278. No open PR covers it.RequiredImportsfor C++ and C; for C#, prefer fullglobal::qualification so it also works when the generation root isn't aSourceFile. Remove the hand-added<stdbool.h>fromCGeneratedSourceCompilesTests.csL267 so the tests actually guard this.Generated by Claude Code
Merge main into fix/inferred-member-type-432