Skip to content

Commit

Permalink
[master] const ref handling (#43)
Browse files Browse the repository at this point in the history
  • Loading branch information
tomhrr committed Mar 31, 2016
1 parent 51886a0 commit 24a46da
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/dale/Form/Proc/Def/Def.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ storeValue(Context *ctx, Node *node, Type *type,
{
std::vector<Type *> param_types;
param_types.push_back(ctx->tr->getPointerType(type));
param_types.push_back(type);
param_types.push_back(pr->type);
std::vector<bool> lvalues;
lvalues.push_back(true);
lvalues.push_back(false);
Expand Down
2 changes: 1 addition & 1 deletion t/999last/001compile-errors.t
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ $ENV{"DALE_TEST_ARGS"} ||= "";
my $test_dir = $ENV{"DALE_TEST_DIR"} || ".";
$ENV{PATH} .= ":.";

use Test::More tests => 218;
use Test::More tests => 220;

my @error_files =
(@ARGV)
Expand Down
33 changes: 33 additions & 0 deletions t/error-src/const-rv-2.dt
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
(import cstdio)

(def mys (struct intern ((a int) (b int))))

(def init
(fn intern bool ((dst (ref mys)) (a int) (b int))
(setf (:@ dst a) a)
(setf (:@ dst b) b)
true))

(def setf-copy-disabled (fn intern void ((dst mys))))

(def mys-move (fn intern bool ((dst (p mys)) (src (rv-ref mys)))
(setf (:@ dst a) (@:@ src a))
(setf (:@ dst b) (@:@ src b))
true))

(def setf-move-init (fn intern bool ((dst (p mys)) (src (rv-ref mys)))
(printf "setf-move-init\n")
(mys-move dst (move (@ src)))))

(def setf-move-assign (fn intern bool ((dst (p mys)) (src (rv-ref mys)))
(printf "setf-move-assign\n")
(mys-move dst (move (@ src)))))

(def no-call (fn intern bool ((dst (ref (const mys))))
(def x (var auto mys (move (@ dst))))
true))

(def main (fn extern-c int (void)
(def a (var auto (const mys) (init a 1 2)))
(no-call a)
0))
1 change: 1 addition & 0 deletions t/error-src/const-rv-2.dt.errors
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
./t/error-src/const-rv-2.dt:27:3: error: copying is disabled for this type

0 comments on commit 24a46da

Please sign in to comment.