Applying too many arguments to a function object #1

Merged
merged 1 commit into from Apr 18, 2011

Projects

None yet

2 participants

@ollef
ollef commented Apr 5, 2011

Hello Edwin!

It's us again.

Consider the following program:

printNat(x : Any) -> Any = foreign Unit "printBig" (x : BigInt)
plus (x : Any, y : Any) -> Any = foreign BigInt "addBig" (x : BigInt, y : BigInt)

kk (x : Any , y : Any) -> Any = x

apply( f : Any, x : Any) -> Any = f(unit, x)

inc (x : Any) -> Any = plus(x, 1L)

main () -> Unit = printNat (apply(kk (inc), 0L))

In the compiled code the apply function will apply (kk (inc)) to two arguments using CLOSURE_APPLY2, but (kk (inc)) only takes one argument and the result of that is a function object which takes the other argument. In this patch we seem to have fixed this, but we are unsure if this will work in general. What do you think?

Kind regards,
Olle and Daniel

=== Commit message
CLOSURE_APPLYn when applied to a function requiring less than n arguments
will now call DO_EVAL which will do the right thing in that case.
This seems to work.

Added BIGINT to DO_EVAL as an already evaluated value.

Changed the code generator so names for imports are not doubly encoded.

Olle Changed the way CLOSURE_APPLYn works.
CLOSURE_APPLYn when applied to a function requiring less than n arguments
will now call DO_EVAL which will do the right thing in that case.
This seems to work.

Added BIGINT to DO_EVAL as an already evaluated value.

Changed the code generator so names for imports are not doubly encoded.
2887557
@edwinb edwinb merged commit 2887557 into edwinb:master Apr 18, 2011
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment