Closed Bananattack closed 4 years ago
I'm having second thoughts about this after doing a bunch of GB code lately. The cast at the call site makes the intent explicit, so you're less likely to miss that you're for example accidentally passing an arbitrary u16
as a pointer to *T
. The cast throws away that safety, but it is explicitly noted at the call site, and keeps the type system in the compiler rules clearer by avoiding this form of implicit conversion. Plus if you forward a local variable of equivalent designated storage type to an argument (eg. var ptr : *u8 in hl
), doing a call foo(ptr);
will pass type-checks without the cast, because it you're passing a definition that already matches the type and storage.
Going to close for now.
If a register assigning to a variable with designated storage, allow differing types to implicitly cast if the register named matches.
eg. given the following declaration (assuming this declaration is well-formed, where
hl
is au16
, andsizeof(*u8) == sizeof(u16)
)Right now, Wiz requires the user to cast
hl
into a*u8
first, even though the type signature specifieshl
as the designated storage:The proposed change will allow the call to implicitly convert
hl
into type*u8 in hl
, like so:Only allow this in cases where the designated storage matches the value being assigned to it.
The examples are shown for function arguments, but same rules apply for variables that use designated storage.