6a37f4a6be82 — Leonard Ritter 11 days ago
* fixed using `viewing` on plain values
2 files changed, 32 insertions(+), 1 deletions(-)

M src/prover.cpp
M testing/test_borrowing.sc
M src/prover.cpp +4 -1
@@ 2242,7 2242,10 @@ repeat:
                 if (!param) {
                     SCOPES_ERROR(ValueKindMismatch, VK_Parameter, value->kind());
                 }
-                param->retype(view_type(param->get_type(), {}));
+                auto T = param->get_type();
+                if (!is_plain(T)) {
+                    param->retype(view_type(param->get_type(), {}));
+                }
             }
             return ref(call.anchor(), ArgumentList::from({}));
         } break;

          
M testing/test_borrowing.sc +28 -0
@@ 531,4 531,32 @@ fn test-drop ()
 test-drop;
 print "done"
 
+do
+    # test viewing on plain arguments
+
+    using import struct
+
+    fn make (json-string)
+
+    fn parse (json-string)
+        viewing json-string
+        make json-string
+
+    fn make2 (json-string)
+        viewing json-string
+
+    fn parse2 (json-string)
+        make2 json-string
+
+    # unique
+    struct M
+        s : string
+    parse (nullof M)
+    parse2 (nullof M)
+    unlet M
+    struct M plain
+        s : string
+    parse (nullof M)
+    parse2 (nullof M)
+
 ;
  No newline at end of file