Skip to content

Errs in function args not being passed along#95

Closed
Levilutz wants to merge 990 commits intocmsc430:mainfrom
Levilutz:main
Closed

Errs in function args not being passed along#95
Levilutz wants to merge 990 commits intocmsc430:mainfrom
Levilutz:main

Conversation

@Levilutz
Copy link
Copy Markdown

See new test for almost-minimal example of bug.

Any 'err present in the arguments of a function would cause the interpreter to fail rather than cleanly returning 'err.

Specifically, when a function arg would bring error, interp-env* returned 'err. This would truncate the overall list being returned, causing unpredictable behavior (either lambda arg length mismatch or interpreter failure).

dvanhorn and others added 30 commits January 19, 2021 17:34
* explain compilation of `begin'
* explain push, pop, call
* explain ABI for calling C
* explain "extern" in ASM
* discuss asm-interp/io as analog of interp-io
* show examples with asm-interp/io, asm-interp only for "pure" programs
* add peek-byte?
This reverts commit 459159d.

This included some other changes that broke the build, so reverting for now.
This reverts commit 48a2fae.

Redo in order to fix up.
There's a challenge in getting Extort and asm-interp to play nice
together.  The problem is that Extort, which adds handled errors,
calls a C function named `error` which prints a symbol and exits.  If
you do this from `asm-interp` this will exit whatever is running
`asm-interp`, prematurely exiting out of whatever you're trying to do
(build the web page, test the code, etc.).  Not what you want.

The solution, as always, is a level of indirection.  The run-time now
has a function pointer called `error`.  The `main` procedure sets to
something that prints and exits.  On the other hand `asm-interp` sets
it to something that raises an exception and then handles it.

This commit isn't the end-all for these kinds of issues, but it's a
first cut and the API for hooking in to the run-time can be refined
based on this basic idea.
It wasn't a good idea to name the function `error`.
@Levilutz
Copy link
Copy Markdown
Author

For following file as testy.rkt:

#lang racket
(begin
  (define (f x) (+ x 3))
  (f (add1 #f)))

Previous behavior:

$ racket -t interp-file.rkt -m testy.rkt
match: no matching clause for '(#<procedure:.../loot/interp.rkt:71:38> . err)
  location...:
   interp.rkt:81:5
  context...:
   /usr/share/racket/collects/racket/match/runtime.rkt:24:0: match:error
   /docker/www/langs/loot/interp-file.rkt:8:0: main
   eval-one-top12

New behavior:

$ racket -t interp-file.rkt -m testy.rkt
err

@Levilutz Levilutz mentioned this pull request Dec 28, 2021
dvanhorn added a commit that referenced this pull request Dec 31, 2021
The issue was identified in #95 and #101, but this is a simpler
solution and adds tests cases.
@dvanhorn dvanhorn closed this Dec 31, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants