summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Chambers <andrewchamberss@gmail.com>2016-02-06 11:20:55 +1300
committerAndrew Chambers <andrewchamberss@gmail.com>2016-02-06 11:21:15 +1300
commit932320f93ec0266a53c3e50600d73d3d23e1db76 (patch)
tree0d106dc6f3064b022fcda0c9e0fbb6ae14d11df4
parent3c1277e37fbaea87d770d4a64a5029c4a693bb63 (diff)
downloadmc-932320f93ec0266a53c3e50600d73d3d23e1db76.tar.gz
fix rval len, fixes #69
-rw-r--r--6/simp.c2
-rw-r--r--test/rvaldotlen.myr21
-rw-r--r--test/tests1
3 files changed, 23 insertions, 1 deletions
diff --git a/6/simp.c b/6/simp.c
index b1fe969..28548c6 100644
--- a/6/simp.c
+++ b/6/simp.c
@@ -295,7 +295,7 @@ static void cjmp(Simp *s, Node *cond, Node *iftrue, Node *iffalse)
static Node *slicelen(Simp *s, Node *sl)
{
/* *(&sl + sizeof(size_t)) */
- return load(addk(addr(s, sl, tyintptr), Ptrsz));
+ return load(addk(addr(s, rval(s, sl, NULL), tyintptr), Ptrsz));
}
Node *loadvar(Simp *s, Node *n, Node *dst)
diff --git a/test/rvaldotlen.myr b/test/rvaldotlen.myr
new file mode 100644
index 0000000..2c87f95
--- /dev/null
+++ b/test/rvaldotlen.myr
@@ -0,0 +1,21 @@
+use std
+
+const f1 = { -> byte[:]
+ -> [1, 2, 3][:]
+}
+
+const f2 = { -> byte[3]
+ -> [1, 2, 3]
+}
+
+
+const main = {
+ if f1().len != 3
+ -> void
+ ;;
+ if f2().len != 3
+ -> void
+ ;;
+ std.put("pass\n")
+}
+
diff --git a/test/tests b/test/tests
index 4ed8cdd..0439482 100644
--- a/test/tests
+++ b/test/tests
@@ -154,3 +154,4 @@ F badop
B voideffect P pass
B foroptexpr P pass
B bounds E 134
+B rvaldotlen P pass