Opened 23 months ago

Last modified 2 months ago

#1390 reopened defect

The behavior between `values` and `call/cc` is inconsistent.

Reported by: kooda Owned by:
Priority: minor Milestone: someday
Component: compiler Version: 4.12.0
Keywords: Cc:
Estimated difficulty: hard

Description

With regard to multiple return values, values and call/cc behave differently.

I think the call/cc case should not error out.

Also, the error message is a bit unhelpful (sometimes the call to call/cc is not known from the user, for example thread-join! uses it) and in some cases no call trace is available.

(print (values 1 2 3)) ;; no problem
 
(define (stuff)
  (call/cc
    (lambda (return)
      (return 1 2 3))))

(print (stuff)) ;; Error: bad argument count - received 3 but expected 1

Change History (4)

comment:1 Changed 22 months ago by sjamaan

  • Estimated difficulty set to easy
  • Milestone changed from someday to 5.0

Makes more sense to fix for 5.x

comment:2 Changed 21 months ago by sjamaan

  • Resolution set to fixed
  • Status changed from new to closed

Fixed with 2dc0c5929a

comment:3 Changed 2 months ago by sjamaan

  • Resolution fixed deleted
  • Status changed from closed to reopened

comment:4 Changed 2 months ago by sjamaan

  • Estimated difficulty changed from easy to hard
  • Milestone changed from 5.0 to someday

Reverted in 3e0f640ecf22f6be7af1947b875132415556ca5b

This turns out not to work because when you capture a generated continuation, this assumes it receives one argument and does not check for the argument count. Adding these checks would be prohibitively slow, so we don't do it.

There might be a way to avoid doing this (the code hardcodes argcount from the lambda, which is not strictly necessary; we could call save_and_reclaim with c from C, instead of the Scheme n, but this doesn't solve everything; we generate t0...tn which index into the argvector and we also generate direct calls to trampoline functions with c set to the argument count we know the trampoline accepts and so on. These assumptions need to be removed before we can do this.

It is not even certain we really should want this feature in the first place.

Note: See TracTickets for help on using tickets.