Navigation

    Fuze Arena Logo
    • Register
    • Login
    • Search
    • Categories
    • Recent
    • Popular
    • Users
    • Groups
    • Help
    • Discord

    ref argument picks up previous function argument on name clash with calling context

    Bug Reporting (FUZE 4 Nintendo Switch)
    3
    3
    202
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • Z-Mann
      Z-Mann last edited by Z-Mann

      Sample program shared with ID NXP87NKD51 (pending)

      A bunch of conditions to this one :) If you have a function with several arguments, an early non-ref argument and a later ref argument, and you call that function and give a variable with the same name as the non-ref argument to the ref slot, the function will receive the non-ref argument value in both arguments.

      Sample program in text form, shortened:

      function test(a, ref b)
          print("a = ", a, "\n")
          print("b = ", b, "\n")
      return void
      
      function main()
          x = "x"
          a = "a"
         test(x, a)
      return void
      
      main()
      

      would be expected to print

      a = x
      b = a
      

      but prints

      a = x
      b = x
      

      If you make a a ref argument in the function definition, too, all is fine. If you make b a non-ref argument, all is fine. If you swap the order of the arguments, all is fine. If you rename a in the calling function, all is fine.

      If you modify the ref argument, thankfully, the variable passed in at the non-ref argument outside the function stays unaffected. Inside, yeah, changing b also changes a.

      Reliable workaround (seems so): always put the ref arguments first.
      I'm not overly bothered, more intrigued, espeically how making the first argument ref too fixes it.

      1 Reply Last reply Reply Quote 3
      • PB____
        PB____ last edited by PB____

        That is indeed a weird and interesting bug.

        I've edited my post to remove my observations with this, because it turns out you had already found out about them, I just didn't notice them in your post :)

        1 Reply Last reply Reply Quote 1
        • Dave
          Dave Fuze Team last edited by

          This is being looked and currently and will most likely be fixed in the next patch!

          1 Reply Last reply Reply Quote 2
          • First post
            Last post