import questionable
proc printObj[T](a: T) =
let x = [1,2,3].some
echo x.?len
printObj(1)
Gives me the following error:
Error: type mismatch: got <Option[array[0..2, int]], proc (x: seq[T]): int{.noSideEffect.} | proc (x: HSlice[len.U, len.V]): int{.inline, noSideEffect.} | proc (x: TOpenArray: openArray or varargs): int{.noSideEffect.} | proc (x: set[T]): int{.noSideEffect.} | proc (x: cstring): int{.noSideEffect.} | proc (w: WideCString): int{.noSideEffect, gcsafe, locks: 0.} | proc (x: type array or array): int{.noSideEffect.} | proc (x: string): int{.noSideEffect.}>
but expected one of:
macro `.?`(expression: typed; brackets: untyped{nkBracket}): untyped
first type mismatch at position: 2
required type for brackets: untyped
but expression 'len' is of type: None
macro `.?`(option: typed; bracket: untyped{nkBracketExpr}): untyped
first type mismatch at position: 2
required type for bracket: untyped
but expression 'len' is of type: None
macro `.?`(option: typed; call: untyped{nkCall}): untyped
first type mismatch at position: 2
required type for call: untyped
but expression 'len' is of type: None
macro `.?`(option: typed; dot: untyped{nkDotExpr}): untyped
first type mismatch at position: 2
required type for dot: untyped
but expression 'len' is of type: None
macro `.?`(option: typed; infix: untyped{nkInfix}): untyped
first type mismatch at position: 2
required type for infix: untyped
but expression 'len' is of type: None
template `.?`(option: typed; identifier: untyped{nkIdent}): untyped
first type mismatch at position: 2
required type for identifier: untyped
but expression 'len' is of type: None
expression: x .? len
Am I missing something or is there a bug somewhere? I'd expect the code to print the length of the array.
Hello!
The following code:
Gives me the following error:
Am I missing something or is there a bug somewhere? I'd expect the code to print the length of the array.
Compiler version:
Questionable version: