summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rwxr-xr-xcompiler/msgs.nim2
-rwxr-xr-xcompiler/parser.nim7
-rwxr-xr-xcompiler/semgnrc.nim6
-rwxr-xr-xcompiler/types.nim3
-rwxr-xr-xlib/pure/unidecode/unidecode.nim3
-rw-r--r--lib/pure/unittest.nim8
-rwxr-xr-xtests/accept/run/mbind3.nim3
-rwxr-xr-xtests/accept/run/tbind1.nim3
-rw-r--r--tests/accept/run/tunidecode.nim4
-rwxr-xr-xtests/reject/tbind2.nim2
-rw-r--r--tests/reject/tmissingnl.nim10
11 files changed, 40 insertions, 11 deletions
diff --git a/compiler/msgs.nim b/compiler/msgs.nim
index 9049fdb22..880ed8d2e 100755
--- a/compiler/msgs.nim
+++ b/compiler/msgs.nim
@@ -19,6 +19,7 @@ type
     errTabulatorsAreNotAllowed, errInvalidToken, errLineTooLong, 
     errInvalidNumber, errNumberOutOfRange, errNnotAllowedInCharacter, 
     errClosingBracketExpected, errMissingFinalQuote, errIdentifierExpected, 
+    errNewlineExpected,
     errInvalidModuleName,
     errOperatorExpected, errTokenExpected, errStringAfterIncludeExpected, 
     errRecursiveDependencyX, errOnOrOffExpected, errNoneSpeedOrSizeExpected, 
@@ -128,6 +129,7 @@ const
     errClosingBracketExpected: "closing ']' expected, but end of file reached", 
     errMissingFinalQuote: "missing final \'", 
     errIdentifierExpected: "identifier expected, but found \'$1\'", 
+    errNewlineExpected: "newline expected, but found \'$1\'",
     errInvalidModuleName: "invalid module name: '$1'",
     errOperatorExpected: "operator expected, but found \'$1\'", 
     errTokenExpected: "\'$1\' expected", 
diff --git a/compiler/parser.nim b/compiler/parser.nim
index 2a136b631..3e195b927 100755
--- a/compiler/parser.nim
+++ b/compiler/parser.nim
@@ -95,6 +95,10 @@ proc optInd(p: var TParser, n: PNode) =
   skipComment(p, n)
   skipInd(p)
 
+proc ExpectNl(p: TParser) = 
+  if p.tok.tokType notin {tkEof, tkSad, tkInd, tkDed}: 
+    lexMessage(p.lex, errNewlineExpected, prettyTok(p.tok))
+
 proc expectIdentOrKeyw(p: TParser) = 
   if p.tok.tokType != tkSymbol and not isKeyword(p.tok.tokType): 
     lexMessage(p.lex, errIdentifierExpected, prettyTok(p.tok))
@@ -761,6 +765,7 @@ proc parseImportOrIncludeStmt(p: var TParser, kind: TNodeKind): PNode =
     if p.tok.tokType != tkComma: break 
     getTok(p)
     optInd(p, a)
+  expectNl(p)
 
 proc parseFromStmt(p: var TParser): PNode = 
   var a: PNode
@@ -798,6 +803,7 @@ proc parseFromStmt(p: var TParser): PNode =
     if p.tok.tokType != tkComma: break 
     getTok(p)
     optInd(p, a)
+  expectNl(p)
 
 proc parseReturnOrRaise(p: var TParser, kind: TNodeKind): PNode = 
   result = newNodeP(kind, p)
@@ -1299,6 +1305,7 @@ proc parseBind(p: var TParser): PNode =
     if p.tok.tokType != tkComma: break 
     getTok(p)
     optInd(p, a)
+  expectNl(p)
   
 proc simpleStmt(p: var TParser): PNode = 
   case p.tok.tokType
diff --git a/compiler/semgnrc.nim b/compiler/semgnrc.nim
index 3d6be4f13..488bdcf8a 100755
--- a/compiler/semgnrc.nim
+++ b/compiler/semgnrc.nim
@@ -253,8 +253,10 @@ proc semGenericStmt(c: PContext, n: PNode,
         addDecl(c, newSym(skUnknown, getIdent("result"), nil))
       n.sons[paramsPos] = semGenericStmt(c, n.sons[paramsPos], flags, toBind)
     n.sons[pragmasPos] = semGenericStmt(c, n.sons[pragmasPos], flags, toBind)
-    var s = n.sons[namePos].sym
-    n.sons[bodyPos] = semGenericStmtScope(c, s.getBody, flags, toBind)
+    var body: PNode
+    if n.sons[namePos].kind == nkSym: body = n.sons[namePos].sym.getBody
+    else: body = n.sons[bodyPos]
+    n.sons[bodyPos] = semGenericStmtScope(c, body, flags, toBind)
     closeScope(c.tab)
   else: 
     for i in countup(0, sonsLen(n) - 1): 
diff --git a/compiler/types.nim b/compiler/types.nim
index 9d5d12b06..7e34031aa 100755
--- a/compiler/types.nim
+++ b/compiler/types.nim
@@ -735,7 +735,8 @@ proc SameTypeAux(x, y: PType, c: var TSameTypeClosure): bool =
       result = sameObjectStructures(a, b, c)
   of tyDistinct:
     CycleCheck()
-    result = sameTypeAux(a.sons[0], b.sons[0], c)
+    if c.cmp == dcEq: result = sameDistinctTypes(a, b)
+    else: result = sameTypeAux(a.sons[0], b.sons[0], c)
   of tyEnum, tyForward, tyProxy:
     # XXX generic enums do not make much sense, but require structural checking
     result = a.id == b.id
diff --git a/lib/pure/unidecode/unidecode.nim b/lib/pure/unidecode/unidecode.nim
index 453e1b289..a302618e3 100755
--- a/lib/pure/unidecode/unidecode.nim
+++ b/lib/pure/unidecode/unidecode.nim
@@ -56,7 +56,8 @@ proc unidecode*(s: string): string =
   ## Example: 
   ## 
   ## ..code-block:: nimrod
-  ##   unidecode("\\x53\\x17\\x4E\\xB0")
+  ##
+  ##   unidecode("\x53\x17\x4E\xB0")
   ##
   ## Results in: "Bei Jing"
   ##
diff --git a/lib/pure/unittest.nim b/lib/pure/unittest.nim
index db3e5a1db..7f70811b0 100644
--- a/lib/pure/unittest.nim
+++ b/lib/pure/unittest.nim
@@ -50,8 +50,9 @@ proc printStatus*(s: TestStatus, name: string) =
   styledEcho styleBright, color, "[", $s, "] ", fgWhite, name, "\n"

   

 template test*(name: expr, body: stmt): stmt =

-  if bind shouldRun(name):

-    bind checkpoints = @[]

+  bind shouldRun, checkPoints

+  if shouldRun(name):

+    checkpoints = @[]

     var TestStatusIMPL = OK

     

     try:

@@ -67,7 +68,8 @@ proc checkpoint*(msg: string) =
   # TODO: add support for something like SCOPED_TRACE from Google Test

 

 template fail* =

-  for msg in items(bind checkpoints):

+  bind checkpoints

+  for msg in items(checkpoints):

     echo msg

 

   if AbortOnError: quit(1)

diff --git a/tests/accept/run/mbind3.nim b/tests/accept/run/mbind3.nim
index 586222eb8..d02bc79d0 100755
--- a/tests/accept/run/mbind3.nim
+++ b/tests/accept/run/mbind3.nim
@@ -3,7 +3,8 @@ var
   lastId = 0
 
 template genId*: expr =
-  inc(bind lastId)
+  bind lastId
+  inc(lastId)
   lastId
 
 
diff --git a/tests/accept/run/tbind1.nim b/tests/accept/run/tbind1.nim
index 536a67f91..6593b2307 100755
--- a/tests/accept/run/tbind1.nim
+++ b/tests/accept/run/tbind1.nim
@@ -7,7 +7,8 @@ discard """
 proc p1(x: int8, y: int): int = return x + y
 
 template tempBind(x, y: expr): expr = 
-  bind p1(x, y) 
+  bind p1
+  p1(x, y) 
 
 proc p1(x: int, y: int8): int = return x - y
 
diff --git a/tests/accept/run/tunidecode.nim b/tests/accept/run/tunidecode.nim
index 92308e1fc..4c074b391 100644
--- a/tests/accept/run/tunidecode.nim
+++ b/tests/accept/run/tunidecode.nim
@@ -5,6 +5,8 @@ discard """
 
 import unidecode
 
-assert unidecode("\\x53\\x17\\x4E\\xB0") == "Bei Jing"
+loadUnidecodeTable("lib/pure/unidecode/unidecode.dat")
+
+assert unidecode("\x53\x17\x4E\xB0") == "Bei Jing"
 echo unidecode("Äußerst")
 
diff --git a/tests/reject/tbind2.nim b/tests/reject/tbind2.nim
index 06065538e..72a9844bb 100755
--- a/tests/reject/tbind2.nim
+++ b/tests/reject/tbind2.nim
@@ -9,7 +9,7 @@ proc p1(x: int8, y: int): int = return x + y
 proc p1(x: int, y: int8): int = return x - y
 
 template tempBind(x, y: expr): expr = 
-  bind p1(x, y)  #ERROR_MSG ambiguous call
+  (bind p1(x, y))  #ERROR_MSG ambiguous call
 
 echo tempBind(1'i8, 2'i8)
 
diff --git a/tests/reject/tmissingnl.nim b/tests/reject/tmissingnl.nim
new file mode 100644
index 000000000..c2f97a807
--- /dev/null
+++ b/tests/reject/tmissingnl.nim
@@ -0,0 +1,10 @@
+discard """
+  file: "tmissingnl.nim"
+  line: 7
+  errormsg: "newline expected, but found 'keyword var'"
+"""
+
+import strutils var s: seq[int] = @[0, 1, 2, 3, 4, 5, 6]
+
+#s[1..3] = @[]
+