8000 `implement:` does not accept a qualified name: `make Fake, implement: FS.File` · Issue #179 · kexhq/kex · GitHub
[go: up one dir, main page]

Skip to content

implement: does not accept a qualified name: make Fake, implement: FS.File #179

Closed

Description

@akoskovacs

make X, implement: Trait accepts only a bare UpperIdent, so a trait or capability that lives inside a module cannot be implemented at all.

module FS2 do
  capability File do
    foul read(path: String) -> String do return "REAL:" + path end
  end
end

record FakeFiles do
  canned : String
end

make FakeFiles, implement: FS2.File do
  foul read(path: String) -> String = @canned + path
end
error: Expected 'do' after make target, got .

parseMakeImplements (src/parser/parser.cxx:689) reads one UpperIdent per entry and never consumes a dotted path.

Why it matters now

It blocks the capability work in #143. A capability's boundary is the innermost module that owns effectful methods — FS.File and FS.Directory, never FS, since FS.Path is pure string manipulation with nothing to substitute. So every realistic capability in the stdlib is nested, and none of them can be implemented until this parses. That in turn blocks converting the stdlib to capability blocks, which blocks deleting Mock.*.

The names already line up on the semantic side: a nested ModuleDef is registered under its qualified name (FS.File), which is exactly what a dotted implement: would need to match.

Activity

  1. added this to the 0.4.0 milestone on Aug 22, 2026
  2. added
    Bug
    on Aug 22, 2026
  3. added
    Confirmed Issue
    on Aug 22, 2026
  4. akoskovacs commented on Aug 22, 2026

    @akoskovacs
    CollaboratorAuthor

    Fixed. parseMakeImplements now consumes a dotted path per entry, so a trait or capability declared inside a module can be implemented:

    module FS2 do
      capability File do
        foul read(path: String) -> String do return "REAL:" + path end
      end
    end
    
    make FakeFiles, implement: FS2.File do
      foul read(path: String) -> String = @canned + path
    end
    
    foul load(p: String) -> String = FS2.File.read(p)
    
    with FS2.File = FakeFiles { canned: "FAKE:" } do
      IO.printLine(load("a.txt"))     # FAKE:a.txt
    end
    

    The names already lined up on the semantic side — a nested ModuleDef is registered under its qualified name — so nothing beyond the parser needed to change.

    The reserved-single-letter check now applies to the whole name rather than each segment: a qualified path is never a type parameter, so A.B is fine while a bare A is still rejected.

    Covered by spec/capabilities.kex, which now exercises a nested capability end to end (declare, implement by qualified name, substitute, restore). This unblocks converting the stdlib to capability blocks, since every realistic capability there is nested — FS.File and FS.Directory are capabilities while FS is not, FS.Path being pure string work with nothing to substitute.

  5. added a commit that references this issue on Aug 22, 2026
    b712888
  6. moved this from Todo to In progress in Kex Roadmapon Aug 23, 2026
  7. moved this from In progress to Done in Kex Roadmapon Aug 23, 2026
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

    BugConfirmed IssueParserTraits

    Type

    No type

    Projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    0