feat(napi/transform): display semantic error (#6160)

This commit is contained in:
Boshen 2024-09-29 04:17:26 +00:00
parent f27d59f748
commit 15552ac499

View file

@ -97,12 +97,14 @@ pub fn transform(
} }
fn transpile(ctx: &TransformContext<'_>) -> CodegenReturn { 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 // Estimate transformer will triple scopes, symbols, references
.with_excess_capacity(2.0) .with_excess_capacity(2.0)
.build(&ctx.program()) .with_check_syntax_error(true)
.semantic .build(&ctx.program());
.into_symbol_table_and_scope_tree(); ctx.add_diagnostics(semantic_ret.errors);
let (symbols, scopes) = semantic_ret.semantic.into_symbol_table_and_scope_tree();
let ret = Transformer::new( let ret = Transformer::new(
ctx.allocator, ctx.allocator,
ctx.file_path(), ctx.file_path(),