<commit_before>(in-package :vari.cl)
(in-readtable fn:fn-reader)

;;------------------------------------------------------------
;; Bind

(v-defspecial multiple-value-bind (vars value-form &rest body)
  :args-valid t
  :return
  (let* ((base (lisp-name->glsl-name 'mvb env))
         (new-env (fresh-environment env :multi-val-base base)))
    (let ((value-obj (compile-form value-form new-env)))
      (unless (= (length vars) (length (type-set value-obj)))
        (error 'multi-val-bind-mismatch
               :val-form value-form
               :bindings vars
               :return-set (type-set value-obj)))
      (let ((types (type-set-to-type-list (type-set value-obj))))
        (vbind ((m-objs s-obj b-objs) final-env)
            (with-fresh-env-scope (fresh-env env)
              (env-> (p-env fresh-env)
                (compile-forms-not-propagating-env-returning-list-of-compiled
                 (lambda (env type name i)
                   (compile-let name (type->type-spec type) nil env
                                (postfix-glsl-index base i)))
                 p-env types vars (alexandria:iota (length types)))
                (compile-form `(setq ,(first vars) ,value-obj) p-env)
                (compile-progn body p-env)))
          (let* ((m-obj (%merge-multi-env-progn m-objs))
                 (merged (merge-progn `(,m-obj ,s-obj ,@b-objs)
                                      env final-env)))
            (values
             (copy-compiled
              merged
              :node-tree (ast-node! 'multiple-value-bind
                                    `(,vars ,(node-tree value-obj)
                                            ,@(mapcar #'node-tree b-objs))
                                    (make-type-set (primary-type merged))
                                    env final-env))
             final-env)))))))

;;------------------------------------------------------------
;; Call

(v-defspecial multiple-value-call (function &rest value-forms)
  ;; {TODO} extend to multiple forms
  :args-valid t
  :return
  (vbind (func-obj fenv) (compile-form function env)
    ;; We want a seperate base for each form to avoid var naming clashes
    (let ((bases (loop :for nil :in value-forms :collect
                    (lisp-name->glsl-name 'mvb fenv))))
      ;; we compile the forms in a way that passes along the env (as in progn)<commit_msg>fix: multiple-value-bind cannot handle void return from body<commit_after>(in-package :vari.cl)
(in-readtable fn:fn-reader)

;;------------------------------------------------------------
;; Bind

(v-defspecial multiple-value-bind (vars value-form &rest body)
  :args-valid t
  :return
  (let* ((base (lisp-name->glsl-name 'mvb env))
         (new-env (fresh-environment env :multi-val-base base)))
    (let ((value-obj (compile-form value-form new-env)))
      (unless (= (length vars) (length (type-set value-obj)))
        (error 'multi-val-bind-mismatch
               :val-form value-form
               :bindings vars
               :return-set (type-set value-obj)))
      (let ((types (type-set-to-type-list (type-set value-obj))))
        (vbind ((m-objs s-obj b-objs) final-env)
            (with-fresh-env-scope (fresh-env env)
              (env-> (p-env fresh-env)
                (compile-forms-not-propagating-env-returning-list-of-compiled
                 (lambda (env type name i)
                   (compile-let name (type->type-spec type) nil env
                                (postfix-glsl-index base i)))
                 p-env types vars (alexandria:iota (length types)))
                (compile-form `(setq ,(first vars) ,value-obj) p-env)
                (compile-progn body p-env)))
          (let* ((m-obj (%merge-multi-env-progn m-objs))
                 (merged (merge-progn `(,m-obj ,s-obj ,@b-objs)
                                      env final-env)))
            (values
             (copy-compiled
              merged
              :node-tree (ast-node! 'multiple-value-bind
                                    `(,vars ,(node-tree value-obj)
                                            ,@(mapcar #'node-tree b-objs))
                                    (type-set merged)
                                    env final-env))
             final-env)))))))

;;------------------------------------------------------------
;; Call

(v-defspecial multiple-value-call (function &rest value-forms)
  ;; {TODO} extend to multiple forms
  :args-valid t
  :return
  (vbind (func-obj fenv) (compile-form function env)
    ;; We want a seperate base for each form to avoid var naming clashes
    (let ((bases (loop :for nil :in value-forms :collect
                    (lisp-name->glsl-name 'mvb fenv))))
      ;; we compile the forms in a way that passes along the env (as in progn)
{'fraction_non_alphanumeric': 0.17686364585508457, 'fraction_numerical': 0.0, 'mean_word_length': 1.4204143506821627, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 14, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4887037', 'n_tokens_mistral': 1407, 'n_tokens_neox': 1349, 'n_words': 362}