fix(astBuilder): fix export statment#1998
Merged
MaxGraey merged 2 commits intoAssemblyScript:mainfrom Aug 2, 2021
Merged
Conversation
Contributor
Author
|
@willemneal Can you take a look? |
Contributor
|
I'm still unsure what the issue is here. Is it that an AST from |
Contributor
Author
Yes, ASTbuilder does not handle the situation when the In /** Initializes an `export` statement. */
private initializeExports(
/** The statement to initialize. */
statement: ExportStatement,
/** Parent file. */
parent: File,
/** So far queued `export`s. */
queuedExports: Map<File,Map<string,QueuedExport>>,
/** So far queued `export *`s. */
queuedExportsStar: Map<File,QueuedExportStar[]>
): void {
var members = statement.members;
if (members) { // export { foo, bar } [from "./baz"]
for (let i = 0, k = members.length; i < k; ++i) {
this.initializeExport(members[i], parent, statement.internalPath, queuedExports);
}
} else { // export * from "./baz"
let queued: QueuedExportStar[];
if (queuedExportsStar.has(parent)) queued = assert(queuedExportsStar.get(parent));
else queuedExportsStar.set(parent, queued = []);
let foreignPath = statement.internalPath!; // must be set for export *
queued.push(new QueuedExportStar(
foreignPath,
foreignPath.endsWith(INDEX_SUFFIX) // strip or add index depending on what's already present
? foreignPath.substring(0, foreignPath.length - INDEX_SUFFIX.length)
: foreignPath + INDEX_SUFFIX,
assert(statement.path)
));
}
} |
willemneal
approved these changes
Jul 28, 2021
Contributor
willemneal
left a comment
There was a problem hiding this comment.
Okay makes sense to me.
Contributor
Author
|
@MaxGraey Hi, anything wrong ? |
MaxGraey
approved these changes
Aug 2, 2021
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.
Now
export * from "xx"will be built toexport {} from "xx".@willemneal visitor-as also has this problem.
It makes the behavior of the compiler plug-in difficult to understand, because there may be many files that are modified.