- Parser_Parse: add beforePos safeguard to skip unrecognized tokens
instead of looping forever when parserParseDecl returns null
- Lexer: increase maxTokens 4096 -> 32768; add explicit break on limit
- CLI: null-check ReadFile result before String_Eq
- Nim CLI: add -O2 to cc invocation for faster self-hosted builds
- Added exprSpawnAsync flag to AST ekSpawn
- Sema checks if callee is async and sets the flag
- HIR hSpawn carries spawnAsync flag
- C backend uses bux_task_spawn for non-async (OS threads) and bux_async_spawn for async (coroutines)
- Added concurrency example to test suite
- T[] slices are now fat pointers {data: T*, len: size_t} in C backend
- Added hSliceIndex HIR node for slice indexing (distinct from hIndexPtr for raw pointers)
- Added exprIndexBoundsCheck flag to AST ekIndex
- Sema sets bounds-check flag in @[Checked] functions
- C backend emits Slice_<T> typedefs and compound literals for slice init
- bux_bounds_check() called automatically on slice indexing in @[Checked] funcs
- Unchecked functions allow raw access (C behavior) for performance
- Lexer tokenizes 'a as tkLifetime
- Parser accepts lifetimes in type params <'a> and reference types &'a T / &'a mut T
- AST TypeExpr has refLifetime field for tekRef/tekMutRef
- TypeParam gains isLifetime flag for generic monomorphization
- Sema infers lifetime params as no-op dummy values; unwraps pointee types for params inside refs
- HIR lower skips lifetime params when generating mangled names and substitution tables
- &mut expr syntax supported in parser (consumed as part of unary &)
Self-hosted compiler (buxc2):
- Add async/await/spawn tokens, parsing, HIR, lowering, C emission
- Fix pointer type emission (*T -> T*) in C backend
- Fix sizeof(Type) parsing with parentheses
- Fix import ::{...} infinite loop guard
- Fix int64 emission by avoiding else-if chain workaround
- Add debug-free cli and hir_lower
Bootstrap compiler (Nim):
- Fix critical else-if lowering bug in hir_lower.nim:
when both elseIfs and else block exist, elseIfs were dropped
causing all else-if chains to collapse to if+else only
Runtime:
- Fix bux_async_await memory corruption (don't free in run)
- Add bux_remove_from_ready for safe cleanup
- Fix forward declaration and deduplicate bux_now_ms
Docs & examples:
- Update async.bux example with proper int64 params
- Update README, LanguageRef, Stdlib, PLAN for async features
- Mark Phase 7.10 bootstrap loop as completed
All 27 examples pass. buxc2 check/build work on all examples.
- runtime: bux_async_return(value, size) copies result to task->result
- runtime: bux_async_await returns void* result pointer
- runtime: bux_async_result(handle) to retrieve result
- sema: ekAwait returns *void
- HIR: await lowered to bux_async_await returning *void
- Example: async Compute() -> int with interleaved execution and result await
Runtime:
- bux_argc()/bux_argv() — command-line arg access from Bux programs
- g_argc/g_argv globals — set by C main() wrapper
Compiler:
- C backend generates extern g_argc/g_argv + int main(argc,argv) wrapper
- main.bux reads args via bux_argc/bux_argv and passes to Cli_Run
buxc2 verified:
- buxc2 version — reads CLI args correctly
- buxc2 check <file.bux> — lexes, parses, type-checks, generates C
- buxc2 build <file.bux> <output.c> — writes C output
PLAN.md updated with Phase 7.10 status and remaining work.
All 18 examples pass, all unit tests pass.
- Rewrite Std::Array as fully generic struct Array<T> with generic methods
- Use sizeof(T) for allocation/reallocation instead of hardcoded 8
- Fix method call lowering to lookup receiver type specifically instead of
iterating all methodTable entries (prevents Array_Get matching for Box type)
- Add resolveTypeExpr typeSubst check for unknown named types
- Rename Array method parameters from 'arr' to 'self' for auto-registration
- Auto-register func Type_Method<T>(self: *Type<T>) as methods in sema
- Add type param awareness to sema resolveType for generic function bodies
- Add lazy monomorphization for generic struct method calls in HIR lowering
- Track varTypeExprs in LowerCtx for local variable type inference
- Fix ekSelf in both sema and hir_lower to resolve actual parameter type
- Fix lowerFunc to use substituteType for param/return types (handles pointers to generic structs)
- Auto-address value receivers when method expects pointer (e.g., b.Get() where self: *Box<T>)
- Add C forward declarations for all functions to fix ordering issues
- Relax type checks for tkTypeParam in assignments and arguments
- Update generics_struct example with Box_Get, Box_Set, Pair_GetFirst/Second
- Add generic struct instantiation (Box<int>, Pair<T,U>) in HIR lowering
- Fix tkUnknown/tkNamed/tkTypeParam ambiguity in sema.nim (qualify with TypeKind)
- Add generics_struct example
- Update Makefile with new example
Add standard library modules:
- Std::String: strlen, strcmp, concat, copy, starts_with wrappers
- Std::Map: linear-probing hash map with String keys, int values
Add error handling:
- Result and Option algebraic enum examples
- ? try operator for automatic error propagation in HIR lowering
Compiler bugfixes:
- Fix sizeof() for user-defined structs (new hSizeOf HIR node)
- Fix HIR type lowering for char8, bool8, int8, uint8, etc.
- Fix let statement lowering for pointer types (*char8 → int* bug)
- Fix PrintInt ABI mismatch (int64_t → int in io.c)
- Fix Makefile test bug (_test_tmp_pkg already exists)
Documentation:
- Rewrite README.md with features, examples, project structure
- Add docs/LanguageRef.md — complete language reference
- Add docs/Stdlib.md — standard library documentation
- Add docs/BuildAndTest.md — build and test guide
New examples: strings, map, result_option, try_operator (13 total)
- Parse range expressions in expressions (0..5, 0..=5)
- Add ekRange AST node, hRange HIR node
- Lower for-range to while loop with alloca counter
- Add hBlock.isScope flag for C scope emission
- Update C backend to emit scope blocks only when isScope is set
- Parse module paths in stdlib (module Std::Array { ... })
- Collect stdlib declarations and inject into user modules before sema
- Add dkExternFunc support throughout pipeline (parser, sema, hir, c backend)
- Auto-dereference pointer types for field access (arr->field)
- Add hArrowField HIR node for cleaner C emission
- Fix resolveTypeExpr for pointer and cast types
- Fix struct field lowering to use resolveTypeExpr
- Allow int <-> uint implicit conversion for bootstrap convenience
- Add stdlib/Std/Array.bux with dynamic array primitives
- Add stdlib_test demonstrating Array usage via import Std::Array::{Array};
- C backend: strip c8/c16/c32 string prefixes in emitted C
- C backend: resolve imports to fully-qualified names (Std_Io_PrintLine)
- Parser: fix infinite loop on < in comparisons vs generic calls
- Parser: fix enum patterns without parens (Option::None)
- Parser: fix match expressions inside blocks
- Sema: extract pattern bindings for match arms
- HIR: lower match expressions to if-else chains with enum tag checks
- HIR/C backend: support block expressions as function return values
- Makefile: add integration tests for all 9 examples
- Add pattern_matching.bux example
- Add ekGenericCall to AST for generic function calls (Max<int>)
- Parse generic type arguments in parsePostfix
- Support generic calls in sema with type parameter substitution
- Implement monomorphization in hir_lower:
- Collect generic function declarations
- Find all generic call sites
- Generate specialized versions with mangled names (Max_int)
- Substitute type parameters with concrete types
- Add generics.bux example
Example:
func Max<T>(a: T, b: T) -> T {
if a > b { return a; }
else { return b; }
}
let m: int = Max<int>(10, 20); // Generates Max_int
- Generate tagged unions in C backend for enums with data
- Add HirEnumVariant type with fields and namedFields
- Support _Tag and _Data field access in sema
- Support enum variant constants (Result_Ok, Result_Err)
- Support _Data union field access (Ok_0, Err_0, etc.)
- Add algebraic_enums.bux example
Example:
enum Result {
Ok(int),
Err(String)
}
let r: Result = Result { tag: Result_Ok };
r.data.Ok_0 = 42;
- Add analyzeFull() to return Sema context with method table
- Improve method call desugaring: obj.method() → Type_method(obj)
- Search methodTable by method name when type inference fails
- Add methods.bux example demonstrating struct with extend blocks
- Use analyzeFull in cli.nim for proper method resolution
- Support ekPath in lowerExpr for enum variants (Color::Red → Color_Red)
- Support module paths (Std::Io::PrintLine → Std_Io_PrintLine)
- Add enums.bux example demonstrating enum usage
- Enums now compile and run correctly
- Map tkAssign to '=' in operatorToC
- Add tkAmpAssign, tkPipeAssign, tkCaretAssign, tkShlAssign, tkShrAssign
- Fibonacci program now works correctly with while loops and assignment
- Add stdlib/io.c with PrintLine, Print, PrintInt, PrintFloat, PrintBool, ReadLine
- Support extern function declarations (functions without body)
- Generate C forward declarations for extern functions
- Map Bux type names (String, int, etc.) to C types in codegen
- Update build system to copy all stdlib files
- Hello World example works: prints 'Hello, Bux!'