Closed bennn closed 2 years ago
This is definitely a bug, h
should be checking it's arg type. I'll check why it isn't doing so!
Oh, this was already fixed back in December in the above-linked commit, we just hadn't closed the issue :) It looks like it wasn't actually anything specific to arrays, just a problem with how we reported (or failed to report) arg typecheck errors in the jit.
In general, we were wondering what's the SP strategy for Arrays and Vectors at the boundaries to untyped code. Is there a conversion story like for int32, should these boundaries always error, or something else?
Our Array/Vector types are actually at runtime thin subclasses of the existing Python array.array
type, which contains compact arrays of primitive values: https://docs.python.org/3/library/array.html. So the type is usable in either static or non-static code; in the former case you get nice compiler integration with SP primitive integer types, in the latter case you interact with it using the normal array
API and boxed values.
What version of SP are you using
43d1ce7bd99145f4fd21e9b87428dbb0141b77c9 2021-10-21
What program did you run?
What happened?
No error
What should have happened?
A runtime error --- either because
["B"]
is not an array or because"B"
is not anint32
.On the bright side, I haven't been able to use the wrong types to get a serious error. Adding (
+
) and comparing (<
)x[0]
with anotherint32
gives an error about mixing strings and numbers.In general, we were wondering what's the SP strategy for Arrays and Vectors at the boundaries to untyped code. Is there a conversion story like for
int32
, should these boundaries always error, or something else?Right now, typed code can send an Array to Python, so I'd expect the function
h
to look for an Array object and reject everything else.