larcenists / larceny

Larceny Scheme implementation
Other
202 stars 32 forks source link

Compiler throws ‘Wrong number of arguments to integrable procedure’ #779

Closed mnieper closed 8 years ago

mnieper commented 8 years ago

I get the following error when trying to run a (rather huge) program with Larceny:

$ larceny -r7rs -path . -program program.scm
ERROR detected by compiler:
Wrong number of arguments to integrable procedure
(cons .T37189)
Error while loading src/Build/iasn-larceny-heap.fasl
larceny.heap, built on Fr 1. Jul 15:42:29 CEST 2016
>    

Is this a compiler bug or an error the user is supposed to see? In case of the latter, is there any advice how it could be debugged?

program.zip

mnieper commented 8 years ago

In the meantime, I have found the application that causes the error detected by the compiler. So, the issue reduces to: Is it possible to give a more helpful error message (e.g. a message that points to the problematic form)?

WillClinger commented 8 years ago

Larceny should report the source line number, but the macro expander doesn't track line numbers through macro expansion so Larceny's compiler can only report the line number for the top-level form. With R6RS and R7RS libraries, that wouldn't help much. Furthermore, R6RS and R7RS top-level programs get turned into pseudo-libraries, so line numbers for top-level forms wouldn't help much even with R6RS/R7RS top-level programs.

The right thing to do here is to track line numbers at least one level further down, but that's a bit hard to implement in Larceny because Andre van Tonder's portable library/macro system contains no provision for tracking line numbers.

Until this gets fixed, one partial workaround is to use the (compile-despite-errors #t) compiler switch to convert this error into a warning, and then try to find the location of the error via execution-based testing.

WillClinger commented 8 years ago

I'm going to treat this as a duplicate for ticket #301