>From 3f0bd61ef584520baf66aa631187a60eaf570e8b Mon Sep 17 00:00:00 2001 From: LemonBoy Date: Wed, 8 Nov 2017 15:56:21 +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 fcf0b0c1..79065def 100644 --- a/support.scm +++ b/support.scm @@ -1198,6 +1198,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))] [else 0] ) ] [else 0] ) ) ) ) (lambda () (quit "foreign type `~S' refers to itself" type)) ) ) @@ -1226,6 +1227,7 @@ [(ref nonnull-pointer pointer c-pointer nonnull-c-pointer function scheme-pointer nonnull-scheme-pointer) (words->bytes 1)] + [(const) (next (cadr t))] [else (err t)] ) ] [else (err t)] ) ) ) ) (lambda () (quit "foreign type `~S' refers to itself" type)) ) ) diff --git a/tests/compiler-tests.scm b/tests/compiler-tests.scm index 53de9711..4c2bf806 100644 --- a/tests/compiler-tests.scm +++ b/tests/compiler-tests.scm @@ -319,3 +319,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