You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Documented str.is_empty() has no intrinsic: compiler aborts with internal BUG (core dump) #1010
lib/std/string.w:5 documents s.is_empty() -> bool as a built-in str method, but the method-intrinsic table has no is_empty arm. Calling it aborts the compiler with an internal-contract BUG and a core dump instead of any diagnostic.
Repro (seed stage1 at 450733e; probe .audit/probes/std_str/is_empty_ice.w)
fn main:
let s = "x"
print(if s.is_empty(): "empty" else: "nonempty")
check → BUG: user generic call lacks a concrete contract: body=659(main) call=0 node=6594 sig=-1 mono=0 [src/MirLower.w:14570 MirModule.validate_generic_call_contracts] then Aborted (core dumped). Re-run by primary.
Root-cause chain (verified by reading + execution)
The unresolved method call proceeds into generic-call lowering, where MirModule.validate_generic_call_contracts (MirLower.w:14570) hits the fatal-assertion path for a missing contract — an unreachable-class abort intended for compiler bugs, here reached from ordinary user code calling a documented API.
Sibling methods from the same doc block (len, contains, starts_with, find, to_upper) all resolve — only is_empty is missing, so this is a one-arm omission, not a design gap.
Severity
High: a documented one-line call core-dumps the compiler. Users cannot distinguish "unimplemented" from "broken" — and an abort loses all session diagnostics.
Suggested fix (owner's call)
Add the is_empty arm (desugar to len == 0) or remove it from the doc block; audit the remaining doc-listed methods against the table for siblings (contains/starts_with/ends_with/find/to_upper present — is_empty looks like the only gap, but verify mechanically).
Audit provenance
Read-only end-to-end audit, string-surface leg (child complete examination, independently verified by primary: doc-vs-table comparison + abort re-run). Related: #1007 (Vec intrinsic check gap — same method-table family, distinct defect).
Verdict. Established on current main. lib/std/string.w documents s.is_empty() -> bool as a built-in str method, no is_empty arm exists in the str method-intrinsic table, and calling it aborts with check (and with run) with the internal-contract assertion BUG: user generic call lacks a concrete contract and rc 134. Every sibling in the same doc block that I tried resolves normally, so this is a one-arm omission, as the report says.
Tested revision and compiler
item
value
source
main @ 5809ac1 (2026-09-14); no commit since 450733e adds an is_empty arm for str
compiler
with build of 5809ac1 in a detached worktree, self-reports with v0.15.2.1
platform
macOS Darwin 25.6.0, arm64
Repro
fn main:
let s = "x"
print(if s.is_empty(): "empty" else: "nonempty")
command
result
with check ie.w
BUG: user generic call lacks a concrete contract: body=744(main) call=0 node=7429 sig=-1 mono=0 [src/MirLower.w:14793 MirModule.validate_generic_call_contracts], rc 134
Expected: either nonempty printed, or a normal unknown method 'is_empty' for type 'str' diagnostic.
Source
Doc claim: lib/std/string.w:5s.is_empty() -> bool — true if length is 0. The only is_empty definition in that file is StringBuilder.is_empty (:75), not a str method.
Intrinsic table: src/CodegenDispatch.w:7218-7234 maps len, byte_at, slice, contains, starts_with, ends_with, find, split, trim, to_upper/upper, to_lower/lower, replace, index_of, repeat; no is_empty. The is_empty arms that do exist (:7259, :7285, and MirLower.w:9830/:9856) are for Vec and fixed strings.
Abort: src/MirLower.w:14793sema_phase_bug(...) in validate_generic_call_contracts, the compiler-bug assertion path, reached because Sema let the call through as an unresolved "generic" method and MIR lowering found no contract.
Two defects, as the report frames them
The documented method does not exist (a one-line intrinsic arm, or a str method in the stdlib, would provide it; the spec itself shows the shape at line 3764: fn is_empty() -> bool: self.len() == 0).
§15.1 lists str operations without is_empty; the spec uses is_empty on Vec (lines 814, 3947). So the doc block in string.w over-promises relative to both the spec and the table. Either adding the method or removing the doc line is spec-consistent; the abort is not.
Related PRs
None merged or open touch the str intrinsic table for this. #1007 (closed) was a different Vec table defect.
Would I champion a fix? Yes, both halves are small.
Acceptance criteria:
s.is_empty() on str compiles and returns len() == 0 (intrinsic arm or stdlib method), with a behaviour test.
Sema rejects an unresolvable method call on a builtin type with unknown method '<m>' for type '<T>' before MIR lowering; a test/compile_errors fixture calls a made-up str method and asserts the diagnostic and rc 1, never a BUG: line.
A mechanical audit (a test that parses the doc block at the top of string.w and asserts each listed method resolves) so the doc and the table cannot drift again.
Untested
Whether other doc-listed methods beyond the five I tried also lack arms was not exhaustively checked; criterion 3 covers it. Linux and Windows not executed (pure frontend).
PR #1947 closed this automatically because its description said "Fixes #1010". That was my mistake: it fixes only the abort. The other acceptance criteria are still open (a Sema diagnostic before any phase bug, and the doc-vs-table audit), and Eric's review on #1947 says this issue stays open for them. Could it be reopened?
Activity
ehartford commentedon Sep 16, 2026
Review: reproduced
Verdict. Established on current
main.lib/std/string.wdocumentss.is_empty() -> boolas a built-instrmethod, nois_emptyarm exists in thestrmethod-intrinsic table, and calling it abortswith check(andwith run) with the internal-contract assertionBUG: user generic call lacks a concrete contractand rc 134. Every sibling in the same doc block that I tried resolves normally, so this is a one-arm omission, as the report says.Tested revision and compiler
main@ 5809ac1 (2026-09-14); no commit since 450733e adds anis_emptyarm forstrwith buildof 5809ac1 in a detached worktree, self-reportswith v0.15.2.1Repro
with check ie.wBUG: user generic call lacks a concrete contract: body=744(main) call=0 node=7429 sig=-1 mono=0 [src/MirLower.w:14793 MirModule.validate_generic_call_contracts], rc 134with run ie.ws.len() == 0,s.contains("x"),s.starts_with("x"),s.to_upper(),s.trim()false true true X x, rc 0Expected: either
nonemptyprinted, or a normalunknown method 'is_empty' for type 'str'diagnostic.Source
lib/std/string.w:5s.is_empty() -> bool — true if length is 0. The onlyis_emptydefinition in that file isStringBuilder.is_empty(:75), not astrmethod.src/CodegenDispatch.w:7218-7234mapslen,byte_at,slice,contains,starts_with,ends_with,find,split,trim,to_upper/upper,to_lower/lower,replace,index_of,repeat; nois_empty. Theis_emptyarms that do exist (:7259,:7285, andMirLower.w:9830/:9856) are forVecand fixed strings.src/MirLower.w:14793sema_phase_bug(...)invalidate_generic_call_contracts, the compiler-bug assertion path, reached because Sema let the call through as an unresolved "generic" method and MIR lowering found no contract.Two defects, as the report frames them
strmethod in the stdlib, would provide it; the spec itself shows the shape at line 3764:fn is_empty() -> bool: self.len() == 0).sema_phase_bugabort: an unresolved method on a builtin type should be an ordinaryunknown methoddiagnostic before MIR lowering, the waya.n()on a struct is (Impl method arity is not checked against the trait (types are, D140): an extra parameter fails late #988's control). That is the more important half, since any other missing table arm produces the same core dump.Spec
§15.1 lists
stroperations withoutis_empty; the spec usesis_emptyonVec(lines 814, 3947). So the doc block instring.wover-promises relative to both the spec and the table. Either adding the method or removing the doc line is spec-consistent; the abort is not.Related PRs
None merged or open touch the
strintrinsic table for this. #1007 (closed) was a differentVectable defect.Would I champion a fix? Yes, both halves are small.
Acceptance criteria:
s.is_empty()onstrcompiles and returnslen() == 0(intrinsic arm or stdlib method), with a behaviour test.unknown method '<m>' for type '<T>'before MIR lowering; atest/compile_errorsfixture calls a made-upstrmethod and asserts the diagnostic and rc 1, never aBUG:line.string.wand asserts each listed method resolves) so the doc and the table cannot drift again.Untested
Whether other doc-listed methods beyond the five I tried also lack arms was not exhaustively checked; criterion 3 covers it. Linux and Windows not executed (pure frontend).
is_empty() on str, arrays, slices, HashMap, HashSet and SlotMap lower…
joshhickson commentedon Oct 3, 2026
PR #1947 closed this automatically because its description said "Fixes #1010". That was my mistake: it fixes only the abort. The other acceptance criteria are still open (a Sema diagnostic before any phase bug, and the doc-vs-table audit), and Eric's review on #1947 says this issue stays open for them. Could it be reopened?
is_empty() via len: ask Sema for len's type; bare sm.insert in the #1010
is_empty() via len: ask Sema for len's type; bare sm.insert in the #1010