-
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.
Merge pull request #1239 from soutaro/rbs-validation
RBS validation
- Loading branch information
Showing
12 changed files
with
302 additions
and
63 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
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 |
---|---|---|
@@ -0,0 +1,48 @@ | ||
module Steep | ||
module Diagnostic | ||
module ResultPrinter2 | ||
def result_line(result) | ||
case result | ||
when Subtyping::Result::Failure | ||
case result.error | ||
when Subtyping::Result::Failure::UnknownPairError | ||
nil | ||
when Subtyping::Result::Failure::UnsatisfiedConstraints | ||
"Unsatisfied constraints: #{result.relation}" | ||
when Subtyping::Result::Failure::MethodMissingError | ||
"Method `#{result.error.name}` is missing" | ||
when Subtyping::Result::Failure::BlockMismatchError | ||
"Incomaptible block: #{result.relation}" | ||
when Subtyping::Result::Failure::ParameterMismatchError | ||
if result.relation.params? | ||
"Incompatible arity: #{result.relation.super_type} and #{result.relation.sub_type}" | ||
else | ||
"Incompatible arity: #{result.relation}" | ||
end | ||
when Subtyping::Result::Failure::PolyMethodSubtyping | ||
"Unsupported polymorphic method comparison: #{result.relation}" | ||
when Subtyping::Result::Failure::SelfBindingMismatch | ||
"Incompatible block self type: #{result.relation}" | ||
end | ||
else | ||
result.relation.to_s | ||
end | ||
end | ||
|
||
def detail_lines | ||
lines = StringIO.new.tap do |io| | ||
failure_path = result.failure_path || [] | ||
failure_path.reverse_each.filter_map do |result| | ||
result_line(result) | ||
end.each.with_index(1) do |message, index| | ||
io.puts "#{" " * (index)}#{message}" | ||
end | ||
end.string.chomp | ||
|
||
unless lines.empty? | ||
lines | ||
end | ||
end | ||
end | ||
end | ||
end |
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
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 |
---|---|---|
@@ -0,0 +1,15 @@ | ||
module LocationHelper : _WithLocation | ||
interface _WithLocation | ||
def location_method: () -> String | ||
end | ||
|
||
def hello: () -> void | ||
end | ||
|
||
class StringGeneric[X < Integer, Y < Integer = String] | ||
def location_method: () -> Integer | ||
|
||
include LocationHelper | ||
extend LocationHelper | ||
end | ||
|
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 |
---|---|---|
@@ -0,0 +1,13 @@ | ||
module Steep | ||
module Diagnostic | ||
module ResultPrinter2 : _DiagnosticWithResult | ||
interface _DiagnosticWithResult | ||
def result: () -> Subtyping::Result::t | ||
end | ||
|
||
def result_line: (Subtyping::Result::t result) -> String? | ||
|
||
def detail_lines: () -> String? | ||
end | ||
end | ||
end |
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
Oops, something went wrong.