What's new?
Parser Hardening: Function Pointers, Template Defaults, Bitfields, and More
This release continues the parser hardening work from v0.3.0, targeting a new batch of valid C++17/20 constructs that were previously mishandled. Fixes span the parser, CodeGen, and the Windows install wizard.
Parser
- Function pointer parameters with defaults:
float (*fn)(float) = nullptrnow parses correctly. The ref-to-array branch ((&arr)[N]) now discriminates against function pointer params by checking whether(or[follows the closing), rather than consuming both forms the same way. - Function pointer parameter encoding: parser encodes fn-ptr params as
name__fnptr__(sig)so CodeGen can round-trip the full declarator shaperettype (*name)(sig). - Template default values with comparisons:
template<int N = (sizeof(float) > 2 ? 8 : 4)>now parses correctly.parseTemplateDefaultValuenow tracksparenDepthandangleDepthseparately, so>inside parentheses is treated as a comparison operator rather than a template closer. - Explicit empty
<>:Foo<> xnow emitsFoo<> xrather thanFoo x. The parser stores a sentinelNamedType("<>")to distinguish explicit empty args from no args. - Array-new value-init:
new float[n]()trailing()is now consumed correctly instead of being left in the stream and breaking the enclosing constructor init-list parser. - Trailing ref-qualifiers:
T& operator=(const T&) &andT& operator=(T&&) &&— trailing&and&&ref-qualifiers on member functions are now consumed in the trailing qualifier loop. - Bitfields: named (
unsigned int active : 1) and unnamed (unsigned int : 2) bitfield declarations now parse correctly inside struct bodies. Unnamed bitfields return an empty name beforeexpectIdentifier()would throw. - Throw as expression:
cond ? val : throw std::runtime_error("null")—throwin ternary else position now handled inparseTernary()before delegating toparseLogicalOr(). - Template speculation and ternary:
looksLikeTemplateArgListnow rejects speculation when a bare?appears at depth 0, preventingv < lo ? lo : v > hifrom being misread as a template instantiation.
CodeGen
- Function pointer param emission: decodes
name__fnptr__(sig)encoding and emitsrettype (*name)(sig)correctly. - Array-of-function-pointer dims:
void (*ops[4])(int)now emits with[4]inside the parens rather than outside — discriminates array-of-fn-ptr from ptr-to-array usingparamTypes.isEmpty(). - Long double literals:
L/lsuffix now excluded from the floatf-append pass —180.0Lwas becoming180.0Lf.
CppBuild / InstallWizard
- E0005 false positive fixed:
Array<T>.get().fieldno longer triggers E0005. The check now requires positive confirmation that the receiver is anArrayListbefore firing —Array<T>is value-storage and.fieldis correct there. - Windows install wizard now fires reliably: PATH
g++(Git for Windows, Cygwin, other MinGW installs) is no longer trusted on Windows. Onlyg++at known MSYS2mingw64paths is accepted. Previously, anyg++on PATH would silently bypass the wizard, leading to linker errors at build time due to missing GLFW/GLEW. BothCppBuild.checkGppAvailable()andInstallWizard.detectWindowsMissing()now check MSYS2 paths exclusively.
Stress Test Coverage
Rounds 21–23 of the parser stress test suite, covering: inline function pointer parameters with defaults, arrays of function pointers, reference-to-array parameters, nested template closes (>>), conditional expression NTTPs, pointer-to-member template parameters, cast inside brace-init, pack expansion in member init-lists, operator overloads with ref-qualifiers, structured bindings in range-for, if/switch-with-init, template type aliases, using X::Y qualified imports, three-link postfix chains on temporaries, trailing return types with decltype, constexpr if, fold expressions, C++20 lambda template parameters, requires clauses on free functions, concept definitions, structured bindings from arrays, immediately invoked lambdas, variable templates, bitfield members, conditional noexcept, and throw-expressions in ternary context.