khasinski · GitHub

@khasinski

gemini-code-assist[bot]

When defining a method with a required keyword argument without
parentheses, mruby incorrectly parsed the next line as the default
value:
    def foo arg:
      123
    end
Was parsed as: def foo(arg: 123); end  (optional kwarg, empty body)
Should be:     def foo(arg:); 123; end (required kwarg, body returns 123)
The fix sets EXPR_ARG lexer state after parsing f_label, making
newlines significant. This prevents the parser from consuming
expressions across line boundaries as default values for keyword
arguments.
Also fixes a pre-existing bug in f_label where tNUMPARAM (type <num>)
was implicitly assigned to $$ (type <id>) without conversion. Now
explicitly uses intern_numparam() to convert numbered parameters to
symbols.
Fixes mruby#6268

@khasinski

@matz

@khasinski

khasinski deleted the fix-required-kwarg-parsing branch

January 8, 2026 20:38

Merged

Read the original on github.com ↗