|
1 | | -using System; |
2 | | -using System.Collections.Generic; |
3 | | -using System.Linq; |
4 | | -using MiniLang.Syntax; |
| 1 | +using ToyLang.Syntax; |
5 | 2 |
|
6 | | -namespace MiniLang.Semantic; |
| 3 | +namespace ToyLang.Semantic; |
7 | 4 |
|
8 | 5 | public sealed class SemanticAnalyzer |
9 | 6 | { |
@@ -353,7 +350,7 @@ private void ValidateMethodBody(MethodDecl m, ClassInfo? cls, Dictionary<string, |
353 | 350 | foreach (var st in b.Statements) |
354 | 351 | { |
355 | 352 | if (afterReturn) |
356 | | - AddWarning(Stage.Semantic, st.Line, "Dead code xd", hint: null); |
| 353 | + AddWarning(Stage.Semantic, st.Line, "Unreachable code", hint: null); |
357 | 354 | ValidateStmt(st, cls, locals, typeParams, m, inLoop: false); |
358 | 355 | if (st is ReturnStmt) |
359 | 356 | afterReturn = true; |
@@ -449,9 +446,6 @@ private void ValidateStmt(Statement s, ClassInfo? cls, Dictionary<string, Simple |
449 | 446 | break; |
450 | 447 | case IfStmt i: |
451 | 448 | ValidateExprSemantics(i.Condition, cls, locals, typeParams, inMethod: true); |
452 | | - var ct = TryInferExprType(i.Condition, locals, cls?.Fields, typeParams, inMethod: true, currentClass: cls); |
453 | | - if (ct != null && !TypeUtils.IsBoolean(ct)) |
454 | | - AddError(Stage.Semantic, i.Line, "If condition must be Boolean", "if"); |
455 | 449 | var thenLocals = new Dictionary<string, SimpleType>(locals, StringComparer.Ordinal); |
456 | 450 | ValidateStmt(i.Then, cls, thenLocals, typeParams, method, inLoop); |
457 | 451 | if (i.Else != null) |
|
0 commit comments