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

Class expression with extends clause is removed #2891

Closed
fasttime opened this issue Jun 3, 2019 · 1 comment · Fixed by #2892
Closed

Class expression with extends clause is removed #2891

fasttime opened this issue Jun 3, 2019 · 1 comment · Fixed by #2892

Comments

@fasttime
Copy link
Contributor

fasttime commented Jun 3, 2019

  • Rollup Version: 1.13.1
  • Operating System (or Browser):
  • Node Version: 12.3.1

How Do We Reproduce?

Consider the following exported function containing an anonymous class expression.

export function isConstructor(fn) {
    if (fn === null)
        return false;
    try {
        void class extends fn { };
    } catch {
        return false;
    }
    return true;
}

In the bundled version, the class expression is dropped, causing the function to always branch out of the catch block.

function isConstructor(fn) {
    if (fn === null)
        return false;
    try {
    } catch {
        return false;
    }
    return true;
}

The only way I found to fix the issue is turning off treeshaking completely, which is not desirable.

Expected Behavior

isConstructor(true);   // false
isConstructor(isNaN);  // false
isConstructor(String); // true

Actual Behavior

isConstructor(true);   // true
isConstructor(isNaN);  // true
isConstructor(String); // true
@lukastaegert
Copy link
Member

As a side-effect, #2892 should solve this issue as well without forcing a complicated deoptimization around super class definitions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants