Open seven1m opened 1 month ago
We shouldn't always evaluate the default value of an argument. Given the following code:
# default.rb def foo(bar = (bar_missing = true)) p(bar:, bar_missing:) end foo foo(1)
CRuby produces:
→ ruby default.rb {:bar=>true, :bar_missing=>true} {:bar=>1, :bar_missing=>nil}
But Natalie produces:
→ bin/natalie default.rb {:bar=>true, :bar_missing=>true} {:bar=>1, :bar_missing=>true}
I guess a more straightforward way to see this is:
def bar raise 'wat' end def foo(arg = bar) arg end p foo(1)
This raises an error with Natalie.
We shouldn't always evaluate the default value of an argument. Given the following code:
CRuby produces:
But Natalie produces: