Skip to content

Commit

Permalink
Fix steep check offense
Browse files Browse the repository at this point in the history
```
❯ bundle exec rake steep
bundle exec steep check
# Type checking files:

.............................................................................................................................F.........................

lib/lrama/grammar/symbols/resolver.rb:201:33: [error] Cannot pass a value of type `(::Integer | nil)` as an argument of type `::Integer`
│   (::Integer | nil) <: ::Integer
│     nil <: ::Integer
│
│ Diagnostic ID: Ruby::ArgumentTypeMismatch
│
└                   sym.token_id = Integer($1, 8)
                                   ~~~~~~~~~~~~~~

lib/lrama/grammar/symbols/resolver.rb:203:36: [error] Type `(::String | nil)` does not have method `bytes`
│ Diagnostic ID: Ruby::NoMethod
│
└                   sym.token_id = $1.bytes.first
                                      ~~~~~

Detected 2 problems from 1 file
```
  • Loading branch information
ydah committed Feb 7, 2024
1 parent c499a0f commit be3a312
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions lib/lrama/grammar/symbols/resolver.rb
Original file line number Diff line number Diff line change
Expand Up @@ -198,9 +198,17 @@ def fill_terms_number
when "\\\\"
sym.token_id = 92
when /\A\\(\d+)\z/
sym.token_id = Integer($1, 8)
unless (id = Integer($1, 8)).nil?
sym.token_id = id
else
raise "Unknown Char s_value #{sym}"
end
when /\A(.)\z/
sym.token_id = $1.bytes.first
unless (id = $1&.bytes&.first).nil?
sym.token_id = id
else
raise "Unknown Char s_value #{sym}"
end
else
raise "Unknown Char s_value #{sym}"
end
Expand Down

0 comments on commit be3a312

Please sign in to comment.