Files
Nim/tests/errmsgs/tsigmatch2.nim
metagn 4ca2dcb404 Named arguments in commands + many grammar fixes (#20994)
* Breaking parser changes, implement https://github.com/nim-lang/RFCs/issues/442

Types are separated from expressions and better reflected in the grammar.

* add test

* more accurate grammar

* fix keyword typedescs

* accept expressions in proc argument lists

* CI "fixes"

* fixes

* allow full ref expressions again, adapt old tests

* cleanup, fix some tests

* improve grammar, try and revert semtypes change

* restrict sigil binding to identOrLiteral

* fix, should have caught this immediately

* add changelog entry, fix double not nil bug

* correct grammar

* change section

* fix

* real fix hopefully

* fix test

* support LL(1) for tuples

* make grammar.txt too
2022-12-06 13:11:56 +01:00

48 lines
1.3 KiB
Nim

discard """
cmd: "nim check --showAllMismatches:on --hints:off $file"
nimout: '''
tsigmatch2.nim(40, 14) Error: type mismatch: got <float64>
but expected one of:
proc foo(args: varargs[string, myproc]): string
first type mismatch at position: 1
required type for args: varargs[string]
but expression '1.2' is of type: float64
proc foo(i: Foo): string
first type mismatch at position: 1
required type for i: Foo
but expression '1.2' is of type: float64
expression: foo(1.2)
tsigmatch2.nim(40, 14) Error: expression '' has no type (or is ambiguous)
tsigmatch2.nim(46, 3) Error: type mismatch: got <int literal(1)>
but expected one of:
proc foo(args: varargs[string, myproc])
first type mismatch at position: 1
required type for args: varargs[string]
but expression '1' is of type: int literal(1)
expression: foo 1
'''
errormsg: "type mismatch"
"""
# line 30
type Foo = object
block: # issue #13182
proc myproc(a: int): string = $("myproc", a)
proc foo(args: varargs[string, myproc]): string = $args
proc foo(i: Foo): string = "in foo(i)"
static: doAssert foo(Foo()) == "in foo(i)"
static: doAssert foo(1) == """["(\"myproc\", 1)"]"""
doAssert not compiles(foo(1.2))
discard foo(1.2)
block:
proc myproc[T](x: T): string =
let temp = 12.isNil
proc foo(args: varargs[string, myproc]) = discard
foo 1
static: echo "done"