Repository navigation
Emit algebra length on host String as string_length - #13567
gunbai-bot[bot] wants to merge 11 commits into
Conversation
The method form already remapped .length on a string receiver; the function form called the generic FreeMonoid body and rustc reported E0308. One decision now covers both spellings. Co-authored-by: Cursor <cursoragent@cursor.com>
A leaf-name rewrite would replace any function called length whose first argument is String. The homonym control (constant 99) stays red if that happens. Co-authored-by: Cursor <cursoragent@cursor.com>
|
Addressed review 77804: lowering now keys on The advisory (route the function form through the existing method-path decision) is left for a later change: those two sites still do not share one fold, and unifying them is a larger emitter refactor than this E0308 repair. |
Leaf-name String also matches v2.std.text.String (structural FreeMonoid), which made emit-build E0308 at string_split_step. Co-authored-by: Cursor <cursoragent@cursor.com>
A homonym named length made every bare length an unimported two-declarer and failed the floor. The control still returns 99 from a uniquely named body so a blanket String rewrite would go red. Co-authored-by: Cursor <cursoragent@cursor.com>
briansrls
left a comment
There was a problem hiding this comment.
NO-LAND at exact head 62b8104.
The production decision itself is coherent. rust_call_target_is_v2_algebra_length admits only the resolved v2.std.algebra.length declaration—directly as SourceDeclarationCall, or through a RuntimePrimitiveCall.projected_from carrying that declaration—and the host-String judgment reads the inferred carrier. Non-String calls fall through to the existing generic path, so list length is unchanged. Moving request_field back to modeled length rather than retaining a call-site string_length patch is also the right boundary.
The blocker is the claimed homonym RED. At this head native_emission_controls_homonym does not declare a homonym named length; it declares length_constant_ninety_nine and homonym_length_of, and the enrolled case calls homonym_length_of. A regression to the rejected spelling rule—rewrite a host-String call whenever the authored callee leaf is length—would touch neither of those calls, so that case would still return 99 and every control would remain green. It discriminates only an implausibly broad rewrite of every host-String call, not the authority-substitution class review 77804 required.
Please restore a true same-leaf control without adding a second length declaration to the accepted corpus. A fixture outside the source roots compiled by an isolated control is one valid construction: define a user length(String) -> Int returning 99, call it through its resolved source-declaration identity, and require 99, while the real v2.std.algebra.length(String) control still requires scalar count. Equivalently, an emission-level control may construct the two distinct call identities directly, but it must execute the same lowering seam and go red under the old leaf-name predicate. The user homonym must have decl_name == "length" and an owner other than v2.std.algebra.
Exact-head seed, generated, floor, emit-build, and aggregate witnesses are green; generated includes all-target lint and fixed-point regeneration. Those runs do not close this discrimination gap because the enrolled case does not contest the rejected implementation. No other blocker found.
A second fn length under dag/ fails the floor. The specimen is a fixtures/ module compiled by an isolated infer_ emit-check: identity keeps the constant 99; the old leaf predicate would have emitted string_length. Co-authored-by: Cursor <cursoragent@cursor.com>
briansrls
left a comment
There was a problem hiding this comment.
LAND at exact head 6bc35c3.
The blocker from 62b8104 is closed. The fixture is a true same-leaf source declaration outside the accepted source roots: algebra_length_homonym_probe.length(String) -> Int returns 99, and probe calls that declaration with a host String. The isolated witness reads the fixture, compiles it through compile_dag_rust_emit_check, inspects the generated target file, requires the constant body, and excludes v1_rt::string_length.
This control is genuinely red under the rejected leaf-name predicate. The fixture call has authored callee leaf exactly length and a host-String argument, so the old rule would lower that call to v1_rt::string_length(...). That token would then appear in src/algebra_length_homonym_probe.rs, trip the witness's exclude list, and make the claim fail. The control therefore traverses the real emit_typed_call lowering seam; it is not merely a unit test of the identity helper. Under the current rule, the carried declaration owner is algebra_length_homonym_probe, not v2.std.algebra, so the special lowering declines and the user function remains the callee.
The complementary isolated probe still requires real v2.std.algebra.length over host String to emit v1_rt::string_length(&...) and forbids the generic algebra call. The native controls continue to pin scalar count and unchanged List length. No second length enters the accepted dag/src-v2 corpus because the same-leaf declaration lives under fixtures/ and is supplied only to the nested compile witness.
Exact-head seed, generated, floor, emit-build, and aggregate witnesses all succeeded. Generated includes all-target lint and stage0 fixed-point regeneration; rust-unit-tests was skipped on the pull-request event by current workflow policy and remains a merge-queue obligation. No other blocker found.
The method arm still asked is_string_typed_expr (leaf name). Both spellings now share rust_algebra_length_lowers_on_host_text so structural String is count, not string_length. Co-authored-by: Cursor <cursoragent@cursor.com>
|
Addressed review 78069: the method arm and the call form now share — sent from tidy-heron-683 |
It restated the emitter's rewrite rule on hand-picked strings and would stay green if emit matched on the leaf. The fixture emit-check already fails that regression. Co-authored-by: Cursor <cursoragent@cursor.com>
|
Addressed review 78097: deleted — sent from tidy-heron-683 |
Co-authored-by: Cursor <cursoragent@cursor.com>
|
Addressed review 78097's successor review 78098: — sent from tidy-heron-683 |
|
Review 78103's seed-census note: not adding a — sent from tidy-heron-683 |
0e1a1c0 to
2ac5150
Compare
Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
2ac5150 to
51c5752
Compare
briansrls
left a comment
There was a problem hiding this comment.
LAND at exact head 51c5752.
The approval at 0e1a1c0 remains valid. The current movement is integration plus regeneration only: 84cbf13 is a two-parent merge whose parents are the approved head and main at ded96bd; the final commit 51c5752 modifies only src/v1/stage0/src/v1_compiler_emit_rust.rs to bring the generated mirror up to the merged authority. No branch-owned lowering rule or control changed.
The previously approved declaration-identity gate for v2.std.algebra.length, shared is_host_text_typed_expr carrier decision, true same-leaf external fixture, real algebra-length positive probe, and unchanged List-length control therefore remain intact. The final mirror delta reflects merged-main emitter authority rather than a new semantic choice in this PR.
Exact-head seed, generated, floor, emit-build, and aggregate witnesses all succeeded. Generated includes all-target lint and the stage0 fixed-point check. rust-unit-tests was skipped on the pull-request event under current workflow policy and remains a merge-queue obligation. No blocker found.
Summary
length()E0308:v2.std.algebralengthover hostStringwas emitted as the generic FreeMonoid body (Rc<Vec<T>>). The method form.lengthalready remapped tov1_rt::string_length; the function form did not.request_fieldnow useslengthon the prefix/line (String asFreeMonoid<Char>) instead of a call-sitestring_lengthworkaround.CTRL_BUILD_MODE=local, emptyRUSTC_WRAPPER, privateCARGO_TARGET_DIR): pass 2first_generation_equal=true, 0 installs after the one mirror write ofv1_compiler_emit_rust.rs.Not in this PR
unsupported mock expressionrows (approval_store_receipt_mac_key_id,store_receipt_request_protocol) are brand-cast data rows. That is exactly gunbc#13219 (still open in the merge queue). Duplicating its guard would fork the serializer domain. Verify those two after emit_rust: a data row takes the JSON path only for a literal tree (brand casts/operators no longer emit 'unsupported mock expression') #13219 lands.Test plan
gunbc test //gunbc/instruments:native-emission-controlsholds the three newalgebra_length_*cases.request_fieldno longer E0308.Made with Cursor