feat: add out of order function calls#282
Open
stringhandler wants to merge 2 commits intoBlockstreamResearch:masterfrom
Open
feat: add out of order function calls#282stringhandler wants to merge 2 commits intoBlockstreamResearch:masterfrom
stringhandler wants to merge 2 commits intoBlockstreamResearch:masterfrom
Conversation
fc68b48 to
d00b714
Compare
Collaborator
|
It is not mentioned in the description, but with this PR types could be also declared out of order, reproduction test: Also this PR introduces regression over duplicated functions, here is the test: |
Contributor
Author
|
Thanks, will fix |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds a double parsing step for analysis in order to allow functions to appear later in the source code.
Motivation:
With the upcoming library references PRs I created a test standard library here. It quickly became clear that it would be difficult to maintain the ordering of function calls so that they were always declared before they were called. This PR removes that restriction by doing a few prechecks before analyzing the parsed tree.
Allowing functions to be declared after they are called now means that extra checks must be done to prevent recursion. Since
mainis treated a little differently, I have not allowed a functionmainto be called.Update
As noted by @KyrylR, types are also allowed to be referenced out of order.