From 0a28dd1064957214d025f3910cbbf9a9eaa7d1e5 Mon Sep 17 00:00:00 2001 From: Matthew Flatt Date: Mon, 14 Dec 2020 15:46:37 -0700 Subject: [PATCH] cs: adjust result-arity error messages Relevant to #3325 --- pkgs/racket-test-core/tests/racket/for.rktl | 4 +- .../racket-test-core/tests/racket/syntax.rktl | 19 ++-- .../src/ChezScheme/mats/patch-compile-0-f-t-f | 18 ++-- .../src/ChezScheme/mats/patch-compile-0-t-f-f | 22 ++--- .../src/ChezScheme/mats/patch-compile-2-f-t-f | 18 ++-- .../src/ChezScheme/mats/patch-compile-2-t-f-f | 22 ++--- .../ChezScheme/mats/patch-interpret-0-f-f-f | 22 ++--- .../ChezScheme/mats/patch-interpret-2-f-f-f | 22 ++--- .../mats/root-experr-compile-0-f-f-f | 14 +-- .../mats/root-experr-compile-2-f-f-f | 14 +-- racket/src/ChezScheme/s/7.ss | 2 +- racket/src/ChezScheme/s/cpnanopass.ss | 4 +- racket/src/bc/src/startup.inc | 1 + racket/src/cs/primitive/internal.ss | 1 + racket/src/cs/rumble/error-rewrite.ss | 15 ++++ racket/src/cs/schemified/expander.scm | 3 +- racket/src/cs/schemified/schemify.scm | 89 ++++++++++++------- .../src/expander/compile/built-in-symbol.rkt | 1 + racket/src/schemify/left-to-right.rkt | 3 +- racket/src/schemify/schemify.rkt | 13 ++- 20 files changed, 185 insertions(+), 122 deletions(-) diff --git a/pkgs/racket-test-core/tests/racket/for.rktl b/pkgs/racket-test-core/tests/racket/for.rktl index 5ef2014712..03b9d062f9 100644 --- a/pkgs/racket-test-core/tests/racket/for.rktl +++ b/pkgs/racket-test-core/tests/racket/for.rktl @@ -676,7 +676,7 @@ #rx".*expected number of values not received.*") (err/rt-test (begin (for/fold ([x 1]) () (values 1 2)) 1) exn:fail:contract:arity? - #rx"expected number of values not received|returned two values to single value return context") + #rx"expected number of values not received") (err/rt-test (begin (for/fold ([x 1] [y 2]) ([i (in-range 10)]) 1) 1) exn:fail:contract:arity? #rx".*expected number of values not received.*") @@ -753,7 +753,7 @@ #rx"expected: hash\\?") (err/rt-test (for ([x (in-hash (hash 1 2))]) x) exn:fail:contract:arity? - #rx"expected number of values not received|returned two values to single value return context") + #rx"expected number of values not received") (err/rt-test (for ([x (in-hash 1 2 3)]) x) exn:fail:contract:arity?) diff --git a/pkgs/racket-test-core/tests/racket/syntax.rktl b/pkgs/racket-test-core/tests/racket/syntax.rktl index b51fc2998e..4dd8f5a1b2 100644 --- a/pkgs/racket-test-core/tests/racket/syntax.rktl +++ b/pkgs/racket-test-core/tests/racket/syntax.rktl @@ -1118,14 +1118,17 @@ (syntax-test #'(cond [(< 2 3) (define x 2)] [else 5])) (syntax-test #'(cond [else (define x 2)])) -;; No good way to test in mzc: -(error-test #'(define x (values)) exn:application:arity?) -(error-test #'(define x (values 1 2)) exn:application:arity?) -(error-test #'(define-values () 3) exn:application:arity?) -(error-test #'(define-values () (values 1 3)) exn:application:arity?) -(error-test #'(define-values (x y) (values)) exn:application:arity?) -(error-test #'(define-values (x y) 3) exn:application:arity?) -(error-test #'(define-values (x y) (values 1 2 3)) exn:application:arity?) +(define (definition-arity-error? x) + (and (exn:application:arity? x) + (regexp-match? #rx"expected number of values not received" (exn-message x)))) + +(error-test #'(define x (values)) definition-arity-error?) +(error-test #'(define x (values 1 2)) definition-arity-error?) +(error-test #'(define-values () 3) definition-arity-error?) +(error-test #'(define-values () (values 1 3)) definition-arity-error?) +(error-test #'(define-values (x y) (values)) definition-arity-error?) +(error-test #'(define-values (x y) 3) definition-arity-error?) +(error-test #'(define-values (x y) (values 1 2 3)) definition-arity-error?) (begin (define ed-t1 1) (define ed-t2 2)) (test 1 'begin-define ed-t1) diff --git a/racket/src/ChezScheme/mats/patch-compile-0-f-t-f b/racket/src/ChezScheme/mats/patch-compile-0-f-t-f index eb350bef17..d1b2d42d2e 100644 --- a/racket/src/ChezScheme/mats/patch-compile-0-f-t-f +++ b/racket/src/ChezScheme/mats/patch-compile-0-f-t-f @@ -36,27 +36,27 @@ 3.mo:Expected warning in mat cpvalid: "possible attempt to reference undefined variable x". *************** *** 266,275 **** - 3.mo:Expected error in mat mrvs: "returned three values to single value return context". - 3.mo:Expected error in mat mrvs: "returned three values to single value return context". - 3.mo:Expected error in mat mrvs: "returned zero values to single value return context". + 3.mo:Expected error in mat mrvs: "returned 3 values to single value return context". + 3.mo:Expected error in mat mrvs: "returned 3 values to single value return context". + 3.mo:Expected error in mat mrvs: "returned 0 values to single value return context". ! 3.mo:Expected error in mat mrvs: "incorrect number of values received in multiple value context". -! 3.mo:Expected error in mat mrvs: "returned zero values to single value return context". +! 3.mo:Expected error in mat mrvs: "returned 0 values to single value return context". ! 3.mo:Expected error in mat mrvs: "incorrect number of values received in multiple value context". ! 3.mo:Expected error in mat mrvs: "incorrect number of values received in multiple value context". 3.mo:Expected error in mat mrvs: "variable $mrvs-foo is not bound". 3.mo:Expected error in mat mrvs: "attempt to apply non-procedure 17". - 3.mo:Expected error in mat mrvs: "returned two values to single value return context". + 3.mo:Expected error in mat mrvs: "returned 2 values to single value return context". --- 266,275 ---- - 3.mo:Expected error in mat mrvs: "returned three values to single value return context". - 3.mo:Expected error in mat mrvs: "returned three values to single value return context". - 3.mo:Expected error in mat mrvs: "returned zero values to single value return context". + 3.mo:Expected error in mat mrvs: "returned 3 values to single value return context". + 3.mo:Expected error in mat mrvs: "returned 3 values to single value return context". + 3.mo:Expected error in mat mrvs: "returned 0 values to single value return context". ! 3.mo:Expected error in mat mrvs: "incorrect argument count in call (call-with-values (lambda () 5 (values 2)) (lambda (x y) (+ x y)))". ! 3.mo:Expected error in mat mrvs: "incorrect argument count in call (call-with-values values (lambda (x) x))". ! 3.mo:Expected error in mat mrvs: "incorrect argument count in call (call-with-values values (lambda (x y) x))". ! 3.mo:Expected error in mat mrvs: "incorrect argument count in call (call-with-values f (lambda (x y) x))". 3.mo:Expected error in mat mrvs: "variable $mrvs-foo is not bound". 3.mo:Expected error in mat mrvs: "attempt to apply non-procedure 17". - 3.mo:Expected error in mat mrvs: "returned two values to single value return context". + 3.mo:Expected error in mat mrvs: "returned 2 values to single value return context". *************** *** 4037,4043 **** misc.mo:Expected error in mat cpletrec: "foreign-procedure: no entry for "foo"". diff --git a/racket/src/ChezScheme/mats/patch-compile-0-t-f-f b/racket/src/ChezScheme/mats/patch-compile-0-t-f-f index 811e8797d5..4a1b92c34b 100644 --- a/racket/src/ChezScheme/mats/patch-compile-0-t-f-f +++ b/racket/src/ChezScheme/mats/patch-compile-0-t-f-f @@ -19,30 +19,30 @@ 3.mo:Expected error in mat letrec: "attempt to assign undefined variable b". *************** *** 266,277 **** - 3.mo:Expected error in mat mrvs: "returned three values to single value return context". - 3.mo:Expected error in mat mrvs: "returned three values to single value return context". - 3.mo:Expected error in mat mrvs: "returned zero values to single value return context". + 3.mo:Expected error in mat mrvs: "returned 3 values to single value return context". + 3.mo:Expected error in mat mrvs: "returned 3 values to single value return context". + 3.mo:Expected error in mat mrvs: "returned 0 values to single value return context". ! 3.mo:Expected error in mat mrvs: "incorrect number of values received in multiple value context". -! 3.mo:Expected error in mat mrvs: "returned zero values to single value return context". +! 3.mo:Expected error in mat mrvs: "returned 0 values to single value return context". ! 3.mo:Expected error in mat mrvs: "incorrect number of values received in multiple value context". ! 3.mo:Expected error in mat mrvs: "incorrect number of values received in multiple value context". 3.mo:Expected error in mat mrvs: "variable $mrvs-foo is not bound". ! 3.mo:Expected error in mat mrvs: "attempt to apply non-procedure 17". - 3.mo:Expected error in mat mrvs: "returned two values to single value return context". - 3.mo:Expected error in mat mrvs: "returned two values to single value return context". + 3.mo:Expected error in mat mrvs: "returned 2 values to single value return context". + 3.mo:Expected error in mat mrvs: "returned 2 values to single value return context". 3.mo:Expected error in mat mrvs: "cdr: a is not a pair". --- 266,277 ---- - 3.mo:Expected error in mat mrvs: "returned three values to single value return context". - 3.mo:Expected error in mat mrvs: "returned three values to single value return context". - 3.mo:Expected error in mat mrvs: "returned zero values to single value return context". + 3.mo:Expected error in mat mrvs: "returned 3 values to single value return context". + 3.mo:Expected error in mat mrvs: "returned 3 values to single value return context". + 3.mo:Expected error in mat mrvs: "returned 0 values to single value return context". ! 3.mo:Expected error in mat mrvs: "incorrect number of arguments 1 to #". ! 3.mo:Expected error in mat mrvs: "incorrect number of arguments 0 to #". ! 3.mo:Expected error in mat mrvs: "incorrect number of arguments 0 to #". ! 3.mo:Expected error in mat mrvs: "incorrect number of arguments 0 to #". 3.mo:Expected error in mat mrvs: "variable $mrvs-foo is not bound". ! 3.mo:Expected error in mat mrvs: "call-with-values: 17 is not a procedure". - 3.mo:Expected error in mat mrvs: "returned two values to single value return context". - 3.mo:Expected error in mat mrvs: "returned two values to single value return context". + 3.mo:Expected error in mat mrvs: "returned 2 values to single value return context". + 3.mo:Expected error in mat mrvs: "returned 2 values to single value return context". 3.mo:Expected error in mat mrvs: "cdr: a is not a pair". *************** *** 308,315 **** diff --git a/racket/src/ChezScheme/mats/patch-compile-2-f-t-f b/racket/src/ChezScheme/mats/patch-compile-2-f-t-f index 6bd4b2fa3b..b34e8046a3 100644 --- a/racket/src/ChezScheme/mats/patch-compile-2-f-t-f +++ b/racket/src/ChezScheme/mats/patch-compile-2-f-t-f @@ -36,27 +36,27 @@ 3.mo:Expected warning in mat cpvalid: "possible attempt to reference undefined variable x". *************** *** 191,200 **** - 3.mo:Expected error in mat mrvs: "returned three values to single value return context". - 3.mo:Expected error in mat mrvs: "returned three values to single value return context". - 3.mo:Expected error in mat mrvs: "returned zero values to single value return context". + 3.mo:Expected error in mat mrvs: "returned 3 values to single value return context". + 3.mo:Expected error in mat mrvs: "returned 3 values to single value return context". + 3.mo:Expected error in mat mrvs: "returned 0 values to single value return context". ! 3.mo:Expected error in mat mrvs: "incorrect number of values received in multiple value context". -! 3.mo:Expected error in mat mrvs: "returned zero values to single value return context". +! 3.mo:Expected error in mat mrvs: "returned 0 values to single value return context". ! 3.mo:Expected error in mat mrvs: "incorrect number of values received in multiple value context". ! 3.mo:Expected error in mat mrvs: "incorrect number of values received in multiple value context". 3.mo:Expected error in mat mrvs: "variable $mrvs-foo is not bound". 3.mo:Expected error in mat mrvs: "attempt to apply non-procedure 17". - 3.mo:Expected error in mat mrvs: "returned two values to single value return context". + 3.mo:Expected error in mat mrvs: "returned 2 values to single value return context". --- 191,200 ---- - 3.mo:Expected error in mat mrvs: "returned three values to single value return context". - 3.mo:Expected error in mat mrvs: "returned three values to single value return context". - 3.mo:Expected error in mat mrvs: "returned zero values to single value return context". + 3.mo:Expected error in mat mrvs: "returned 3 values to single value return context". + 3.mo:Expected error in mat mrvs: "returned 3 values to single value return context". + 3.mo:Expected error in mat mrvs: "returned 0 values to single value return context". ! 3.mo:Expected error in mat mrvs: "incorrect argument count in call (call-with-values (lambda () 5 (values 2)) (lambda (x y) (+ x y)))". ! 3.mo:Expected error in mat mrvs: "incorrect argument count in call (call-with-values values (lambda (x) x))". ! 3.mo:Expected error in mat mrvs: "incorrect argument count in call (call-with-values values (lambda (x y) x))". ! 3.mo:Expected error in mat mrvs: "incorrect argument count in call (call-with-values f (lambda (x y) x))". 3.mo:Expected error in mat mrvs: "variable $mrvs-foo is not bound". 3.mo:Expected error in mat mrvs: "attempt to apply non-procedure 17". - 3.mo:Expected error in mat mrvs: "returned two values to single value return context". + 3.mo:Expected error in mat mrvs: "returned 2 values to single value return context". *************** *** 3645,3651 **** misc.mo:Expected error in mat cpletrec: "foreign-procedure: no entry for "foo"". diff --git a/racket/src/ChezScheme/mats/patch-compile-2-t-f-f b/racket/src/ChezScheme/mats/patch-compile-2-t-f-f index f951012ca0..b378e42bed 100644 --- a/racket/src/ChezScheme/mats/patch-compile-2-t-f-f +++ b/racket/src/ChezScheme/mats/patch-compile-2-t-f-f @@ -19,30 +19,30 @@ 3.mo:Expected error in mat letrec: "attempt to assign undefined variable b". *************** *** 191,202 **** - 3.mo:Expected error in mat mrvs: "returned three values to single value return context". - 3.mo:Expected error in mat mrvs: "returned three values to single value return context". - 3.mo:Expected error in mat mrvs: "returned zero values to single value return context". + 3.mo:Expected error in mat mrvs: "returned 3 values to single value return context". + 3.mo:Expected error in mat mrvs: "returned 3 values to single value return context". + 3.mo:Expected error in mat mrvs: "returned 0 values to single value return context". ! 3.mo:Expected error in mat mrvs: "incorrect number of values received in multiple value context". -! 3.mo:Expected error in mat mrvs: "returned zero values to single value return context". +! 3.mo:Expected error in mat mrvs: "returned 0 values to single value return context". ! 3.mo:Expected error in mat mrvs: "incorrect number of values received in multiple value context". ! 3.mo:Expected error in mat mrvs: "incorrect number of values received in multiple value context". 3.mo:Expected error in mat mrvs: "variable $mrvs-foo is not bound". ! 3.mo:Expected error in mat mrvs: "attempt to apply non-procedure 17". - 3.mo:Expected error in mat mrvs: "returned two values to single value return context". - 3.mo:Expected error in mat mrvs: "returned two values to single value return context". + 3.mo:Expected error in mat mrvs: "returned 2 values to single value return context". + 3.mo:Expected error in mat mrvs: "returned 2 values to single value return context". 3.mo:Expected error in mat mrvs: "cdr: a is not a pair". --- 191,202 ---- - 3.mo:Expected error in mat mrvs: "returned three values to single value return context". - 3.mo:Expected error in mat mrvs: "returned three values to single value return context". - 3.mo:Expected error in mat mrvs: "returned zero values to single value return context". + 3.mo:Expected error in mat mrvs: "returned 3 values to single value return context". + 3.mo:Expected error in mat mrvs: "returned 3 values to single value return context". + 3.mo:Expected error in mat mrvs: "returned 0 values to single value return context". ! 3.mo:Expected error in mat mrvs: "incorrect number of arguments to #". ! 3.mo:Expected error in mat mrvs: "incorrect number of arguments to #". ! 3.mo:Expected error in mat mrvs: "incorrect number of arguments to #". ! 3.mo:Expected error in mat mrvs: "incorrect number of arguments to #". 3.mo:Expected error in mat mrvs: "variable $mrvs-foo is not bound". ! 3.mo:Expected error in mat mrvs: "call-with-values: 17 is not a procedure". - 3.mo:Expected error in mat mrvs: "returned two values to single value return context". - 3.mo:Expected error in mat mrvs: "returned two values to single value return context". + 3.mo:Expected error in mat mrvs: "returned 2 values to single value return context". + 3.mo:Expected error in mat mrvs: "returned 2 values to single value return context". 3.mo:Expected error in mat mrvs: "cdr: a is not a pair". *************** *** 233,240 **** diff --git a/racket/src/ChezScheme/mats/patch-interpret-0-f-f-f b/racket/src/ChezScheme/mats/patch-interpret-0-f-f-f index 9948097d7b..886fe6888e 100644 --- a/racket/src/ChezScheme/mats/patch-interpret-0-f-f-f +++ b/racket/src/ChezScheme/mats/patch-interpret-0-f-f-f @@ -183,30 +183,30 @@ 3.mo:Expected error in mat letrec: "attempt to reference undefined variable a". *************** *** 266,277 **** - 3.mo:Expected error in mat mrvs: "returned three values to single value return context". - 3.mo:Expected error in mat mrvs: "returned three values to single value return context". - 3.mo:Expected error in mat mrvs: "returned zero values to single value return context". + 3.mo:Expected error in mat mrvs: "returned 3 values to single value return context". + 3.mo:Expected error in mat mrvs: "returned 3 values to single value return context". + 3.mo:Expected error in mat mrvs: "returned 0 values to single value return context". ! 3.mo:Expected error in mat mrvs: "incorrect number of values received in multiple value context". -! 3.mo:Expected error in mat mrvs: "returned zero values to single value return context". +! 3.mo:Expected error in mat mrvs: "returned 0 values to single value return context". ! 3.mo:Expected error in mat mrvs: "incorrect number of values received in multiple value context". ! 3.mo:Expected error in mat mrvs: "incorrect number of values received in multiple value context". 3.mo:Expected error in mat mrvs: "variable $mrvs-foo is not bound". ! 3.mo:Expected error in mat mrvs: "attempt to apply non-procedure 17". - 3.mo:Expected error in mat mrvs: "returned two values to single value return context". - 3.mo:Expected error in mat mrvs: "returned two values to single value return context". + 3.mo:Expected error in mat mrvs: "returned 2 values to single value return context". + 3.mo:Expected error in mat mrvs: "returned 2 values to single value return context". 3.mo:Expected error in mat mrvs: "cdr: a is not a pair". --- 266,277 ---- - 3.mo:Expected error in mat mrvs: "returned three values to single value return context". - 3.mo:Expected error in mat mrvs: "returned three values to single value return context". - 3.mo:Expected error in mat mrvs: "returned zero values to single value return context". + 3.mo:Expected error in mat mrvs: "returned 3 values to single value return context". + 3.mo:Expected error in mat mrvs: "returned 3 values to single value return context". + 3.mo:Expected error in mat mrvs: "returned 0 values to single value return context". ! 3.mo:Expected error in mat mrvs: "incorrect number of arguments 1 to #". ! 3.mo:Expected error in mat mrvs: "incorrect number of arguments 0 to #". ! 3.mo:Expected error in mat mrvs: "incorrect number of arguments 0 to #". ! 3.mo:Expected error in mat mrvs: "incorrect number of arguments 0 to #". 3.mo:Expected error in mat mrvs: "variable $mrvs-foo is not bound". ! 3.mo:Expected error in mat mrvs: "call-with-values: 17 is not a procedure". - 3.mo:Expected error in mat mrvs: "returned two values to single value return context". - 3.mo:Expected error in mat mrvs: "returned two values to single value return context". + 3.mo:Expected error in mat mrvs: "returned 2 values to single value return context". + 3.mo:Expected error in mat mrvs: "returned 2 values to single value return context". 3.mo:Expected error in mat mrvs: "cdr: a is not a pair". *************** *** 7466,7472 **** diff --git a/racket/src/ChezScheme/mats/patch-interpret-2-f-f-f b/racket/src/ChezScheme/mats/patch-interpret-2-f-f-f index 508883ff79..fdd7ea379a 100644 --- a/racket/src/ChezScheme/mats/patch-interpret-2-f-f-f +++ b/racket/src/ChezScheme/mats/patch-interpret-2-f-f-f @@ -170,30 +170,30 @@ 3.mo:Expected error in mat letrec: "attempt to reference undefined variable a". *************** *** 191,202 **** - 3.mo:Expected error in mat mrvs: "returned three values to single value return context". - 3.mo:Expected error in mat mrvs: "returned three values to single value return context". - 3.mo:Expected error in mat mrvs: "returned zero values to single value return context". + 3.mo:Expected error in mat mrvs: "returned 3 values to single value return context". + 3.mo:Expected error in mat mrvs: "returned 3 values to single value return context". + 3.mo:Expected error in mat mrvs: "returned 0 values to single value return context". ! 3.mo:Expected error in mat mrvs: "incorrect number of values received in multiple value context". -! 3.mo:Expected error in mat mrvs: "returned zero values to single value return context". +! 3.mo:Expected error in mat mrvs: "returned 0 values to single value return context". ! 3.mo:Expected error in mat mrvs: "incorrect number of values received in multiple value context". ! 3.mo:Expected error in mat mrvs: "incorrect number of values received in multiple value context". 3.mo:Expected error in mat mrvs: "variable $mrvs-foo is not bound". ! 3.mo:Expected error in mat mrvs: "attempt to apply non-procedure 17". - 3.mo:Expected error in mat mrvs: "returned two values to single value return context". - 3.mo:Expected error in mat mrvs: "returned two values to single value return context". + 3.mo:Expected error in mat mrvs: "returned 2 values to single value return context". + 3.mo:Expected error in mat mrvs: "returned 2 values to single value return context". 3.mo:Expected error in mat mrvs: "cdr: a is not a pair". --- 197,208 ---- - 3.mo:Expected error in mat mrvs: "returned three values to single value return context". - 3.mo:Expected error in mat mrvs: "returned three values to single value return context". - 3.mo:Expected error in mat mrvs: "returned zero values to single value return context". + 3.mo:Expected error in mat mrvs: "returned 3 values to single value return context". + 3.mo:Expected error in mat mrvs: "returned 3 values to single value return context". + 3.mo:Expected error in mat mrvs: "returned 0 values to single value return context". ! 3.mo:Expected error in mat mrvs: "incorrect number of arguments to #". ! 3.mo:Expected error in mat mrvs: "incorrect number of arguments to #". ! 3.mo:Expected error in mat mrvs: "incorrect number of arguments to #". ! 3.mo:Expected error in mat mrvs: "incorrect number of arguments to #". 3.mo:Expected error in mat mrvs: "variable $mrvs-foo is not bound". ! 3.mo:Expected error in mat mrvs: "call-with-values: 17 is not a procedure". - 3.mo:Expected error in mat mrvs: "returned two values to single value return context". - 3.mo:Expected error in mat mrvs: "returned two values to single value return context". + 3.mo:Expected error in mat mrvs: "returned 2 values to single value return context". + 3.mo:Expected error in mat mrvs: "returned 2 values to single value return context". 3.mo:Expected error in mat mrvs: "cdr: a is not a pair". *************** *** 4004,4019 **** diff --git a/racket/src/ChezScheme/mats/root-experr-compile-0-f-f-f b/racket/src/ChezScheme/mats/root-experr-compile-0-f-f-f index e57cd0a7d3..35b7e117cc 100644 --- a/racket/src/ChezScheme/mats/root-experr-compile-0-f-f-f +++ b/racket/src/ChezScheme/mats/root-experr-compile-0-f-f-f @@ -262,18 +262,18 @@ primvars.mo:Expected error in mat trace-output-port: "trace-output-port: #> ~s\n" str) (cond [(equal? str "attempt to reference undefined variable ~s") (values (string-append @@ -75,6 +78,18 @@ [(and (equal? str "undefined for ~s") (equal? irritants '(0))) (values "division by zero" null)] + [(and (string-prefix? result-arity-msg-head str) + (string-suffix? result-arity-msg-tail str)) + (values (string-append "result arity mismatch;\n" + " expected number of values not received\n" + " expected: 1\n" + " received: " (let ([s (substring str + (string-length result-arity-msg-head) + (- (string-length str) (string-length result-arity-msg-tail)))]) + (if (equal? s "~a") + (number->string (car irritants)) + s))) + null)] [(equal? str "~s is not a pair") (format-error-values "contract violation\n expected: pair?\n given: ~s" irritants)] diff --git a/racket/src/cs/schemified/expander.scm b/racket/src/cs/schemified/expander.scm index 68af8e2b04..dfba868463 100644 --- a/racket/src/cs/schemified/expander.scm +++ b/racket/src/cs/schemified/expander.scm @@ -24512,7 +24512,7 @@ (begin (begin-unsafe (hash-set! built-in-symbols built-in-s_0 #t)) built-in-s_0)))) -(define effect_2243 +(define effect_2278 (begin (void (begin @@ -24580,6 +24580,7 @@ unsafe-struct? unsafe-struct raise-binding-result-arity-error + raise-definition-result-arity-error structure-type-lookup-prefab-uid struct-type-constructor-add-guards impersonator-val diff --git a/racket/src/cs/schemified/schemify.scm b/racket/src/cs/schemified/schemify.scm index fc2130f510..fd9bd2fc2f 100644 --- a/racket/src/cs/schemified/schemify.scm +++ b/racket/src/cs/schemified/schemify.scm @@ -20991,10 +20991,14 @@ (list ids_0 body_0) (list 'args - (list* - 'raise-binding-result-arity-error - (length ids_0) - '(args)))))))))))) + (let ((app_0 + (if (eq? target_0 'system) '() '(|#%app/no-return|)))) + (qq-append + app_0 + (list* + 'raise-binding-result-arity-error + (length ids_0) + '(args)))))))))))))) (define equal-implies-eq? (lambda (e_0) (let ((hd_0 @@ -23192,32 +23196,57 @@ app_0 app_1 (if no-prompt?_0 - (cons - schemified_0 - (let ((app_2 (cdr l_0))) - (loop_0 - add-import!_0 - allow-inline?_0 - allow-set!-undefined?_0 - datum-intern?_0 - explicit-unnamed?_0 - exports_0 - extra-variables_0 - final-knowns_0 - imports_0 - mutated_0 - no-prompt?_0 - prim-knowns_0 - primitives_0 - serializable?-box_0 - simples_0 - target_0 - unsafe-mode?_0 - app_2 - mut-l_0 - null - (reverse$1 ids_0) - knowns_0))) + (let ((app_2 + (if (if unsafe-mode?_0 + unsafe-mode?_0 + (let ((or-part_0 (eq? target_0 'system))) + (if or-part_0 + or-part_0 + (if (pair? ids_0) + (null? (cdr ids_0)) + #f)))) + schemified_0 + (list + 'define-values + ids_0 + (list + 'call-with-values + (list 'lambda '() rhs_0) + (list + 'case-lambda + (list ids_0 (list* 'values ids_0)) + (list + 'vals + (list* + 'raise-definition-result-arity-error + (list 'quote ids_0) + '(vals))))))))) + (cons + app_2 + (let ((app_3 (cdr l_0))) + (loop_0 + add-import!_0 + allow-inline?_0 + allow-set!-undefined?_0 + datum-intern?_0 + explicit-unnamed?_0 + exports_0 + extra-variables_0 + final-knowns_0 + imports_0 + mutated_0 + no-prompt?_0 + prim-knowns_0 + primitives_0 + serializable?-box_0 + simples_0 + target_0 + unsafe-mode?_0 + app_3 + mut-l_0 + null + (reverse$1 ids_0) + knowns_0)))) (let ((expr_0 (let ((app_2 (list diff --git a/racket/src/expander/compile/built-in-symbol.rkt b/racket/src/expander/compile/built-in-symbol.rkt index 8a98f99a59..0f73d9b4b0 100644 --- a/racket/src/expander/compile/built-in-symbol.rkt +++ b/racket/src/expander/compile/built-in-symbol.rkt @@ -93,6 +93,7 @@ unsafe-struct? unsafe-struct raise-binding-result-arity-error + raise-definition-result-arity-error structure-type-lookup-prefab-uid struct-type-constructor-add-guards impersonator-val diff --git a/racket/src/schemify/left-to-right.rkt b/racket/src/schemify/left-to-right.rkt index 4b462cbaea..760ca7f9fa 100644 --- a/racket/src/schemify/left-to-right.rkt +++ b/racket/src/schemify/left-to-right.rkt @@ -129,4 +129,5 @@ `(call-with-values (lambda () ,rhs) (case-lambda [,ids ,body] - [args (#%app/no-return raise-binding-result-arity-error ,(length ids) args)]))])])])) + [args (,@(if (aim? target 'system) '() '(#%app/no-return)) + raise-binding-result-arity-error ,(length ids) args)]))])])])) diff --git a/racket/src/schemify/schemify.rkt b/racket/src/schemify/schemify.rkt index b88e67c1e9..e526abef60 100644 --- a/racket/src/schemify/schemify.rkt +++ b/racket/src/schemify/schemify.rkt @@ -342,7 +342,18 @@ (cond [no-prompt? (cons - schemified + (cond + [(or unsafe-mode? + (aim? target 'system) + (and (pair? ids) (null? (cdr ids)))) + schemified] + [else + `(define-values ,ids + (call-with-values + (lambda () ,rhs) + (case-lambda + [,ids (values . ,ids)] + [vals (raise-definition-result-arity-error ',ids vals)])))]) (loop (cdr l) mut-l null (reverse ids) knowns))] [else (define expr