Announcement

Collapse
No announcement yet.

[#4105] error at string addition in version 17.10

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

    [#4105] error at string addition in version 17.10

    In following constellation (element from class/struct) do'nt function the string addition '+=' !
    In previous version (example 16.8) it was ok.

    public static class App
    {
       public struct st
       {
          public string s0;
       }
    
       public static void Main()
       {
          cl myCl = new cl();
          myCl.str = new App.st();
    
          myCl.str.s0 = "a";
    
          myCl.str.s0 += "b";
       }
    
       class cl
       {
           public App.st str;
       }
    -> bridge.net compile:

    var myCl = new gecomain.cl();
    myCl.str = new gecomain.App.st();
    
    myCl.str.s0 = "a";
    
    ($t = myCl.str.$clone()).s0 = ($t.s0 || "") + "b";
    -> result for myCl.str.s0: "a"
    Last edited by geoffrey.mcgill; 2020-01-27 @ 10:12 PM.

    #2
    Hi. Can you provide a link to a Deck.NET sample demonstrating this issue?

    Comment


      #3
      https://deck.net/53b1c4030c4bb6079c34c7ffa9f1459a

      Comment


        #4
        Thanks for the sample. I formatted your sample properly and provided a comment with the Expected and Actual result.

        https://deck.net/2301e93ced406bb907ffe8e9d1f2344d

        public static class Program
        {
            public struct st
            {
                public string s0;
            }
        
            public static void Main()
            {
                cl myCl = new cl();
                myCl.str = new st[1];
                myCl.str[0] = new st();
        
                myCl.str[0].s0 = "a";
                myCl.str[0].s0 += "b";
        
                // Expected: ab
                // Actual:   a
                Console.WriteLine(myCl.str[0].s0);
            }
        }
        
        class cl
        {
            public Program.st[] str;
        }
        This does appear to be a defect. I will log as an issue and we will do our best to fix as quickly as we can.

        Comment


          #5
          Here's a sample using class and member names that are easier to follow:

          https://deck.net/818b2b71daed9cde5d145bbcc5b0e409

          public static class Program
          {
              public struct Book
              {
                  public string Title;
              }
          
              public static void Main()
              {
                  var delivery = new Delivery();
                  delivery.Books = new Book[1];
                  delivery.Books[0] = new Book();
          
                  delivery.Books[0].Title = "Animal";
                  delivery.Books[0].Title += " Farm";
          
                  // Expected: Animal Farm
                  // Actual:   Animal
                  Console.WriteLine(delivery.Books[0].Title);
              }
          }
          
          public class Delivery
          {
              public Program.Book[] Books;
          }

          Comment


            #6
            The following issue was created to track this defect:

            https://github.com/bridgedotnet/Bridge/issues/4105

            Comment

            Working...
            X