diff options
author | Oscar NihlgÄrd <oscarnihlgard@gmail.com> | 2018-04-06 22:44:54 +0200 |
---|---|---|
committer | Andreas Rumpf <rumpf_a@web.de> | 2018-04-06 22:44:54 +0200 |
commit | d6793ded27537b51bbcc1dbdfacaf6f7655bf289 (patch) | |
tree | 440c4f8d10e68d80b1038cda8eabd30eef28d4a5 | |
parent | 8b7c2bd06783c916c9f3725ee571bf2463140a73 (diff) | |
download | Nim-d6793ded27537b51bbcc1dbdfacaf6f7655bf289.tar.gz |
Fix parser bug with type classes (#7480)
-rw-r--r-- | compiler/parser.nim | 1 | ||||
-rw-r--r-- | tests/parser/ttypeclasses.nim | 17 |
2 files changed, 18 insertions, 0 deletions
diff --git a/compiler/parser.nim b/compiler/parser.nim index 78a89f6c6..c14330ec2 100644 --- a/compiler/parser.nim +++ b/compiler/parser.nim @@ -1080,6 +1080,7 @@ proc parseTypeDescKAux(p: var TParser, kind: TNodeKind, #| distinct = 'distinct' optInd typeDesc result = newNodeP(kind, p) getTok(p) + if p.tok.indent != -1 and p.tok.indent <= p.currInd: return optInd(p, result) if not isOperator(p.tok) and isExprStart(p): addSon(result, primary(p, mode)) diff --git a/tests/parser/ttypeclasses.nim b/tests/parser/ttypeclasses.nim new file mode 100644 index 000000000..9f487c7a8 --- /dev/null +++ b/tests/parser/ttypeclasses.nim @@ -0,0 +1,17 @@ +discard """ + action: run +""" + +type + R = ref + V = var + D = distinct + P = ptr + +var x: ref int +var y: distinct int +var z: ptr int + +doAssert x is ref +doAssert y is distinct +doAssert z is ptr \ No newline at end of file |