Confusing warning for many return values
/home/cgay/dylan/ws.all/time/time.dylan:58-65: Warning -
Result type check can fail - values(singleton(0 :: <integer>), singleton(0 :: <integer>),
singleton(0 :: <integer>), singleton(0 :: <integer>), singleton(0 :: <integer>),
singleton(0 :: <integer>), singleton(0 :: <integer>), <object>) inferred,
values(<abstract-integer>, <month>, <abstract-integer>, <abstract-integer>,
<abstract-integer>, <abstract-integer>, <abstract-integer>, <zone>) expected.
-------------------------
58 define method decode-time
59 (t :: <time>)
60 => (year :: <integer>, month :: <month>, day :: <integer>,
[...]
64 values(0, 0, 0, 0, 0, 0, 0, $utc)
65 end;
---
Perhaps, when there are many return values, it would be useful to say how many were expected and how many were returned.
(Separate issue, but I'll drop it here for now... All of those singleton(0 :: <integer>)s would sure be easier to read as 0. This doesn't strike me as counter-intuitive for types that have built-in literal syntax.)
Also, judicious use of \n would make this a lot easier to read. For example,
Warning - Result type check can fail:
8 values expected: ...
8 values inferred: ...
Better yet:
Warning - Result type check can fail:
Return value "year" - expected: type1, actual: type1
-> Return value "month" - expected: type2, actual: type3
Return value "_" - expected: type4, actual: type4
The leading -> indicates where there's a type mismatch.
If for some reason the names of the return values aren't available easily a 1-based index can be used.
For the original error posted above, we would have...
/home/cgay/dylan/ws.all/time/time.dylan:58-65: Warning - Result type check can fail:
Return value "year" - expected: <abstract-integer>, actual: singleton(0 :: <integer>)
-> Return value "month" - expected <month>, actual: singleton(0 :: <integer>)
Return value "day" - expected: <abstract-integer>, actual: singleton(0 :: <integer>)
Return value "hour" - expected: <abstract-integer>, actual: singleton(0 :: <integer>)
Return value "minute" - expected: <abstract-integer>, actual: singleton(0 :: <integer>)
Return value "second" - expected: <abstract-integer>, actual: singleton(0 :: <integer>)
Return value "nanosecond" - expected: <abstract-integer>, actual: singleton(0 :: <integer>)
-> Return value "zone" - expected: <zone>, actual: <object>
-------------------------
58 define method decode-time
59 (t :: <time>)
60 => (year :: <integer>, month :: <month>, day :: <integer>,
[...]
64 values(0, 0, 0, 0, 0, 0, 0, $utc)
65 end;
---
I wouldn't be surprised if warnings for callers not matching function args needs similar treatment.
This TODO covers part of what I reported above. https://github.com/dylan-lang/opendylan/blob/master/sources/dfmc/optimization/constant-folding.dylan#L708