Repository navigation
Conversation
- #1074: struct-literal array field copy across modules uses memcpy when the struct def is not in the current arena - #1066: &f() spills the call result to a temporary before taking address - #1078: field read through a module-level ptr<T> emits -> - #1046: parse *p = v as a deref-store statement - #1050: array literals in value position get a compound-literal type - #1048: null for span statics (covered by static span null forms test) Co-authored-by: Abhishek Shivakumar <[email protected]>
- #1073: normalize bundle import paths so ../x and x are one module - #952: sizeof<T>() is a sem_check builtin (mangled sizeof_T) - #1080: reject struct value where ptr<T> is expected under typecheck - #986: parse error for `else if` suggests `elif` Co-authored-by: Abhishek Shivakumar <[email protected]>
Co-authored-by: Abhishek Shivakumar <[email protected]>
Array and pointer element types were unknown to expr_prim, so `s + frequency[0]` passed a float into __flowc_str_concat. Resolve the element type of AST_INDEX and format it like other numeric operands. Co-authored-by: Abhishek Shivakumar <[email protected]>
…en stored The path fold added for #1073 ran inside flowc_resolve_append_path, so the module store held folded paths while flowc_resolve_deps_ready and flowc_resolve_topo still looked deps up by the path flowc_resolve_import_at had written. `import "helper.flow"` from a module in the search directory resolves to `./helper.flow`, was stored as `helper.flow`, and the lookup for `./helper.flow` missed. The ordering pass read that as "this dep is not in the bundle", so a module was emitted before the module it imports and the bundle typechecker reported the imported functions as undefined. 98 of the 234 programs under tests/lang stopped building; 87 of them are plain two-module imports. Fold at the single point where an import becomes a path instead, the tail of flowc_resolve_import_at, so the store and every lookup see one form. The fold inside append_path stays and is now idempotent. tests/lang/test_import_path_spelling.flow reaches one module by three spellings, through a module that imports it with a fourth. It fails on main with `redefinition of ips_dep_val` (the bug #1073 fixed) and failed here with `Undefined function ips_mid_val` (the ordering regression). Refs #1073 Co-authored-by: Abhishek Shivakumar <[email protected]>
…1080 Two programs that build on main stopped building on this branch. cgen, struct literals. The #1074 fallback treats a field whose destination type is not in this module's arena as a possible array and memcpy's it. An enum's literal takes that path, because an enum is not an AST_STRUCT, so `Kind { tag: Kind_A }` emitted `memcpy(&sl.tag, &(Kind_A), ...)` and cc refused to take the address of an enum constant. Require a plain name to resolve to a variable before copying it; a field access or an index still does, which is the #1074 case (`Lat { k: a.k }`). sem_check, method receivers. #1080 dropped the blanket struct-to-ptr coercion so `take(m)` with `take(m: ptr<M>)` errors instead of emitting C that cc rejects. The note left the method-receiver case to #1009, but nothing implemented it, so `c.bump(4)` with `bump(c: ptr<Counter>, ...)` became "No matching overload". Accept a struct value for the receiver slot of a method call only, which is where cgen passes `&recv`. A plain call is still an error. Recovered: test_enum_match_arms, test_lowered_forms, test_method_ptr_receiver, test_method_recv_import and test_notation_parser. test_ptr_arg_struct_reject and the #1074 tests still pass, and `take(m)` still errors. Refs #1009, #1074, #1080 Co-authored-by: Abhishek Shivakumar <[email protected]>
…er field #1074 widened the struct-literal copy to fields whose type is only known in another bundle module, and in doing so replaced the source operand of the memcpy with the plain address of the value. That is right for a scalar or an array field, and wrong for a pointer field fed by an array: it copied the array's first bytes into the pointer, so the field held data as an address. examples/dynamics/ga_dsys_syntax.flow faults on its first matrix read, which is the parity_dynamics_dsl e2e failure (exit 139). Choose the source by what the value is. An array value keeps the __builtin_choose_expr form from before #1074, where cc compares the field's type with the type of a pointer to its first element and hands over either the decayed array or its elements. Anything else keeps #1074's plain address, which is what its own case (`Lat { k: a.k }` of an imported struct) needs. tests/lang/test_struct_lit_ptr_field_array.flow fills an imported struct's `ptr<f64>` field from a local array and reads it back; it faults without this. Refs #1074 Co-authored-by: Abhishek Shivakumar <[email protected]>
…struct literal fixes bootstrap_from_c.sh --verify and self_host_full.sh both pass: three consecutive generations are byte-identical. Co-authored-by: Abhishek Shivakumar <[email protected]>
run_lang_tests takes every .flow under tests/lang/ as a program, links it and reads its exit code. The suite has grown files that only export items for a test to import (tests/lang/bpn_m/a.flow and five others), and linking one on its own fails for want of main, so `./flow test-lang` reported six failures that are not tests. Skip a file with no main() and say how many were skipped, so a helper that loses its main is still visible in the count. With this, `./flow test-lang` is 231/233 on this branch. The two failures, test_c_import_dirs and test_dlopen, also fail on main and need headers and a shared library this environment does not have. Co-authored-by: Abhishek Shivakumar <[email protected]>
godofecht
added a commit
that referenced
this pull request
Sep 30, 2026
…1090) Ports the two fixes in #1081 that #1082 did not cover, with their tests. - #1050: an array literal used as a value (indexed, cast or measured with len) gets a compound literal's type, `(int32_t[]){ ... }`, because a bare initializer list is not a C expression. `let a = [1, 2, 3]` takes its element type and dimensions from the literal, and a statement-level literal evaluates nested rows for their effects. - #1048: a module static of type `&[T]` or `&mut [T]` initialised from `null` is the empty span, as `span<T>` already was. Tests, from #1081: `tests/lang/test_array_literal_value.flow`, `tests/lang/test_static_span_null_forms.flow` and the `tests/cgen/array_literal_value` golden. Both lang tests failed on main before this change. Local gates: bootstrap fixed point, self_host_full, roundtrip, cgen 107/0, test-lang 230, every parity gate (parity_shader_dsl only at its Metal step, as always on this Mac), parity_typecheck, typecheck_rules, conformance, mlir_commands 72/72, fuzz, corpus parity and the ratchet.
Contributor
Author
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
Fixes a batch of Stage-A flowc bugs found while porting tools to Flow.
C emitter / parser
memcpys when the struct def is not in the current module arena.&f()spills the call result before taking its address.ptr<T>static emits->.*pdereference is a parse error #1046 — Prefix*p = vparses as a deref-store statement.span<T> = nullemits= NULLfor a struct #1048 —nullfor span statics emits{0}(regression test).find/bsearchwin over the builtin / libc clash.Resolve / typecheck / diagnostics
x/c.flowvsm/../x/c.flow) are one module.sizeof<T>()is a semantic-checker builtin (mangledsizeof_T).ptr<T>is expected is a type error under--strict.else ifparse error should suggestelif#986 —else ifparse error suggestselif.Tests
Bootstrap C regeneration follows in a separate commit.
Fixes #1074
Fixes #1066
Fixes #1078
Fixes #1046
Fixes #1048
Fixes #1045
Fixes #1073
Fixes #952
Fixes #1080
Fixes #986