UCSD-PL / refscript

Refinement Types for Scripting Languages
BSD 3-Clause "New" or "Revised" License
65 stars 3 forks source link

Bizarre error with HOF #61

Closed ranjitjhala closed 10 years ago

ranjitjhala commented 10 years ago

See

https://github.com/UCSD-PL/RefScript/blob/master/tests/pos/fb/min-index-01.ts

What is this mysterious null that it is trying to convert to number ????

Also, how would one go about typing reduce in

https://github.com/UCSD-PL/RefScript/blob/master/tests/pos/fb/min-index-02.ts

panagosg7 commented 10 years ago

Fixed both (no change in rsc). Comments:

panagosg7 commented 10 years ago

Error messages could be much better. But I guess that's the price to pay for being able to carry on with deadcode annotations.

ranjitjhala commented 10 years ago

The dead-cast thing has nothing to do with it, btw, because it results in the same error that we would throw from the TC phase...

On Mon, Oct 13, 2014 at 2:41 PM, Panagiotis Vekris <notifications@github.com

wrote:

Closed #61 https://github.com/UCSD-PL/RefScript/issues/61.

Reply to this email directly or view it on GitHub https://github.com/UCSD-PL/RefScript/issues/61#event-177814146.

Ranjit.

ranjitjhala commented 10 years ago

Thanks a ton!

(Btw, rather than the bounds check in body, the trick is to refine the type of reduce to say that the "number" is always within bounds...)

On Mon, Oct 13, 2014 at 2:41 PM, Panagiotis Vekris <notifications@github.com

wrote:

Fixed both (no change in rsc). Comments:

-

This TypeScript signature: foo(A,A,number): A implies the type (any, any,any) => A. Those symbols in the argument positions are just the binder names -- not types. So you'd have to write: foo(x: A,y: A, n: number): A. In RefScript the former case is the actual type.

I added a bounds check in body function

I also needed to write out the type for reduce because the array argument needs to be immutable. By default tsc -> rsc translation makes arrays mutable (we don't do immutability inference).

In min-index-02.ts, reduce is provided in the prelude. So I just made the this argument an immutable array there.

Reply to this email directly or view it on GitHub https://github.com/UCSD-PL/RefScript/issues/61#issuecomment-58936017.

Ranjit.