Skip to content

Commit 75f6857

Browse files
committed
Fix method name validation edge-case
It turns out that `:4_to_5=` is not a valid symbol but `"4_to_5=".to_sym` does not quote it and represents it as `:4_to_5=`, which throws off our whole method name validation logic. The fix is to check validity of the name after stripping trailing `=` as well. That leaves `==` as an edge-case, that we handle separately.
1 parent bb5fd22 commit 75f6857

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

lib/tapioca/helpers/rbi_helper.rb

+4-1
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,10 @@ def self.serialize_type_variable(type, variance, fixed, upper, lower)
9393

9494
sig { params(name: String).returns(T::Boolean) }
9595
def valid_method_name?(name)
96-
!name.to_sym.inspect.start_with?(':"', ":@", ":$")
96+
name == "==" || !(
97+
name.to_sym.inspect.start_with?(':"', ":@", ":$") ||
98+
name.delete_suffix("=").to_sym.inspect.start_with?(':"', ":@", ":$")
99+
)
97100
end
98101

99102
sig { params(name: String).returns(T::Boolean) }

0 commit comments

Comments
 (0)