Skip to content

Commit

Permalink
fix(compiler-core): check if expression is constant
Browse files Browse the repository at this point in the history
closes #7973
  • Loading branch information
sxzz committed Mar 28, 2023
1 parent 63ad77f commit 3df3354
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions packages/compiler-core/src/transforms/transformExpression.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,11 @@ export function processExpression(
const isDestructureAssignment =
parent && isInDestructureAssignment(parent, parentStack)

if (isConst(type) || localVars[raw]) {
if (
isConst(type) ||
type === BindingTypes.SETUP_REACTIVE_CONST ||
localVars[raw]
) {
return raw
} else if (type === BindingTypes.SETUP_REF) {
return `${raw}.value`
Expand Down Expand Up @@ -371,8 +375,6 @@ export function stringifyExpression(exp: ExpressionNode | string): string {

function isConst(type: unknown) {
return (
type === BindingTypes.SETUP_CONST ||
type === BindingTypes.LITERAL_CONST ||
type === BindingTypes.SETUP_REACTIVE_CONST
type === BindingTypes.SETUP_CONST || type === BindingTypes.LITERAL_CONST
)
}

0 comments on commit 3df3354

Please sign in to comment.