File: t15949.nim

package info (click to toggle)
nim 2.2.0-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 1,911,644 kB
  • sloc: sh: 24,603; ansic: 1,761; python: 1,492; makefile: 1,013; sql: 298; asm: 141; xml: 13
file content (16 lines) | stat: -rw-r--r-- 659 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
# bug #15949 and RFC #480

proc procWarn(a, b = 1): (int, int) = (a, b) #[tt.Warning
              ^ a, b all have default value '1', this may be unintentional, either use ';' (semicolon) or explicitly write each default value [ImplicitDefaultValue]]#

proc procGood(a = 1, b = 1): (int, int) = (a, b)

doAssert procGood() == (1, 1)
doAssert procGood(b = 3) == (1, 3)
doAssert procGood(a = 2) == (2, 1)
doAssert procGood(a = 5, b = 6) == (5, 6)

# The type (and default value propagation breaks in the below example
# as semicolon is used instead of comma.
proc procBad(a; b = 1): (int, int) = (a, b) #[tt.Error
             ^ parameter 'a' requires a type]#