8000 A private method of a top-level `make` block can be called from outside it · Issue #780 · kexhq/kex · GitHub
[go: up one dir, main page]

Skip to content

A private method of a top-level make block can be called from outside it #780

Open

Description

@akoskovacs

A method in a private do block of a make is rejected when called from outside the block, if the make is inside a module (KEXET-0489). For a make at the top level of the file, the same call checks clean and runs.

record User do
  name : String
end

make User do
  let label -> String = secret

  private do
    let secret -> String = @name
  end
end

main do
  IO.printLine(User { name: "Ada" }.secret)
end

kex -C says No errors found., and kex -R prints Ada. Wrapping the record and the make in module Accounts do ... end gives the expected error:

example.kex:14:16: [KEXET-0489]: Error, `secret` is private to `make Accounts.User` in `Accounts`. It is only callable inside that block

Expected: KEXET-0488 for the top-level case. #281 fixed this for make blocks in modules.

Seen on kex 0.4.0-rc.4 built from main at 371bbdf. Found while writing explanations for oops.kex.run.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      0