mirror of
https://github.com/nim-lang/Nim.git
synced 2026-04-20 14:25:23 +00:00
add type check for default fields (#20652)
This commit is contained in:
22
tests/objects/tdefaultfieldscheck.nim
Normal file
22
tests/objects/tdefaultfieldscheck.nim
Normal file
@@ -0,0 +1,22 @@
|
||||
discard """
|
||||
cmd: "nim check --hints:off $file"
|
||||
errormsg: ""
|
||||
nimout:
|
||||
'''
|
||||
tdefaultfieldscheck.nim(17, 17) Error: type mismatch: got <string> but expected 'int'
|
||||
tdefaultfieldscheck.nim(18, 20) Error: type mismatch: got <int literal(12)> but expected 'string'
|
||||
tdefaultfieldscheck.nim(20, 16) Error: type mismatch: got <float64> but expected 'int'
|
||||
tdefaultfieldscheck.nim(17, 5) Error: type mismatch: got <string> but expected 'int'
|
||||
tdefaultfieldscheck.nim(18, 5) Error: type mismatch: got <int literal(12)> but expected 'string'
|
||||
tdefaultfieldscheck.nim(20, 5) Error: type mismatch: got <float64> but expected 'int'
|
||||
'''
|
||||
"""
|
||||
|
||||
type
|
||||
Date* = object
|
||||
name: int = "string"
|
||||
time: string = 12
|
||||
goal: float = 7
|
||||
fun: int = 1.4
|
||||
|
||||
echo default(Date)
|
||||
Reference in New Issue
Block a user