Wasm and using inc() inside a with clause

Hi
In wasm module using inc() (and maybe dec()) doesn’t work inside a with clause. Here is a test case :

namespace _Module;

type
  TTest = record
    i1 : Integer ;
    i2 : Integer ;  
  end;
  
  [Export]
  Program = public class
  public
    method Main;
    begin
      writeLn('The magic happens here.');

      var test : TTest ;
      test.i1 := 10 ;
      test.i2 := 10 ;
      with test do begin
        i1 := i1 + 1 ;  // OK
        i2 := i2 + 1 ;  // OK
        inc( i2 )  ;    // ERROR - does not work !
      end ;
      assert( test.i1 = 11 ) ;
      assert( test.i2 = 12 ) ;    
    end;
  end;
end.

The module is compiled with Delphi Compatibility and Legacy “with” options.

Artur,

thanx for reporting this. Can you elaborate on “does not work” — does it fail to compile, crash/fail at runtime, or merely give an incorrect result at runtime?

thanx!

As asserts suggest, inc() doesn’t increment i2 value at runtime. The value stays unchanged.

Logged as bugs://E25306.

bugs://E25306 was closed as fixed.

1 Like