Skip to content

Strange unreachable error when mixing base class with other classes w/ function override. #1536

Closed

Description

@AfflatusX

It's hard to describe the issue... so I created a repro here: https://webassembly.studio/?f=025lli7p08dc

The bug requires following conditions to be met:

  1. a base class type needs to be used when creating the instance. In the example, that's line 38. If we create concrete class type, no exception.
  2. we need 2 separate classes, where one inherit another. Base should have a virtual function defined, and Child should overload that. See line 11 and line 1.
  3. invoke the function from a function in a class created in 1. See line 31.

Running the code should yield unreachable exception while the code above is perfectly legal.

I feel the class/interface implementation of AS isn't complete, and it's hard to debug these issues since it will usually just say "unreachable".

Activity

  1. MaxGraey commented on Nov 5, 2020

    @MaxGraey
    Member
  2. dcodeIO commented on Dec 8, 2020

    @dcodeIO
    Member

    Looking at the generated code, for some reason A#callImpl's virtual stub reads like this

     (func $A#callImpl@virtual (param $0 i32) (result i32)
      unreachable
     )

    which is missing the B#callImpl overload. In fact, B#callImpl is not part of the binary, indicating that some sort of tree-shaking is going on, missing that it may still be called.

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

      ⌂ Proxy