-
-
Notifications
You must be signed in to change notification settings - Fork 158
Specify more inference behavior for variable reassignment #863
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@castwide: As I work towards flow-sensitive typing, I'd like to get consensus on what exactly we ideally want types to be inferred as when variables are reassigned. Would you mind looking through these to see if any of them seem controversial? |
|
||
clip = api_map.clip_at('test.rb', [8, 6]) | ||
expect(clip.infer.to_s).to eq('Foo') | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The above are behavior that I managed to break in some of my early attempts, so I figured I'd get them merged in advance to tie my hands in #856 :)
Tests look reasonable to me. 👍 |
* Retire more RubyVM-specific code * Add basic plugin integration testing (#798) * Add basic plugin integration testing Add a GitHub Actions workflow to run very basic smoke tests for solargraph-rails and solargraph rspec (typechecking and then running solargraph's specs with it installed and configured) Also: * Document solargraph-rspec as a plugin in README.md * Add solargraph-rspec to .Gemfile as well * Fix YAML syntax * Fix GitHub workflow syntax * Fix GitHub workflow syntax * Fix GitHub workflow syntax * Fix GitHub workflow syntax * Switch yq syntax for the *other* yq, cache apt installation * Switch yq syntax for the *other* yq, cache apt installation * Restore Legacy module for solargraph-rails backwards compatibility * Infer block-pass symbols (#793) * BlockSymbol link * First iteration of block-pass symbol resolution * Chain::Call#block * Superfluous block tracking * Refactor NodeChainer * Fix chain block check * Sync with #780 * BlockSymbol link * First iteration of block-pass symbol resolution * Change spec to test Call#block * Resolve generics from BlockSymbol * More annotations in Solargraph code (#801) * More annotations in Solargraph code * More annotations from strict typechecking * More internal annotations * Add some method overloads * Add #to_rbs methods to pins, use for better .inspect() output (#789) * Add #to_rbs methods to pins, use for better .inspect() output * Add inspect() to Chain::Link, to_rbs to Pin::Namespace * Fix typo * Show variable assignments in #desc * Method generics resolution via argument types (#794) * Improve block handling in signature selection Fixes #777 * Resolve method generics * Track generics in method signatures from RBS and YARD * Erase method generics that couldn't be resolved * Refactor Pin#resolve_types to use Pin#transform_types * Fix issues with UniqueType#transform() * Cleanups * Move to keyword parameters for resolved_generic_values * Add type erasure, method pin rewrite code * Populate Method parameter/return_type/block from signature * Mark completed TODOs * Ruby 3.0 compatibility * Add erase_generics() to ComplexType::TypeMethods * TODO -> @todo * Resolve some TODOs * Resolve TODOs * Revert accidental change * Bring back spec * Provide full tag to get_method_stack() for better inference * Fix a missed spot referring to allowlist * Ensure Signature#generics is not nil * Various #to_rbs and #inspect improvements * Clean up code * Drop accidental addition * Improve RBS generation from UniqueType * Use rooted names when generating RBS when available * Drop bad documentation * Remove deprecated commands (#790) * Cache command * Add :if support to NodeChainer for if statements as lvalues (#805) * Add :if support to NodeChainer for if statements as lvalues * Add :if support to NodeChainer for if statements as lvalues * Fix ApiMap::Cache (#806) * Fix ApiMap::Cache * Refactoring * Gems command * Various DocMap improvements (#807) * Retire dead DocMap-related code, restore 'solargraph uncache' * Best-effort work to support bundler's 'path:' directive in Gemfiles * Restore support for 'solargraph uncache' * Clarify names in DocMap * Tell Thor to exit with status 1 on error, inc. deprecated command * Clarify shell deprecation messages * Send deprecation errors to stderr * Fix merge * Async gem caching (#809) * Various regression and future-feature specs (#800) * Various regression and future-feature specs * Merge remote-tracking branch 'origin/master' into more_specs * Another batch of specs * Drop duplicated spec * Various regression and future-feature specs * Various regression and future-feature specs * Resolve a small issue found on merge * Fix pre-mature marking of spec as ready * Unify method generics resolution (#810) * Map mixins from RBS (#808) * Map mixins from RBS * DRY mixin processing * Fix issue with wrong signature selection by call with block node (#815) We were picking the wrong signature for Enumerator#select and Enumerator#find because Chain::Call didn't have access to the block that was passed in and didn't think the arity matched as a result. * Keep gem pins in memory (#811) * Keep gem pins in memory * DocMap warns on unresolved paths * Fic cache errors * Keep stdlib pins in memory * Move logs for pins in memory from info to debug * Use previous stdlib memory cache * Use cursor node in clip cache index * Changelog * Add more internal type annotations required by strict typechecking (#814) * Add more internal type annotations required by strict typechecking * Add more internal type annotations required by strict typechecking * Fix types in existing annotations * Fix names in existing annotations * Add more internal type annotations required by strict typechecking * Add more internal type annotations required by strict typechecking * Disable ApiMap clip cache (#817) * Refactor gems command (#816) * Use return type of literal blocks in inference (#818) * Use simple return type of literal blocks in inference Also: * Document block symbol handling issue * Add failing spec for less trivial literal block inference * Mark spec as working after merging in latest master * Add Thread::Mutex#synchronize spec just to be sure * Fix an internal return type annotation * Insert Module methods (#820) * ApiMap#get_methods includes Module * Redundant code * Another test * Fix kwoptarg string in Parameter#to_rbs (#822) * Revise documentation formatting (#823) * Revise documentation formatting * Ruby 3.0 compatibility * Changelog * DocMap logging (#825) * Clean up DocMap logging * Remove stale requires and autoloads * Redundant `require 'set'` * Test redundant require * Ignore test in Ruby < 3.1.1 * Stub test * Require set at root and suppress warning * Remove workaround for now-fixed ComplexType.parse limitations (#827) Parser bug was fixed in #775 * Add annotations needed for strict typechecking of solargraph code (#828) * Rescue exceptions in docstring parsing (#830) * Update README * Reject nil requires in live code (#831) * DocMap rejects nil requires * Handle empty requires * RbsMap adds mixins to current namespace (#832) * RbsMap adds mixins to current namespace * Smoke test * Release 0.53.1 * Fix a self-type-related false-positive in strict typechecking (#834) * DocMap fetches gem dependencies (#835) * Use configured command path to spawn solargraph processes (#837) * Release 0.53.2 * Remove redundant core fills (#824) * Remove Errno core fills * Retire CoreSigns * Retire MISSING core fills * Remove implicit .new pins * Stale specs * Switch Class#new to [Caller]#initialize for arity checks * Remove implicit .new pins from source maps * Resolve self type in variable assignments (#839) * Eliminate splat-related false-alarms in strict typechecking (#840) * Dynamic block binding with yieldreceiver (#842) * Rebind with yieldreceiver * Unused rebindable_method_names * Refactor Block#binder_or_nil * Resolve generics by descending through context type (#847) * Release 0.53.3 * [regression] Restore 'Unresolved call' typecheck for stdlib objects (#849) The 'Unresolved call to' typecheck suppresses warnings for calls against non-RBS-origin pins. However, the labeling assigning :rbs as the source of pins from conversions.rb was recently removed as part of an unrelated cleanup. * Lazy dynamic rebinding (#851) * Lazy dynamic rebinding * Stub failing test * Move rebinding to Clip * Restore fill for Class#allocate (#848) * [regression] Ensure YardMap gems have return type for Class<T>.new (#850) * [regression] Ensure YardMap gems have return type for Class<T>.new * Handle self return-type-setting at lower level * Fix bug where signature return type was based only on annotation * Create implicit .new pins in namespace method queries (#853) * Create implicit .new pins in namespace method queries * Comment for Host#locate_pins exception * Release 0.53.3 * Use logger in Solargraph::YardMap::Mapper spec * Add support for simple block argument destructuring (#821) * Add support for simple block argument destructuring * Add spec for Array<Array(String, Integer)>#each * Internal typechecking-driven annotations and code changes (#838) * Internal typechecking-driven annotations and code changes * Add @todo for predicate method return type issue * Internal typechecking-driven annotations and code changes * Benchmark the typecheck command (#852) * Enable passing tests (#854) * Send Gem Caching Progress Notifications to LSP Clients (#855) * Send gem caching notifications * LanguageServer::Progress * DRY progress notifications * Refactor * added failing tests (#573) * [breaking] Fix more complex_type_spec.rb cases (#813) * [breaking] Fix more complex_type_spec.rb cases * Consolidate the code that generates substrings to a single place * Clean up more paths to pass through 'rooted' flag unchanged * [breaking] Drop special-case interpretation of, e.g., `Array<(String)>` as 'one element tuple' for future consistency with https://yardoc.org/types * (String) is a one element tuple in https://yardoc.org/types * <String> is an array of zero or more Strings in https://yardoc.org/types * Array<(String)> could be an Array of one-element tuples or a one element tuple. https://yardoc.org/types treats it as the former. * Array<(String), Integer> is not ambiguous if we accept (String) as a tuple type, but not currently understood by Solargraph. * Close out complex_type_spec @todos for better RBS output * Simplify qualify() with transform() * Resolve merge issue * Mass assignment support - e.g., a, b = ['1', '2'] (#843) * Memoize result of Chain#infer (#857) * Memoize result of Chain#infer * Add links to cache key * Add node.location separately to cache key https://github.com/whitequark/ast/blob/master/lib/ast/node.rb https://github.com/whitequark/parser/blob/05b88aa0468ce29dfa21e1aff2f0506b1d5d82e1/lib/parser/ast/node.rb#L17 Parser::AST adds 'location' in Parser::AST::Node to its superclass AST::Node, but doesn't overwrite the #hash and #eql? methods * Fall back to using links.map(&:word) * Implement eql? and hash for ApiMap for cache coherency * Remove @cache from ApiMap#equality_fields * Remove clip caches (#860) * Add rbs_collection to maps (#858) * Fix flaky rename specs (#869) * Ignore malformed mixins and overloads (#862) * Ignore malformed mixins * Ignore malformed overload tags * Add internal type annotations needed for strict-level typechecking (#865) * Add internal type annotations needed for strict-level typechecking * Fix annotations * Add internal type annotations needed for strict-level typechecking * Fix flaky rename specs * Move to untyped as Hash value --------- Co-authored-by: Fred Snyder <[email protected]> * Drop Parser::ParserGem::ClassMethods#returns_from_node (#866) * Refactor TypeChecker#argument_problems_for for type safety (#867) * Refactor TypeChecker#argument_problems_for for type safety This should put it in a state that it can pass type checking once we have another feature or two * Editor compatibility hack * Fix class name * Fix flaky rename specs --------- Co-authored-by: Fred Snyder <[email protected]> * Specify more type behavior for variable reassignment (#863) * One-step source synchronization (#871) * One-step source synchronization * Synchronize libraries * Fix progress notification timing (#873) * Show cache progress in shell commands (#874) * Show cache progress in shell commands * Typecheck error --------- Co-authored-by: Fred Snyder <[email protected]> Co-authored-by: BonitaTerror <[email protected]>
No description provided.