1d16650e8303 — Leonard Ritter a month ago
* added default copy operator for `none`
* using `dupe` on plain, unviewed arguments generates no operator in the IL
5 files changed, 19 insertions(+), 3 deletions(-)

M lib/scopes/core.sc
M src/prover.cpp
M testing/test_copy.sc
M testing/test_enums.sc
M testing/test_label.sc
M lib/scopes/core.sc +2 -0
@@ 2548,6 2548,8 @@ do
         __copy = default-copy
     'set-symbols Error
         __copy = default-copy
+    'set-symbols Nothing
+        __copy = default-copy
 
 'set-symbols typename
     # inverted compare attempts regular compare

          
M src/prover.cpp +2 -0
@@ 2240,6 2240,8 @@ repeat:
             CHECKARGS(1, 1);
             READ_NODEREF_TYPEOF(X);
             const Type *DestT = strip_lifetime(X);
+            if (X == DestT)
+                return _X;
             auto op = Cast::from(CastBitcast, _X, DestT);
             if (is_plain(X)) {
                 return TypedValueRef(call.anchor(), op);

          
M testing/test_copy.sc +2 -0
@@ 24,5 24,7 @@ test-compiler-error
         local x = (One 303)
         copy &x
 
+test (constant? (copy none))
+
 
 ;
  No newline at end of file

          
M testing/test_enums.sc +10 -0
@@ 255,5 255,15 @@ do
     test ((hash (Atom.Number 1 2)) != (hash (Atom.Number 2 2)))
     test ((hash (Atom.Number 1 3)) == (hash (Atom.Number 1 3)))
 
+do
+    # copying enums
+    enum Q
+        A
+        B : i32 i32
+        C
+
+    copy (Q.A)
+    ;
+
 ;
 

          
M testing/test_label.sc +3 -3
@@ 55,9 55,9 @@ do
     # forward label form
 
     :: ok
-    merge ok 1 2 3
-    ok (x y z) ::
-    print x y z
+    merge ok 1 2 3 4 5
+    ok (x y z w...) ::
+    print x "," y "," z "," w...
 
     let select1 = (gen-label-merge-test)
     fn select2 (k str)