Skip to content

fix: Fix crash with default arguments. #24

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
merged 1 commit into from
Jul 18, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion scip_indexer/SCIPIndexer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -825,7 +825,10 @@ class CFGTraversal final {
}
// For aliases, don't emit an occurrence for the LHS; it will be emitted
// when the alias is used or separately at the end. See NOTE[alias-handling].
if (binding.value.tag() != cfg::Tag::Alias) {
//
// For ArgPresent instructions (which come up with default arguments), we will
// emit defs/refs for direct usages, so don't emit a local for the temporary here.
if (binding.value.tag() != cfg::Tag::Alias && binding.value.tag() != cfg::Tag::ArgPresent) {
// Emit occurrence information for the LHS
auto occ = cfg::LocalOccurrence{binding.bind.variable, lhsLocIfPresent(binding)};
this->emitLocalOccurrence(cfg, bb, occ, ValueCategory::LValue);
Expand Down
13 changes: 13 additions & 0 deletions test/scip/testdata/args.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,16 @@ def args(x, y)
end
z
end

def keyword_args(w:, x: 3, y: [], **kwargs)
y << w + x
y << [a]
return
end

def use_kwargs
h = { a: 3 }
keyword_args(w: 0, **h)
keyword_args(w: 0, x: 1, y: [2], **h)
return
end
27 changes: 27 additions & 0 deletions test/scip/testdata/args.snapshot.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,30 @@ def args(x, y)
z
# ^ reference local 3~#2634721084
end

def keyword_args(w:, x: 3, y: [], **kwargs)
#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition scip-ruby gem TODO TODO Object#keyword_args().
# ^^ definition local 1~#3526982640
# ^^ definition local 2~#3526982640
# ^^ definition local 3~#3526982640
y << w + x
# ^ reference local 3~#3526982640
# ^ reference local 1~#3526982640
# ^ reference local 2~#3526982640
y << [a]
# ^ reference local 3~#3526982640
return
end

def use_kwargs
#^^^^^^^^^^^^^^ definition scip-ruby gem TODO TODO Object#use_kwargs().
h = { a: 3 }
# ^ definition local 1~#571973038
keyword_args(w: 0, **h)
# ^^^^^^^^^^^^ reference scip-ruby gem TODO TODO Object#keyword_args().
# ^ reference local 1~#571973038
keyword_args(w: 0, x: 1, y: [2], **h)
# ^^^^^^^^^^^^ reference scip-ruby gem TODO TODO Object#keyword_args().
# ^ reference local 1~#571973038
return
end