Minor improvements to warning messages
This commit is contained in:
parent
e87428b85d
commit
f86925edba
|
@ -1995,7 +1995,7 @@ proc assignment(self: Compiler, node: ASTNode, compile: bool = true): Type {.dis
|
||||||
self.check(node.value, r.valueType)
|
self.check(node.value, r.valueType)
|
||||||
self.expression(node.value, compile)
|
self.expression(node.value, compile)
|
||||||
var position = r.position
|
var position = r.position
|
||||||
if r.depth < self.depth:
|
if r.depth < self.depth and r.belongsTo != self.currentFunction:
|
||||||
self.warning(WarningKind.MutateOuterScope, &"mutation of '{r.ident.token.lexeme}' declared in outer scope ({r.owner.file}.pn:{r.ident.token.line}:{r.ident.token.relPos.start})", nil, node)
|
self.warning(WarningKind.MutateOuterScope, &"mutation of '{r.ident.token.lexeme}' declared in outer scope ({r.owner.file}.pn:{r.ident.token.line}:{r.ident.token.relPos.start})", nil, node)
|
||||||
result = r.valueType
|
result = r.valueType
|
||||||
if not compile:
|
if not compile:
|
||||||
|
@ -2025,7 +2025,7 @@ proc blockStmt(self: Compiler, node: BlockStmt, compile: bool = true) =
|
||||||
if not last.isNil():
|
if not last.isNil():
|
||||||
case last.kind:
|
case last.kind:
|
||||||
of breakStmt, continueStmt:
|
of breakStmt, continueStmt:
|
||||||
self.warning(UnreachableCode, &"code after '{last.token.lexeme}' statement is unreachable", nil, last)
|
self.warning(UnreachableCode, &"code after '{last.token.lexeme}' statement is unreachable", nil, decl)
|
||||||
else:
|
else:
|
||||||
discard
|
discard
|
||||||
self.declaration(decl)
|
self.declaration(decl)
|
||||||
|
@ -2618,7 +2618,7 @@ proc namedBlock(self: Compiler, node: NamedBlockStmt) =
|
||||||
if not last.isNil():
|
if not last.isNil():
|
||||||
case last.kind:
|
case last.kind:
|
||||||
of NodeKind.breakStmt, NodeKind.continueStmt:
|
of NodeKind.breakStmt, NodeKind.continueStmt:
|
||||||
self.warning(UnreachableCode, &"code after '{last.token.lexeme}' statement is unreachable", nil, last)
|
self.warning(UnreachableCode, &"code after '{last.token.lexeme}' statement is unreachable", nil, decl)
|
||||||
else:
|
else:
|
||||||
discard
|
discard
|
||||||
if blk.broken:
|
if blk.broken:
|
||||||
|
@ -2809,7 +2809,7 @@ proc funDecl(self: Compiler, node: FunDecl, name: Name) =
|
||||||
for decl in BlockStmt(node.body).code:
|
for decl in BlockStmt(node.body).code:
|
||||||
if not last.isNil():
|
if not last.isNil():
|
||||||
if last.kind == returnStmt:
|
if last.kind == returnStmt:
|
||||||
self.warning(UnreachableCode, "code after 'return' statement is unreachable")
|
self.warning(UnreachableCode, "code after 'return' statement is unreachable", nil, decl)
|
||||||
self.declaration(decl)
|
self.declaration(decl)
|
||||||
last = decl
|
last = decl
|
||||||
let typ = self.currentFunction.valueType.returnType
|
let typ = self.currentFunction.valueType.returnType
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
import std;
|
import std;
|
||||||
|
|
||||||
fn foo {return;}
|
|
||||||
|
|
||||||
|
|
||||||
block outer {
|
block outer {
|
||||||
var x = 1;
|
var x = 1;
|
||||||
|
|
Loading…
Reference in New Issue