Closed skydread1 closed 3 years ago
Unlike in nostrand
, Unity seems to not be able to use the clojure ^dynamic
vars such as *warn-on-reflection*
, *unchecked-math*
etc.
I noticed that those dynamic vars present in clojure.main
seems to be able to be set!
in magic clj files.
However, custom dynamic vars such as *load-fn*
cannot be used in the magic clj files.
So I replaced all the magic and stdlib dlls with the last ones except for clojure.core
because the new clojure.core.clj.dll
contains CUSTOM dynamic vars.
It worked now and clojure.pprint
can compile properly by adding the hack.
Adding those 2 lines solve the issues:
RT.var("clojure.core", "require").invoke(Symbol.intern("clojure.spec.alpha"));
RT.var("clojure.core", "require").invoke(Symbol.intern("clojure.pprint"));
However now I have an error related to my port of clr.test.check
:
InvalidOperationException: Can't change/establish root binding of: *unchecked-math* with set
clojure.lang.Var.set (System.Object val) (at <2c4df3465e5849519b125a15e0496a36>:0)
<magic>expr_8.eval () (at <6f6c15ebcbd84ed8a96e520e9827649f>:0)
System.Reflection.MonoMethod.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at <695d1cc93cca45069c528c15c9fdd749>:0)
Rethrow as TargetInvocationException: Exception has been thrown by the target of an invocation.
<magic>clojure_core$load-lib__0.invokeTyped (System.Object prefix, System.Object lib, clojure.lang.ISeq options) (at <bdcc818227a246b5b90c8569ad610c1e>:0)
<magic>clojure_core$load-lib__0.doInvoke (System.Object prefix, System.Object lib, System.Object options) (at <bdcc818227a246b5b90c8569ad610c1e>:0)
clojure.lang.RestFn.applyTo (clojure.lang.ISeq arglist) (at <2c4df3465e5849519b125a15e0496a36>:0)
clojure.lang.AFunction+MetaWrapper.doInvoke (System.Object args) (at <2c4df3465e5849519b125a15e0496a36>:0)
clojure.lang.RestFn.applyTo (clojure.lang.ISeq arglist) (at <2c4df3465e5849519b125a15e0496a36>:0)
<magic>clojure_core$apply__0.invokeTyped (clojure.lang.IFn f, System.Object x, System.Object args) (at <bdcc818227a246b5b90c8569ad610c1e>:0)
<magic>clojure_core$apply__0.invoke (System.Object f, System.Object x, System.Object args) (at <bdcc818227a246b5b90c8569ad610c1e>:0)
<magic>clojure_core$load-libs__0.invokeTyped (clojure.lang.ISeq args) (at <bdcc818227a246b5b90c8569ad610c1e>:0)
<magic>clojure_core$load-libs__0.doInvoke (System.Object args) (at <bdcc818227a246b5b90c8569ad610c1e>:0)
clojure.lang.RestFn.applyTo (clojure.lang.ISeq arglist) (at <2c4df3465e5849519b125a15e0496a36>:0)
<magic>clojure_core$apply__0.invokeTyped (clojure.lang.IFn f, System.Object x, System.Object args) (at <bdcc818227a246b5b90c8569ad610c1e>:0)
<magic>clojure_core$apply__0.invoke (System.Object f, System.Object x, System.Object args) (at <bdcc818227a246b5b90c8569ad610c1e>:0)
<magic>clojure_core$require__0.invokeTyped (clojure.lang.ISeq args) (at <bdcc818227a246b5b90c8569ad610c1e>:0)
<magic>clojure_core$require__0.doInvoke (System.Object args) (at <bdcc818227a246b5b90c8569ad610c1e>:0)
clojure.lang.RestFn.invoke (System.Object arg1, System.Object arg2, System.Object arg3) (at <2c4df3465e5849519b125a15e0496a36>:0)
<magic>flybot_specs_generators$loading__17689__auto____0.invoke () (at <ce1eb66c912e448682aac718d0ef0566>:0)
<magic>expr_2.eval () (at <ce1eb66c912e448682aac718d0ef0566>:0)
System.Reflection.MonoMethod.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at <695d1cc93cca45069c528c15c9fdd749>:0)
Rethrow as TargetInvocationException: Exception has been thrown by the target of an invocation.
<magic>clojure_core$load-lib__0.invokeTyped (System.Object prefix, System.Object lib, clojure.lang.ISeq options) (at <bdcc818227a246b5b90c8569ad610c1e>:0)
<magic>clojure_core$load-lib__0.doInvoke (System.Object prefix, System.Object lib, System.Object options) (at <bdcc818227a246b5b90c8569ad610c1e>:0)
clojure.lang.RestFn.applyTo (clojure.lang.ISeq arglist) (at <2c4df3465e5849519b125a15e0496a36>:0)
clojure.lang.AFunction+MetaWrapper.doInvoke (System.Object args) (at <2c4df3465e5849519b125a15e0496a36>:0)
clojure.lang.RestFn.applyTo (clojure.lang.ISeq arglist) (at <2c4df3465e5849519b125a15e0496a36>:0)
<magic>clojure_core$apply__0.invokeTyped (clojure.lang.IFn f, System.Object x, System.Object args) (at <bdcc818227a246b5b90c8569ad610c1e>:0)
<magic>clojure_core$apply__0.invoke (System.Object f, System.Object x, System.Object args) (at <bdcc818227a246b5b90c8569ad610c1e>:0)
<magic>clojure_core$load-libs__0.invokeTyped (clojure.lang.ISeq args) (at <bdcc818227a246b5b90c8569ad610c1e>:0)
<magic>clojure_core$load-libs__0.doInvoke (System.Object args) (at <bdcc818227a246b5b90c8569ad610c1e>:0)
clojure.lang.RestFn.applyTo (clojure.lang.ISeq arglist) (at <2c4df3465e5849519b125a15e0496a36>:0)
<magic>clojure_core$apply__0.invokeTyped (clojure.lang.IFn f, System.Object x, System.Object args) (at <bdcc818227a246b5b90c8569ad610c1e>:0)
<magic>clojure_core$apply__0.invoke (System.Object f, System.Object x, System.Object args) (at <bdcc818227a246b5b90c8569ad610c1e>:0)
<magic>clojure_core$require__0.invokeTyped (clojure.lang.ISeq args) (at <bdcc818227a246b5b90c8569ad610c1e>:0)
<magic>clojure_core$require__0.doInvoke (System.Object args) (at <bdcc818227a246b5b90c8569ad610c1e>:0)
clojure.lang.RestFn.invoke (System.Object arg1, System.Object arg2, System.Object arg3, System.Object arg4, System.Object arg5, System.Object arg6) (at <2c4df3465e5849519b125a15e0496a36>:0)
<magic>flybot_big-two$loading__17689__auto____0.invoke () (at <1d73102014b84db8a43ada1f3de4132f>:0)
<magic>expr_1.eval () (at <1d73102014b84db8a43ada1f3de4132f>:0)
System.Reflection.MonoMethod.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at <695d1cc93cca45069c528c15c9fdd749>:0)
Rethrow as TargetInvocationException: Exception has been thrown by the target of an invocation.
<magic>clojure_core$load-lib__0.invokeTyped (System.Object prefix, System.Object lib, clojure.lang.ISeq options) (at <bdcc818227a246b5b90c8569ad610c1e>:0)
<magic>clojure_core$load-lib__0.doInvoke (System.Object prefix, System.Object lib, System.Object options) (at <bdcc818227a246b5b90c8569ad610c1e>:0)
clojure.lang.RestFn.applyTo (clojure.lang.ISeq arglist) (at <2c4df3465e5849519b125a15e0496a36>:0)
clojure.lang.AFunction+MetaWrapper.doInvoke (System.Object args) (at <2c4df3465e5849519b125a15e0496a36>:0)
clojure.lang.RestFn.applyTo (clojure.lang.ISeq arglist) (at <2c4df3465e5849519b125a15e0496a36>:0)
<magic>clojure_core$apply__0.invokeTyped (clojure.lang.IFn f, System.Object x, System.Object args) (at <bdcc818227a246b5b90c8569ad610c1e>:0)
<magic>clojure_core$apply__0.invoke (System.Object f, System.Object x, System.Object args) (at <bdcc818227a246b5b90c8569ad610c1e>:0)
<magic>clojure_core$load-libs__0.invokeTyped (clojure.lang.ISeq args) (at <bdcc818227a246b5b90c8569ad610c1e>:0)
<magic>clojure_core$load-libs__0.doInvoke (System.Object args) (at <bdcc818227a246b5b90c8569ad610c1e>:0)
clojure.lang.RestFn.applyTo (clojure.lang.ISeq arglist) (at <2c4df3465e5849519b125a15e0496a36>:0)
<magic>clojure_core$apply__0.invokeTyped (clojure.lang.IFn f, System.Object x, System.Object args) (at <bdcc818227a246b5b90c8569ad610c1e>:0)
<magic>clojure_core$apply__0.invoke (System.Object f, System.Object x, System.Object args) (at <bdcc818227a246b5b90c8569ad610c1e>:0)
<magic>clojure_core$require__0.invokeTyped (clojure.lang.ISeq args) (at <bdcc818227a246b5b90c8569ad610c1e>:0)
<magic>clojure_core$require__0.doInvoke (System.Object args) (at <bdcc818227a246b5b90c8569ad610c1e>:0)
clojure.lang.RestFn.invoke (System.Object arg1, System.Object arg2, System.Object arg3, System.Object arg4, System.Object arg5, System.Object arg6, System.Object arg7) (at <2c4df3465e5849519b125a15e0496a36>:0)
<magic>clojure_core$loading__17689__auto____0.invoke () (at <0e1fd591b147447b9d05db61e1c3b804>:0)
<magic>expr_0.eval () (at <0e1fd591b147447b9d05db61e1c3b804>:0)
System.Reflection.MonoMethod.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at <695d1cc93cca45069c528c15c9fdd749>:0)
Rethrow as TargetInvocationException: Exception has been thrown by the target of an invocation.
System.Reflection.MonoMethod.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at <695d1cc93cca45069c528c15c9fdd749>:0)
System.Reflection.MethodBase.Invoke (System.Object obj, System.Object[] parameters) (at <695d1cc93cca45069c528c15c9fdd749>:0)
(wrapper dynamic-method) System.Object.CallSite.Target(System.Runtime.CompilerServices.Closure,System.Runtime.CompilerServices.CallSite,object,object,object)
(wrapper dynamic-method) System.Object.CallSite.Target(System.Runtime.CompilerServices.Closure,System.Runtime.CompilerServices.CallSite,object,object,object)
magic$api$compile_expression__10864fn__10893__10897.__interop_Invoke10899 (System.Object , System.Object __temp_1, System.Object __temp_2) (at <a520349010584a7cae975de3943b41e7>:0)
magic$api$compile_expression__10864fn__10893__10897.invoke () (at <a520349010584a7cae975de3943b41e7>:0)
<magic>clojure_core$with-redefs-fn__0.invoke (System.Object binding-map, System.Object func) (at <bdcc818227a246b5b90c8569ad610c1e>:0)
clojure.lang.AFn.ApplyToHelper (clojure.lang.IFn fn, clojure.lang.ISeq argList) (at <2c4df3465e5849519b125a15e0496a36>:0)
clojure.lang.AFn.applyTo (clojure.lang.ISeq arglist) (at <2c4df3465e5849519b125a15e0496a36>:0)
clojure.lang.AFunction+MetaWrapper.doInvoke (System.Object args) (at <2c4df3465e5849519b125a15e0496a36>:0)
clojure.lang.RestFn.invoke (System.Object arg1, System.Object arg2) (at <2c4df3465e5849519b125a15e0496a36>:0)
magic$api$compile_expression__10864__10904.invokeStatic (System.Object , System.Object , System.Object ) (at <a520349010584a7cae975de3943b41e7>:0)
magic$api$compile_expression__10864__10904.invoke (System.Object , System.Object , System.Object ) (at <a520349010584a7cae975de3943b41e7>:0)
magic$api$compile_expression_top_level__10913__10920.invoke (System.Object , System.Object , System.Object ) (at <a520349010584a7cae975de3943b41e7>:0)
magic$api$load_file__10923__10933.invokeStatic (System.Object , System.Object , System.Object ) (at <a520349010584a7cae975de3943b41e7>:0)
magic$api$load_file__10923__10933.invoke (System.Object , System.Object , System.Object ) (at <a520349010584a7cae975de3943b41e7>:0)
magic$api$compile_file__10964__10967.invokeStatic (System.Object , System.Object , System.Object ) (at <a520349010584a7cae975de3943b41e7>:0)
magic$api$compile_file__10964__10967.invoke (System.Object , System.Object , System.Object ) (at <a520349010584a7cae975de3943b41e7>:0)
magic$api$compile_namespace__10987fn__11003__11007.invoke () (at <a520349010584a7cae975de3943b41e7>:0)
<magic>clojure_core$with-redefs-fn__0.invoke (System.Object binding-map, System.Object func) (at <bdcc818227a246b5b90c8569ad610c1e>:0)
clojure.lang.AFn.ApplyToHelper (clojure.lang.IFn fn, clojure.lang.ISeq argList) (at <2c4df3465e5849519b125a15e0496a36>:0)
clojure.lang.AFn.applyTo (clojure.lang.ISeq arglist) (at <2c4df3465e5849519b125a15e0496a36>:0)
clojure.lang.AFunction+MetaWrapper.doInvoke (System.Object args) (at <2c4df3465e5849519b125a15e0496a36>:0)
clojure.lang.RestFn.invoke (System.Object arg1, System.Object arg2) (at <2c4df3465e5849519b125a15e0496a36>:0)
magic$api$compile_namespace__10987__11010.invoke (System.Object , System.Object ) (at <a520349010584a7cae975de3943b41e7>:0)
clojure.lang.Var.invoke (System.Object arg1, System.Object arg2) (at <2c4df3465e5849519b125a15e0496a36>:0)
Magic.Unity.Window.BuildNamespace (System.String ns) (at Assets/Magic.Unity/Editor/Window.cs:236)
Magic.Unity.Window.BuildNamespaces (System.String buildPath) (at Assets/Magic.Unity/Editor/Window.cs:215)
Magic.Unity.Window.OnGUI () (at Assets/Magic.Unity/Editor/Window.cs:176)
UnityEditor.HostView.InvokeOnGUI (UnityEngine.Rect onGUIPosition, UnityEngine.Rect viewRect) (at /Users/bokken/buildslave/unity/build/Editor/Mono/HostView.cs:410)
UnityEditor.DockArea.DrawView (UnityEngine.Rect viewRect, UnityEngine.Rect dockAreaRect) (at /Users/bokken/buildslave/unity/build/Editor/Mono/GUI/DockArea.cs:382)
UnityEditor.DockArea.OldOnGUI () (at /Users/bokken/buildslave/unity/build/Editor/Mono/GUI/DockArea.cs:372)
UnityEngine.UIElements.IMGUIContainer.DoOnGUI (UnityEngine.Event evt, UnityEngine.Matrix4x4 parentTransform, UnityEngine.Rect clippingRect, System.Boolean isComputingLayout, UnityEngine.Rect layoutSize, System.Action onGUIHandler, System.Boolean canAffectFocus) (at /Users/bokken/buildslave/unity/build/External/MirroredPackageSources/com.unity.ui/Core/IMGUIContainer.cs:353)
UnityEngine.UIElements.IMGUIContainer.HandleIMGUIEvent (UnityEngine.Event e, UnityEngine.Matrix4x4 worldTransform, UnityEngine.Rect clippingRect, System.Action onGUIHandler, System.Boolean canAffectFocus) (at /Users/bokken/buildslave/unity/build/External/MirroredPackageSources/com.unity.ui/Core/IMGUIContainer.cs:663)
UnityEngine.UIElements.IMGUIContainer.HandleIMGUIEvent (UnityEngine.Event e, System.Action onGUIHandler, System.Boolean canAffectFocus) (at /Users/bokken/buildslave/unity/build/External/MirroredPackageSources/com.unity.ui/Core/IMGUIContainer.cs:635)
UnityEngine.UIElements.IMGUIContainer.HandleIMGUIEvent (UnityEngine.Event e, System.Boolean canAffectFocus) (at /Users/bokken/buildslave/unity/build/External/MirroredPackageSources/com.unity.ui/Core/IMGUIContainer.cs:628)
UnityEngine.UIElements.IMGUIContainer.SendEventToIMGUIRaw (UnityEngine.UIElements.EventBase evt, System.Boolean canAffectFocus, System.Boolean verifyBounds) (at /Users/bokken/buildslave/unity/build/External/MirroredPackageSources/com.unity.ui/Core/IMGUIContainer.cs:594)
UnityEngine.UIElements.IMGUIContainer.SendEventToIMGUI (UnityEngine.UIElements.EventBase evt, System.Boolean canAffectFocus, System.Boolean verifyBounds) (at /Users/bokken/buildslave/unity/build/External/MirroredPackageSources/com.unity.ui/Core/IMGUIContainer.cs:583)
UnityEngine.UIElements.IMGUIContainer.HandleEvent (UnityEngine.UIElements.EventBase evt) (at /Users/bokken/buildslave/unity/build/External/MirroredPackageSources/com.unity.ui/Core/IMGUIContainer.cs:516)
UnityEngine.UIElements.CallbackEventHandler.HandleEventAtTargetPhase (UnityEngine.UIElements.EventBase evt) (at /Users/bokken/buildslave/unity/build/External/MirroredPackageSources/com.unity.ui/Core/Events/EventHandler.cs:125)
UnityEngine.UIElements.MouseCaptureDispatchingStrategy.DispatchEvent (UnityEngine.UIElements.EventBase evt, UnityEngine.UIElements.IPanel panel) (at /Users/bokken/buildslave/unity/build/External/MirroredPackageSources/com.unity.ui/Core/Events/MouseCaptureDispatchingStrategy.cs:83)
UnityEngine.UIElements.EventDispatcher.ApplyDispatchingStrategies (UnityEngine.UIElements.EventBase evt, UnityEngine.UIElements.IPanel panel, System.Boolean imguiEventIsInitiallyUsed) (at /Users/bokken/buildslave/unity/build/External/MirroredPackageSources/com.unity.ui/Core/EventDispatcher.cs:373)
UnityEngine.UIElements.EventDispatcher.ProcessEvent (UnityEngine.UIElements.EventBase evt, UnityEngine.UIElements.IPanel panel) (at /Users/bokken/buildslave/unity/build/External/MirroredPackageSources/com.unity.ui/Core/EventDispatcher.cs:336)
UnityEngine.UIElements.EventDispatcher.ProcessEventQueue () (at /Users/bokken/buildslave/unity/build/External/MirroredPackageSources/com.unity.ui/Core/EventDispatcher.cs:299)
UnityEngine.UIElements.EventDispatcher.OpenGate () (at /Users/bokken/buildslave/unity/build/External/MirroredPackageSources/com.unity.ui/Core/EventDispatcher.cs:264)
UnityEngine.UIElements.EventDispatcherGate.Dispose () (at /Users/bokken/buildslave/unity/build/External/MirroredPackageSources/com.unity.ui/Core/EventDispatcher.cs:75)
UnityEngine.UIElements.EventDispatcher.ProcessEvent (UnityEngine.UIElements.EventBase evt, UnityEngine.UIElements.IPanel panel) (at /Users/bokken/buildslave/unity/build/External/MirroredPackageSources/com.unity.ui/Core/EventDispatcher.cs:364)
UnityEngine.UIElements.EventDispatcher.Dispatch (UnityEngine.UIElements.EventBase evt, UnityEngine.UIElements.IPanel panel, UnityEngine.UIElements.DispatchMode dispatchMode) (at /Users/bokken/buildslave/unity/build/External/MirroredPackageSources/com.unity.ui/Core/EventDispatcher.cs:216)
UnityEngine.UIElements.BaseVisualElementPanel.SendEvent (UnityEngine.UIElements.EventBase e, UnityEngine.UIElements.DispatchMode dispatchMode) (at /Users/bokken/buildslave/unity/build/External/MirroredPackageSources/com.unity.ui/Core/Panel.cs:372)
UnityEngine.UIElements.UIElementsUtility.DoDispatch (UnityEngine.UIElements.BaseVisualElementPanel panel) (at /Users/bokken/buildslave/unity/build/External/MirroredPackageSources/com.unity.ui/Core/UIElementsUtility.cs:461)
UnityEngine.UIE<message truncated>
I don't see why (set! *unchecked-math* :warn-on-boxed)
cannot be done since the var *unchecked-math*
is in the clojure.main/with-bindings
function.
Because we cannot set!
dynamic vars because the binding could not be done, I guess all the deps of a project cannot contain any dynamic vars.
So I removed (set! *unchecked-math* :warn-on-boxed)
and added manually the unchecked-add
, unchecked-multiply
etc in the clojure/test/check/random.cljc#L88
The problem occurs when compiling the library with Magic inside Unity, not at the build with IL2CPP moment as I thought.
Problem
If we replace the dlls in
Assets/infrastructure
with the last one from thenasser/magic
github artifact dlls, we have the following error :Even if I replace also the
Assets/magic/compiler/magic
folder with the last magic version, same results.