From caf3b101779fbe987e36e5544b6e7083157bd666 Mon Sep 17 00:00:00 2001 From: Varun Gandhi Date: Tue, 4 Oct 2022 20:39:25 +0800 Subject: [PATCH 1/2] test: Add crashing test with defaulted block params. --- test/scip/testdata/blocks_lambdas_procs.rb | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/test/scip/testdata/blocks_lambdas_procs.rb b/test/scip/testdata/blocks_lambdas_procs.rb index 2748a4a54..9cb86032b 100644 --- a/test/scip/testdata/blocks_lambdas_procs.rb +++ b/test/scip/testdata/blocks_lambdas_procs.rb @@ -49,3 +49,15 @@ def prc p3.call(x: 3) p4.call(x: 4) end + +def call_block(&blk) + blk.call +end + +def use_block_with_defaults + call_block do |oops: nil| + end + + call_block do |oops = "nil"| + end +end From f5383246ed343c5f101d7886d8a0edc2955db8cb Mon Sep 17 00:00:00 2001 From: Varun Gandhi Date: Tue, 4 Oct 2022 20:41:07 +0800 Subject: [PATCH 2/2] fix: Fix crash with defaulted lambda parameters. --- scip_indexer/SCIPIndexer.cc | 4 ++-- .../testdata/blocks_lambdas_procs.snapshot.rb | 20 +++++++++++++++++++ 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/scip_indexer/SCIPIndexer.cc b/scip_indexer/SCIPIndexer.cc index a324ef609..08f3c1713 100644 --- a/scip_indexer/SCIPIndexer.cc +++ b/scip_indexer/SCIPIndexer.cc @@ -69,8 +69,8 @@ static bool isTemporary(const core::GlobalState &gs, const core::LocalVariable & } auto n = var._name; return n == Names::blockPreCallTemp() || n == Names::blockTemp() || n == Names::blockPassTemp() || - n == Names::blkArg() || n == Names::blockCall() || n == Names::blockBreakAssign() || n == Names::forTemp() || - n == Names::keepForCfgTemp() || + n == Names::blkArg() || n == Names::blockCall() || n == Names::blockBreakAssign() || + n == Names::argPresent() || n == Names::forTemp() || n == Names::keepForCfgTemp() || // Insert checks because sometimes temporaries are initialized with a 0 unique value. 😬 n == Names::finalReturn() || n == NameRef::noName() || n == Names::blockCall() || n == Names::selfLocal() || n == Names::unconditional(); diff --git a/test/scip/testdata/blocks_lambdas_procs.snapshot.rb b/test/scip/testdata/blocks_lambdas_procs.snapshot.rb index bfb0055fa..b64e7fd88 100644 --- a/test/scip/testdata/blocks_lambdas_procs.snapshot.rb +++ b/test/scip/testdata/blocks_lambdas_procs.snapshot.rb @@ -141,3 +141,23 @@ def prc # ^^ reference local 11~#1283111692 # ^^^^ reference [..] Proc#call(). end + + def call_block(&blk) +# ^^^^^^^^^^ definition [..] Object#call_block(). +# ^^^ definition local 1~#1487178087 + blk.call +# ^^^ reference local 1~#1487178087 + end + + def use_block_with_defaults +# ^^^^^^^^^^^^^^^^^^^^^^^ definition [..] Object#use_block_with_defaults(). + call_block do |oops: nil| +# ^^^^^^^^^^ reference [..] Object#call_block(). +# ^^^^^ definition local 1~#4118119342 + end + + call_block do |oops = "nil"| +# ^^^^^^^^^^ reference [..] Object#call_block(). +# ^^^^ definition local 2~#4118119342 + end + end