Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1498 from lukastaegert/master
Correctly handle variables introduced in switch scopes
- Loading branch information
Showing
9 changed files
with
109 additions
and
1 deletion.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import Scope from '../scopes/Scope.js'; | ||
import Statement from './shared/Statement.js'; | ||
|
||
export default class SwitchStatement extends Statement { | ||
initialise ( scope ) { | ||
this.scope = new Scope( { | ||
parent: scope, | ||
isBlockScope: true, | ||
isLexicalBoundary: false | ||
} ); | ||
|
||
super.initialise( this.scope ); | ||
} | ||
} |
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
module.exports = { | ||
description: 'correctly handles switch scopes', | ||
options: { | ||
moduleName: 'myBundle' | ||
} | ||
}; |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
define(function () { 'use strict'; | ||
|
||
const x = globalFunction; | ||
switch ( anotherGlobal ) { | ||
case 2: | ||
x(); | ||
} | ||
|
||
switch ( globalFunction() ) { | ||
case 4: | ||
} | ||
|
||
}); |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
'use strict'; | ||
|
||
const x = globalFunction; | ||
switch ( anotherGlobal ) { | ||
case 2: | ||
x(); | ||
} | ||
|
||
switch ( globalFunction() ) { | ||
case 4: | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
const x = globalFunction; | ||
switch ( anotherGlobal ) { | ||
case 2: | ||
x(); | ||
} | ||
|
||
switch ( globalFunction() ) { | ||
case 4: | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
(function () { | ||
'use strict'; | ||
|
||
const x = globalFunction; | ||
switch ( anotherGlobal ) { | ||
case 2: | ||
x(); | ||
} | ||
|
||
switch ( globalFunction() ) { | ||
case 4: | ||
} | ||
|
||
}()); |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
(function (global, factory) { | ||
typeof exports === 'object' && typeof module !== 'undefined' ? factory() : | ||
typeof define === 'function' && define.amd ? define(factory) : | ||
(factory()); | ||
}(this, (function () { 'use strict'; | ||
|
||
const x = globalFunction; | ||
switch ( anotherGlobal ) { | ||
case 2: | ||
x(); | ||
} | ||
|
||
switch ( globalFunction() ) { | ||
case 4: | ||
} | ||
|
||
}))); |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
const x = globalFunction; | ||
function y () {} | ||
|
||
switch ( anotherGlobal ) { | ||
case 1: | ||
const x = function () {}; | ||
x(); | ||
} | ||
|
||
switch ( anotherGlobal ) { | ||
case 2: | ||
x(); | ||
} | ||
|
||
switch ( anotherGlobal ) { | ||
case 3: | ||
const y = globalFunction; | ||
} | ||
y(); | ||
|
||
switch ( globalFunction() ) { | ||
case 4: | ||
} |