opendylan icon indicating copy to clipboard operation
opendylan copied to clipboard

Need compiler warning for limited vector access

Open cgay opened this issue 5 years ago • 1 comments

I would expect a compile-time warning for this:

  let v = make(limited(<vector>, of: <integer>), size: 1);
  v[0] := #t;

(There is a run-time error, as expected.)

cgay avatar Jan 12 '20 21:01 cgay

I meant to use the following code, where I explicitly declared the type of v:

define constant <int-vector> = limited(<vector>, of: <integer>);
let v :: <int-vector> = make(<int-vector>, size: 1);
v[0] := #t;

This also doesn't get a compile-time warning.

(It would be wonderful if the type of v were inferred to be <int-vector> without being explicitly declared to be that type, but that's a different issue. I can't find where in the DRM this is defined, but it's kind of implied in the let doc.)

cgay avatar Jan 13 '20 04:01 cgay