Bugfixes & refactors batch August 8, 2026 - #2303
Merged
Merged
Conversation
…end (#2242) The codegen for arrays.append, insert_at, and prepend was missing TK_ENUM handling in the element type switch, causing it to fall through to the __auto_type default. This produced sizeof(__auto_type) which is invalid C. Now resolves enum types via gray_type_to_c_codegen to emit the correct GrayEnum_<Name> type.
fix(codegen): emit concrete enum type in arrays.append/insert_at/prepend (#2242)
Add sqlite.exec_params and sqlite.query_params functions that accept a SQL string with ? placeholders and a [string] params array, binding values via sqlite3_bind_text to prevent SQL injection. Parameters are bound as text; SQLite handles type affinity internally.
fix(stdlib): add parameterized query API to sqlite module (#1690)
fix(typechecker): resolve implicit enum selectors in struct field defaults (#2223)
fix(stdlib): unescape doubled quotes in csv.parse() quoted fields (#2239)
fix(typechecker): resolve implicit enum selectors in map key bracket access (#2246)
…num patterns in when/is (#2259)
…acros (#2275) Extract duplicated ANSI color macros from error.c and runtime.c into a shared util/colors.h header, and consolidate three near-identical panic functions into a single gray_panic_impl() with thin public wrappers.
…2282) Replace identical static GrayString-to-C-string helpers in net.c, http.c, and regex.c with a single gray_cstr() inline in runtime.h. Also simplify the inline copy in regex.c's compile_pattern().
…#2271) Define a reusable GROW_ARRAY macro in xalloc.h with a named GROW_ARRAY_INIT_CAP constant, replacing 16 inline capacity-doubling blocks across typechecker.c and codegen.c.
…#2270) Move is_unsigned_type, is_signed_int_type, and is_bigint_type from static functions in typechecker.c/codegen.c into shared static inline predicates in types.h. Add is_any_int_type and use it to replace inline strcmp chains in typechecker.c and parser.c.
…#2278) Extract shared cp_to_utf8() and utf8_next() helpers, replacing 3 copies of the encoding cascade and 2 copies of the decoding cascade.
…rconv.c (#2286) Replace 7 copies of the truncate+copy+null-terminate sequence with a shared strconv_prepare() helper.
…2285) Replace 12 identical iteration guard checks with a single macro.
…2248) Enum arrays were read as int64_t (8 bytes) during string interpolation but C enums are stored as int (4 bytes), causing overlapping reads that produced garbage values.
…#2261) Tagged enums are C structs, but interpolation and map codegen paths treated them as int64_t, leaking raw C compiler errors. Add E3041 check for interpolation and new E5041 for map value type declarations.
The parser was counting individual tokens inside tagged enum variant payload parentheses instead of parsing complete type expressions. This caused ^T to be counted as 2 payloads, [T] as 3, and map[K:V] as 6. Replace token counting with parse_complex_type() calls.
…/prepend (#2297) The element type switch in append, insert_at, and prepend was missing TK_CHAR and TK_BYTE cases, causing the codegen to fall through to __auto_type which is not valid in sizeof(). Add char → int32_t and byte → uint8_t mappings.
…t/prepend (#2298) i128/u128/i256/u256 share TK_INT/TK_UINT as their kind, so the element type switch mapped them to int64_t/uint64_t instead of gray_i128 etc. After the switch, resolve via gray_type_to_c_codegen when the kind is TK_INT or TK_UINT to pick up the correct wide type from the name.
The fill codegen path only handled float, bool, and string. Add char, byte, array, map, struct, enum, and wide int (i128/u128/i256/u256) element type mappings, consistent with append/insert_at/prepend.
…2244) p^.func() was rejected as a chained call (E3075) because the member expression object was NODE_POSTFIX_EXPR, not NODE_LABEL. Extend the instance dispatch condition to also accept explicit dereferences of labels. When rewriting the AST for dispatch, replace the postfix node with a fresh NODE_LABEL so the struct name assignment doesn't corrupt the union.
…on (#2277) Replace 4 near-identical copy-pasted families (print/println/eprint/eprintln × 7 types) with 7 core helpers and a PRINT_FAMILY macro that stamps out the 28 public wrappers.
#2280) Consolidate identical encode_le, encode_be, decode_le, and decode_be patterns into BINARY_CODEC macro for flat types (16-64 bit ints + floats). 128/256-bit BE decoders kept hand-written due to multi-limb struct layout.
Extract ParserSnapshot save/restore and scan_paren_bindings helper to replace three near-identical speculative parse blocks for when-pattern detection (explicit, qualified, implicit forms).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR contains several bugfixes as well as changes focusing on maintainability and readability through refactors, performance and optimization improvments.
Summary
Bugfixes
cast()syntaxarrays.fill/append/insert_at/prependwith wide ints/char/byte/enumsor_returnfallback count@csvstdlib module@sqlitestdlib moduleMaintainability and performance optimizations/refactors
gray_cstr()helperGROW_ARRAYmacroARRAY_CHECK_ITERguard macro