-
Notifications
You must be signed in to change notification settings - Fork 3
feat: Add support for fields, attribute accessors and funcs in method calls #21
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
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Closed
57 tasks
This patch rewrites the handling for aliases to largely consistently handle classes etc., instead of having one-off hacks. (TBF, I didn't fully understand how aliases worked earlier.) Thanks to this, constants also seem to mostly work now.
While I was working on attr_* items, I needed to fix the implementation for methods. It seems much simpler now, and we automatically get stdlib support as a result. I'll add proper support for attr_* items in a subsequent PR, since it requires some more plumbing, and it seems useful to keep merging things; this PR has already gotten quite big.
0adb0ca
to
d5d83fa
Compare
varungandhi-src
commented
Jul 15, 2022
Comment on lines
-100
to
+102
# ^ reference scip-ruby gem TODO TODO C7#j(). | ||
# ^ reference scip-ruby gem TODO TODO C7#<Class:M8>#i(). |
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.
This was just plain incorrect earlier and I didn't even notice. 🤦🏽
varungandhi-src
added a commit
that referenced
this pull request
Jul 20, 2022
This patch rewrites the handling for aliases to largely consistently handle classes etc., instead of having one-off hacks. (TBF, I didn't fully understand how aliases worked earlier.) Thanks to this, constants also seem to mostly work now. Additionally, adding support for attr_* forms required that we support emitting references for functions in method invocations properly. So I fixed that too. The earlier implementation of trying recursive lookup seems very silly in hindsight. 🤦🏽 However thanks to this change, we also get support for occurrences from the stdlib for "free."
varungandhi-src
added a commit
that referenced
this pull request
Jul 29, 2022
This patch rewrites the handling for aliases to largely consistently handle classes etc., instead of having one-off hacks. (TBF, I didn't fully understand how aliases worked earlier.) Thanks to this, constants also seem to mostly work now. Additionally, adding support for attr_* forms required that we support emitting references for functions in method invocations properly. So I fixed that too. The earlier implementation of trying recursive lookup seems very silly in hindsight. 🤦🏽 However thanks to this change, we also get support for occurrences from the stdlib for "free."
varungandhi-src
pushed a commit
that referenced
this pull request
Aug 5, 2022
* Add a failing test + exec test/lsp_test_runner --single_test=test/testdata/lsp/go_to_type_definition.rb Pausing Resuming [doctest] doctest version is "2.4.1" [doctest] run with "--help" for options [2022-08-01 22:09:09.445] [fatalFallback] [error] Exception::raise(): ./core/TypePtr.h:223 enforced condition store != 0 has failed: (no message provided) [2022-08-01 22:09:09.490] [fatalFallback] [error] Backtrace: #3 0xc859b2 #4 0xdbc197 sorbet::core::TypePtr::tag() #5 0xef9fe7 sorbet::realmain::lsp::(anonymous namespace)::locsForType()::$_13::operator()() #6 0xef95d3 sorbet::typecaseHelper<>() #7 0xef8f85 sorbet::typecase<>() #8 0xef8b0a sorbet::realmain::lsp::(anonymous namespace)::locsForType() #9 0xef859f sorbet::realmain::lsp::TypeDefinitionTask::runRequest() #10 0xda699c sorbet::realmain::lsp::LSPRequestTask::run() #11 0xf160f4 sorbet::realmain::lsp::(anonymous namespace)::TypecheckerTask::run() #12 0xf1454e sorbet::realmain::lsp::LSPTypecheckerCoordinator::asyncRunInternal() #13 0xf14620 sorbet::realmain::lsp::LSPTypecheckerCoordinator::syncRun() #14 0xf12d44 sorbet::realmain::lsp::LSPLoop::runTask() #15 0xf12698 sorbet::realmain::lsp::LSPLoop::processRequests() #16 0xf0410d sorbet::realmain::lsp::SingleThreadedLSPWrapper::getLSPResponsesFor() #17 0xcbf398 sorbet::test::getLSPResponsesFor() #18 0xcbcece sorbet::test::getLSPResponsesFor() #19 0xcf1709 sorbet::test::TypeDefAssertion::check() #20 0xbbff18 sorbet::test::_DOCTEST_ANON_FUNC_71() #21 0x1d060a9 doctest::Context::run() #22 0xbc2380 main #23 0x7f162d27c083 __libc_start_main #24 0xbb34ae _start [2022-08-01 22:09:09.496] [fatalFallback] [error] Backtrace: #3 0x1d8f6e8 std::terminate() #4 0xbcb94b #5 0xdbc1c9 #6 0xef9fe7 sorbet::realmain::lsp::(anonymous namespace)::locsForType()::$_13::operator()() #7 0xef95d3 sorbet::typecaseHelper<>() #8 0xef8f85 sorbet::typecase<>() #9 0xef8b0a sorbet::realmain::lsp::(anonymous namespace)::locsForType() #10 0xef859f sorbet::realmain::lsp::TypeDefinitionTask::runRequest() #11 0xda699c sorbet::realmain::lsp::LSPRequestTask::run() #12 0xf160f4 sorbet::realmain::lsp::(anonymous namespace)::TypecheckerTask::run() #13 0xf1454e sorbet::realmain::lsp::LSPTypecheckerCoordinator::asyncRunInternal() #14 0xf14620 sorbet::realmain::lsp::LSPTypecheckerCoordinator::syncRun() #15 0xf12d44 sorbet::realmain::lsp::LSPLoop::runTask() #16 0xf12698 sorbet::realmain::lsp::LSPLoop::processRequests() #17 0xf0410d sorbet::realmain::lsp::SingleThreadedLSPWrapper::getLSPResponsesFor() #18 0xcbf398 sorbet::test::getLSPResponsesFor() #19 0xcbcece sorbet::test::getLSPResponsesFor() #20 0xcf1709 sorbet::test::TypeDefAssertion::check() #21 0xbbff18 sorbet::test::_DOCTEST_ANON_FUNC_71() #22 0x1d060a9 doctest::Context::run() #23 0xbc2380 main #24 0x7f162d27c083 __libc_start_main #25 0xbb34ae _start libc++abi: terminate_handler unexpectedly returned =============================================================================== test/lsp_test_runner.cc:497: TEST CASE: LSPTest test/lsp_test_runner.cc:497: FATAL ERROR: test case CRASHED: SIGABRT - Abort (abnormal termination) signal * Set type to untyped if null
varungandhi-src
pushed a commit
that referenced
this pull request
Jun 25, 2024
* Add a failing test * thread #1, name = 'lsp_test_runner', stop reason = signal SIGSEGV: invalid address (fault address: 0x0) * frame #0: 0x0000000000e3d2c5 lsp_test_runner`absl::inlined_vector_internal::Storage<sorbet::core::SymbolRef, 1ul, std::__1::allocator<sorbet::core::SymbolRef>>::GetIsAllocated(this=0x0000000000000000) const at inlined_vector.h:353:40 frame #1: 0x0000000000eabec9 lsp_test_runner`absl::InlinedVector<sorbet::core::SymbolRef, 1ul, std::__1::allocator<sorbet::core::SymbolRef>>::data(this=0x0000000000000000) const at inlined_vector.h:305:21 frame #2: 0x0000000000eabb3a lsp_test_runner`absl::InlinedVector<sorbet::core::SymbolRef, 1ul, std::__1::allocator<sorbet::core::SymbolRef>>::operator=(this=0x00007fffffff6fe8, other=0x0000000000000000) at inlined_vector.h:465:40 frame #3: 0x0000000000ea879f lsp_test_runner`sorbet::realmain::lsp::(anonymous namespace)::matchesQuery(ctx=Context @ 0x00007fffffff7100, lit=0x00000000035c0cc0, lspQuery=0x0000000002d0bfd0, symbolBeforeDealias=(_id = 24890)) at DefLocSaver.cc:121:24 frame #4: 0x0000000000ea8357 lsp_test_runner`sorbet::realmain::lsp::DefLocSaver::postTransformConstantLit(this=0x00007fffffff86b8, ctx=Context @ 0x00007fffffff7148, tree=0x0000000002be4140) at DefLocSaver.cc:144:5 frame #5: 0x0000000000e682da lsp_test_runner`decltype(self=0x00007fffffff86b8, args=0x00007fffffff7380, args=0x0000000002be4140) sorbet::ast::MapFunctions<(sorbet::ast::TreeMapKind)1>::CALL_MEMBER_impl_postTransformConstantLit<sorbet::realmain::lsp::DefLocSaver, true>::call<sorbet::core::Context&, sorbet::ast::ExpressionPtr&>(sorbet::realmain::lsp::DefLocSaver&, sorbet::core::Context&, sorbet::ast::ExpressionPtr&) at treemap.h:168:5 frame #6: 0x0000000000e65ce8 lsp_test_runner`sorbet::ast::TreeMapper<sorbet::realmain::lsp::DefLocSaver, sorbet::core::Context, (sorbet::ast::TreeMapKind)1, (sorbet::ast::TreeMapDepthKind)0>::mapConstantLit(this=0x00007fffffff8648, v=0x0000000002be4140, ctx=Context @ 0x00007fffffff7380) at treemap.h:417:9 frame #7: 0x0000000000e64515 lsp_test_runner`sorbet::ast::TreeMapper<sorbet::realmain::lsp::DefLocSaver, sorbet::core::Context, (sorbet::ast::TreeMapKind)1, (sorbet::ast::TreeMapDepthKind)0>::mapIt(this=0x00007fffffff8648, what=0x0000000002be4140, ctx=Context @ 0x00007fffffff7780) at treemap.h:569:28 frame #8: 0x0000000000e649a0 lsp_test_runner`sorbet::ast::TreeMapper<sorbet::realmain::lsp::DefLocSaver, sorbet::core::Context, (sorbet::ast::TreeMapKind)1, (sorbet::ast::TreeMapDepthKind)0>::mapSend(this=0x00007fffffff8648, v=0x0000000002c9d308, ctx=Context @ 0x00007fffffff7bd0) at treemap.h:372:13 frame #9: 0x0000000000e63c11 lsp_test_runner`sorbet::ast::TreeMapper<sorbet::realmain::lsp::DefLocSaver, sorbet::core::Context, (sorbet::ast::TreeMapKind)1, (sorbet::ast::TreeMapDepthKind)0>::mapIt(this=0x00007fffffff8648, what=0x0000000002c9d308, ctx=Context @ 0x00007fffffff7c50) at treemap.h:491:28 frame #10: 0x0000000000e64dd4 lsp_test_runner`sorbet::ast::TreeMapper<sorbet::realmain::lsp::DefLocSaver, sorbet::core::Context, (sorbet::ast::TreeMapKind)1, (sorbet::ast::TreeMapDepthKind)0>::mapClassDef(this=0x00007fffffff8648, v=0x0000000002bc0fa0, ctx=Context @ 0x00007fffffff8070) at treemap.h:249:13 frame #11: 0x0000000000e63c75 lsp_test_runner`sorbet::ast::TreeMapper<sorbet::realmain::lsp::DefLocSaver, sorbet::core::Context, (sorbet::ast::TreeMapKind)1, (sorbet::ast::TreeMapDepthKind)0>::mapIt(this=0x00007fffffff8648, what=0x0000000002bc0fa0, ctx=Context @ 0x00007fffffff80f0) at treemap.h:494:28 frame #12: 0x0000000000e65e78 lsp_test_runner`sorbet::ast::TreeMapper<sorbet::realmain::lsp::DefLocSaver, sorbet::core::Context, (sorbet::ast::TreeMapKind)1, (sorbet::ast::TreeMapDepthKind)0>::mapInsSeq(this=0x00007fffffff8648, v=0x000000000246d3e0, ctx=Context @ 0x00007fffffff82f0) at treemap.h:438:13 frame #13: 0x0000000000e645c6 lsp_test_runner`sorbet::ast::TreeMapper<sorbet::realmain::lsp::DefLocSaver, sorbet::core::Context, (sorbet::ast::TreeMapKind)1, (sorbet::ast::TreeMapDepthKind)0>::mapIt(this=0x00007fffffff8648, what=0x000000000246d3e0, ctx=Context @ 0x00007fffffff8638) at treemap.h:582:28 frame #14: 0x0000000000e6397a lsp_test_runner`void sorbet::ast::TreeWalk::apply<sorbet::core::Context, sorbet::realmain::lsp::DefLocSaver>(ctx=Context @ 0x00007fffffff8680, func=0x00007fffffff86b8, to=0x000000000246d3e0) at treemap.h:622:20 frame #15: 0x0000000000e52acc lsp_test_runner`sorbet::realmain::lsp::(anonymous namespace)::tryApplyDefLocSaver(gs=0x0000000002d0bf90, indexedCopies=size=1) at LSPTypechecker.cc:621:9 frame #16: 0x0000000000e5235d lsp_test_runner`sorbet::realmain::lsp::LSPTypechecker::query(this=0x0000000002472050, q=0x00007fffffff8ca8, filesForQuery=size=1, workers=0x000000000246e9c0) const at LSPTypechecker.cc:643:5 frame #17: 0x0000000000e53e1b lsp_test_runner`sorbet::realmain::lsp::LSPTypecheckerDelegate::query(this=0x0000000002bc27c0, q=0x00007fffffff8ca8, filesForQuery=size=1) const at LSPTypechecker.cc:770:24 frame #18: 0x0000000000e42128 lsp_test_runner`sorbet::realmain::lsp::LSPQuery::byLoc(config=0x000000000246bcd8, typechecker=0x0000000002bc27c0, uri="file:///Users/jez/stripe/sorbet/test/testdata/lsp/hover_static_field_alias_to_nothing.rb", pos=0x0000000002bc0500, forMethod=TextDocumentHover, errorIfFileIsUntyped=true) at LSPQuery.cc:89:24 frame #19: 0x0000000000f74ee0 lsp_test_runner`sorbet::realmain::lsp::HoverTask::runRequest(this=0x0000000002d373d0, typechecker=0x0000000002bc27c0) at hover.cc:44:19 frame #20: 0x0000000000e3226c lsp_test_runner`sorbet::realmain::lsp::LSPRequestTask::run(this=0x0000000002d373d0, typechecker=0x0000000002bc27c0) at LSPTask.cc:222:21 frame #21: 0x0000000000fbf3e4 lsp_test_runner`sorbet::realmain::lsp::(anonymous namespace)::TypecheckerTask::run(this=0x0000000002bc0028) at LSPTypecheckerCoordinator.cc:58:19 frame #22: 0x0000000000fbda0e lsp_test_runner`sorbet::realmain::lsp::LSPTypecheckerCoordinator::asyncRunInternal(this=0x0000000002471db0, task=std::__1::shared_ptr<sorbet::core::lsp::Task>::element_type @ 0x0000000002bc0028 strong=2 weak=1) at LSPTypecheckerCoordinator.cc:129:15 frame #23: 0x0000000000fbdae0 lsp_test_runner`sorbet::realmain::lsp::LSPTypecheckerCoordinator::syncRun(this=0x0000000002471db0, task=nullptr) at LSPTypecheckerCoordinator.cc:137:5 frame #24: 0x0000000000fb34f8 lsp_test_runner`sorbet::realmain::lsp::LSPLoop::runTask(this=0x0000000002471d28, task=nullptr) at LSPLoop.cc:263:26 frame #25: 0x0000000000fb2e38 lsp_test_runner`sorbet::realmain::lsp::LSPLoop::processRequests(this=0x0000000002471d28, messages=<unavailable>) at LSPLoop.cc:218:13 frame #26: 0x0000000000fa3d6d lsp_test_runner`sorbet::realmain::lsp::SingleThreadedLSPWrapper::getLSPResponsesFor(this=0x000000000246ea10, messages=size=0) at wrapper.cc:68:14 frame #27: 0x0000000000d2afd7 lsp_test_runner`sorbet::test::getLSPResponsesFor(wrapper=0x000000000246ea10, messages=size=0) at lsp.cc:490:27 frame #28: 0x0000000000d2894e lsp_test_runner`sorbet::test::getLSPResponsesFor(wrapper=0x000000000246ea10, message=nullptr) at lsp.cc:530:12 frame #29: 0x0000000000d664a3 lsp_test_runner`sorbet::test::HoverAssertion::check(this=0x0000000001eada28, sourceFileContents=0x00007fffffffc018, wrapper=0x000000000246ea10, nextId=0x00007fffffffbf24, errorPrefix="") at position_assertions.cc:1318:22 frame #30: 0x0000000000d66224 lsp_test_runner`sorbet::test::HoverAssertion::checkAll(assertions=size=2, sourceFileContents=0x00007fffffffc018, wrapper=0x000000000246ea10, nextId=0x00007fffffffbf24, errorPrefix="") at position_assertions.cc:1280:30 frame #31: 0x0000000000c29f46 lsp_test_runner`sorbet::test::DOCTEST_ANON_FUNC_58() at lsp_test_runner.cc:842:5 frame #32: 0x0000000001de1180 lsp_test_runner`doctest::Context::run(this=0x00007fffffffcd58) at doctest.h:6930:21 frame #33: 0x0000000000c2bcd0 lsp_test_runner`main(argc=2, argv=0x00007fffffffd258) at lsp_test_runner.cc:976:20 frame #34: 0x00007ffff7c29d90 libc.so.6`__libc_start_call_main(main=(lsp_test_runner`main at lsp_test_runner.cc:959), argc=2, argv=0x00007fffffffd258) at libc_start_call_main.h:58:16 frame #35: 0x00007ffff7c29e40 libc.so.6`__libc_start_main_impl(main=(lsp_test_runner`main at lsp_test_runner.cc:959), argc=2, argv=0x00007fffffffd258, init=<unavailable>, fini=<unavailable>, rtld_fini=<unavailable>, stack_end=0x00007fffffffd248) at libc-start.c:392:3 frame #36: 0x0000000000c1ac85 lsp_test_runner`_start + 37 * Fix failing test
varungandhi-src
pushed a commit
that referenced
this pull request
Jun 25, 2024
* Add failing test ❯ sorbet test/testdata/definition_validator/superclass_class_loc__1.rb test/testdata/definition_validator/superclass_class_loc__2.rbi msg="Bad offset2Pos off" path="test/testdata/definition_validator/superclass_class_loc__1.rb" off="778"" source="# typed: true\n\nmodule Parent\nend\n\nclass Child < Parent\nend\n" Exception::raise(): core/Loc.cc:43 enforced condition false has failed: (no message provided) Backtrace: #3 0xbb3f32 #4 0x1a5b870 sorbet::core::Loc::offset2Pos() #5 0x1a5bbda sorbet::core::Loc::position() #6 0x1a5da17 sorbet::core::Loc::filePosToString() #7 0x19df6b8 sorbet::core::Error::toString() #8 0x19f292e sorbet::core::ErrorQueue::pushError() #9 0x1a3e882 sorbet::core::GlobalState::_error() #10 0x19e11c0 sorbet::core::ErrorBuilder::~ErrorBuilder() #11 0x1288d5a sorbet::definition_validator::(anonymous namespace)::validateSuperClass() #12 0x12861b6 sorbet::definition_validator::(anonymous namespace)::ValidateWalk::preTransformClassDef() #13 0x1285f6a sorbet::ast::MapFunctions<>::CALL_MEMBER_impl_preTransformClassDef<>::call<>() #14 0x1284c0f sorbet::ast::TreeMapper<>::mapClassDef() #15 0x1283d55 sorbet::ast::TreeMapper<>::mapIt() #16 0x1285a58 sorbet::ast::TreeMapper<>::mapInsSeq() #17 0x12846a6 sorbet::ast::TreeMapper<>::mapIt() #18 0x12839fa sorbet::ast::TreeWalk::apply<>() #19 0x12838db sorbet::definition_validator::runOne() #20 0xf5e8b0 sorbet::realmain::pipeline::(anonymous namespace)::typecheckOne() #21 0xf5e50d sorbet::realmain::pipeline::typecheck()::$_5::operator()() #22 0xf5e19d std::__1::__invoke<>() #23 0xf5e14d std::__1::__invoke_void_return_wrapper<>::__call<>() #24 0xf5e11d std::__1::__function::__alloc_func<>::operator()() #25 0xf5d2e9 std::__1::__function::__func<>::operator()() #26 0x1753d52 std::__1::__function::__value_func<>::operator()() #27 0x174a5f5 std::__1::function<>::operator()() #28 0x1bf5d7a sorbet::WorkerPoolImpl::multiplexJob()::$_2::operator()() #29 0x1bf5d1d std::__1::__invoke<>() #30 0x1bf5ccd std::__1::__invoke_void_return_wrapper<>::__call<>() #31 0x1bf5c9d std::__1::__function::__alloc_func<>::operator()() #32 0x1bf4ea9 std::__1::__function::__func<>::operator()() #33 0x1bfa5b2 std::__1::__function::__value_func<>::operator()() #34 0x1bf91d5 std::__1::function<>::operator()() #35 0x1bf313d sorbet::WorkerPoolImpl::WorkerPoolImpl()::$_0::operator()() #36 0x1bf307d std::__1::__invoke<>() #37 0x1bf302d std::__1::__invoke_void_return_wrapper<>::__call<>() #38 0x1bf2ffd std::__1::__function::__alloc_func<>::operator()() #39 0x1bf2219 std::__1::__function::__func<>::operator()() #40 0x1753d52 std::__1::__function::__value_func<>::operator()() #41 0x174a5f5 std::__1::function<>::operator()() #42 0x1bfdd53 Joinable::trampoline() #43 0x7f5e1d694b43 #44 0x7f5e1d726a00 * Fix failing test
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This patch rewrites the handling for aliases to largely consistently
handle classes etc., instead of having one-off hacks.
(TBF, I didn't fully understand how aliases worked earlier.)
Thanks to this, constants also seem to mostly work now.
Motivation
Progress towards #1.
Test plan
Added some tests for instance variables.
TODO: