Files
Nim/tests/errmsgs/tunknown_named_parameter.nim
metagn 821d0806fe Revert "make default values typed in proc AST same as param sym AST" (#24191)
Reverts #24184, reopens #12942, reopens #19118

#24184 seems to have caused a regression in
https://github.com/c-blake/thes and
https://github.com/c-blake/bu/blob/main/rp.nim#L84 reproducible with
`git clone https://github.com/c-blake/cligen; git clone
https://github.com/c-blake/thes; cd thes; nim c -p=../cligen thes`.
Changing the `const` to `let` makes it compile.

A minimization that is probably the same issue is:

```nim
const a: seq[string] = @[]

proc foo(x = a) =
  echo typeof(x)
  echo x

import macros

macro resemFoo() =
  result = getImpl(bindSym"foo")

block:
  resemFoo() # Error: cannot infer the type of parameter 'x'
```

This should be a regression test in a future reimplementation of #24184.
2024-09-27 15:34:09 +02:00

28 lines
788 B
Nim

discard """
cmd: "nim check $file"
errormsg: "type mismatch: got <string, set[char], maxsplits: int literal(1)>"
nimout: '''
func rsplit(s: string; sep: char; maxsplit: int = -1): seq[string]
first type mismatch at position: 2
required type for sep: char
but expression '{':'}' is of type: set[char]
func rsplit(s: string; sep: string; maxsplit: int = -1): seq[string]
first type mismatch at position: 2
required type for sep: string
but expression '{':'}' is of type: set[char]
func rsplit(s: string; seps: set[char] = Whitespace; maxsplit: int = -1): seq[
string]
first type mismatch at position: 3
unknown named parameter: maxsplits
expression: rsplit("abc:def", {':'}, maxsplits = 1)
'''
"""
# bug #8043
import strutils
"abc:def".rsplit({':'}, maxsplits = 1)