Type safety!
-
Inb4 Dave says "tell me more"...
-
Nice, what inspired this addition?
Got a build error here:
../../../../../HISE/hi_core/hi_dsp/modules/MidiPlayer.cpp:1270:12: error: ‘isinf’ was not declared in this scope; did you mean ‘std::isinf’? 1270 | if(isinf(newAmount))
-
This post but I also found myself making annoying errors where I store a file as absolute path string while it expects to be a File object in the called method and other stuff. It's just another goodie taken from C++ to mitigate the Javascript madness of "Anything goes" :)
-
@Christoph-Hart Found another one
In file included from ../../../../../HISE/hi_scripting/hi_scripting_01.cpp:98, from ../../JuceLibraryCode/include_hi_scripting_01.cpp:9: ../../../../../HISE/hi_scripting/scripting/api/ScriptingApi.cpp:3601:64: error: macro "ADD_TYPED_API_METHOD_2" requires 3 arguments, but only 2 given 3601 | ADD_TYPED_API_METHOD_2(setAttribute, VarTypeChecker::Number);
-
What's going on here?
Too many arguments in API call Server.callWithPOST(). Expected: 1
-
super nice! now I can obsessively type everything :D
-
I notice this now returns an error
local myVariable; myComponent.set("tooltip", myVariable);
In my actual project myVariable may or may not contain a value. So now I have to add an
isDefined
check.Would it be possible to add something like:
myComponent.set("tooltip", myVariable || "");
?Edit: Oh actually that appears to already work!
-
From the source code, these are the types and the identifiers, right?
static const Identifier Undefined("undefined"); static const Identifier Integer("int"); static const Identifier Double("double"); static const Identifier Number("number"); static const Identifier String("string"); DECLARE_ID(Colour); DECLARE_ID(Array); DECLARE_ID(Buffer); DECLARE_ID(ObjectWithLength); DECLARE_ID(JSON); DECLARE_ID(ScriptObject); static const Identifier Object("object"); DECLARE_ID(Function); DECLARE_ID(ComplexType); DECLARE_ID(NotUndefined);
@Christoph-Hart Please correct me, then add this to the docs
-
In my actual project myVariable may or may not contain a value. So now I have to add an isDefined check.
Yes but this was already the case - you can't call functions with an undefined variable - I've introduced this "limitation" to HiseScript years ago because the times it silently fails is much higher than when you actually want to pass on an undefined value. It was just that the detection logic so far didn't catch these problems when the object that you call it to is dynamic:
// A const object const var MyEffect = Synth.getEffect("My Effect"); // The same object but not accessed through a const var const var MyDynamicEffect = [MyEffect]; // This will throw an error MyEffect.setAttribute(undefined, 12); // Up until now this went through fine, but should also cause an error just like the line above MyDynamicEffect[0].setAttribute(undefined, 12);
then add this to the docs
Done, but it's not in the HISE docs website because I need to rebuild the HTML files when I'm back tomorrow.
-
-
@d-healey ah good catch, it mistakenly interpreted a function as a JSON object (which is technically correct, but it should identify as Function before). Should be fixed now.
-
@Christoph-Hart Thank you
-
This safety check is pretty aggressive. I'm trying to track down some API call with undefined parameter 0 errors, but HISE isn't being helpful at the moment.
I get an error at a line that doesn't contain code, and if I comment out the ENTIRE script I still get the error
The only way to make it clear the error is to restart HISE.It seems to be circling around addComboBox, and that combo box initializes with a value of 0.0.
edit:
it seems to initialize to 0.0 if "saveInPreset": "0" . Is that by design? -
@Dan-Korneff said in Type safety!:
I get an error at a line that doesn't contain code
I'm seeing this a lot too. However if you look above the Console, on the same line as the Compile button you might get a more helpful message.
ComboBox values start at 1, so that might be the issue.
-
You guys know you can just change a flag in HISE to restore the old compiler strictness?
I really stand by this decision from a language design perspective,
undefined
as function arguments cause more pain than it is useful, but I understand how annoying it is if you just want to pull the latest changes and find your interface completely broken because of a new restriction.Anyways, I've changed the default value here so that old projects load without issues, and you even can deactivate the warning in the Hise preferences (Development -> Warn If Undefined Parameters) if you want to go full on ostrich on your code quality :)
-
@Christoph-Hart nah, I'd rather know that these issues exist and deal with them. Thankful for the feature, annoyed with debugging
-
@Christoph-Hart do we just need to change #define HISE_WARN_UNDEFINED_PARAMETER_CALLS 0 to 1? or is there something else that needs to be changed?
-
@Adam_G pull the latest changes, then this flag is set and prints the warning. If you then want to disable the warning, untick the box in the preferences.
-
@Christoph-Hart getting some errors on compiling
-
@Adam_G I think that means you are low on RAM. Try closing other programs that you are not using when compiling or reduce the number of threads that VS is using during the compilation.