Tags: tyty999/sorbet
Tags
Replace most maps in CFG with vectors (sorbet#3346) This PR replaces most maps/sets in CFG with vectors for a significant speedup on individual files with many basic blocks/variables (70%+ faster on one particular input I iterated on). This translates into a noticeable end-to-end speedup on large codebases and improves IDE responsiveness. I was able to do this by introducing a LocalRef abstraction, which is a CFG-local reference to a local variable. Like other Ref classes, a LocalRef has a numerical ID that is the index into a vector of LocalVariables. A LocalRef is also half the size of a LocalVariable (4 bytes). I use LocalRef for two data structures that were key to the speedup: * Vectors of size # of locals that act like maps (vector[LocalRef.id] = value for that LocalRef). These can be preallocated and support insertion/deletion with no further memory allocation at the cost of slower iteration thru elements in the vector. * Sorted vectors that contain LocalRef IDs, which act as sets. These are great for sparse sets that code needs to iterate through. It's cheap to take the union of two of these (linear time). These are less good for lookup (O(n) or O(logn) if using binary search). While working on this change, I made a few additional common case optimizations.
Process Id returned from wait methods can be nil (sorbet#3361) Follow-up to: sorbet#3115 There is a rare but valid case where a certain combination of `pid` values and `flags` to the `Process.wait` (and friends) will make a `nil` return value possible. The previous attempt at fixing the signature had only done it for `Process.wait2` but it should be applied to `Process.wait`, `Process.waitpid` and `Process.waitpid2` as well.
Better detection of enumerable type from an instance (sorbet#3358) * Add failing tests * Change fallback type detection of Enumerable instance When detecting the type of an enumerable from an instance, `TypedEnumerable` tries to match it to a couple of well-known enumerable classes (like `Array`, `Hash`, etc). The fallback case, however, tries to match it to the class of the type that the instance is being validated against, which does not make a lot sense. That behaviour means, if the instance is being compared against `T::Array[Foo]`, we would try to infer the type of the enumerable instance as a kind of `T::Array`. But, if it was being compared against a `T::Set[Foo]`, then the type of the instance would be inferred to be a `T::Set`. This leads to the problem outlined in sorbet#2808. In reality, Sorbet should not try to infer the type based on what type the instance is being compared against, but should return the type of the instance as is.
Return a proper error code when `srb` fails (sorbet#3355) Signed-off-by: Alexandre Terrasa <alexandre.terrasa@shopify.com>
Bump prismjs from 1.20.0 to 1.21.0 in /website (sorbet#3354) Bumps [prismjs](https://github.com/PrismJS/prism) from 1.20.0 to 1.21.0. - [Release notes](https://github.com/PrismJS/prism/releases) - [Changelog](https://github.com/PrismJS/prism/blob/master/CHANGELOG.md) - [Commits](PrismJS/prism@v1.20.0...v1.21.0) Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Fix incorrect `json` sigs (sorbet#3296) We are trying to update to json 2.3 (from 1.8). We use tapioca. After updating `json` and re-running `tapioca` we got these 3 errors from `srb tc`: ``` sorbet/rbi/gems/json@2.3.1.rbi:31: Method JSON.dump redefined without matching argument count. Expected: 2, got: 3 https://srb.help/4010 31 | def self.dump(obj, anIO = _, limit = _); end ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ https://github.com/sorbet/sorbet/tree/576e1fe628309d57783b13d7d7c7e7c546060b49/rbi/stdlib/json.rbi#L137: Previous definition 137 | def self.dump(obj, *args); end ^^^^^^^^^^^^^^^^^^^^^^^^^ sorbet/rbi/gems/json@2.3.1.rbi:36: Method JSON.generate redefined with argument opts as a non-splat argument https://srb.help/4010 36 | def self.generate(obj, opts = _); end ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ https://github.com/sorbet/sorbet/tree/576e1fe628309d57783b13d7d7c7e7c546060b49/rbi/stdlib/json.rbi#L193: The corresponding argument args in the previous definition was a splat argument 193 | def self.generate(obj, *args); end ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ sorbet/rbi/gems/json@2.3.1.rbi:47: Method JSON.pretty_generate redefined with argument opts as a non-splat argument https://srb.help/4010 47 | def self.pretty_generate(obj, opts = _); end ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ https://github.com/sorbet/sorbet/tree/576e1fe628309d57783b13d7d7c7e7c546060b49/rbi/stdlib/json.rbi#L312: The corresponding argument args in the previous definition was a splat argument 312 | def self.pretty_generate(obj, *args); end ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ``` As far as I can tell, in every case tapioca's sig is correct, and matches the method sig in the [json gem](https://github.com/flori/json/blob/v2.3.1/lib/json/common.rb). Therefore I am updating the rbis to match.
lsp_test_runner: Support tests that expect multiple definition locati… …ons. (sorbet#3340) Also refactors some redundant location diffing logic to make code cleaner _and_ shorter.
Fix return type for `Regexp::last_match` (sorbet#3331) * Fix return type for `Regexp::last_match` Signed-off-by: Alexandre Terrasa <alexandre.terrasa@shopify.com> * Fix `Regexp::last_match` type for `arg0` Signed-off-by: Alexandre Terrasa <alexandre.terrasa@shopify.com>
Introduce ENFORCE_FAST to speed up tests in debug builds (sorbet#3341) * Add ENFORCE_FAST, which is a faster version of ENFORCE that omits the timer code. * Use ENFORCE_FAST for SymbolRef::data/dataAllowingNone. * Make Symbol::is* checks faster in debug builds. * ENFORCE_FALSE for SymbolDataDebugCheck::check * ENFORCE_FAST for resolver::computeClassLinearization change * ENFORCE_FAST for other common Symbols methods (mixins(), superClass()). * ENFORCE_FAST more hotspots * ENFORCE_FAST => ENFORCE_NO_TIMER
Actually use fast path for alias_method when checked (sorbet#3339) * Use fast path for alias_method when checked * Add lots more asserts
PreviousNext