Skip to content

Self.make(x) in a method body calls the static method: MIR reads Sema's record of a type receiver (#3335) - #3342

Merged
ehartford merged 1 commit into
mainfrom
self-receiver
Nov 15, 2026
Merged

ehartford merged 1 commit into
mainfrom
self-receiver

Conversation

@ehartford

Copy link
Copy Markdown
Contributor

Self.make(x) in a method body (a trait's default method, or an impl's own) was lowered with a receiver the static method does not take: invalid LLVM (call @i32.Make.make(%str zeroinitializer, %str …)) or "MIR lowering failed".

Exact line. Sema read Self as the type and resolved the call with no receiver (resolved-call args=1). MirLower.lower_method_call asked again whether the receiver named a type, with self.sema.named_types.contains(sym), a table in which Self is bound only while its body is checked; at lowering time it is absent, so the receiver was lowered as a value.

Fix (D65). Sema records the calls whose receiver it read as a type (static_receiver_calls, where the method call's parameter offset is decided); MIR reads that at its three is-static tests instead of deriving it again.

Test: behav_3335_self_static_call_in_method_body (a one-argument and a no-argument static, from a default body, for a primitive and a record). Fails on the installed compiler, passes here; the five reduced programs from the issue pass.

Battery: GREEN on f8e5f9d.

Closes #3335.

…'s record of a type receiver instead of asking named_types, where Self is bound only while its body is checked (#3335)
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.

A default trait method that calls the type's other static methods (Self.a(x)) emits invalid LLVM: an extra receiver argument

1 participant