-
Notifications
You must be signed in to change notification settings - Fork 93
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Raise UnsupportedSyntax if a proc object is given as block-pass-argument
At present, users will see BlockTypeMismatch diagnostic when a proc object is passed as block-pass-argument. We'll usually see the diagnostic with `&method` idiom. ```ruby [1, 2, 3].map(&method(:puts)) ``` But there is nothing to do from the user side because such a call is not invalid. It seems like a false positive. This changes the diagnostic type for the case to UnsupportedSyntax. It notifies users that the source code is valid and that change is unnecessary. refs: #149
- Loading branch information
Showing
3 changed files
with
153 additions
and
122 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,133 +1,131 @@ | ||
--- | ||
- file: a.rb | ||
diagnostics: | ||
- range: | ||
start: | ||
line: 8 | ||
character: 0 | ||
end: | ||
line: 8 | ||
character: 9 | ||
severity: ERROR | ||
message: |- | ||
Cannot assign a value of type `::Integer` to a variable of type `::String` | ||
::Integer <: ::String | ||
::Numeric <: ::String | ||
::Object <: ::String | ||
::BasicObject <: ::String | ||
code: Ruby::IncompatibleAssignment | ||
- range: | ||
start: | ||
line: 10 | ||
character: 0 | ||
end: | ||
line: 10 | ||
character: 17 | ||
severity: ERROR | ||
message: |- | ||
Cannot assign a value of type `::String` to a variable of type `::Integer` | ||
::String <: ::Integer | ||
::Object <: ::Integer | ||
::BasicObject <: ::Integer | ||
code: Ruby::IncompatibleAssignment | ||
- file: b.rb | ||
diagnostics: | ||
- range: | ||
start: | ||
line: 5 | ||
character: 2 | ||
end: | ||
line: 5 | ||
character: 9 | ||
severity: ERROR | ||
message: |- | ||
Cannot break with a value of type `::Integer` because type `::Symbol` is assumed | ||
::Integer <: ::Symbol | ||
::Numeric <: ::Symbol | ||
::Object <: ::Symbol | ||
::BasicObject <: ::Symbol | ||
code: Ruby::BreakTypeMismatch | ||
- range: | ||
start: | ||
line: 10 | ||
character: 0 | ||
end: | ||
line: 13 | ||
character: 3 | ||
severity: ERROR | ||
message: |- | ||
Cannot assign a value of type `(::Integer | ::Symbol)` to a variable of type `::String` | ||
(::Integer | ::Symbol) <: ::String | ||
- range: | ||
start: | ||
line: 8 | ||
character: 0 | ||
end: | ||
line: 8 | ||
character: 9 | ||
severity: ERROR | ||
message: |- | ||
Cannot assign a value of type `::Integer` to a variable of type `::String` | ||
::Integer <: ::String | ||
::Numeric <: ::String | ||
::Object <: ::String | ||
::BasicObject <: ::String | ||
code: Ruby::IncompatibleAssignment | ||
code: Ruby::IncompatibleAssignment | ||
- range: | ||
start: | ||
line: 10 | ||
character: 0 | ||
end: | ||
line: 10 | ||
character: 17 | ||
severity: ERROR | ||
message: |- | ||
Cannot assign a value of type `::String` to a variable of type `::Integer` | ||
::String <: ::Integer | ||
::Object <: ::Integer | ||
::BasicObject <: ::Integer | ||
code: Ruby::IncompatibleAssignment | ||
- file: b.rb | ||
diagnostics: | ||
- range: | ||
start: | ||
line: 5 | ||
character: 2 | ||
end: | ||
line: 5 | ||
character: 9 | ||
severity: ERROR | ||
message: |- | ||
Cannot break with a value of type `::Integer` because type `::Symbol` is assumed | ||
::Integer <: ::Symbol | ||
::Numeric <: ::Symbol | ||
::Object <: ::Symbol | ||
::BasicObject <: ::Symbol | ||
code: Ruby::BreakTypeMismatch | ||
- range: | ||
start: | ||
line: 10 | ||
character: 0 | ||
end: | ||
line: 13 | ||
character: 3 | ||
severity: ERROR | ||
message: |- | ||
Cannot assign a value of type `(::Integer | ::Symbol)` to a variable of type `::String` | ||
(::Integer | ::Symbol) <: ::String | ||
::Integer <: ::String | ||
::Numeric <: ::String | ||
::Object <: ::String | ||
::BasicObject <: ::String | ||
code: Ruby::IncompatibleAssignment | ||
- file: d.rb | ||
diagnostics: | ||
- range: | ||
start: | ||
line: 6 | ||
character: 0 | ||
end: | ||
line: 6 | ||
character: 19 | ||
severity: ERROR | ||
message: |- | ||
Cannot assign a value of type `::Array[::String]` to a variable of type `::Array[::Float]` | ||
::Array[::String] <: ::Array[::Float] | ||
::String <: ::Float | ||
::Object <: ::Float | ||
::BasicObject <: ::Float | ||
code: Ruby::IncompatibleAssignment | ||
- range: | ||
start: | ||
line: 8 | ||
character: 0 | ||
end: | ||
line: 8 | ||
character: 23 | ||
severity: ERROR | ||
message: |- | ||
Cannot assign a value of type `::Array[::String]` to a variable of type `::Array[::Float]` | ||
::Array[::String] <: ::Array[::Float] | ||
::String <: ::Float | ||
::Object <: ::Float | ||
::BasicObject <: ::Float | ||
code: Ruby::IncompatibleAssignment | ||
- range: | ||
start: | ||
line: 10 | ||
character: 12 | ||
end: | ||
line: 10 | ||
character: 28 | ||
severity: ERROR | ||
message: |- | ||
Cannot pass a value of type `::Proc` as a block-pass-argument of type `^(::Integer) -> U(3)` | ||
::Proc <: ^(::Integer) -> U(3) | ||
code: Ruby::BlockTypeMismatch | ||
- range: | ||
start: | ||
line: 11 | ||
character: 12 | ||
end: | ||
line: 11 | ||
character: 20 | ||
severity: ERROR | ||
message: |- | ||
Cannot pass a value of type `::Proc` as a block-pass-argument of type `^(::Integer) -> U(4)` | ||
::Proc <: ^(::Integer) -> U(4) | ||
code: Ruby::BlockTypeMismatch | ||
- range: | ||
start: | ||
line: 6 | ||
character: 0 | ||
end: | ||
line: 6 | ||
character: 19 | ||
severity: ERROR | ||
message: |- | ||
Cannot assign a value of type `::Array[::String]` to a variable of type `::Array[::Float]` | ||
::Array[::String] <: ::Array[::Float] | ||
::String <: ::Float | ||
::Object <: ::Float | ||
::BasicObject <: ::Float | ||
code: Ruby::IncompatibleAssignment | ||
- range: | ||
start: | ||
line: 8 | ||
character: 0 | ||
end: | ||
line: 8 | ||
character: 23 | ||
severity: ERROR | ||
message: |- | ||
Cannot assign a value of type `::Array[::String]` to a variable of type `::Array[::Float]` | ||
::Array[::String] <: ::Array[::Float] | ||
::String <: ::Float | ||
::Object <: ::Float | ||
::BasicObject <: ::Float | ||
code: Ruby::IncompatibleAssignment | ||
- range: | ||
start: | ||
line: 10 | ||
character: 12 | ||
end: | ||
line: 10 | ||
character: 28 | ||
severity: ERROR | ||
message: |- | ||
Unsupported block-pass-argument given `::Proc` | ||
code: Ruby::UnsupportedSyntax | ||
- range: | ||
start: | ||
line: 11 | ||
character: 12 | ||
end: | ||
line: 11 | ||
character: 20 | ||
severity: ERROR | ||
message: |- | ||
Unsupported block-pass-argument given `::Proc` | ||
code: Ruby::UnsupportedSyntax | ||
- file: e.rb | ||
diagnostics: | ||
- range: | ||
start: | ||
line: 11 | ||
character: 2 | ||
end: | ||
line: 11 | ||
character: 5 | ||
severity: ERROR | ||
message: Type `(::Integer | ::String)` does not have method `foo` | ||
code: Ruby::NoMethod | ||
- range: | ||
start: | ||
line: 11 | ||
character: 2 | ||
end: | ||
line: 11 | ||
character: 5 | ||
severity: ERROR | ||
message: Type `(::Integer | ::String)` does not have method `foo` | ||
code: Ruby::NoMethod |
This file contains 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