Development Log
Ongoing chronological record of major milestones, engineering refactors, and architectural evolutions in cppbolt.
2026-11-03: std::initializer_list Review Fixes
Fixed five findings in the initializer-list and brace-initialization support added earlier the same day.
Summary of Work
- Resolved non-template method parameter and return types in
register_struct_declarations(src/sema/analyze.rs), so a constructor such asX(std::initializer_list<int>)orX(std::vector<int>)matches an argument whose template type was already instantiated (c78aa25). - Ranked every initializer-list constructor instead of taking the first whose elements were convertible: exact conversions beat integral promotions, which beat other standard conversions. A narrowing candidate is skipped, and its diagnostic is reported only when no candidate is viable (
fb4a983). - Added empty initializer-list constructor fallback for value-initialization (
T x{}) when the class declares no default constructor (fb4a983). - Normalized extracted template element types to their registered struct names and resolved nested brace lists against the chosen element type, enabling
std::vector<std::vector<int>> v{{1, 2}, {3, 4}}(cadf45c). - Routed a namespace-scope brace initializer through the same list resolution as locals, and lowered a namespace-scope
std::initializer_list<T>by building its backing array inmain's frame and storing the pointer and length in the global object (366bad8).
Known Issue
Range-based for loops and structured bindings inside non-template method bodies are not analyzed: analyze_declarations type-checks a clone of the body and discards it, so the loop compiles to nothing. Writing the analyzed body back changes 137 golden hashes; corpus tests avoid method-body loops for now. Free functions and template method bodies are unaffected.
Verification Results
- Corpus: 428 tests on disk, 428 passed, 0 unexpected failures; all 118 negative tests passed.
- Golden baseline: all 310 entries match
tests/golden.txt, with only the two new tests added. - Census audit: 0 files over 500 lines, 0 functions over 80 lines, 0 functions with more than 5 parameters excluding self.
- Clippy: 0 warnings with
-D warningsacross all targets.
2026-11-03: std::initializer_list and Brace Initialization
Implemented std::initializer_list<T> and container brace initialization.
Summary of Work
- Added the vector count-and-value constructor so
vector<int>(3, 4)remains distinct fromvector<int>{3, 4}. - Implemented semantic initializer-list resolution with constructor preference,
autodeduction, homogeneous element checks, narrowing diagnostics, and support for parenthesized braced arguments. - Lowered each list to a frame-backed contiguous element array plus an eight-byte
{pointer, length}std::initializer_list<T>value. Temporary backing elements are destroyed at full-expression cleanup; local list elements are destroyed with their containing scope. - Added positive, variant, and negative corpus coverage for list arguments,
autodeduction, vector brace initialization, mismatched types, emptyauto, and narrowing.
Verification Results
- Corpus: 416 tests on disk, 416 passed, 0 unexpected failures; all 114 negative tests passed.
- New positive coverage includes
std::vector<std::string>brace initialization andvector({1, 2, 3, 4}).
2026-11-02: Template Method Defaults, Lifecycle Synthesis, and Out-of-Class Qualified Attachment
Resolved review findings in member template default argument mapping, same-arity template candidate deduplication, parameter shadowing, out-of-class qualified constructor parsing, and base subobject copying.
Summary of Work
- Corrected member template default argument indexing in
src/sema/constructor.rs, mapping default argument expressions across the full signature parameter slice including the leading implicit instance receiver. - Deduplicated function template candidates in
src/sema/template_registry.rsusing exact parameter types rather than arity alone, preserving coexisting same-arity overloads and updating bodies on forward declarations. - Aligned out-of-class template method attachment with parameter types and constness, preventing same-arity overloads from overwriting existing definitions.
- Extended constructor and destructor detection in
src/parser/template.rsto traverse multi-part namespace and class qualifier paths (Outer::Inner::Class::Class()). - Added in-place out-of-class non-template method attachment in
src/sema/analyze.rs, attaching method and constructor bodies to target struct declarations prior to layout and semantic checking. - Enforced member template parameter shadowing during outer class template substitution in
src/sema/template_subst.rs, preserving inner template parameters. - Refined functor dispatch in
src/sema/expr_call.rsto verify that member templates matchoperator()before rewriting instance calls. - Included base class initializers in synthesized copy constructors and prepended base assignments in copy assignment operators in
src/sema/synthesize.rs, with base subobject offset adjustments insrc/codegen/call_args.rsandsrc/codegen/lvalue.rs. - Added dynamic destructor and copy operation synthesis for instantiated template classes containing members with non-trivial lifecycles.
- Added 8 unit tests in
src/sema/tests.rscovering all resolved cases, and updated golden baseline hashes across 13 affected tests.
Verification Results
- Unit and integration tests: 394 corpus tests on disk, 390 passed, 4 expected failures, 0 unexpected failures. All 16 unit tests in
src/sema/tests.rsand 88 library unit tests passed. - Golden baseline: all 283 entries match
tests/golden.txt. - Census audit: 0 files over 500 lines, 0 functions over 80 lines, 0 functions with more than 5 parameters excluding self.
- Clippy: 0 warnings with
-D warningsacross all targets.
2026-11-02: Member Function Templates, Standard Vector, and Algorithm Overloads
Implemented member function templates, out-of-class template method definitions, dependent member type aliases, and multi-arity function template overloads. These additions unlock <vector>, <utility> (std::pair), and <algorithm> (std::sort, std::reverse, std::min, std::max).
Summary of Work
- Added parsing and registration for out-of-class template method definitions (
template <typename T> void Class<T>::method()) insrc/parser/decl.rsandsrc/sema/template_registry.rs. - Supported member function templates inside class templates and concrete structs in
src/parser/structs.rs,src/sema/constructor.rs, andsrc/sema/template_registry.rs. This enables templated constructors and call operators such aspair(U1&&, U2&&)and functor invocations. - Enabled dependent member type aliases on instantiated template classes (such as
std::vector<int>::iteratortoint*) insrc/parser/types.rsandsrc/sema/template_registry.rs. Range-based for loops over template containers now resolve iterators and dereferenced elements directly. - Expanded function template registration in
src/sema/template_registry.rsto track candidate lists rather than single declarations. Candidate filtering by arity and default arguments enables overloads such asstd::sort(first, last)andstd::sort(first, last, comp)to coexist. - Handled member template instantiations for plain structs (such as
DefaultLess::operator()<T>) by synthesizing concrete method declarations into the AST for WebAssembly codegen. - Added constructor conversion for by-value struct arguments in
src/codegen/call_args.rs, creating managed temporaries when passing arguments such as string literals to struct parameters. - Synthesized copy constructors and copy assignment operators for classes containing non-trivial subobjects in
src/sema/synthesize.rs, and updated placement new and member initializers insrc/codegen/expr_new.rsandsrc/codegen/function_lifecycle.rsto copy struct bytes when explicit copy constructors are absent. - Extracted
src/sema/template_func.rs,src/sema/synthesize.rs, andsrc/sema/expr_call_member.rsto maintain repository census compliance. - Added 5 variant tests:
tests/templates_operators_variant/template_class_methods_variant.cpp,tests/mini_stl_variant/pair_basic.cpp,tests/mini_stl_variant/vector_basic.cpp,tests/mini_stl_variant/iterators_range_for_variant.cpp,tests/mini_stl_variant/algorithm_sort_variant.cpp, andtests/mini_stl_variant/combined_integration_variant.cpp.
Verification Results
- Unit and integration tests: 394 corpus tests on disk, 390 passed, 4 expected failures (remaining associative container tests), 0 unexpected failures. All 107 negative tests passed.
- Host oracle gate: matched native compiler behavior on all expected files (82.2s).
- Census audit: 0 files over 500 lines, 0 functions over 80 lines, 0 functions with more than 5 parameters excluding self.
- Clippy: 0 warnings with
-D warningsacross all targets.
2026-11-01: Template Integration Bugfixes and Lifecycle Lowering
Resolved edge cases across template type resolution, field layout calculation, lazy operator lowering, RAII destructor lifecycles, and function argument deduction.
Summary of Work
- Made type resolution recursive across pointers, references, const qualifiers, and arrays in
src/sema/template_registry.rs, generating concrete struct layouts before field lookup. Added a cycle guard insrc/sema/lookup.rsto stop infinite alias looping. - Resolved template instance types in struct fields before computing struct layouts in
src/sema/analyze.rs, setting correct field offsets and total struct sizes. Resolved template types in non-template function parameters and return types during declaration registration and function analysis. - Lowered lazy template operator methods (
operator[], unary operators) upon match insrc/sema/expr_ops.rs. Eagerly instantiated non-virtual template class destructors insrc/sema/template_registry.rsso destructor synthesis registers cleanup calls on scope exit. - Filled default arguments on function template calls via
self.full_arguments(&sig, args)insrc/sema/expr_call.rs, providing all required stack values in WebAssembly bytecode. - Passed known class templates into explicit template argument list parsing in
src/sema/template_deduce.rsto support nested types likefunc<Inner<int>>(x). - Stripped top-level const during pointer argument deduction in
src/sema/template_deduce.rsto deduceTfromT* const. - Refined template name substitution in
src/sema/template_subst.rsto prevent accidental replacement across scope qualifiers. - Added regression tests for pointer access, const-reference binding, struct template fields, non-template functions with template arguments, overloaded subscript operators, destructor scope cleanups, function default arguments, nested explicit types, and const pointer deduction (
template_ptr_const_ref.cpp,template_field_and_func.cpp,template_ops_dtor.cpp,template_default_arg_deduce.cpp).
Verification Results
- Unit and integration tests: 381 corpus tests on disk, 364 passed, 17 expected failures, 0 unexpected failures. All 107 negative tests passed.
- Golden baseline: updated to 267 entries in
tests/golden.txt, all matchingtarget/debug/cppbolt-cli. - Census audit: 0 files over 500 lines, 0 functions over 80 lines, 0 functions with more than 5 parameters excluding self.
- Clippy: 0 warnings with
-D warningsacross all targets.
2026-11-01: Template Core Implementation
We implemented class and function templates with type parameters, single-phase name lookup, lazy member instantiation, and function template argument deduction.
Summary of Work
- Added template AST definitions in
src/ast/template.rs, includingTemplateDecl,TemplateParam, andType::TemplateInstance. - Implemented parsing for template declarations, template argument lists (
<T, U>), and template-ids insrc/parser/template.rs. Added diagnostics rejecting unsupported constructs: explicit specialization, explicit instantiation, template template parameters, variadic templates, and non-type template parameters. - Implemented AST substitution in
src/sema/template_subst.rs, replacing type parameters with concrete types across expressions, statements, types, and declarations. - Implemented template registry in
src/sema/template_registry.rsto lay out struct fields, assign canonical specialization names, cache instantiated declarations, and lower member methods lazily on call. - Implemented function template argument deduction in
src/sema/template_deduce.rs, deducing concrete types from call argument types, handling reference and const qualifiers, and checking type consistency across repeated parameters. - Integrated function templates into overload resolution in
src/sema/expr_call.rs. The compiler prefers exact matches, falls back to function templates when available, and respects defaulted arguments during candidate selection. - Added positive regression tests covering class templates, function templates, multi-parameter templates, reference deduction, and distinct instantiations (
template_class_basic,template_func_basic,template_multi_param,template_pair,template_func_multi,template_lazy_member,template_multi_instance,template_deduce_ref). - Added negative tests verifying rejection of template recursion exceeding the 500 depth limit and deduction conflicts (
template_instantiation_depth.cpp,template_deduction_conflict.cpp).
Verification Results
- Unit and integration tests: 377 corpus tests on disk, 360 passed, 17 expected failures, 0 unexpected failures. All 107 negative tests passed.
- Host oracle gate: matched native compiler behavior on all expected files (73.6s).
- Golden baseline: updated to 263 entries in
tests/golden.txt, all matchingtarget/debug/cppbolt-cli. - Census audit: 0 files over 500 lines, 0 functions over 80 lines, 0 functions with more than 5 parameters excluding self.
- Clippy: 0 warnings with
-D warningsacross all targets.
2026-11-01: Scalar Operations and Baseline Synchronization
The test suite, clippy, census audit, and golden manifest are green across all targets.
Summary of Work
- Synchronized golden baseline: reconciled 49 stale entries in
tests/golden.txtinitially, then added all newly passing tests, bringing the total to 255 verified entries. - Added
std::abs(long)andstd::abs(long long)overloads instdlib/cmath. Unsigned types now trigger ambiguity errors instead of silently promoting to float. - Implemented functional casts and value initialization (
T(),Type(val)) for scalar types and typedef aliases in the parser and sema. - Added scalar pseudo-destructor support (
p->~T(),x.~T(),arr[i].~T()). The compiler evaluates receiver expressions for side effects and treats the destructor call as a no-op. - Resolved struct destructor calls through typedef aliases (
sp->~ClassT()), checking that the alias resolves to the receiver class before calling the destructor. - Corrected
classes_oop/lambdas/lambda_unary_plusto compare pointer size againstsizeof(void*), allowing the test to pass both in 32-bit WebAssembly and under the 64-bit native oracle gate.
Verification Results
- Unit and integration tests: 370 corpus tests on disk, 351 passed, 19 expected failures, 0 unexpected failures, 0 manifest violations.
- Oracle gate: 544 matched, 2 runtime-trap tests skipped across g++ and clang++.
- Golden manifest: 255 entries recorded in
tests/golden.txt, all matchingtarget/release/cppbolt-cli. - Census audit: 119 files scanned, 0 files over 500 lines, 0 functions over 80 lines, 0 functions with more than 5 parameters excluding self.
- Clippy: 0 warnings with
-D warningsacross all targets.
2026-11-01: Baseline Snapshot and Scalar Prerequisite Probes
Context & Motivation
We reconciled test runner manifests and probed compiler behavior on typedef stand-in types representing scalar type parameters (typedef int T;).
Work Executed
- Golden manifest reconciliation:
- Synchronized
tests/golden.txtagainst commit 13051c384029eb2f4b05a4e958b8ca893234c23f. - Resolved 49 stale entries that differed due to previous qualification conversions, numeric literals, and brace-initialization updates.
- Re-verified clean golden output across all 247 recorded test entries with
cargo run --bin cppbolt-testrunner -- --check-golden tests/golden.txt target/release/cppbolt-cli.
- Synchronized
- Scalar prerequisite probes:
- Value-initialization
T a = T();: failed withUndefined function 'T'. The parser interpretsT()as a function call instead of a scalar functional cast. - Direct-initialization
T b(5);: passed. - Size evaluation and allocation
sizeof(T)and(T*)malloc(...): passed. - Scalar placement new
new (buf) T(7);: passed. - Scalar pseudo-destructor
p->~T(): failed withArrow member access on non-struct pointer. Member access rejects non-struct pointers and lacks pseudo-destructor grammar. - Class destructor call via typedef
sp->~ClassT(): failed withMethod '~ClassT' not found in class 'S'. Destructor lookup does not resolve typedef aliases to target class names.
- Value-initialization
Verification
- Synchronized golden manifest passes: 247 entries matched, 19 uncompilable tests skipped.
- Corpus test suite execution: 360 total tests on disk, 341 passed, 19 expected failures, 0 unexpected failures. All 94 negative tests passed.
2026-11-01: Type Qualification, Pointer Conversions, and String Literal Semantics
Context & Motivation
Work on this date addressed C++17 pointer conversion semantics, qualification conversions, and string literals:
- The compiler allowed arbitrary integers and variables to convert to pointers instead of restricting null pointer constants to literal zero and
nullptr. nullptrwas represented internally asvoid*, collapsingstd::nullptr_ttype identity and distorting overload ranking.- Multi-level pointer qualification conversions did not enforce C++17 rules, incorrectly allowing
int**to convert toconst int**. - String literals were typed as pointers rather than
const char[N], causing incorrectsizeofresults and permitting assignment tochar*. - Implicit conversion from
void*to typed pointers was accepted without an explicitstatic_cast.
Work Executed
nullptrtype identity:- Added
Type::Nullptr(mangledDn) fornullptr,std::nullptr_t, anddecltype(nullptr), with implicit conversions to pointers andbool. - Mapped
KwNullptrandnullptr_ttokens toType::Nullptracross lexer and parser.
- Added
- Pointer qualification and null pointer constants:
- Implemented null pointer constant validation in
src/sema/assign.rs, accepting only literal zeroes (0,0u) andnullptr. - Implemented
check_pointer_conversioninsrc/sema/assign.rsfor multi-level qualification conversions, requiringconston all preceding levels when introducingconstat an inner level. - Allowed object-pointer-to-
void*conversion; rejected implicitvoid*-to-typed-pointer conversions. - Updated overload resolution (
score_arguments) and constructor ranking (score_constructor_candidate) to score qualification conversions and null pointer constant conversions.
- Implemented null pointer constant validation in
- String literal semantics:
- Represented string literals as
Type::Array(Type::Char(const), len + 1)insrc/sema/expr.rsand codegen. - Preserved array typing through
sizeof(sizeof("hello") == 6) and decayed toconst char*for call arguments and pointer assignments. - Rejected assignments of string literals to mutable
char*.
- Represented string literals as
Verification
- Added positive tests in
tests/c_basics/types/pointer_conversions.cppfor null pointer constants,nullptr, multi-level qualification,void*, and string literals. - Added 7 negative diagnostic tests in
tests/negative/. - 69 library and binary tests pass (
cargo test --lib --bins). - 337 corpus tests pass without regressions (
cargo run --bin cppbolt-testrunner). - Census metrics and clippy pass with zero warnings.
2026-10-30: C++17 Numeric Literals, Macro Undef, and Raw Token Pasting
Context & Motivation
Work on this date expanded literal syntax and fixed macro token pasting:
- The lexer did not support binary literals (
0b1010), digit separators (1'000'000), or octal digit checks. - The preprocessor could not undefine macros (
#undef). - Macro token pasting (
##) expanded operand macros before pasting instead of concatenating raw argument tokens.
Work Executed
- Numeric literals:
- Parsed binary literals with
0band0Bprefixes. - Supported single-quote digit separators, rejecting consecutive quotes or quotes at literal boundaries.
- Rejected digits
8and9in octal literals.
- Parsed binary literals with
- Preprocessor directives and macro expansion:
- Added the
#undefdirective insrc/preprocessor/directive_line.rs. - Updated
src/preprocessor/macros.rsto paste raw tokens directly on##without prior expansion.
- Added the
Verification
- Added positive tests in
tests/c_basics/types/numeric_literals.cppandtests/c_basics/preprocessor/macro_token_paste_raw.cpp. - Added negative diagnostic tests in
tests/negative/for invalid binary digits, misplaced digit separators, and invalid octal digits. - Formatting and clippy clean.
2026-10-29: List Initialization, Array Decay, and Constructor Resolution
Context & Motivation
Work on this date addressed list initialization and several compiler edge cases exposed during testing:
- Braced initializer lists were previously limited to array declarations and struct assignments. Direct initialization (
Type x{42}), value initialization (Type x{}), C++17 aggregate subobjects, narrowing conversions, typed temporaries (Type{}.get()), and bracednewallocations were unsupported. - Multi-dimensional pointer dereferencing (
*(*(matrix + 1) + 2)) mistakenly emitted scalar loads on intermediate array addresses rather than decaying to row base pointers. - Namespace-scope global variables with parenthesized constructor initializers (
Item global_item(1);) conflicted with function declaration grammar. - User-defined conversion operators and pointer constructors were improperly matching copy constructor lookups during by-value argument passing and returns.
- Free
operator*overloads were asymmetric between rvalue reading and lvalue assignment (*it = 42;).
Work Executed
- List initialization:
- Added
Expr::TypedInitList { ty, elements, pos }to the AST and attached source positions toExpr::InitializerList. - Updated Pratt expression parsing to handle typed initializers and braced lists across variable declarations, member initializers, return statements, arguments, assignments, and
newexpressions. ExtractedParser::parse_brace_expr_listinsrc/parser/mod.rsto deduplicate grammar loops. - Implemented
resolve_list_initinsrc/sema/init.rsdriven byInitContext, allowing explicit constructors in direct-list contexts while rejecting them in copy-list contexts. - Enforced narrowing conversion checks per C++17 [dcl.init.list] p7 for floats, doubles, and integer types, with compile-time range evaluation for constants and negative literals.
- Added C++17 aggregate classification (
is_cxx17_aggregate) rejecting classes with user-declared constructors (layout.has_user_declared_constructors), private members, or virtual functions, while supporting public non-virtual base subobjects and flattened brace elision. - Extended code generation in
src/codegen/stmt_var_init.rsfor empty brace zeroing, added dynamic array allocation with trailing element value-initialization insrc/codegen/expr_new_array.rs, and allocated frame slots for typed temporaries.
- Added
- Pointer dereference and array decay:
- In
src/codegen/expr_unary.rs, updated dereference emission so that when the dereferenced element is an array (such asint (*)[3]), the base address stays on the stack instead of emitting a scalar load, allowing subsequent pointer arithmetic to compute proper offsets.
- In
- Global variable constructor disambiguation:
- In
src/parser/decl.rs, introducedparse_ambiguous_global_or_funcwith lookahead for function qualifiers and bodies, falling back to parenthesized constructor expressions for global variable definitions.
- In
- Copy constructor resolution:
- In
src/codegen/construct.rs, introducedfind_copy_constructorrequiring the parameter to be a reference, preventing conversion operators or pointer constructors from being picked as copy constructors.
- In
- Free
operator*lvalue assignment:- In
src/codegen/lvalue.rs, routed assignments through freeoperator*overloads returning references (T& operator*(Iter)).
- In
Verification
- Added positive tests in
tests/classes_oop/structs/for scalar initialization, class constructors, aggregates, brace elision, temporaries, and dynamicnew. - Added negative tests in
tests/negative/for narrowing conversions, explicit constructor rejection, and excess initializer counts. - Added regression tests for multi-dimensional pointer dereferencing, global constructor arguments, and conversion operator parameter passing.
- 51 library tests pass (
cargo test --lib). - 324 corpus tests pass without manifest violations (
cargo run --bin cppbolt-testrunner). - Formatting and clippy clean.
2026-10-28: Lambdas, Operator Overloading, and Language Conformance
Context & Motivation
Work on this date added core C++17 language constructs, expanded operator overloading, and implemented lambda expressions:
- Smart pointer, iterator, and functor abstractions required
operator*(), pointer member accessoperator->, function calloperator(), and postfixoperator++(int)/operator--(int). - Chained smart pointer delegation required recursive
operator->resolution with cycle detection. - C++17 lambdas (captures, return type deduction, direct call, and conversion to function pointers) were needed for modern functional patterns.
- Compiler compatibility audits revealed gaps in array parameter decay, constexpr global initializer reachability, delegating constructors, switch case constant expressions, scoped enums (
enum class), user conversion operators, ref-qualified member methods, structured bindings, and explicitthrowrejection diagnostics.
Work Executed
- Operator overloading:
- Enabled parsing and semantic resolution for unary dereference
operator*(), pointer member accessoperator->, functoroperator(), and postfixoperator++/--(distinguished via dummyintparameter). - In
src/sema/expr_member.rs, implemented recursiveoperator->resolution across intermediate wrapper objects with cycle detection and a 128-hop recursion budget. - In
src/codegen/expr_unary.rs,lvalue.rs, andexpr_call_member.rs, lowered operator calls and routed receiver evaluations through overloaded operators.
- Enabled parsing and semantic resolution for unary dereference
- Lambda expressions:
- Added
Expr::LambdaAST node and parsing for capture lists ([],[x],[&x],[=],[&]), parameters, trailing return types (-> T), andmutable. - In
src/sema/expr_lambda.rs, synthesized anonymous closure structs (__lambda_N) with capture member fields, member initializers, andoperator()methods (constby default). - Added automatic return type deduction and static
__invoketrampolines for captureless lambdas, enabling implicit conversion to C function pointers (R (*)(P...)) and unary+decay (+[](){}).
- Added
- Language conformance:
- Adjusted function parameter array syntax (
int arr[],int arr[N]) to pointer types (int* arr) insrc/parser/decl_func.rs. - Preserved global variable initializer call targets through dead-code elimination in
src/codegen/program_prepare.rs. - Supported delegating constructors (
Point() : Point(5) {}) and enforced mutual exclusivity against member initializers. - Allowed arbitrary constant expressions and scoped enum variants in switch case labels.
- Added scoped enums (
enum class) with qualified lookup (Scope::Val) and distinct type identity. - Supported user-defined conversion operators (
operator T() const), respectingexplicitqualification. - Added
&and&&ref-qualified member methods with value-category receiver dispatch and distinct symbol mangling (_R,_O). - Implemented structured bindings (
auto [a, b] = p;,auto&,const auto&) for aggregate structs. - Diagnosed
throwwith a clear message noting that exceptions are not supported on this WebAssembly target.
- Adjusted function parameter array syntax (
Verification
- Added positive and negative test suites across operators, lambdas, structured bindings, conversion operators, and delegating constructors.
- Test corpus reached 300 passing tests with zero unexpected failures.
- Formatting and clippy clean.
2026-10-27: Range-Based for Loops and Documentation Architecture
Context & Motivation
Following completion of the initial compiler subset, work focused on adding high-impact iteration syntax and restructuring project documentation into a standardized reference system.
Work Executed
- Range-based
forloops:- Added
StmtKind::RangeFor { decl, range, body }to the AST and parser. - In
src/sema/stmt_range_for.rs, validated range expressions and desugared loops into scoped standardforloops. - For fixed-size 1D and multi-dimensional arrays (
int[N],int[M][N]), lowered iteration to pointer bounds[__begin, __end). - For classes with
.begin()and.end()methods (such asstd::string), synthesized member call bounds. - Supported by-value (
auto x), by-reference (auto& x), and const-reference (const auto& x) bindings. - Verified RAII destructor cleanups on early
break,continue, andreturn. - Added validation diagnostics for non-iterable types.
- Added
- Documentation architecture:
- Organized documentation into an mdBook hierarchy (
docs/book/) with User Guides and Internals chapters. - Standardized Architecture Decision Records in
docs/adr/. - Consolidated development and testing workflows into
docs/contributing.mdanddocs/book/internals/testing.md. - Established
CHANGELOG.mdand movedROADMAP.mdto the repository root. - Added
#![warn(missing_docs)]tosrc/lib.rsand documented public pipeline entry points.
- Organized documentation into an mdBook hierarchy (
Verification
- Added test coverage in
tests/c_basics/pointers_arrays/range_for_array.cpp,tests/mini_stl/range_for_string.cpp,tests/classes_oop/memory_raii/range_for_raii.cpp, andtests/negative/range_for_non_iterable.cpp. - Verified automated mdBook,
cargo doc, and playground builds in CI.
2026-11-01: C++17 Namespace Aliases
Context & Motivation
Section 2 of the roadmap tracked namespace aliases (namespace NewName = OriginalName;), which were rejected upfront by the parser unsupported validator.
Work Executed
- Removed the parser rejection rule for namespace aliases.
- Added
Decl::NamespaceAliasandStmtKind::NamespaceAliasto AST definitions. - Parsed namespace alias declarations at global, namespace, and block scopes.
- Added transitive alias resolution in
ParserandSemaacross types, functions, variables, andusing namespacedirectives. - Diagnosed invalid alias redefinitions in semantic analysis.
Verification
- Added test coverage in
tests/classes_oop/statics_namespaces/namespace_aliases.cpp. - Updated negative test coverage in
tests/negative/namespace_alias.cpp. - Verified clean suite with 338 passing tests in
cppbolt-testrunner.
2026-11-01: C++17 Extended Casts (reinterpret_cast)
Context & Motivation
Section 2 of the roadmap tracked reinterpret_cast across scalar and pointer types within the ILP32 model. Previously, only static_cast and C-style casts were recognized, while reinterpret_cast was rejected at parse time.
Work Executed
- Added
TokenKind::KwReinterpretCastto the lexer and parser. - Introduced
CastKind(Static,Reinterpret,CStyle) and unified cast expressions intoExpr::Cast { kind, target_type, expr }. - Extended the parser to handle
reinterpret_cast<Type>(expr)with template bracket matching. - Implemented semantic validation for
reinterpret_castinsrc/sema/expr.rs:- Allowed conversions between integer types and pointer types without loss under 32-bit ILP32 semantics.
- Allowed conversions between arbitrary pointer types.
- Handled lvalue reference reinterpretations (
reinterpret_cast<T&>(expr)). - Rejected scalar floating-point value conversions (direct float-to-int or float-to-pointer casts) per C++17 rules.
- Bypassed user-defined conversion operators (
operator T()) and constructors.
- Implemented WebAssembly code generation lowering in
src/codegen/expr.rsandsrc/codegen/memory.rs, generating bit-preserving no-ops or width adjustments (wrapping or extending for 64-bit integers). - Documented all additions and marked Roadmap Section 2 complete.
Verification
- Added end-to-end integration tests in
tests/c_basics/types/reinterpret_cast.cpp. - Added unit tests across lexer, parser, sema, and codegen in
src/. - Verified clean suite with 339 passing tests in
cppbolt-testrunner. - Verified zero warnings with
cargo clippyand satisfied all census constraints.
2026-11-02: Nested Classes, Dependent Types, and Associative Containers (std::map, std::set)
Implemented member classes within structs and templates, the typename keyword for dependent type specifiers, template nested class instantiation, and method overload selection by value category. These additions enabled std::map, std::set, and their self-balancing binary search tree detail::AVLTree in stdlib/.
Summary of Work
- Parsed inner struct and class declarations in
src/parser/structs.rsandsrc/parser/structs_nested.rs, registering nested definitions under their outer qualified paths (Outer::Inner) and flattening them into top-level declarations. - Added
typenamekeyword handling insrc/parser/types.rsandsrc/parser/prefix.rs, requiring qualification (typename Scope::Type) and preserving qualified specifiers across function signatures. - Implemented
instantiate_nested_structsandpopulate_instantiation_member_aliasesinsrc/sema/template_nested.rs, cloning and specializing inner classes with outer template arguments substituted and computing their record layouts. - Added
select_member_overloadinsrc/sema/expr_call_member.rsto score candidate signatures and resolve calls across receiver constness and value categories. - Added eager constructor dependency resolution in
src/sema/constructor.rs, instantiating member subobject and array element constructors before body analysis. - Handled scoped destructor lookups in
src/codegen/function_lifecycle.rsandsrc/codegen/raii.rsvia short and qualified names. - Enabled
tests/mini_stl/map_basic.cpp,tests/mini_stl/set_basic.cpp, and the 20-seed differential fuzzing suitetests/mini_stl/differential_fuzz.cppintests/PASSING.txt.
Verification Results
- Unit and integration tests: 401 corpus tests on disk, 401 passed, 1 expected failure (
vector_brace_init), 0 unexpected failures. All 109 negative tests passed. - Host oracle gate: matched native compiler behavior on all expected files.
- Golden baseline: updated to 294 entries in
tests/golden.txt, all matchingtarget/release/cppbolt-cli. - Census audit: 0 files over 500 lines, 0 functions over 80 lines, 0 functions with more than 5 parameters excluding self.
- Clippy: 0 warnings with
-D warningsacross all targets.
2026-11-02: Nested Class Access Control, Scope Resolution, and Fixed-Point Dependent Aliases
Resolved review findings in nested struct scope tracking, global namespace pollution, type specifier access control, and chained dependent alias resolution.
Summary of Work
- Pushed qualified names onto
active_struct_scopesinsrc/parser/structs_nested.rs, ensuring member aliases declared in inner structs bind to the inner scope rather than the outer class. - Removed unqualified nested struct names from
known_typesinsrc/parser/structs_nested.rs, scoping nested names to their enclosing struct and resolving them viaresolve_active_struct_scope_type. - Implemented
check_nested_type_accessinsrc/sema/lookup.rsand called it during type resolution insrc/sema/template_registry.rs, rejecting external references to private nested types while permitting enclosing classes and parameterized templates. - Replaced the fixed 3-iteration alias expansion loop in
src/sema/template_nested.rswith fixed-point iteration (while changed && iterations < 16), supporting arbitrary alias chain depths. - Guarded member alias injection in
src/sema/template_nested.rsandsrc/sema/template_registry.rs, injectingstd::aliases only for classes declared within thestdnamespace. - Added positive tests for nested scopes and alias chains (
nested_classes_scopes.cpp,template_nested_alias_chain.cpp), and negative diagnostic tests for unqualified leakage and private access (nested_class_unqualified_leak.cpp,nested_type_private_access.cpp).
Verification Results
- Unit and integration tests: 406 corpus tests on disk, 405 passed, 1 expected failure (
vector_brace_init), 0 unexpected failures. All 111 negative tests passed. - Golden baseline: all 294 entries match
tests/golden.txt. - Census audit: 0 files over 500 lines, 0 functions over 80 lines, 0 functions with more than 5 parameters excluding self.
- Clippy: 0 warnings with
-D warningsacross all targets.