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
private method in a make block: uncallable from sibling methods, callable from outside the block #281
Found while migrating rodolfo's examples/library to one module per file. Toolchain: kex 0.4.0-beta.2 (6ccdf35).
Two facets, same area — private inside a make block behaves exactly inverted from what docs/modules.md promises ("private in a make block — only callable within that make"):
1. A private make-method cannot be called from a sibling method in the same block
# src/thing.kex
module Thing
record Thing do
name : String
end
make Thing do
shouted :> String
let shouted = decorate(@name)
private do
decorate : String -> String
let decorate(text) = "${text}!"
end
end
# src/main.kex
using Thing, only: [Thing]
main do
IO.printLine(Thing { name: "kex" }.shouted)
end
kex -R --source-root src src/main.kex:
error: could not compile Kex.Thing: {error,
[{"Kex.Thing",
[{none,core_lint,
{undefined_function,
{decorate,1},
{shouted,1}}}]}],
[]}
The call passes the type checker and fails at Core Erlang lint: the private method is apparently not emitted as a function the sibling can reach.
2. A private make-method is callable from another module's make block
# src/thing.kex
module Thing
record Thing do
name : String
end
make Thing do
private do
secret :> String
let secret = @name
end
end
# src/uses.kex
module Uses
using Thing, only: [Thing]
make [Thing] do
firsts :> [String]
let firsts = this.map { |thing| thing.secret }
end
# src/main.kex
using Thing, only: [Thing]
using Uses
main do
IO.printLine("${[Thing { name: \"x\" }].firsts}")
end
Prints [x] — the private method secret is reached from a different module's make block, which the docs forbid.
Workaround
Helpers that a make-method needs go in a module-level private do ... end block instead; module-private functions are callable from make-methods in the same module:
make Thing do
shouted :> String
let shouted = decorate(@name)
end
private do
decorate : String -> String
let decorate(text) = "${text}!"
end
Verified fixed on current main. Facet 1: a private make-method (decorate) is callable from a sibling method (shouted) — compiles and prints on interpreter and BEAM. Facet 2: reaching secret from another module's make block is now rejected at check time: ``secretis private tomake Thing.Thing` in `Thing` — it is only callable inside that block`, matching docs/modules.md.
Activity
akoskovacs commentedon Sep 7, 2026
Verified fixed on current main. Facet 1: a private make-method (
decorate) is callable from a sibling method (shouted) — compiles and prints on interpreter and BEAM. Facet 2: reachingsecretfrom another module's make block is now rejected at check time: ``secretis private tomake Thing.Thing` in `Thing` — it is only callable inside that block`, matching docs/modules.md.