Closed ranjitjhala closed 10 years ago
Fixed both (no change in rsc
). Comments:
foo<A>(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<A>(x: A,y: A, n: number): A
. In RefScript the former case is the actual type.body
functionreduce
because the array argument needs to be immutable. By default tsc -> rsc translation makes arrays mutable (we don't do immutability inference).min-index-02.ts
, reduce
is provided in the prelude. So I just made the this
argument an immutable array there.Error messages could be much better. But I guess that's the price to pay for being able to carry on with deadcode
annotations.
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.
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.
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 tonumber
????Also, how would one go about typing
reduce
inhttps://github.com/UCSD-PL/RefScript/blob/master/tests/pos/fb/min-index-02.ts