Skip to content

bugfixes July 25 2026 - #2199

Merged
SchoolyB merged 34 commits into
mainfrom
bugfixes/july-25-2026
Jul 25, 2026
Merged

bugfixes July 25 2026 #2199
SchoolyB merged 34 commits into
mainfrom
bugfixes/july-25-2026

Conversation

@SchoolyB

@SchoolyB SchoolyB commented Jul 25, 2026

Copy link
Copy Markdown
Member

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

SchoolyB and others added 30 commits July 24, 2026 00:47
…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.
)

The prescan re-tokenized the full input to collect struct/enum names,
but every call site already fell back to the uppercase-first-letter
check which handles all cases — the type system itself requires
uppercase for struct/enum names.
)

Replace 9 redundant full scans of the statement array with a single
pass that buckets statements by kind (enum, func, var, other), then
iterates per-bucket. Struct declarations already collected in pass 1
are reused for topo sort, generic instantiation, JSON helpers, and
struct function emission.
…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.
)

Covers i256, u256, and large division to exercise the borrow
propagation fix across max-value limbs.
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.
@github-actions github-actions Bot added documentation Improvements or additions to documentation lexer Related to tokenization and lexical analysis parser Related to parsing and AST construction typechecker Related to type checking and validation module-system Related to imports, exports, and module loading stdlib General standard library issues tests Related to unit tests or test infrastructure error-messages Related to improving error messages CI/CD Continuous Integration/Continuous Deployment cli Command-line interface related grayc Related to the grayscale compiler core or its internal tooling labels Jul 25, 2026
@SchoolyB SchoolyB changed the title fix: July 2026 batch bug fixes bugfixes July 25 2026 Jul 25, 2026
@SchoolyB
SchoolyB merged commit 2370c54 into main Jul 25, 2026
@SchoolyB
SchoolyB deleted the bugfixes/july-25-2026 branch July 25, 2026 05:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CI/CD Continuous Integration/Continuous Deployment cli Command-line interface related documentation Improvements or additions to documentation error-messages Related to improving error messages grayc Related to the grayscale compiler core or its internal tooling lexer Related to tokenization and lexical analysis module-system Related to imports, exports, and module loading parser Related to parsing and AST construction stdlib General standard library issues tests Related to unit tests or test infrastructure typechecker Related to type checking and validation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: #flags enums rejected by bitwise operators, defeating their purpose

1 participant