Skip to content
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

fix(testing): Use program as entry #7221

Closed
wants to merge 1 commit into from

Conversation

magic-akari
Copy link
Member

Description:

BREAKING CHANGE:

Related issue (if exists):
this issue block #7202

@@ -154,20 +154,20 @@ impl<'a> Tester<'a> {
name: &str,
syntax: Syntax,
src: &str,
) -> Result<Module, ()> {
) -> Result<Program, ()> {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this change necessary? I think we can alternatively change only the argument passed to fold_**

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I need to ensure that what fold_with is a program, so the return value has been changed to Program.

let program = program
.fold_with(&mut tr)
.fold_with(&mut as_folder(Normalizer));

convert back to Module might be difficult, as it is possible for it to be parsed as a script.
do you have some good ways to improve it?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You mean you want to use parse_program?
If so, your code is the correct direction

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I want to use visit_mut_program.
If I get Module instead of Program, the visit_mut_program will be skipped.

See https://github.com/swc-project/swc/pull/7202/files#r1159484231

@magic-akari
Copy link
Member Author

There are too many errors about script and module.
I don't know what is the correct behaviour.

Could you fix it? @kdy1

@magic-akari magic-akari closed this Apr 6, 2023
@kdy1
Copy link
Member

kdy1 commented Apr 6, 2023

Of course, I'll do it tomorrow

@magic-akari magic-akari deleted the testing branch April 7, 2023 02:30
@swc-project swc-project locked as resolved and limited conversation to collaborators May 7, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants