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
Field access is resolved as a call to any same-named function in the program #448
value.field is taken as the UFCS call field(value) whenever a function of that name is visible, and it wins over the record's own field. Depending on the case this is a type error, a wrong value, or (in a spec with Harmat) a silently wrong result.
Cases
1. Wrong value at run time. With using Harmat.Schema, only: [text] in scope:
record Statement do
text : String
values : [String] = []
end
let q = Statement { text: "SELECT 1" }
Assert.equal(q.text, "SELECT 1")
# expected SELECT 1, got Harmat.Schema.TextColumn { label: Statement { text: SELECT 1, values: [] } }
q.text ran text(q). Harmat.Query already names its field statement for this reason, citing an in-repo precedent in regex.kex.
2. Type error against a prelude function. A record with a name field, reached through a method declared in another file:
let mortgage = draft.holding
Assert.equal(mortgage.name, "Home mortgage")
# error: `name` expects argument 1 to be Weekday, but got Holding
# name : Weekday -> String
and likewise `value` expects 2 argument(s), got 1 for a value field.
3. Inside .ket templates. With a typed parameter section: Section whose record has a code field, and an unrelated App.Models.Kind.code : Kind -> String elsewhere in the program (not imported by the template's module):
<template>:1:9: error: `code` expects argument 1 to be App.Models.Kind.Kind, but got Section
The same for fields named name, value, kind, facts, plural, singular.
Expected
When the receiver's static type is a record with that field, the field wins. A same-named function should only be considered when the type has no such field.
Workaround
Field names that no function shares (title, caption, content, anchor…), which gets harder as a program grows.
Related: #242 and #234 (closed) covered narrower versions of this.
Environment: Kex 0.4.0-rc.1 (30c7979), Tey 0.2.1, Erlang/OTP 29.0.5 (Homebrew), macOS arm64. Found while building an application on Rodolfo 0.2 and Harmat 0.1.
Fixed on current main (0fd796c) by #478 and #482. All three cases were checked on both backends, with the colliding function in another module of the program:
q.text on a Statement with an imported text function in scope gives SELECT 1.
mortgage.name and mortgage.value on a record reached through another module's function give the fields.
In a .ket template with params: [section: Section], section.code reads the field while another module defines code : Kind -> String.
Activity
akoskovacs commentedon Oct 17, 2026
Fixed on current
main(0fd796c) by #478 and #482. All three cases were checked on both backends, with the colliding function in another module of the program:q.texton aStatementwith an importedtextfunction in scope givesSELECT 1.mortgage.nameandmortgage.valueon a record reached through another module's function give the fields..kettemplate withparams: [section: Section],section.codereads the field while another module definescode : Kind -> String.