fix(compiler-sfc): fix TLA codegen semicolon insertion

fix #4596
This commit is contained in:
Evan You
2021-09-16 16:49:59 -04:00
parent ae942cdcd9
commit 39cebf5f7a
3 changed files with 92 additions and 17 deletions

View File

@@ -96,6 +96,36 @@ export default /*#__PURE__*/ Object.assign(__default__, {
})"
`;
exports[`SFC compile <script setup> async/await detection await in expression statement 1`] = `
"import { withAsyncContext as _withAsyncContext } from 'vue'
export default {
async setup(__props, { expose }) {
expose()
let __temp, __restore
foo()
;(
([__temp,__restore] = _withAsyncContext(() => {
return 1
})),
__temp = await __temp,
__restore(),
__temp
) + (
([__temp,__restore] = _withAsyncContext(() => {
return 2
})),
__temp = await __temp,
__restore(),
__temp
)
return { }
}
}"
`;
exports[`SFC compile <script setup> async/await detection expression statement 1`] = `
"import { withAsyncContext as _withAsyncContext } from 'vue'
@@ -109,7 +139,8 @@ let __temp, __restore
return foo
})),
__temp = await __temp,
__restore()
__restore(),
__temp
)
return { }
}
@@ -137,7 +168,8 @@ let __temp, __restore
))
})),
__temp = await __temp,
__restore()
__restore(),
__temp
)
return { }
}
@@ -165,7 +197,8 @@ let __temp, __restore
)))
})),
__temp = await __temp,
__restore()
__restore(),
__temp
)
return { }
}
@@ -200,7 +233,8 @@ let __temp, __restore
))
})),
__temp = await __temp,
__restore()
__restore(),
__temp
)
return { }
}
@@ -216,18 +250,20 @@ export default {
expose()
let __temp, __restore
if (ok) { ;(
if (ok) { (
([__temp,__restore] = _withAsyncContext(() => {
return foo
})),
__temp = await __temp,
__restore()
) } else { ;(
__restore(),
__temp
) } else { (
([__temp,__restore] = _withAsyncContext(() => {
return bar
})),
__temp = await __temp,
__restore()
__restore(),
__temp
) }
return { }
}
@@ -301,6 +337,28 @@ return { cls }
}"
`;
exports[`SFC compile <script setup> async/await detection single line conditions 1`] = `
"import { withAsyncContext as _withAsyncContext } from 'vue'
export default {
async setup(__props, { expose }) {
expose()
let __temp, __restore
if (false) (
([__temp,__restore] = _withAsyncContext(() => {
return foo()
})),
__temp = await __temp,
__restore(),
__temp
)
return { }
}
}"
`;
exports[`SFC compile <script setup> async/await detection variable 1`] = `
"import { withAsyncContext as _withAsyncContext } from 'vue'