typeToString: type float => typedesc[float] (#17011)
* typeToString: type float => typedesc[float] * fixup * fix tests
This commit is contained in:
parent
f57774e1e7
commit
e40ff24c23
13 changed files with 21 additions and 18 deletions
|
|
@ -162,6 +162,8 @@ provided by the operating system.
|
||||||
- The required name of case statement macros for the experimental
|
- The required name of case statement macros for the experimental
|
||||||
`caseStmtMacros` feature has changed from `match` to `` `case` ``.
|
`caseStmtMacros` feature has changed from `match` to `` `case` ``.
|
||||||
|
|
||||||
|
- `typedesc[Foo]` now renders as such instead of `type Foo` in compiler messages.
|
||||||
|
|
||||||
## Compiler changes
|
## Compiler changes
|
||||||
|
|
||||||
- Added `--declaredlocs` to show symbol declaration location in messages.
|
- Added `--declaredlocs` to show symbol declaration location in messages.
|
||||||
|
|
|
||||||
|
|
@ -448,6 +448,7 @@ proc rangeToStr(n: PNode): string =
|
||||||
const
|
const
|
||||||
typeToStr: array[TTypeKind, string] = ["None", "bool", "char", "empty",
|
typeToStr: array[TTypeKind, string] = ["None", "bool", "char", "empty",
|
||||||
"Alias", "typeof(nil)", "untyped", "typed", "typeDesc",
|
"Alias", "typeof(nil)", "untyped", "typed", "typeDesc",
|
||||||
|
# xxx typeDesc=>typedesc: typedesc is declared as such, and is 10x more common.
|
||||||
"GenericInvocation", "GenericBody", "GenericInst", "GenericParam",
|
"GenericInvocation", "GenericBody", "GenericInst", "GenericParam",
|
||||||
"distinct $1", "enum", "ordinal[$1]", "array[$1, $2]", "object", "tuple",
|
"distinct $1", "enum", "ordinal[$1]", "array[$1, $2]", "object", "tuple",
|
||||||
"set[$1]", "range[$1]", "ptr ", "ref ", "var ", "seq[$1]", "proc",
|
"set[$1]", "range[$1]", "ptr ", "ref ", "var ", "seq[$1]", "proc",
|
||||||
|
|
@ -550,7 +551,7 @@ proc typeToString(typ: PType, prefer: TPreferedDesc = preferName): string =
|
||||||
result.add(']')
|
result.add(']')
|
||||||
of tyTypeDesc:
|
of tyTypeDesc:
|
||||||
if t[0].kind == tyNone: result = "typedesc"
|
if t[0].kind == tyNone: result = "typedesc"
|
||||||
else: result = "type " & typeToString(t[0])
|
else: result = "typedesc[" & typeToString(t[0]) & "]"
|
||||||
of tyStatic:
|
of tyStatic:
|
||||||
if prefer == preferGenericArg and t.n != nil:
|
if prefer == preferGenericArg and t.n != nil:
|
||||||
result = t.n.renderTree
|
result = t.n.renderTree
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,9 @@
|
||||||
discard """
|
discard """
|
||||||
cmd: "nim check $file"
|
cmd: "nim check $file"
|
||||||
errormsg: "invalid type: 'type int' in this context: 'array[0..0, type int]' for var"
|
errormsg: "invalid type: 'typedesc[int]' in this context: 'array[0..0, typedesc[int]]' for var"
|
||||||
nimout: '''
|
nimout: '''
|
||||||
t9932.nim(10, 5) Error: invalid type: 'type' in this context: 'array[0..0, type]' for var
|
t9932.nim(10, 5) Error: invalid type: 'type' in this context: 'array[0..0, type]' for var
|
||||||
t9932.nim(11, 5) Error: invalid type: 'type int' in this context: 'array[0..0, type int]' for var
|
t9932.nim(11, 5) Error: invalid type: 'typedesc[int]' in this context: 'array[0..0, typedesc[int]]' for var
|
||||||
'''
|
'''
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
discard """
|
discard """
|
||||||
errormsg: "type mismatch: got <type float, string>"
|
errormsg: "type mismatch: got <typedesc[float], string>"
|
||||||
line: 10
|
line: 10
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
discard """
|
discard """
|
||||||
errormsg: "invalid type: 'type int' for const"
|
errormsg: "invalid type: 'typedesc[int]' for const"
|
||||||
"""
|
"""
|
||||||
## issue #8610
|
## bug #8610
|
||||||
const Foo = int
|
const Foo = int
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@ discard """
|
||||||
errormsg: "cannot instantiate B"
|
errormsg: "cannot instantiate B"
|
||||||
line: 20
|
line: 20
|
||||||
nimout: '''
|
nimout: '''
|
||||||
got: <type string>
|
got: <typedesc[string]>
|
||||||
but expected: <T: A>
|
but expected: <T: A>
|
||||||
'''
|
'''
|
||||||
"""
|
"""
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@ discard """
|
||||||
errormsg: "cannot instantiate B"
|
errormsg: "cannot instantiate B"
|
||||||
line: 14
|
line: 14
|
||||||
nimout: '''
|
nimout: '''
|
||||||
got: <type int>
|
got: <typedesc[int]>
|
||||||
but expected: <T: string or float>
|
but expected: <T: string or float>
|
||||||
'''
|
'''
|
||||||
"""
|
"""
|
||||||
|
|
|
||||||
|
|
@ -1,17 +1,17 @@
|
||||||
discard """
|
discard """
|
||||||
errormsg: "type mismatch: got <array[0..0, type int]>"
|
errormsg: "type mismatch: got <array[0..0, typedesc[int]]>"
|
||||||
line: 22
|
line: 22
|
||||||
nimout: '''
|
nimout: '''
|
||||||
twrong_at_operator.nim(22, 30) Error: type mismatch: got <array[0..0, type int]>
|
twrong_at_operator.nim(22, 30) Error: type mismatch: got <array[0..0, typedesc[int]]>
|
||||||
but expected one of:
|
but expected one of:
|
||||||
proc `@`[IDX, T](a: sink array[IDX, T]): seq[T]
|
proc `@`[IDX, T](a: sink array[IDX, T]): seq[T]
|
||||||
first type mismatch at position: 1
|
first type mismatch at position: 1
|
||||||
required type for a: sink array[IDX, T]
|
required type for a: sink array[IDX, T]
|
||||||
but expression '[int]' is of type: array[0..0, type int]
|
but expression '[int]' is of type: array[0..0, typedesc[int]]
|
||||||
proc `@`[T](a: openArray[T]): seq[T]
|
proc `@`[T](a: openArray[T]): seq[T]
|
||||||
first type mismatch at position: 1
|
first type mismatch at position: 1
|
||||||
required type for a: openArray[T]
|
required type for a: openArray[T]
|
||||||
but expression '[int]' is of type: array[0..0, type int]
|
but expression '[int]' is of type: array[0..0, typedesc[int]]
|
||||||
|
|
||||||
expression: @[int]
|
expression: @[int]
|
||||||
'''
|
'''
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
discard """
|
discard """
|
||||||
errormsg: "invalid type: 'type int' for var"
|
errormsg: "invalid type: 'typedesc[int]' for var"
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
discard """
|
discard """
|
||||||
errormsg: "type mismatch: got <type int>"
|
errormsg: "type mismatch: got <typedesc[int]>"
|
||||||
line: 6
|
line: 6
|
||||||
"""
|
"""
|
||||||
# bug #3079, #1146
|
# bug #3079, #1146
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
discard """
|
discard """
|
||||||
errormsg: "type mismatch: got <type int> but expected 'int'"
|
errormsg: "type mismatch: got <typedesc[int]> but expected 'int'"
|
||||||
file: "ttypenoval.nim"
|
file: "ttypenoval.nim"
|
||||||
line: 38
|
line: 38
|
||||||
"""
|
"""
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
discard """
|
discard """
|
||||||
errormsg: "invalid type: 'type seq[tuple[title: string, body: string]]' for var"
|
errormsg: "invalid type: 'typedesc[seq[tuple[title: string, body: string]]]' for var"
|
||||||
line: 7
|
line: 7
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,10 @@
|
||||||
discard """
|
discard """
|
||||||
errormsg: "invalid type: 'type Table' for const"
|
errormsg: "invalid type: 'typedesc[Table]' for const"
|
||||||
file: "typedescs2.nim"
|
file: "typedescs2.nim"
|
||||||
line: 16
|
line: 16
|
||||||
"""
|
"""
|
||||||
|
|
||||||
# issue #9961
|
# bug #9961
|
||||||
|
|
||||||
import typetraits
|
import typetraits
|
||||||
import tables
|
import tables
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue