Skip to content

Commit

Permalink
Merge pull request #896 from soutaro/begin-conditional
Browse files Browse the repository at this point in the history
Fix type checking parenthesized conditional nodes
  • Loading branch information
soutaro authored Aug 10, 2023
2 parents bbedb8d + 3033fe3 commit a5e5a5e
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 5 deletions.
4 changes: 0 additions & 4 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,3 @@ group :stackprof, optional: true do
gem "stackprof"
end
gem 'minitest-slow_test'

group :development do
gem "ruby-lsp", require: false
end
2 changes: 1 addition & 1 deletion lib/steep/type_construction.rb
Original file line number Diff line number Diff line change
Expand Up @@ -710,7 +710,7 @@ def synthesize(node, hint: nil, condition: false)
end
end

p = pair.constr.synthesize(last_node, hint: hint)
p = pair.constr.synthesize(last_node, hint: hint, condition: condition)
last_pair = pair + p
last_pair.constr.add_typing(node, type: last_pair.type, constr: last_pair.constr)
else
Expand Down
21 changes: 21 additions & 0 deletions test/type_check_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1601,4 +1601,25 @@ def test_untyped_nilp
YAML
)
end

def test_paren_conditional
run_type_check_test(
signatures: {},
code: {
"a.rb" => <<~RUBY
a = [1].first
b = [2].first
if (a && b)
a + b
end
RUBY
},
expectations: <<~YAML
---
- file: a.rb
diagnostics: []
YAML
)
end
end

0 comments on commit a5e5a5e

Please sign in to comment.