Merge pull request #6747 from katafrakt/handle-hash-default-arg

This commit is contained in:
Yukihiro "Matz" Matsumoto
2026-03-20 16:44:27 +09:00
committed by GitHub
3 changed files with 1183 additions and 1171 deletions
+2 -2
View File
@@ -4563,13 +4563,13 @@ f_label : tIDENTIFIER tLABEL_TAG
{
$$ = $1;
local_nest(p);
p->lstate = EXPR_ARG; /* make newlines significant after label */
p->lstate = EXPR_MID; /* make newlines significant after label */
}
| tNUMPARAM tLABEL_TAG
{
$$ = intern_numparam($1);
local_nest(p);
p->lstate = EXPR_ARG; /* make newlines significant after label */
p->lstate = EXPR_MID; /* make newlines significant after label */
}
;
File diff suppressed because it is too large Load Diff
+14
View File
@@ -680,6 +680,20 @@ assert 'keyword arguments' do
assert_equal [{a: 1}, {b: 2}], m({a: 1}, b: 2)
assert_raise(ArgumentError) { m({a: 1}, {b: 2}) }
def m1(a: {}) a end
assert_equal({}, m1)
assert_equal(:abc, m1(a: :abc))
def m2(a: +1) a end
assert_equal(1, m2)
assert_nothing_raised do
def m3 arg:
123
end
end
assert_equal(123, m3(arg: 456))
def m(*, a:) a end
assert_equal 1, m(a: 1)
assert_equal 3, m(1, 2, a: 3)