From 14d313b78a19e55cb743a4e17f63089b0904e43c Mon Sep 17 00:00:00 2001 From: Ufuk Kayserilioglu Date: Wed, 14 Feb 2024 01:47:15 +0200 Subject: [PATCH] `T::Props#props` is expected to be a hash not an array `T::Props#props` is public API of `T::Struct` and is used to enumerate all the properties defined on a typed struct. The original implementation of this method, however, returns a hash with method name keys and rules as the value. Returning an array as the value of `props` violates this expectation. --- lib/sorbet/eraser/t/props.rb | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/lib/sorbet/eraser/t/props.rb b/lib/sorbet/eraser/t/props.rb index eb12e33..f470a7c 100644 --- a/lib/sorbet/eraser/t/props.rb +++ b/lib/sorbet/eraser/t/props.rb @@ -16,7 +16,7 @@ def self.included(base) # them and not raise errors and for bookkeeping. module ClassMethods def props - @props ||= [] + @props ||= {} end def prop(name, rules = {}) @@ -32,8 +32,7 @@ def const(name, rules = {}) private def create_prop(name, rules) - props << [name, rules] - props.sort_by!(&:first) + props[name] = rules end end