#Nested JS function doesn't seem to work

19 messages · Page 1 of 1 (latest)

humble bison
#

I'm trying to implement some compat recipe for the Mekanism Painting Machine. To avoid repetition I am using a function. (See below) For some reason, console.log("Hiiiiiii"); works but console.log("Ohhhhhhh"); doesn't. Does the JS engine not support nested functions?

slender valleyBOT
#

Once your ticket has been resolved, please close it with </ticket close:1054771505520717835> command!

humble bison
subtle dewBOT
#

Paste version of MekPaintingCompat.js from @humble bison

humble bison
#

@shell kiln Here's the support ticket. Thank you so much for the help ❤️

shell kiln
#

Nested functions should work

summer skiff
#

If i remember correctly a ?? b is currently broken in some way - I don't know what exactly the issue was, but try logging the variables you are assigning with that

#

it really shouldn't stop code execution though

shell kiln
#

Though things to note I noticed:

  • what PigTurtle mentioned - nullish coalescing operator ?? doesn't work properly
  • Use lowercase types for string, number etc. in jsdoc, uppercase refers to wrapper objects but TS changes them to primitives anyway
#
for (const color of COLORS) {
#

Change this to

for (let color of COLORS) {
#

Since const in for-of loop is also broken

humble bison
summer skiff
#

and there is no error in the log?

humble bison
#

No, no error in the log

humble bison
#

After much trial and error I have found the culprit: it wasn't the nested function not working, rather

"somestring".replaceAll(A, B);

crashes the JS engine silently. Whereas

"somestring".replace(A, B);

works just fine! Yeah...

summer skiff
#

... yet another illogical rhino bug

#

at least you can still use regex to replace all occurences with the string.replace method

shell kiln
#

crashes the JS engine silently