Skip to content

Commit e09038e

Browse files
test(semantic): add edge case test for multi-level shadowing detection
Co-authored-by: Tcode-Motion <188012755+Tcode-Motion@users.noreply.github.com>
1 parent 3b2e1b2 commit e09038e

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

‎compiler/semantic/tests/semantic_tests.rs‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,17 @@ fn test_semantic_shadowing_warning() {
6262
assert!(matches!(diags[0].code, ErrorCode::W0010));
6363
}
6464

65+
#[test]
66+
fn test_semantic_shadowing_multiple_levels() {
67+
let (res, diags) = check_source("make x = 10\n{\n make y = 20\n {\n make x = 30\n }\n}");
68+
assert!(res.is_ok()); // Shadowing is allowed, so compile succeeds
69+
assert!(!diags.is_empty());
70+
71+
// We should find W0010 among the diagnostics
72+
let has_shadow_warning = diags.iter().any(|d| d.level == DiagnosticLevel::Warning && matches!(d.code, ErrorCode::W0010));
73+
assert!(has_shadow_warning, "Expected W0010 shadowing warning, but diagnostics were: {:?}", diags);
74+
}
75+
6576
#[test]
6677
fn test_semantic_constant_reassignment() {
6778
let (res, diags) = check_source("const x = 10\nx = 20");

0 commit comments

Comments
 (0)