Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Weird implicit cast hangs the compiler in pattern matching. #10082

Open
back2dos opened this issue Jan 21, 2021 · 2 comments
Open

Weird implicit cast hangs the compiler in pattern matching. #10082

back2dos opened this issue Jan 21, 2021 · 2 comments

Comments

@back2dos
Copy link
Member

back2dos commented Jan 21, 2021

class Test {
  static function main() {
    final v = new Vector([1, 2]);
    switch v {
      case [1,2]: true;
      case _: false;
    }
  }
}

abstract Vector<T>(Array<T>) {
  public inline function new(a)
    this = a;
  @:from static function fromVector<T, R:T>(v:Vector<R>):Vector<T>
    return cast v;
}

Compiler seems to be stuck in a loop. From haxetink/tink_pure#18

@RealyUniqueName
Copy link
Member

It loops in these lines of function pattern:

haxe/src/typing/matcher.ml

Lines 403 to 405 in 0dc581c

| TAbstract(a,tl) ->
begin match TyperBase.get_abstract_froms a tl with
| [t2] -> pattern t2

TyperBase.get_abstract_froms a tl returns Vector<?> every time and that goes into pattern call again.

@RealyUniqueName RealyUniqueName added this to the Bugs milestone Jan 21, 2021
Simn added a commit that referenced this issue Feb 16, 2021
@Simn Simn self-assigned this Feb 16, 2021
@Simn
Copy link
Member

Simn commented Feb 16, 2021

I have fixed the hang because hanging sucks, but I'm a bit confused about this code checking for abstract @:from in the first place. Where would that casting code even be inserted...

@Simn Simn modified the milestones: Bugs, Later Mar 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants