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
Record name called like a function: Point(x: 1, y: 2) passes the checker, fails on both backends #747
Calling a record's name like a function, Point(x: 1, y: 2), passes kex -C but fails on both backends. The checker doesn't look at the named arguments at all: Point(z: "no") also checks clean.
record Point do
x : Integer
y : Integer
end
main do
let p = Point(x: 1, y: 2)
IO.printLine(p.x)
end
Form
kex -C
BEAM (kex)
walker (kex -R)
Point(x: 1, y: 2)
No errors found
[KEXEB-0030]: Error, IR lower: named args to unknown function Point
Internal error: …:7:11: runtime error: 'Point' is not callable
Point(1, 2)
No errors found
runs, prints 1
Internal error: … 'Point' is not callable
Point(x: 1)
No errors found
—
—
Point(z: "no")
No errors found
KEXEB-0030
'Point' is not callable
Point { x: 1, y: 2 }
No errors found
prints 1
prints 1
Problems
The checker accepts a call on a record name with any arguments: unknown fields, missing fields and wrong types all pass.
BEAM and the walker disagree on positional Point(1, 2): BEAM builds the record, the walker rejects it at runtime.
The walker's failure is reported as an Internal error ("a bug in the Kex compiler") rather than a diagnostic.
Expected: decide whether Point(...) is a constructor call. If it isn't, which the guide suggests (make.md only constructs with Point { … }), the checker should reject it with a diagnostic that points at Point { x: 1, y: 2 }, and lowering should never be reached. If it is, the checker should check the arguments against the fields, and the walker should accept the forms BEAM does.
Activity