Skip to content

Commit 4893e3d

Browse files
committed
Update Sorbet and start fixing sorbet errors
1 parent 285cbe3 commit 4893e3d

File tree

17 files changed

+111
-52
lines changed

17 files changed

+111
-52
lines changed

.github/workflows/build.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,8 @@ jobs:
5050
- name: RBS Inline
5151
run: bundle exec rake rbs_inline
5252

53-
# - name: Sorbet
54-
# run: bundle exec srb tc
53+
- name: Sorbet
54+
run: bundle exec srb tc
5555

5656
- name: Run C tests
5757
run: ./run_herb_tests

Gemfile.lock

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -113,11 +113,11 @@ GEM
113113
prism (~> 1.4)
114114
ruby-progressbar (1.13.0)
115115
securerandom (0.4.1)
116-
sorbet (0.5.12214)
117-
sorbet-static (= 0.5.12214)
118-
sorbet-static (0.5.12214-aarch64-linux)
119-
sorbet-static (0.5.12214-universal-darwin)
120-
sorbet-static (0.5.12214-x86_64-linux)
116+
sorbet (0.6.12473)
117+
sorbet-static (= 0.6.12473)
118+
sorbet-static (0.6.12473-aarch64-linux)
119+
sorbet-static (0.6.12473-universal-darwin)
120+
sorbet-static (0.6.12473-x86_64-linux)
121121
steep (1.10.0)
122122
activesupport (>= 5.1)
123123
concurrent-ruby (>= 1.1.10)

lib/herb/ast/node.rb

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,22 +4,30 @@
44
module Herb
55
module AST
66
class Node
7-
attr_reader :type #: String
8-
attr_reader :location #: Location
9-
attr_reader :errors #: Array[Herb::Errors::Error]
10-
11-
#: (String, Location, Array[Herb::Errors::Error]) -> void
7+
#: String
8+
attr_reader :type
9+
#: Location
10+
attr_reader :location
11+
#: Array[Herb::Errors::Error]
12+
attr_reader :errors
13+
14+
#: (String, Location, ?Array[Herb::Errors::Error]) -> void
1215
def initialize(type, location, errors = [])
1316
@type = type
1417
@location = location
1518
@errors = errors
1619
end
1720

21+
#: type serialized_node = {
22+
#| type: String,
23+
#| location: serialized_location,
24+
#| errors: Array[serialized_error]
25+
#| }
1826
#: () -> serialized_node
1927
def to_hash
2028
{
2129
type: type,
22-
location: location&.to_hash,
30+
location: location.to_hash,
2331
errors: errors.map(&:to_hash),
2432
}
2533
end

lib/herb/lex_result.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
# frozen_string_literal: true
2+
# typed: true
23

34
module Herb
45
class LexResult < Result
5-
attr_reader :value #: TokenList
6+
#: Array[Herb::Token]
7+
attr_reader :value
68

79
#: (Array[Herb::Token], String, Array[Herb::Warnings::Warning], Array[Herb::Errors::Error]) -> void
810
def initialize(value, source, warnings, errors)

lib/herb/location.rb

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,14 @@
22
# typed: true
33

44
module Herb
5+
#: type serialized_location = { start: Position, end: Position }
56
class Location
6-
attr_reader :start #: Position
7-
attr_reader :end #: Position
7+
#: Herb::Position
8+
attr_reader :start
9+
#: Herb::Position
10+
attr_reader :end
811

9-
#: (Position, Position) -> void
12+
#: (Herb::Position, Herb::Position) -> void
1013
def initialize(start_position, end_position)
1114
@start = start_position
1215
@end = end_position
@@ -30,7 +33,7 @@ def to_hash
3033
{
3134
start: start,
3235
end: self.end,
33-
} #: Herb::serialized_location
36+
}
3437
end
3538

3639
#: (?untyped) -> String

lib/herb/parse_result.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
# frozen_string_literal: true
2+
# typed: true
23

34
require "json"
45

56
module Herb
67
class ParseResult < Result
7-
attr_reader :value #: Herb::AST::DocumentNode
8+
#: Herb::AST::DocumentNode
9+
attr_reader :value
810

911
#: (Herb::AST::DocumentNode, String, Array[Herb::Warnings::Warning], Array[Herb::Errors::Error]) -> void
1012
def initialize(value, source, warnings, errors)

lib/herb/position.rb

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,12 @@
22
# typed: true
33

44
module Herb
5+
#: type serialized_position = { line: Integer, column: Integer }
56
class Position
6-
attr_reader :line #: Integer
7-
attr_reader :column #: Integer
7+
#: Integer
8+
attr_reader :line
9+
#: Integer
10+
attr_reader :column
811

912
#: (Integer, Integer) -> void
1013
def initialize(line, column)

lib/herb/range.rb

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,12 @@
22
# typed: true
33

44
module Herb
5+
#: type serialized_range = [Integer, Integer]
56
class Range
6-
attr_reader :from #: Integer
7-
attr_reader :to #: Integer
7+
#: Integer
8+
attr_reader :from
9+
#: Integer
10+
attr_reader :to
811

912
#: (Integer, Integer) -> void
1013
def initialize(from, to)

lib/herb/result.rb

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,12 @@
33

44
module Herb
55
class Result
6-
attr_reader :source #: String
7-
attr_reader :warnings #: Array[Herb::Warnings::Warning]
8-
attr_reader :errors #: Array[Herb::Errors::Error]
6+
#: String
7+
attr_reader :source
8+
#: Array[Herb::Warnings::Warning]
9+
attr_reader :warnings
10+
#: Array[Herb::Errors::Error]
11+
attr_reader :errors
912

1013
#: (String, Array[Herb::Warnings::Warning], Array[Herb::Errors::Error]) -> void
1114
def initialize(source, warnings, errors)

lib/herb/token.rb

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,16 @@
22
# typed: true
33

44
module Herb
5+
#: type serialized_token = { value: String, range: [Integer, Integer], location: serialized_location, type: String }
56
class Token
6-
attr_reader :value #: String
7-
attr_reader :range #: Range
8-
attr_reader :location #: Location
9-
attr_reader :type #: String
7+
#: String
8+
attr_reader :value
9+
#: Range
10+
attr_reader :range
11+
#: Location
12+
attr_reader :location
13+
#: String
14+
attr_reader :type
1015

1116
#: (String, Range, Location, String) -> void
1217
def initialize(value, range, location, type)
@@ -20,10 +25,10 @@ def initialize(value, range, location, type)
2025
def to_hash
2126
{
2227
value: value,
23-
range: range&.to_a,
24-
location: location&.to_hash,
28+
range: range.to_a,
29+
location: location.to_hash,
2530
type: type,
26-
} #: Herb::serialized_token
31+
}
2732
end
2833

2934
#: (?untyped) -> String

0 commit comments

Comments
 (0)