# Sim Error: Calling non-function

**URL:** https://forum.makecode.com/t/sim-error-calling-non-function/36862
**Category:** Help
**Created:** [May 22, 2025, 2:48pm UTC](https://forum.makecode.com/t/sim-error-calling-non-function/36862 "2025-05-22T14:48:54Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![SoCuul](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/socuul/32/22563_2.png) [@SoCuul](https://forum.makecode.com/u/SoCuul)
#### Post date: [May 22, 2025, 2:48pm UTC](https://forum.makecode.com/t/sim-error-calling-non-function/36862/1 "2025-05-22T14:48:54Z")

</div>

I’m trying to work on a little editor to edit the multiple instruments on a song (based on @richard 's instrument editor). I’ve mostly figured out the internals of how the song format is represented and utilized, but I’m running into a strange simulator error that prevents the game from running.

To my knowledge, the function I’m calling should be valid which leaves me with not much to go with.

If anyone could give me any more information on how to debug this, it would be much appreciated!

Project file: [https://makecode.com/\_aXrMXkRFuVU7](https://makecode.com/_aXrMXkRFuVU7)

---

<div class="post-metadata">

### Author: ![richard](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/richard/32/5417_2.png) [@richard](https://forum.makecode.com/u/richard)
#### Post date: [May 22, 2025, 4:34pm UTC](https://forum.makecode.com/t/sim-error-calling-non-function/36862/2 "2025-05-22T16:34:38Z")

</div>

@SoCuul the problem here is just the ordering of your code, you’re calling the functions before they get defined.

Simply move the Main namespace under Util or use declared functions instead of assigning arrow functions to variables like you are right now

---

<div class="post-metadata">

### Author: ![WoofWoof](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/woofwoof/32/32523_2.png) [@WoofWoof](https://forum.makecode.com/u/WoofWoof)
#### Post date: [May 22, 2025, 4:50pm UTC](https://forum.makecode.com/t/sim-error-calling-non-function/36862/3 "2025-05-22T16:50:17Z")

</div>

Found it! Your issue is that the outlined function is not defined when this code runs:

 ![Screenshot 2025-05-22 at 12.30.22 PM](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/3X/7/2/7242010fe173257925849307e10cce36be223be0.png)  
When I moved the Util namespace above Main, it worked! To debug, I used those game.splash() functions to tell if the game was really erroring at the point it claimed to be. Took a while to figure this one out because the error was being reported as being on the wrong line!

@makecode any idea why the error was being reported as occurring on the wrong line? The error was quite obviously not on that line!

P.S. this project looks super cool so far!! I hope you stick around here and share it when it’s done!

---

<div class="post-metadata">

### Author: ![SoCuul](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/socuul/32/22563_2.png) [@SoCuul](https://forum.makecode.com/u/SoCuul)
#### Post date: [May 22, 2025, 10:38pm UTC](https://forum.makecode.com/t/sim-error-calling-non-function/36862/4 "2025-05-22T22:38:28Z")

</div>

Aah, can’t believe I didn’t notice that! Thanks for the help 😃

The error on the wrong line threw me off as well.
