summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Llorens <daniel.llorens@bluewin.ch>2013-05-08 16:06:40 +0200
committerAndy Wingo <wingo@pobox.com>2014-01-27 21:49:10 +0100
commit96f733226313b797e5f38948dc8216112f54f756 (patch)
treed3dc6869831ee493b3fa54b76c9fcc93d257b3e1
parentf6ec824401ab46e74be358130c4d4d2bd209bbc4 (diff)
downloadguile-96f733226313b797e5f38948dc8216112f54f756.tar.gz
array-contents returns root for empty arrays with empty root
This fixes a compiler issue where (uniform-array->bytevector #2f64()) failed because of the stricter definition of uniform-vector? on this branch. Perhaps it would be better if uniform-array->bytevector didn't require a contiguous argument. * libguile/arrays.c: (scm_array_contents): return the root regardless of the value of SCM_I_ARRAY_DIMS (ra)->inc. * test-suite/tests/arrays.test: check.
-rw-r--r--libguile/arrays.c5
-rw-r--r--test-suite/tests/arrays.test5
2 files changed, 7 insertions, 3 deletions
diff --git a/libguile/arrays.c b/libguile/arrays.c
index 6e032a9db..49015a4ca 100644
--- a/libguile/arrays.c
+++ b/libguile/arrays.c
@@ -588,9 +588,8 @@ SCM_DEFINE (scm_array_contents, "array-contents", 1, 1, 0,
}
v = SCM_I_ARRAY_V (ra);
- if ((len == scm_c_array_length (v)) && (0 == SCM_I_ARRAY_BASE (ra))
- && SCM_I_ARRAY_DIMS (ra)->inc)
- return v;
+ if ((len == scm_c_array_length (v)) && (0 == SCM_I_ARRAY_BASE (ra)))
+ return v;
else
{
SCM sra = scm_i_make_array (1);
diff --git a/test-suite/tests/arrays.test b/test-suite/tests/arrays.test
index 2652bfda4..57d23af5c 100644
--- a/test-suite/tests/arrays.test
+++ b/test-suite/tests/arrays.test
@@ -335,6 +335,11 @@
(let* ((a (make-array 0 4 4)))
(not (array-contents (transpose-array a 1 0) #t))))
+ ;; This is a consequence of (array-contents? a #t) => #t.
+ (pass-if "empty array"
+ (let ((a (make-typed-array 'f64 2 0 0)))
+ (uniform-vector? (array-contents a))))
+
(pass-if "broadcast vector I"
(let* ((a (make-array 0 4))
(b (make-shared-array a (lambda (i j k) (list k)) 1 1 4)))