Skip to content

Commit acc5084

Browse files
committed
runtime: Don't call regular method if assignment hash matches
This is a pretty nasty breakage in lookup code that I somehow didn't catch in tests, so I'm adding one for it now. This caused all unary methods that had a single-keyword variant to ignore the single-keyword variant and only use the unary one. This also broke argument sentinel checks but I never noticed it. Ouch!
1 parent b919c45 commit acc5084

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

src/runtime/objects/slots.zig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ pub fn slotsLookup(
145145

146146
const matches_constant = selector.equals(slot_selector);
147147
const matches_assignable = selector.canAssignTo(slot_selector);
148-
if (matches_constant or matches_assignable) {
148+
if (matches_constant or (matches_assignable and slot.isAssignable())) {
149149
return .{
150150
.Found = .{
151151
.object = @ptrCast(object),
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
"Checks for a regression in the lookup code. Suppose we had this object:
2+
(|
3+
foo = 1.
4+
foo: x = (""Do something."").
5+
|)
6+
We would accidentally send a message to `foo' when sending `foo:' to this
7+
object."
8+
9+
(|
10+
parent* = std traits singleton.
11+
12+
foo = (false assert: 'Lookup code broke!').
13+
foo: x = ("Hooray, no regression!").
14+
15+
run = (
16+
foo: 'x'.
17+
).
18+
|) run.

0 commit comments

Comments
 (0)