Ruby Tree Deserialization Error
Closed this issue · 1 comments
neanias commented
- Ruby version: 3.1.3
- Rubyfmt git sha: rubyfmt-main 0.8.0-pre ed99cc4 (output of
rubyfmt --version
, current Homebrew version) (if unsure, redownload the latest version and run against that)
Input file
# lib/day3.rb
# typed: true
# frozen_string_literal: true
require "sorbet-runtime"
class Day3
extend T::Sig
sig { params(item_file: String).void }
def initialize(item_file)
@rucksacks = T.let(File.readlines(item_file, chomp: true), T::Array[String])
end
sig { returns(Integer) }
def part_one
@rucksacks.sum do |rucksack|
contents = rucksack.chars
size = contents.length
lhs = T.must(contents.take(size/2))
rhs = T.must(contents.drop(size/2))
T.must(lhs.intersection(rhs).map { calculate_priority(_1) }.first)
end
end
sig { returns(Integer) }
def part_two
@rucksacks.each_slice(3).sum do |group|
chars = group.map(&:chars)
T.must(
T.cast(
(chars[0] & T.must(chars[1]) & T.must(chars[2])), T::Array[String]
).map { calculate_priority(_1) }.first
)
end
end
private
sig { params(char: String).returns(Integer) }
def calculate_priority(char)
if char in ("a".."z")
(char.ord % 97) + 1
else
(char.ord % 65) + 27
end
end
end
Rubyfmt's output
Error! source: lib/day3.rb
!!! Ruby Tree Deserialization Error !!!
Rubyfmt failed to correctly deserialize a tree from ripper. This is a bug that needs to be reported.
File a bug report at https://github.com/penelopezone/rubyfmt/issues/new.
Ideally you would include the full source code of the program you ran rubyfmt with.
If you can't do that for some reason, the best thing you can do is rerun rubyfmt on this program
with the debug binary with `2>log_file` on the end and then send us the log file that gets generated.
This breaks because
I'm not sure what it should look like, sorry