From 6f04609f2499b1dce90f4daa836bafa6d51e0d16 Mon Sep 17 00:00:00 2001 From: Giacomo Cavalieri Date: Sat, 4 Jan 2025 09:56:34 +0100 Subject: [PATCH] add another test --- compiler-core/src/javascript/tests/blocks.rs | 14 +++++++++++++ ..._position_with_just_an_assignment.snap.new | 21 +++++++++++++++++++ 2 files changed, 35 insertions(+) create mode 100644 compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__blocks__block_in_tail_position_with_just_an_assignment.snap.new diff --git a/compiler-core/src/javascript/tests/blocks.rs b/compiler-core/src/javascript/tests/blocks.rs index 8c45f0c271a..778c60d67ca 100644 --- a/compiler-core/src/javascript/tests/blocks.rs +++ b/compiler-core/src/javascript/tests/blocks.rs @@ -245,3 +245,17 @@ fn b() { "# ); } + +#[test] +fn block_in_tail_position_with_just_an_assignment() { + assert_js!( + r#" +fn b() { + let x = 1 + { + let x = x + } +} +"# + ); +} diff --git a/compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__blocks__block_in_tail_position_with_just_an_assignment.snap.new b/compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__blocks__block_in_tail_position_with_just_an_assignment.snap.new new file mode 100644 index 00000000000..16553032ad6 --- /dev/null +++ b/compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__blocks__block_in_tail_position_with_just_an_assignment.snap.new @@ -0,0 +1,21 @@ +--- +source: compiler-core/src/javascript/tests/blocks.rs +assertion_line: 251 +expression: "\nfn b() {\n let x = 1\n {\n let x = x\n }\n}\n" +--- +----- SOURCE CODE + +fn b() { + let x = 1 + { + let x = x + } +} + + +----- COMPILED JAVASCRIPT +function b() { + let x = 1; + let x$1 = x; + return x$1; +}