Skip to content

Commit 8583271

Browse files
committed
Fixed [error] Type (::String | nil) does not have method gsub
``` lib/ruby_header_parser/parser.rb:238:58: [error] Type `(::String | nil)` does not have method `gsub` │ Diagnostic ID: Ruby::NoMethod │ └ definition[0...definition.index(function_name)].gsub("char *", "char*").strip ~~~~ ```
1 parent b5fad90 commit 8583271

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

lib/ruby_header_parser/parser.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,8 @@ def parse_typeref_type(definition:, function_name:, typeref_field:, filepath:, l
235235
typeref_field.gsub(/[A-Z_]+\s*\(\(.*\)\)/, "").gsub("RUBY_SYMBOL_EXPORT_BEGIN", "")
236236
else
237237
# parse typeref in definition
238-
definition[0...definition.index(function_name)].gsub("char *", "char*").strip
238+
type = definition[0...definition.index(function_name)] || ""
239+
type.gsub("char *", "char*").strip
239240
end
240241

241242
typeref_type = Util.sanitize_type(typeref_type)

0 commit comments

Comments
 (0)