Skip to content

Compile virtual dependencies before finalizing stubs #2040

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

Merged
merged 7 commits into from
Sep 4, 2021
Merged

Conversation

dcodeIO
Copy link
Member

@dcodeIO dcodeIO commented Aug 19, 2021

Should fix #2034 by first compiling virtual overload dependencies so late cross-dependencies are not missed during stub finalization.

  • I've read the contributing guidelines
  • I've added my name and email to the NOTICE file

@MaxGraey
Copy link
Member

Any test which test this issue?

@dcodeIO
Copy link
Member Author

dcodeIO commented Aug 21, 2021

This one is ordering dependent and I haven't yet managed to create a reliable reproduction. Ordering changes in the affected fixtures however indicate that the mechanism fixes ordering.

@MaxGraey
Copy link
Member

I see.

@Scutterman
Copy link

There's a "minimal" reproduction here - about 8 typescript files.
https://github.com/Scutterman/assemblyscript-virtual-bug

@dcodeIO
Copy link
Member Author

dcodeIO commented Aug 30, 2021

Giving the repro a first try, the fix appears to do what it is supposed to

discover assembly/actions/lemmingAction/LemmingAction#label
  assembly/actions/fall/Fall#label, kind=5
discover assembly/actions/lemmingAction/LemmingAction#update
  assembly/actions/fall/Fall#update, kind=5
finalize assembly/actions/lemmingAction/LemmingAction#label
  assembly/actions/fall/Fall#label
  assembly/actions/walk/Walk#label
finalize assembly/actions/lemmingAction/LemmingAction#update
  assembly/actions/fall/Fall#update
  assembly/actions/walk/Walk#update

but the call still produces an unreachable.

@dcodeIO
Copy link
Member Author

dcodeIO commented Aug 30, 2021

Turns out that issue with cross-dependencies runs even deeper. Was able to fix the remaining problem in an ugly way, but feels like there must be a better solution.

@MaxGraey
Copy link
Member

MaxGraey commented Aug 30, 2021

Turns out that issue with cross-dependencies runs even deeper.

What does it mean? It's problem with cyclic class dependencies? Like:
A extends C, B extends C, C extends A ?

@dcodeIO
Copy link
Member Author

dcodeIO commented Aug 30, 2021

There are multiple levels of dependencies that can be discovered, and the fix right now isn't catching all of them. Needs some sort of bookkeeping over multiple loops it seems, say starting at virtual calls and from there on continually checking which stub recently discovered more overloads while compiling until there is nothing left. The levels there are that both virtual calls as well as overloads that aren't itself virtual calls can be discovered, and either of them can discover the other. Kinda a result of the aggressive tree-shaking we do upfront.

@dcodeIO
Copy link
Member Author

dcodeIO commented Sep 3, 2021

Now loops until no more virtual calls or overloads are discovered, which fixes the repro.

@dcodeIO dcodeIO merged commit 115c820 into main Sep 4, 2021
@dcodeIO dcodeIO deleted the issue-2034 branch September 5, 2021 10:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Missing overloads due to virtual stub finalization order
3 participants