Tags: sharpobject/sorbet
Tags
Update Hash#merge! RBI definition (sorbet#3445) Prior RBI definition did not know about Hash#merge! accepting multiple a splat of Hashes and merging into self. This PR fixes that. The method doc and code samples were also updated, copied from Ruby 2.7's documentation.
ruby27: Add kwargs field to parser::Hash (sorbet#3421) * Add kwargs field to parser::Hash This lets us model how Ruby 2.7 treats keyword args better. Compare this (hash literal, mentions curly braces): ❯ ruby --dump=parsetree -e 'foo({x: 0})' ########################################################### ## Do NOT use this node dump for any purpose other than ## ## debug and research. Compatibility is not guaranteed. ## ########################################################### # @ NODE_SCOPE (line: 1, location: (1,0)-(1,11)) # +- nd_tbl: (empty) # +- nd_args: # | (null node) # +- nd_body: # @ NODE_FCALL (line: 1, location: (1,0)-(1,11))* # +- nd_mid: :foo # +- nd_args: # @ NODE_LIST (line: 1, location: (1,4)-(1,10)) # +- nd_alen: 1 # +- nd_head: # | @ NODE_HASH (line: 1, location: (1,4)-(1,10)) # | +- nd_brace: 1 (hash literal) # | +- nd_head: # | @ NODE_LIST (line: 1, location: (1,5)-(1,9)) # | +- nd_alen: 2 # | +- nd_head: # | | @ NODE_LIT (line: 1, location: (1,5)-(1,7)) # | | +- nd_lit: :x # | +- nd_head: # | | @ NODE_LIT (line: 1, location: (1,8)-(1,9)) # | | +- nd_lit: 0 # | +- nd_next: # | (null node) # +- nd_next: # (null node) with this (keyword args, doesn't mention curly braces): ❯ ruby --dump=parsetree -e 'foo(x: 0)' ########################################################### ## Do NOT use this node dump for any purpose other than ## ## debug and research. Compatibility is not guaranteed. ## ########################################################### # @ NODE_SCOPE (line: 1, location: (1,0)-(1,9)) # +- nd_tbl: (empty) # +- nd_args: # | (null node) # +- nd_body: # @ NODE_FCALL (line: 1, location: (1,0)-(1,9))* # +- nd_mid: :foo # +- nd_args: # @ NODE_LIST (line: 1, location: (1,4)-(1,8)) # +- nd_alen: 1 # +- nd_head: # | @ NODE_HASH (line: 1, location: (1,4)-(1,8)) # | +- nd_brace: 0 (keyword argument) # | +- nd_head: # | @ NODE_LIST (line: 1, location: (1,4)-(1,8)) # | +- nd_alen: 2 # | +- nd_head: # | | @ NODE_LIT (line: 1, location: (1,4)-(1,6)) # | | +- nd_lit: :x # | +- nd_head: # | | @ NODE_LIT (line: 1, location: (1,7)-(1,8)) # | | +- nd_lit: 0 # | +- nd_next: # | (null node) # +- nd_next: # (null node) Specifically, look for the `nd_brace` field on `NODE_HASH`. * Update parse tree test output for Hash node changes * Add a test for various kwargs parse trees Co-authored-by: Trevor Elliott <awesomelyawesome@gmail.com>
Fix crash when escaping JSON strings with UTF-8 characters (sorbet#3447) Signed-off-by: Alexandre Terrasa <alexandre.terrasa@shopify.com>
Split metrics for modules and classes count (sorbet#3441) Signed-off-by: Alexandre Terrasa <alexandre.terrasa@shopify.com>
Penelope add exception base (sorbet#3442) * Add Exception as a possible argument to Exception's constructor. This is to allow wrapping exceptions to be typed: ``` (penelope-add-exception-base)$ irb irb(main):001:0> e = RuntimeError.new => #<RuntimeError: RuntimeError> irb(main):002:0> Exception.new(e) => #<Exception: RuntimeError> irb(main):003:0> ``` * add a test
Fix wrong signature for `StringScanner#scan`. (sorbet#3438)
Fix easy Lint and Performance Rubocop TODOs (sorbet#3433) * rubocop_todo: Lint/BinaryOperatorWithIdenticalOperands * rubocop_todo: Lint/BooleanSymbol * rubocop_todo: Lint/MissingSuper * rubocop_todo: Lint/SafeNavigationChain * rubocop_todo: Lint/UnusedBlockArgument * rubocop_todo: Lint/UselessAssignment * rubocop_todo: Lint/UselessMethodDefinition * rubocop_todo: Performance/CollectionLiteralInLoop * rubocop_todo: Performance/RegexpMatch * rubocop_todo: Performance/StringInclude
Remove the big lub test. (sorbet#3430) It's too slow.
Fix `hidden-methods` failure in Ruby 2.7 (sorbet#3422) Resolves sorbet#2771 Due to the way argument forwarding is implemented in Ruby 2.7, at runtime Sorbet will see parameter names for the expanded method parameters that are invalid. This causes a failure in the hidden methods generation process since the output ends up being an invalid RBI file. The fix is to sanitize the parameter names to be valid unique names so that we still capture the runtime method signature but also have valid parameter names as well.
PreviousNext