HaxeFoundation / HaxeFoundation/haxe

Similarly named typedefs in adjacent modules cause overlap.

Open
#11,079 16 comments 0 reactions 0 assignees View on GitHub
Dominant language
Haxe
Stars
6.9k
Forks
715
Avg merge
2d 2h
Merged PRs (30d)
11

Description

Assume the contents of module `A.hx`:
```haxe
class A {
public function new() {}
}

class A_Builder {
public static function build():A { return new A(); }
}

typedef Builder = A_Builder;
```

...and of module `B.hx`:
```haxe
class B {
public function new() {}
}

class B_Builder {
public static function build():B { return new B(); }
}

typedef Builder = B_Builder;
```

As long as I am not defining a typedef that is the same name as an existing module, my expectation is that I would like to be able to refer to `com.example.A.Builder` as `A.Builder` elsewhere in my code, but I get an error that `Builder` is already defined in this package.

My use case is that I am creating a set of externs for Java, and I have a set of classes which have inner classes called `Builder`. The first extern I create works as expected, but the second extern I create fails, and I am forced to prefix the name of the extern to distinguish them to Haxe. This prefixing forces me to change the function name, which means the Haxe library's names are mangled compared to the underlying API.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.