jhass / crystal-gobject

gobject-introspection for Crystal
BSD 3-Clause "New" or "Revised" License
127 stars 13 forks source link

Error: undefined method 'size' for optional Enumerables #96

Closed christopherzimmerman closed 2 years ago

christopherzimmerman commented 2 years ago

When a method is generated to accept Enumerable? as an argument, the generated code leaves paths with certain variables undefined, causing compile-time errors.

Minimal example:

require "gobject"
require_gobject "Arrow"

b = Arrow::Buffer.new(Bytes.new(10))
arr = Arrow::Tensor.new(Arrow::UInt8DataType.new, b, [10], [1], nil)
puts arr

# > 21190 | if strides
# > 21191 |   __strides = strides ? (__strides_ary = strides.map { |__item| Int64.new(__item) }.to_a).to_unsafe : Pointer(Int64).null
# > 21192 |   n_strides = __strides_ary.size
#                                       ^---
# Error: undefined method 'size' for Nil (compile-time type is (Array(Int64) | Nil))