encore icon indicating copy to clipboard operation
encore copied to clipboard

Code Generation problems with Bounded Polymorphic Functions

Open supercooldave opened this issue 7 years ago • 0 comments

The following function, which uses a bounded polymorphic type argument, results in invalid C:

fun arreq[t : Eq[t]](arr1 : [t], arr2 : [t]) : bool
  repeat i <- |arr1| do
    if arr1(i) != arr2(i) then
      return false
    end
  end
  true
end

active class Main
  def main() : unit
    ()
  end
end

The resulting error is (one warning removed):

BugReportPlay_src/shared.c:190:110: error: invalid operands to binary expression
      ('void *' and 'encore_arg_t')
  ...({encore_arg_t _access_14 = array_get(_enc__arg_arr1, _i_10); _access_14.p;}) == ((encore_arg_t) ({encore_arg_t _access_15 = array_get(_enc__arg_arr2, _i_10); _access_15.p;}))...
     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 error generated.

supercooldave avatar Jul 10 '17 11:07 supercooldave