fix(reactivity-transform): should not rewrite catch param (#5711)
fix #5709
This commit is contained in:
parent
86858a9582
commit
1f14f19439
@ -216,6 +216,11 @@ exports[`should not rewrite scope variable 1`] = `
|
|||||||
console.log(d.value)
|
console.log(d.value)
|
||||||
console.log(e)
|
console.log(e)
|
||||||
}
|
}
|
||||||
|
let err = _ref(null)
|
||||||
|
try {
|
||||||
|
} catch (err) {
|
||||||
|
console.log(err)
|
||||||
|
}
|
||||||
"
|
"
|
||||||
`;
|
`;
|
||||||
|
|
||||||
|
@ -222,12 +222,18 @@ test('should not rewrite scope variable', () => {
|
|||||||
console.log(d)
|
console.log(d)
|
||||||
console.log(e)
|
console.log(e)
|
||||||
}
|
}
|
||||||
|
let err = $ref(null)
|
||||||
|
try {
|
||||||
|
} catch (err) {
|
||||||
|
console.log(err)
|
||||||
|
}
|
||||||
`)
|
`)
|
||||||
expect(code).toMatch('console.log(a)')
|
expect(code).toMatch('console.log(a)')
|
||||||
expect(code).toMatch('console.log(b.value)')
|
expect(code).toMatch('console.log(b.value)')
|
||||||
expect(code).toMatch('console.log(c)')
|
expect(code).toMatch('console.log(c)')
|
||||||
expect(code).toMatch('console.log(d.value)')
|
expect(code).toMatch('console.log(d.value)')
|
||||||
expect(code).toMatch('console.log(e)')
|
expect(code).toMatch('console.log(e)')
|
||||||
|
expect(code).toMatch('console.log(err)')
|
||||||
assertCode(code)
|
assertCode(code)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -566,6 +566,16 @@ export function transformAST(
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// catch param
|
||||||
|
if (node.type === 'CatchClause') {
|
||||||
|
scopeStack.push((currentScope = {}))
|
||||||
|
if (node.param && node.param.type === 'Identifier') {
|
||||||
|
registerBinding(node.param)
|
||||||
|
}
|
||||||
|
walkScope(node.body)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
// non-function block scopes
|
// non-function block scopes
|
||||||
if (node.type === 'BlockStatement' && !isFunctionType(parent!)) {
|
if (node.type === 'BlockStatement' && !isFunctionType(parent!)) {
|
||||||
scopeStack.push((currentScope = {}))
|
scopeStack.push((currentScope = {}))
|
||||||
|
Loading…
Reference in New Issue
Block a user