Skip to content

Commit

Permalink
Proc type should be enclosed in parentheses.
Browse files Browse the repository at this point in the history
  • Loading branch information
ksss committed Sep 27, 2023
1 parent 95cc8b8 commit 99cbd22
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/rbs/types.rb
Original file line number Diff line number Diff line change
Expand Up @@ -552,6 +552,8 @@ def to_s(level = 0)
when Symbol
return "#{type.to_s(1)} ?"
end
when RBS::Types::Proc
return "(#{type.to_s(1)})?"
end

"#{type.to_s(1)}?"
Expand Down
1 change: 1 addition & 0 deletions test/rbs/types_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ def test_to_s
assert_equal "(Integer | String & bool)?", parse_type("(Integer | String & bool)?").to_s
assert_equal "((Integer | String) & bool)?", parse_type("((Integer | String) & bool)?").to_s
assert_equal "^() -> void", parse_type("^() -> void").to_s
assert_equal "(^() -> void)?", parse_type("(^() -> void)?").to_s
assert_equal "^(bool flag, ?untyped, *Symbol, name: String, ?email: nil, **Symbol) -> void", parse_type("^(bool flag, ?untyped, *Symbol, name: String, ?email: nil, **Symbol) -> void").to_s
assert_equal "^(untyped untyped, untyped footype) -> void", parse_type("^(untyped `untyped`, untyped footype) -> void").to_s
end
Expand Down

0 comments on commit 99cbd22

Please sign in to comment.