added warning for confusing var declarations
This commit is contained in:
parent
9222a8a0eb
commit
2ff8d17369
5 changed files with 19 additions and 7 deletions
|
|
@ -284,8 +284,8 @@ proc genSection(d: PDoc, kind: TSymKind) =
|
|||
ord(kind).toRope, title, toRope(ord(kind) + 50), d.toc[kind]])
|
||||
|
||||
proc genOutFile(d: PDoc): PRope =
|
||||
var
|
||||
code, content: PRope = nil
|
||||
var
|
||||
code, content: PRope
|
||||
title = ""
|
||||
var j = 0
|
||||
var tmp = ""
|
||||
|
|
|
|||
|
|
@ -103,7 +103,7 @@ type
|
|||
warnUnknownSubstitutionX, warnLanguageXNotSupported, warnCommentXIgnored,
|
||||
warnXisPassedToProcVar, warnAnalysisLoophole,
|
||||
warnDifferentHeaps, warnWriteToForeignHeap, warnImplicitClosure,
|
||||
warnUser,
|
||||
warnEachIdentIsTuple, warnUser,
|
||||
hintSuccess, hintSuccessX,
|
||||
hintLineTooLong, hintXDeclaredButNotUsed, hintConvToBaseNotNeeded,
|
||||
hintConvFromXtoItselfNotNeeded, hintExprAlwaysX, hintQuitCalled,
|
||||
|
|
@ -346,6 +346,7 @@ const
|
|||
warnDifferentHeaps: "possible inconsistency of thread local heaps [DifferentHeaps]",
|
||||
warnWriteToForeignHeap: "write to foreign heap [WriteToForeignHeap]",
|
||||
warnImplicitClosure: "implicit closure convention: '$1' [ImplicitClosure]",
|
||||
warnEachIdentIsTuple: "each identifier is a tuple [EachIdentIsTuple]",
|
||||
warnUser: "$1 [User]",
|
||||
hintSuccess: "operation successful [Success]",
|
||||
hintSuccessX: "operation successful ($# lines compiled; $# sec total; $#) [SuccessX]",
|
||||
|
|
@ -363,14 +364,14 @@ const
|
|||
hintUser: "$1 [User]"]
|
||||
|
||||
const
|
||||
WarningsToStr*: array[0..17, string] = ["CannotOpenFile", "OctalEscape",
|
||||
WarningsToStr*: array[0..18, string] = ["CannotOpenFile", "OctalEscape",
|
||||
"XIsNeverRead", "XmightNotBeenInit",
|
||||
"Deprecated", "ConfigDeprecated",
|
||||
"SmallLshouldNotBeUsed", "UnknownMagic",
|
||||
"RedefinitionOfLabel", "UnknownSubstitutionX", "LanguageXNotSupported",
|
||||
"CommentXIgnored", "XisPassedToProcVar",
|
||||
"AnalysisLoophole", "DifferentHeaps", "WriteToForeignHeap",
|
||||
"ImplicitClosure,", "User"]
|
||||
"ImplicitClosure", "EachIdentIsTuple", "User"]
|
||||
|
||||
HintsToStr*: array[0..13, string] = ["Success", "SuccessX", "LineTooLong",
|
||||
"XDeclaredButNotUsed", "ConvToBaseNotNeeded", "ConvFromXtoItselfNotNeeded",
|
||||
|
|
|
|||
|
|
@ -270,6 +270,9 @@ proc semVarOrLet(c: PContext, n: PNode, symkind: TSymKind): PNode =
|
|||
b.sons[length-2] = a.sons[length-2] # keep type desc for doc generator
|
||||
b.sons[length-1] = def
|
||||
addSon(result, b)
|
||||
elif tup.kind == tyTuple and def.kind == nkPar and
|
||||
a.kind == nkIdentDefs and a.len > 3:
|
||||
Message(a.info, warnEachIdentIsTuple)
|
||||
for j in countup(0, length-3):
|
||||
var v = semIdentDef(c, a.sons[j], symkind)
|
||||
addInterfaceDecl(c, v)
|
||||
|
|
|
|||
|
|
@ -244,7 +244,16 @@ proc transformConstSection(c: PTransf, v: PNode): PTransNode =
|
|||
result[i] = PTransNode(b)
|
||||
else:
|
||||
result[i] = PTransNode(it)
|
||||
|
||||
|
||||
proc trivialBody(s: PSym): PNode =
|
||||
# a routine's body is trivially inlinable if marked as 'inline' and its
|
||||
# body consists of only 1 statement. It is important that we perform this
|
||||
# optimization here as 'distinct strings' may cause string copying otherwise:
|
||||
# proc xml(s: string): TXmlString = return xmlstring(s)
|
||||
# We have to generate a ``nkLineTracking`` node though to not lose
|
||||
# debug information:
|
||||
# XXX to implement
|
||||
nil
|
||||
|
||||
proc hasContinue(n: PNode): bool =
|
||||
case n.kind
|
||||
|
|
|
|||
1
todo.txt
1
todo.txt
|
|
@ -4,7 +4,6 @@ version 0.9.0
|
|||
- closure: implement closure support for procs capturing nested
|
||||
module vars
|
||||
- implicit deref for parameter matching
|
||||
- deprecate ``var x, y = 0`` as it's confusing for tuple consistency
|
||||
|
||||
- ``borrow`` needs to take type classes into account
|
||||
- ``=`` should be overloadable; requires specialization for ``=``
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue