From e09038e5aec9fbd15750bbe757107c06930c43d6 Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Tue, 25 Aug 2026 09:36:58 +0000 Subject: [PATCH] test(semantic): add edge case test for multi-level shadowing detection Co-authored-by: Tcode-Motion <188012755+Tcode-Motion@users.noreply.github.com> --- compiler/semantic/tests/semantic_tests.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/compiler/semantic/tests/semantic_tests.rs b/compiler/semantic/tests/semantic_tests.rs index ae9f3669..a0667ec5 100644 --- a/compiler/semantic/tests/semantic_tests.rs +++ b/compiler/semantic/tests/semantic_tests.rs @@ -62,6 +62,17 @@ fn test_semantic_shadowing_warning() { assert!(matches!(diags[0].code, ErrorCode::W0010)); } +#[test] +fn test_semantic_shadowing_multiple_levels() { + let (res, diags) = check_source("make x = 10\n{\n make y = 20\n {\n make x = 30\n }\n}"); + assert!(res.is_ok()); // Shadowing is allowed, so compile succeeds + assert!(!diags.is_empty()); + + // We should find W0010 among the diagnostics + let has_shadow_warning = diags.iter().any(|d| d.level == DiagnosticLevel::Warning && matches!(d.code, ErrorCode::W0010)); + assert!(has_shadow_warning, "Expected W0010 shadowing warning, but diagnostics were: {:?}", diags); +} + #[test] fn test_semantic_constant_reassignment() { let (res, diags) = check_source("const x = 10\nx = 20");