From 5b00be4954a4a9d679a1db29862a8eff1220187a Mon Sep 17 00:00:00 2001 From: Vinicius Stock Date: Wed, 20 Apr 2022 15:08:42 -0400 Subject: [PATCH] Make missing kwargs `nil` instead of `false` --- lib/syntax_tree/parser.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/syntax_tree/parser.rb b/lib/syntax_tree/parser.rb index 696a944c..f167aa83 100644 --- a/lib/syntax_tree/parser.rb +++ b/lib/syntax_tree/parser.rb @@ -2079,12 +2079,16 @@ def on_params( keyword_rest, block ) + # This is to make it so that required keyword arguments + # have a `nil` for the value instead of a `false`. + keywords&.map! { |(key, value)| [key, value || nil] } + parts = [ *requireds, *optionals&.flatten(1), rest, *posts, - *keywords&.flat_map { |(key, value)| [key, value || nil] }, + *keywords&.flatten(1), (keyword_rest if keyword_rest != :nil), (block if block != :&) ].compact