bugfixes July 25 2026 - #2199
Merged
Merged
Conversation
…cross-function leaks (#2142)
…ng collision The Go wrapper package shared its name with grayc/, the C compiler source directory. Renamed to "driver" which accurately describes its role as the compiler driver layer. Also added *.stub to gitignore.
…okup (#2154) Replace 7 near-identical format call blocks (printf, printfln, eprintf, eprintfln, sprintf, format, sprintfln) with a shared emit_format_body helper driven by a static table of prefix/newline variants.
…#2153) Extract shared emit_print_variant helper that accepts the C builtin name fragment, replacing four identical ~25-line blocks with single calls.
Replace ~960-line if-else strcmp chain in resolve_stdlib_call() with O(log n) bsearch via existing stdlib_func_meta[] table. Add return_type field to StdlibFuncMeta, populate for all ~320 entries, and delete the redundant _using_funcs[] table (~220 lines). Single source of truth for all stdlib function metadata.
Runtime panics (P0033, P0034, P0035, P0021-P0032, P0078, P0093-P0100, P0002) now print the Grayscale source file and line number instead of the C compiler's __FILE__/__LINE__. This makes debugging runtime errors significantly easier since users see where in their .gray source the panic originated. - Switch gray_panic_code to gray_panic_code_at in array.c, map.c, runtime.c, and all 12 bigint _checked functions - Add GRAY_ARRAY_GET_AT/SET_AT macros; codegen emits these with Grayscale source locations for array index operations - Add file/line params to bigint divmod, div, mod, and 8 cast functions; update codegen to pass source locations - Add file/line params to gray_array_push, gray_map_set, and gray_map_remove; add GRAY_ARRAY_PUSH/GRAY_MAP_SET/GRAY_MAP_REMOVE convenience macros for stdlib callers - Update 11 stdlib files to use the new convenience macros
When a subtrahend limb equals UINT64_MAX and an incoming borrow exists, b.w[i] + borrow wraps to 0, making the comparison always false and silently dropping the borrow. Use a two-part check that avoids the overflow: (a < b) || (a - b < borrow). Fixes gray_i256_sub, gray_u256_sub, and the internal subtraction loop in gray_u256_divmod.
gray_u128_from_decimal and gray_u256_from_decimal performed `*s - '0'` without checking that the character is actually a digit. Non-digit, non-underscore characters silently produced garbage values. Add validation that panics with P0102 on invalid input.
Prevents signed integer overflow in diagnostics when scanning pathologically large files. Counters now clamp instead of wrapping to negative values.
Rearrange the bounds comparison from `used + size > capacity` to `size > capacity - used` to eliminate a possible unsigned overflow when both values are large.
The flags enum codegen used `1 << j` where `1` is a 32-bit signed int, causing undefined behavior at j==31 and wrong results for j>=32. Use `1LL << j` to match Grayscale's 64-bit int type.
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.
Summary
This PR contains several bug fixes across the compiler's core and runtime as well as minor docs updates.
Closes #2133, #2145, #2166, #2168, #2169, #2171, #2178, #2179, #2182, #2183, #2184, #2186, #2188, #2192