From d6793ded27537b51bbcc1dbdfacaf6f7655bf289 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oscar=20Nihlg=C3=A5rd?= Date: Fri, 6 Apr 2018 22:44:54 +0200 Subject: [PATCH] Fix parser bug with type classes (#7480) --- compiler/parser.nim | 1 + tests/parser/ttypeclasses.nim | 17 +++++++++++++++++ 2 files changed, 18 insertions(+) create mode 100644 tests/parser/ttypeclasses.nim diff --git a/compiler/parser.nim b/compiler/parser.nim index 78a89f6c64..c14330ec29 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 0000000000..9f487c7a8c --- /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