Skip to content

abort/cc under a call/prompt cannot be invoked normally #1387

Open
@dannypsnl

Description

@dannypsnl

What version of Racket are you using?

v8.12 [cs]

What program did you run?

#lang typed/racket
(require/typed racket/control
               [abort/cc
                ((Prompt-Tagof Any (-> Any Void))
                 (-> Any Void)
                 Number
                 -> Void)]
               [call/prompt
                ((-> Void)
                 (Prompt-Tagof Any (-> Any Void))
                 Any
                 -> Any)])

(: tag : (Prompt-Tagof Any (-> Any Void)))
(define tag (make-continuation-prompt-tag 'tag))

(: f : -> Void)
(define (f)
  (println 1)
  (call/cc (λ ([k : (-> Any Void)]) (abort/cc tag k 2)))
  (println 3)
  (call/cc (λ ([k : (-> Any Void)]) (abort/cc tag k 4)))
  (println 5))

(call/prompt f
             tag
             (λ ([resume : (-> Any Void)]
                 [v : Number])
               (println v)
               (resume 'ignore)))

What should have happened?

As a very similar untyped version can print 1-5 in order.

#lang racket
(require racket/control)

(define tag (make-continuation-prompt-tag 'tag))

(define (f)
  (println 1)
  (call/cc (λ (k) (abort/cc tag k 2)))
  (println 3)
  (call/cc (λ (k) (abort/cc tag k 4)))
  (println 5))

(call/prompt f
             tag
             (λ (resume v)
               (println v)
               (resume)))

If you got an error message, please include it here.

At (abort/cc tag k 2) invoke

result arity mismatch;
 expected number of values not received
  expected: 2
  received: 1
  at: use of prompt-abort redirecting procedure
  arguments...:

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions