I'm implementing a variant object type, where one of the enum cases has no fields associated with it, but get a syntax error:
type
AuthenticatorType = enum
None,
Basic,
Session,
Cookie
Authenticator = object
case type: AuthenticatorType:
of None:
# Error: identifier expected, but got 'keyword of'
of Basic: username, password: string
of Session: sessionID: string
of Cookie: name, value: string
What can I put after of None: to satisfy the parser? Or is it impossible to have a case with no associated value?
(I've checked the manual but it says nothing about this possibility.)
it works this way:
type
AuthenticatorType = enum
None,
Basic,
Session,
Cookie
Authenticator = object
case type: AuthenticatorType:
of None: discard
of Basic: username, password: string
of Session: sessionID: string
of Cookie: name, value: string
you can't just let of None: dangle around, you need to add a discard