8000 A spec function named options compiles to an undefined options$free/0 when Net.HTTP is imported · Issue #591 · kexhq/kex · GitHub
[go: up one dir, main page]

Skip to content

A spec function named options compiles to an undefined options$free/0 when Net.HTTP is imported #591

Open

Description

@akoskovacs

A zero-argument function named options, declared in a spec file that imports from Net.HTTP, passes the type checker and then fails in erlc:

kex_free.spec: undefined function 'options$free'/0 in main/0
error: erlc failed

Reproduction

# spec/free.spec.kex
using Net.HTTP, only: [Headers]

record Settings do
  limit : Integer
end

foul options() -> Settings = Settings { limit: 3 }

describe("a zero-argument function named options") do
  it("is called by name") do
    Assert.equal(options().limit, 3)
  end
end

tey test in a package containing only this spec fails as above.

Without the using Net.HTTP line, the compiler stops earlier with a clear message:

error: IR lower: `options/1` names both a free function and a receiver method in this compilation unit — rename one of them

So the clash with a method named options (the HTTP verb) is detected in one case. When Net.HTTP is imported, the free function is renamed to options$free, but the call site is not, and the failure surfaces only as an erlc error.

Expected

Either the free function compiles and is called (the name is the spec's own), or the same "names both a free function and a receiver method" diagnostic is reported at the declaration. It should not end in an undefined-function error from erlc.

Kex 0.4.0-rc.3 (1e99345, built 2026-10-27).

Related: #476 (section 4, the same "free function and a receiver method" clash).

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