Forum
    • Categories
    • Register
    • Login

    Bug? Inline function locals/params shadow namespace members - Palette.text resolves to local text

    Scheduled Pinned Locked Moved Bug Reports
    8 Posts 3 Posters 400 Views
    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.
    • dannytaurusD
      dannytaurus
      last edited by dannytaurus

      Inside an inline function, a local or parameter whose name matches a namespace member hijacks even the fully-qualified access (cases 2 and 3 below print the local value instead of 123).

      Cost a lot of time and tokens today, since there's no error. 😫

      Am I doing something wrong here around namespaces, or is this a bug?

      HiseSnippet 1059.3ocsVstaZbDEdVr2nx11nFo9.Lh+TnwwFvXLIn1Fa.2fZrMJ3Fk+kLr6P1Id1YVsyPrQQQpOD8IrOA8Mn8L6rvB1Degpt+.wbt9ctLmyLHQ5SUJYBxw6rowTjy23NbpPG1IjvDn9cQNOz8XhRSSvVRGNMlnTz.jiyF+pgfSwMQoe+8ubHgSD9zbRHzqkLe5KYQLcN03m+aLN+HR.8LVzBR23488khNRtbBfmMbqhhI9mSdO8DhQrBtnWPTgHmezsUypMCnjliqG7TexdiaTuVq8GETqQvnVT+Qs1eu8CZ0jzD47fdALsLYnlnoJvnGJClNLTdgv5fWyTrQbp4PMzPvyVxnNgLdvfYIGEB4r4f7T0F1T026dLKfMmddJ66RYfy0XwjlSgaBR0tGPxYAHsoEROxcneBKVmywfmu1su.pfiIPsYQnXkEU3gttcjfDB81QjyoGk.GlqQ4lUqtEF9oRaOuc1A+BlhZU7YXlfyDzmLdhvWyjBLW5S3pchIIjHEVERBjWfEP0SAURJNhFMhlnvGz4UmNbH9.b2SOaaiMGX5v.qokXh.Sih0SwwIxOP80+fxP2BErTzWvzfLAX+Pp+4XcHEC8LJImlZndWFC5PCdFlv43wPiD1fPEXMvJ3Z02EW1nSNlLZqqrsmWNoADNUqodepnWwT13ORRvZ5kZ7OYLQauOmlIpUAefPJlFImnvyyA+0e7mFipSjbubsIfff1yjpbEuO4UbAyVJM0AhxmPK01CCecxhqTnWtD3MRt2D34eO4mwkvOdFp2N0fOFHgwkoYoCCpqTBJfetsmwHkypk0qf6mVByg+ELcHlXqjooo.76Ll7cdrUH4KMhYCFqF24vAbs0fak4KqWtmgi2BfvFR69ECoztRpYR1sFVCLhV1v2DZq.86li9Ty9e.8VeUxZFaBKKTZ7EBEgLMBftLNGFVbkdtqFOBYmYxUdVzXy3R3lPxcpX0HObAmm626Y3tDTZOGgRwIRM8zrKEfb3qxZ73UxqiMj4zjUx1rcI4lTrrXhYfzV1PetfvzzkGQ+f61HZe6LzEDzNu5zXZ14ij7.ynWy+u9.cT1PX3e+d+tDMwLiOiFHWLMQyLvwoK8ivVU6D+htcopy0xXD55qCfEQxfIbhd4sSl81YLf7wRqDLi8EJld5h60uGqrpdiqrtqP7QtCXZ+vUiwBq.iPl5+CLlsn+ac6MdLzLmCvMcO5Mq6V8aw8uRNQyDu+XhNgcIxw8jIQCg8X9Tv6BAkCF20ofoawdtp4rICLjJBRO7OvWFyZlyNYLqMiIJh3mHea1DCySI9pTJ.lDoO0pH7lO3LtFJ8lwh44H3kMu02eYScMEqutJt65pXi0Uw8VWEattJt+5pXqaWQyCOOXhVFYu1fPGOnW5nDGmdBBzAl1sh9W.hI72f
      
      // Inline-function locals/params shadow namespace members ACROSS A DOT.
      // Expected: all four lines print 123 (the namespace const).
      
      namespace Palette
      {	
      	const var text = 123;
      }
      
      // 1. Anonymous function — control
      const var anon = function()
      {
      	var text = "local value";
          Console.print("1. anonymous function    -> " + Palette.text );
      };
      anon();
      
      // 2. Inline function with a local named `text`
      inline function withLocal()
      {
      	local text = "local value";
          Console.print("2. inline, local `text`  -> " + Palette.text);
      }
      withLocal();
      
      // 3. Inline function with a parameter named `text`
      inline function withParam(text)
      {
          Console.print("3. inline, param `text`  -> " + Palette.text);
      }
      withParam("param value");
      
      // 4. Inline function with no name collision — control
      inline function noCollision()
      {
          local other = "local value";
          Console.print("4. inline, no collision  -> " + Palette.text);
      }
      noCollision();
      

      expected 123 for all four functions but get:

      Interface: 1. anonymous function    -> 123
      Interface: 2. inline, local `text`  -> local value
      Interface: 3. inline, param `text`  -> param value
      Interface: 4. inline, no collision  -> 123
      

      Meat Beats: https://meatbeats.com
      Klippr Video: https://klippr.video

      David HealeyD 1 Reply Last reply Reply Quote 1
      • David HealeyD
        David Healey @dannytaurus
        last edited by

        @dannytaurus Yeah looks a bug to me, I would expect 123 to be printed in all cases.

        Free HISE Bootcamp Full Course for beginners.
        YouTube Channel - HISE tutorials
        My Patreon - More HISE tutorials

        dannytaurusD 2 Replies Last reply Reply Quote 2
        • dannytaurusD
          dannytaurus @David Healey
          last edited by

          @David-Healey Issue created https://github.com/christophhart/HISE/issues/997

          Meat Beats: https://meatbeats.com
          Klippr Video: https://klippr.video

          1 Reply Last reply Reply Quote 0
          • dannytaurusD
            dannytaurus @David Healey
            last edited by

            And PR fix https://github.com/christophhart/HISE/pull/998

            Meat Beats: https://meatbeats.com
            Klippr Video: https://klippr.video

            ustkU 1 Reply Last reply Reply Quote 3
            • ustkU
              ustk @dannytaurus
              last edited by

              @dannytaurus Nice one 👍

              Hise made me an F5 dude, any other app just suffers...

              1 Reply Last reply Reply Quote 1
              • ustkU
                ustk
                last edited by ustk

                When the time comes for @Christoph-Hart to merge/manage the current pile of PRs, we'll not see him until his beard touches the ground... Let's hope he has a strong pilosity! (and a good stock of "Hopfenkaltschale" 😛)

                Gemini_Generated_Image_y9b4jvy9b4jvy9b4.png

                Hise made me an F5 dude, any other app just suffers...

                dannytaurusD 1 Reply Last reply Reply Quote 6
                • dannytaurusD
                  dannytaurus @ustk
                  last edited by dannytaurus

                  @ustk Yeah, definitely be good to get the nod from Christoph on a lot of these PRs.

                  Claude does a great job of making and testing bug fixes, but only Christoph really knows where the dragons are hiding in the code! 😜

                  Meat Beats: https://meatbeats.com
                  Klippr Video: https://klippr.video

                  dannytaurusD 1 Reply Last reply Reply Quote 4
                  • dannytaurusD
                    dannytaurus @dannytaurus
                    last edited by

                    @Christoph-Hart Thanks for the proper fix. (Here in case anyone missed it)

                    Claude says there's still one case that your fix doesn't catch:

                    Calling Palette.text where Palette has no text but a local text is in scope will silently bind to the local instead of erroring. Degenerate case (the code is already wrong at that point), but just thought you should know. Maybe you saw it and elected not to cover it.

                    Meat Beats: https://meatbeats.com
                    Klippr Video: https://klippr.video

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

                    21

                    Online

                    2.4k

                    Users

                    13.9k

                    Topics

                    120.7k

                    Posts