Fix parsing bug with type declarations
This commit is contained in:
parent
8cac75ecef
commit
13eea04e74
|
@ -1232,7 +1232,7 @@ proc parseTypeFields(self: Parser): seq[tuple[name: IdentExpr, valueType: Expres
|
|||
argPrivate: bool
|
||||
argType: Expression
|
||||
argDefault: Expression
|
||||
while not self.match(RightBrace) and not self.done():
|
||||
while not self.check(RightBrace) and not self.done():
|
||||
self.expect(Identifier, "expecting type member name")
|
||||
argName = newIdentExpr(self.peek(-1), self.scopeDepth)
|
||||
argPrivate = not self.match("*")
|
||||
|
@ -1261,15 +1261,16 @@ proc typeDecl(self: Parser): TypeDecl =
|
|||
if self.match(LeftBracket):
|
||||
self.parseGenerics(result)
|
||||
self.expect("=", "expecting '=' after type name")
|
||||
case self.peek().lexeme:
|
||||
of "ref":
|
||||
var hasNone = false
|
||||
case self.peek().kind:
|
||||
of Ref:
|
||||
discard self.step()
|
||||
self.expect("object", "expecting 'object' after 'ref'")
|
||||
result.isRef = true
|
||||
of "enum":
|
||||
of Enum:
|
||||
discard self.step()
|
||||
result.isEnum = true
|
||||
of "object":
|
||||
of Object:
|
||||
discard self.step()
|
||||
else:
|
||||
result.value = self.expression()
|
||||
|
@ -1307,8 +1308,9 @@ proc typeDecl(self: Parser): TypeDecl =
|
|||
result.members.add(variant)
|
||||
if self.match(","):
|
||||
continue
|
||||
elif self.match("}"):
|
||||
elif self.check("}"):
|
||||
break
|
||||
self.expect(RightBrace, "expecting '}' after type declaration")
|
||||
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue