From 635ce55c778eb0ccf0cb0f5d495402dbbb42deb1 Mon Sep 17 00:00:00 2001 From: Li Jin Date: Fri, 20 Feb 2026 21:17:16 +0800 Subject: Skip line-number comments on empty lines in table/class blocks --- spec/cli/test_compilation.sh | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'spec/cli/test_compilation.sh') diff --git a/spec/cli/test_compilation.sh b/spec/cli/test_compilation.sh index 4ddde5a..780f135 100755 --- a/spec/cli/test_compilation.sh +++ b/spec/cli/test_compilation.sh @@ -88,6 +88,27 @@ EOF assert_success "Compile with line numbers" $YUE_BIN -l "$TMP_DIR/test_line.yue" -o "$TMP_DIR/test_line.lua" assert_output_contains "Compiled file should have line comment" "yue" cat "$TMP_DIR/test_line.lua" +cat > "$TMP_DIR/test_line_empty_block.yue" << 'EOF' +x = { + 1 + + 2 +} + +y = + a: 1 + + b: 2 + +Z = class + m: 1 + + n: 2 +EOF + +assert_success "Compile with line numbers for table/class blocks with empty lines" $YUE_BIN -l "$TMP_DIR/test_line_empty_block.yue" -o "$TMP_DIR/test_line_empty_block.lua" +assert_success "Empty lines should not generate standalone line number comments" bash -lc '! grep -Eq "^[[:space:]]*-- [0-9]+$" "$0"' "$TMP_DIR/test_line_empty_block.lua" + # Test 7: Compile with spaces instead of tabs (-s) echo "" echo "Testing compilation with spaces..." -- cgit v1.2.3-55-g6feb