From 9061dc4a15cdc4fd32e25430f99efc41182de3a6 Mon Sep 17 00:00:00 2001 From: Haoqun Jiang Date: Thu, 9 May 2024 16:45:41 +0800 Subject: [PATCH] test: add a failing test for #10852 --- .../__tests__/compileTemplate.spec.ts | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/packages/compiler-sfc/__tests__/compileTemplate.spec.ts b/packages/compiler-sfc/__tests__/compileTemplate.spec.ts index 45dc54a69db..2ea1eb9d378 100644 --- a/packages/compiler-sfc/__tests__/compileTemplate.spec.ts +++ b/packages/compiler-sfc/__tests__/compileTemplate.spec.ts @@ -1,4 +1,5 @@ import { type RawSourceMap, SourceMapConsumer } from 'source-map-js' +import { parse as babelParse } from '@babel/parser' import { type SFCTemplateCompileOptions, compileTemplate, @@ -452,6 +453,36 @@ test('prefixing edge case for reused AST ssr mode', () => { ).not.toThrowError() }) +// #10852 +test('non-identifier expression in legacy filter syntax', () => { + const src = ` + + ` + + const { descriptor } = parse(src) + const compilationResult = compileTemplate({ + id: 'xxx', + filename: 'test.vue', + ast: descriptor.template!.ast, + source: descriptor.template!.content, + ssr: false, + compilerOptions: { + compatConfig: { + MODE: 2, + }, + }, + }) + + expect(() => { + babelParse(compilationResult.code, { sourceType: 'module' }) + }).not.toThrow() +}) + interface Pos { line: number column: number