Skip to content

Commit

Permalink
Resolve undefined variables for optional Enumerable arguments (#97)
Browse files Browse the repository at this point in the history
* Update nullable checks to resolve null elements

* Fix null check

* Remove additional null check
  • Loading branch information
christopherzimmerman committed Nov 15, 2021
1 parent 5fa8d06 commit 1e29983
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions src/g_i_repository/info/function_info.cr
Original file line number Diff line number Diff line change
Expand Up @@ -115,12 +115,9 @@ module GIRepository

collection_args.each do |arg|
if arg.nilable?
line def_if(arg.name) { |b|
b.line b.assign "__#{arg.name}", arg.for_wrapper_pass(builder, libname)
b.line b.assign "n_#{arg.name}", b.call("size", receiver: "__#{arg.name}_ary")
}.else { |b|
b.line b.assign "n_#{arg.name}", b.literal(0)
}
line assign "__#{arg.name}", arg.for_wrapper_pass(builder, libname)
size = call("size", receiver: "__#{arg.name}_ary")
line assign "n_#{arg.name}", ternary("__#{arg.name}_ary", size, literal(0))
else
line assign "__#{arg.name}", arg.for_wrapper_pass(builder, libname)
line assign "n_#{arg.name}", call("size", receiver: "__#{arg.name}_ary")
Expand Down

0 comments on commit 1e29983

Please sign in to comment.