From 15552ac4999870e4cb3945d6e64c68d80a3173d2 Mon Sep 17 00:00:00 2001 From: Boshen <1430279+Boshen@users.noreply.github.com> Date: Sun, 29 Sep 2024 04:17:26 +0000 Subject: [PATCH] feat(napi/transform): display semantic error (#6160) --- napi/transform/src/transformer.rs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/napi/transform/src/transformer.rs b/napi/transform/src/transformer.rs index 82e9bd99b6354..6e5ce050edbd7 100644 --- a/napi/transform/src/transformer.rs +++ b/napi/transform/src/transformer.rs @@ -97,12 +97,14 @@ pub fn transform( } fn transpile(ctx: &TransformContext<'_>) -> CodegenReturn { - let (symbols, scopes) = SemanticBuilder::new(ctx.source_text()) + let semantic_ret = SemanticBuilder::new(ctx.source_text()) // Estimate transformer will triple scopes, symbols, references .with_excess_capacity(2.0) - .build(&ctx.program()) - .semantic - .into_symbol_table_and_scope_tree(); + .with_check_syntax_error(true) + .build(&ctx.program()); + ctx.add_diagnostics(semantic_ret.errors); + + let (symbols, scopes) = semantic_ret.semantic.into_symbol_table_and_scope_tree(); let ret = Transformer::new( ctx.allocator, ctx.file_path(),