Skip to content

is_empty() via len: ask Sema for len's type; bare sm.insert in the #1010 test - #2069

Merged
ehartford merged 1 commit into
withlang-dev:mainfrom
joshhickson:josh/is-empty-len-sema-type
Oct 5, 2026
Merged

ehartford merged 1 commit into
withlang-dev:mainfrom
joshhickson:josh/is-empty-len-sema-type

Conversation

@joshhickson

Copy link
Copy Markdown
Contributor

Follow-up to #1947, for Eric's two non-blocking review notes:

  • lower_is_empty_via_len spelled len()'s return type as ty_i64 by hand, a third copy of a fact Sema owns. It now asks Sema (collection_len_method_return_type("len")) for the type of the len call and of the 0 it compares with. MIR's own older copy (MirBuilder.collection_len_method_return_type, which says usize) is unchanged: it also feeds intrinsic_return_type, so it is a separate change.
  • test/behavior/behav_1010_is_empty_len_family.w: let _h = sm.insert(1) is now a bare sm.insert(1).

No behaviour change: the MIR for s.is_empty() on a str is the same as before (binop(eq, copy _2, const 0ty4) on the len call's result).

Checked on Linux x86_64 (WSL2) with the pinned seed and linux SDK, on 0c09d9f9 plus the one-line fix from #2068 (without it main does not build from the linux seed): :dev green; the test passes on stage1; :deep-debug-tool-tests --no-deps and :drop-audit green; :gate green except the four corpus drift checks of #2060, which fail the same way without this commit. Main has since moved to 1e1b1cd6; neither new commit touches these files or Sema's collection_len_method_return_type. The battery has not been run.

…thlang-dev#1010 test

Review notes on withlang-dev#1947. lower_is_empty_via_len spelled len()'s return type as ty_i64 by hand, a third copy of a fact Sema owns; it now asks Sema (collection_len_method_return_type) for the type of the len call and of the 0 it compares with. The MIR is unchanged (binop(eq, copy _2, const 0ty4) for str.is_empty()). The test discards SlotMap.insert's handle with a bare call, the house style.
@ehartford

Copy link
Copy Markdown
Contributor

Battery GREEN on the stack tip 73f0b39bf, which holds this change (with run tools/battery.w: gate, UAT and battery-checks all rc=0; pinned seed). Marking ready and merging first; the rest of the stack follows.

@ehartford
ehartford marked this pull request as ready for review October 5, 2026 04:10
@ehartford
ehartford merged commit 447b6d2 into withlang-dev:main Oct 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants