>From 33b13f2cfb7a4b6f15e28c59b4507cdb576fa8ca Mon Sep 17 00:00:00 2001 From: LemonBoy Date: Wed, 8 Nov 2017 15:36:29 +0100 Subject: [PATCH] Correctly parse FFI types wrapped in `const' forms Keep parsing the cdr when calculating the total size of the type. --- support.scm | 2 ++ tests/compiler-tests.scm | 9 +++++++++ 2 files changed, 11 insertions(+) diff --git a/support.scm b/support.scm index 905f7ae8..8a489217 100644 --- a/support.scm +++ b/support.scm @@ -1183,6 +1183,7 @@ (case (car t) ((ref nonnull-pointer pointer c-pointer nonnull-c-pointer function instance instance-ref nonnull-instance) (words->bytes 3) ) + ((const) (next (cadr t))) ((enum) (words->bytes 6)) ; 1 bignum digit on 32-bit (overallocs on 64-bit) (else (err t)))) (else (err t)))))) @@ -1211,6 +1212,7 @@ ((ref nonnull-pointer pointer c-pointer nonnull-c-pointer function scheme-pointer nonnull-scheme-pointer enum) (words->bytes 1)) + ((const) (next (cadr t))) (else (err t)) ) ) (else (err t)) ) ) ) ) (lambda () (quit-compiling "foreign type `~S' refers to itself" type)) ) ) diff --git a/tests/compiler-tests.scm b/tests/compiler-tests.scm index c2f0c068..61eabd66 100644 --- a/tests/compiler-tests.scm +++ b/tests/compiler-tests.scm @@ -426,3 +426,12 @@ (define (also-do-it arg) (get-value arg 3)) ) + +; let-location with const-wrapped type +(let-location ((foo (const c-string) "boo")) + (assert (equal? foo "boo"))) + +; #1424: a foreign lambda with const return type was wrongly rejected +(let ((v0 ((foreign-lambda* c-string () "C_return(\"str\");"))) + (v1 ((foreign-lambda* (const c-string) () "C_return(\"str\");")))) + (assert (equal? v0 v1))) -- 2.11.0