bflattened / bflat

C# as you know it but with Go-inspired tooling (small, selfcontained, and native executables)
GNU Affero General Public License v3.0
3.56k stars 102 forks source link

[zerolib x86] Implement Concat, string Assignment issues? #145

Open ghost opened 5 months ago

ghost commented 5 months ago

Let's say string implements Concat:

namespace System
{
    public sealed class String
    {
         public unsafe static string Concat(string? str1, string? str2)
        {
            return "Test";
        }
    }
}

There is no problem with compilation, but after declaring the variable and concatenating it, p2 is printed. Name has no result, but prints p1. Name is no problem

using System.Runtime.InteropServices;
using System;
using System.Threading;
unsafe
{
  var str1 = "Hello";
  var str2 = "World";

  var p1 = new Person("Hello" + "World");
  Console.WriteLine(p1.Name); // √
  var p2 = new Person(str1 + str2);
  Console.WriteLine(p2.Name); // x
  Thread.Sleep(1000);
}

public class Person {
  public string Name;

  public Person(string name){
      Name = name;
  }
}
ghost commented 5 months ago

Added: x64 normal x86 abnormal