manual: Document that comma propagates the default values of parameters (#19080)

* manual: Document that comma propagates the default values of parameters

Fixes https://github.com/nim-lang/Nim/issues/15949.

* Use the "bug #NNNN" comment syntax for consistency

Ref:
https://nim-lang.github.io/Nim/contributing.html#writing-tests-stdlib

> Always refer to a GitHub issue using the following exact syntax: bug
for tooling.
This commit is contained in:
Kaushal Modi
2021-11-03 03:08:50 -04:00
committed by GitHub
parent 5fed1c05ce
commit dbbafd320c
2 changed files with 29 additions and 1 deletions

20
tests/proc/t15949.nim Normal file
View File

@@ -0,0 +1,20 @@
# bug #15949
discard """
errormsg: "parameter 'a' requires a type"
nimout: '''
t15949.nim(20, 14) Error: parameter 'a' requires a type'''
"""
# line 10
proc procGood(a, 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)