Fix class transpile issue with child class constructor not inherriting parent params#1390
Merged
TwitchBronBron merged 12 commits intomasterfrom Jan 13, 2025
Merged
Conversation
src/parser/Statement.ts
Outdated
Comment on lines
2183
to
2184
| // @todo: somehow, ancestors can have a list where the last element is null. | ||
| // this is exposed by the test named "extending namespaced class transpiles properly". |
Collaborator
There was a problem hiding this comment.
There's likely to be a bug in getAncestors, specifically with this part:
const namespace = this.findAncestor<NamespaceStatement>(isNamespaceStatement);
stmt = state.file.getClassFileLink(
stmt.parentClassName.getName(ParseMode.BrighterScript),
namespace?.getName(ParseMode.BrighterScript)
)?.item;
ancestors.push(stmt);In some cases (namely the test mentioned in the comment), stmt is null and yet it still gets pushed to the result array. I'll try and figure out where exactly it's becoming null.
Collaborator
There was a problem hiding this comment.
I believe the problem is:
this.findAncestor<NamespaceStatement>(isNamespaceStatement)Which should actually be:
stmt.findAncestor<NamespaceStatement>(isNamespaceStatement)@TwitchBronBron is it okay if I make that change in this PR? Or would you rather have a separate one for this fix?
Member
Author
There was a problem hiding this comment.
Yeah that's fine, go ahead and fix it in this PR.
TwitchBronBron
commented
Jan 13, 2025
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.
When a child class extends a super class, but does not include its own
newfunction, and the parent class has parameters, we are missing those parameters in the child class's factory.