Skip to content

#3038, #3039, #3041, #3042, #2958: five spec-gap fixes from the #2987 audit - #3045

Merged
ehartford merged 2 commits into
mainfrom
spec-gaps-2
Nov 5, 2026
Merged

ehartford merged 2 commits into
mainfrom
spec-gaps-2

Conversation

@ehartford

Copy link
Copy Markdown
Contributor

Closes #3038
Closes #3039
Closes #3041
Closes #3042
Closes #2958

Five compiler and stdlib gaps uncovered during the #2987 specification example audit:

  1. Codegen: monomorphizing a generic function inside an async: block leaks async_block_rbuf (LLVM verification failure) #3038 (src/Codegen.w, src/CodegenDispatch.w): pair async_block_rbuf with async_block_fn (self.current_function == self.async_block_fn at TK_RETURN emission) and save/clear across gen_function_mir_mono and gen_async_block, fixing the LLVM IR verification failure (Referring to an argument in another function! store ... ptr %1) when monomorphizing a generic function inside an async: block. Fixture: test/behavior/behav_3038_async_block_mono_call.w.
  2. std.sync (§7.1, §7.5, §7.7, §14.3, §14.17): Mutex.lock() and RwLock.read() / RwLock.write() guard methods missing #3039 (lib/std/sync.w, src/Sema.w, src/SemaCheck.w): add Mutex.lock(), RwLock.read(), RwLock.write(), RwLock.set(value), Scoped[&T] on MutexGuardMut[T] and RwWriteGuard[T], RwLockReadGuard[T] / RwLockWriteGuard[T] generic type aliases (expanding parameterized TY_ALIAS declarations in resolve_generic_type and resolve_generic_type_frozen), and may_suspend + view-store checks in SemaCheck. Fixture: test/behavior/behav_3039_sync_lock_read_write.w.
  3. Comptime (§17.6): str.bytes() / str.as_bytes() fails on (*self) as []u8 cast #3041 (src/ComptimeEval.w, docs/spec/017_metaprogramming.md): support str as []u8 (CV_BYTES), CV_BYTES iteration, Iter[T] struct iteration (eval_struct_iter_to_extras, including implicit Some returns), and unit variants of payload enums (None) in eval_disc_variant_sym, so str.bytes() and str.as_bytes() evaluate in comptime for loops and comprehensions (§17.6; wrapping *%/+% in the DJB2 example). Fixture: test/behavior/behav_3041_comptime_str_bytes.w.
  4. Sema (§10.7, D165): List.traverse does not propagate expected Option[List[U]] / Result[List[U], E] return demand into its closure #3042 (src/SemaCheck.w): propagate an enclosing Option[List[U]] or Result[List[U], E] demand on List.traverse as the closure's expected return type Option[U] / Result[U, E] (§10.7, D165). Fixture: test/behavior/behav_3042_traverse_expected_demand.w.
  5. §18.3: calling a non-pub std function from a program says "undefined variable" instead of naming the visibility rule #2958 (src/Sema.w): walk displaced_fn_index (and unimported std modules when no pub std declaration shares the name) in private_symbol_path_from_current so calling a non-pub std function reports the §18.3 package-privacy error naming the declaring module rather than "undefined variable". Fixture: test/compile_errors/err_2958_private_std_fn_visibility.w.

@ehartford

Copy link
Copy Markdown
Contributor Author

Seed-driven battery GREEN on adb288241 (tools/verdict.w out/battery/battery.log: rc=0 green).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment