X Tutup
Skip to content

Crash when hoisting inside a switch statement #1099

@tomblind

Description

@tomblind
let x = 0;
switch (x) {
    case 1:
        hoisted();
        break;
    case 2:
        function hoisted() {
            console.log("hoisted");
        }
        break;
}

It looks like hoisting inside a switch statement causes a crash inside TSTL:

Exception has occurred: AssertionError [ERR_ASSERTION]: The expression evaluated to a falsy value:

  nativeAssert(value, message)
   at Object.assert (utils.js:67:5)
    at hoistVariableDeclarations (transformation\utils\scope.js:157:21)
    at Object.performHoisting (transformation\utils\scope.js:113:14)
    at Object.transformSwitchStatement [as transform] (transformation\visitors\switch.js:60:26)
    at TransformationContext.transformNode (transformation\context\context.js:44:62)
    at transformation\context\context.js:70:58
    at Array.flatMap (<anonymous>)
    at TransformationContext.transformStatements (transformation\context\context.js:70:40)
    at Object.transformSourceFileNode [as transform] (transformation\visitors\sourceFile.js:29:63)
    at TransformationContext.transformNode (transformation\context\context.js:44:62)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      X Tutup