August 1, 2026 batch - #2227
Merged
Merged
Conversation
…#2189) Add pointer aliasing and const-sourced pointer documentation to Section 3.1.10 and safety table rows to Section 11.7, reflecting current compiler behavior after the addr() const changes.
Clarify E3122 to "cannot modify value through pointer; the pointee is a const-declared variable" and update the call site comment and integration test descriptions to match.
Add `gray cross build` and `gray cross targets` commands that route the C compilation step through `zig cc` for cross-platform builds. Zig is only required for cross-compilation — native builds are unchanged. Adds `--cc` flag to grayc so the Go CLI can override the C compiler, a target map (linux-amd64, linux-arm64, windows-amd64, mac-arm64, mac-amd64), and Go unit tests for target validation, flag wiring, and error handling.
new() previously only accepted struct types. It now works with primitives, sized integers, floats, arrays, maps, enums (regular, string, tagged), and arbitrarily nested collection types.
…ant zeroing (#2151) Split gray_arena_alloc into a zeroing wrapper and an uninitialized core. Callers that immediately overwrite the allocation (string ops, array growth, map rehash/clone, bigint conversions) now skip the redundant memset, eliminating double-writes on hot paths.
Add man doc blocks to threads, sync, channels, and atomic headers. Fix malformed man blocks in channels.h. Skip unqualified man lookup for stdlib names that collide with language keywords (e.g. gray man or shows the keyword; gray man atomic.or shows the atomic op).
…revent spurious E4017 (#2197) The Pass 3 generic re-check loop did not save/restore current_struct_name, causing private-access checks to treat calls from within a struct function as external calls when the function used wildcards.
…ations (#2215) These were superseded by mem.init and mem.destroy but their table entries remained, allowing invalid code to pass typechecking and fail at C compilation.
…egfault The inline assignment `(result = ...) != NULL` clobbered `result` with NULL when the lookup returned nothing, replacing the TYPE_UNKNOWN default and causing a segfault in the typechecker test suite.
…-return, error handling, pointers, containers (#2212)
Define GRAY_SYNTH_PREFIX, GRAY_SYNTH_TMP, and GRAY_SYNTH_OR in ast.h and replace hardcoded "_gray_tmp", "_gray_or", and "_gray_" strings in parser.c, typechecker.c, and codegen.c.
Cover strings, arrays, maps, math, fmt, encoding, and strconv with direct C unit tests exercising happy paths, edge cases, and result-returning error variants.
…codes (#2214) Adds dedicated fail tests for 42 single-file error codes and 2 multi-file error codes that had no integration test coverage. Covered codes: E1005, E2013, E2062, E2074, E2075, E2076, E2079, E2080, E2081, E2083, E2087, E3007, E3038, E3072, E3075, E3076, E3077, E3078, E3079, E3080, E3081, E3086, E3087, E3088, E3095, E3100, E3111, E3112, E3113, E3114, E3115, E3116, E3125, E3127, E3128, E3129, E4004, E4012, E4014, E5012, E5013, E5027, E5035, E6004.
…name E4006 test (#2226) Remove E3067 from error registry (duplicate of E3027, never emitted). Fix E4021 private type alias check to strip module prefix before comparing (lib_ID -> ID) so cross-module private alias access is correctly rejected. Rename E4006_private_function_access test directory to E4015 to match the error code it actually triggers.
|
|
||
| void *gray_arena_alloc(GrayArena *arena, size_t size) { | ||
| void *ptr = gray_arena_alloc_uninitialized(arena, size); | ||
| memset(ptr, 0, ALIGN_UP(size, 8)); |
| memcpy(sname_buf, fs->name, prefix_len); | ||
| sname_buf[prefix_len] = '\0'; | ||
| if (is_struct_name(checker, sname_buf)) | ||
| checker->current_struct_name = sname_buf; |
| continue; | ||
| } | ||
| if (strcmp(argv[i], "--cc") == 0 && i + 1 < argc) { | ||
| cc_override = argv[++i]; |
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, new features, added test coverage, documentation updates, performance & security improvements, and general cleanup.
Features
aliaskeyword for creating type aliases (feat: type aliasing with the alias keyword #2136)zig ccbackend support via CLI (feat: add gray cross command for cross-compilation via Zig #2093)new()builtin function now supports all primitive types and collection tyoes — extend builtinnew()beyond structs to primitives, enums, and collections (feat: extend new() to support all types, not just structs #2193)Bug Fixes
Security
arc4random/urandominstead oftime(NULL)(bug: random and math modules seed PRNG with time(NULL) #2180)Performance
typechecker_lookup_using_constantresult (perf: typechecker_lookup_using_constant called twice on same label #2149)gray_arena_alloc_uninitializedto eliminate redundant zeroingTests
GrayArena,GrayString,GrayArray,GrayMap(tests: expand unit test coverage for runtime, stdlib, and codegen #2212)Documentation
mem,crypto,regexmodules (feat: add gray man documentation for remaining 26 stdlib modules #1701)arrays.any()andarrays.all()(feat: add gray man documentation for remaining 26 stdlib modules #1701)new()man page (feat: extend new() to support all types, not just structs #2193)Misc.
ast.h,scope.cfiles and remove deadmem.make()/mem.free()registrationsgray verifystep to CI (tests: add end-to-end tests for CLI commands #2213)