Sugar.DateTime.ToString fails in Java

Current public release introduced a bug in DateTime.ToString. The method should end with :

  exit Formatter.format(mapped.Time);

but now it’s

  exit Formatter.format(mapped);

causing error.

Thanks, logged as bugs://72566

Fixed, thanx.

bugs://72566 got closed with status fixed.

Thanks. One thing I noticed is that Sugar tests are not compiling and not working correctly hiding errors. I had NRE when creating new DateTime objects using constructors with little parameters (not full datetime info) . Please also check this.

will do, thanx.

Thanks, logged as bugs://72578

For test case

  var dt0 := new sugar.DateTime() ;
  var dt1 := new sugar.DateTime(2020,11,8,1,1,1) ;
  var dt2 := new sugar.DateTime(2020,11,8,1,1) ;
  var dt3 := new sugar.DateTime(2020,11,8) ;

  System.out.println(dt0.toString() );
  System.out.println(dt1.toString() );
  System.out.println(dt2.toString() );
  System.out.println(dt3.toString() );

Only dt0 and dt1 are creating an object, other return nil. The problem are constructors not returning result (missing exit). Should be

constructor DateTime(...);
begin
  exit constructor(...);
end;

does this persist with last nights beta? we had regression with constructors in the first 8.2 beta…

fwiw, no it should not. constructors do not have return values, and cannot edit a value.

8.1.83.1761 works fine (old DateTime implementation). I used 8.1.85.1801 with new Sugar that fails. Current 8.2 beta compilation fails with my projects so I cannot use it.
About constructors it’s true, but not for mapped types (when looking into the sugar code). I changed sugar code, recompiled and now it works fine for all constructors calls.

BTW. Is it possible to debug mapped types (somehow switch inline off), how do you write and debug Sugar without the debugger :wink: ? Can mapped types be used in the same project that is using them or they should be in separate lib and just referenced. I use Java.

One more thing about typeOf on DateTime variable. Now I have problem with testing what type is dt:

  TDateTime = public sugar.DateTime ;

  case typeOf(dt0) of
    typeOf( sugar.DateTime )    : System.out.println( 'DateTime' ) ;
    typeOf( TDateTime )         : System.out.println( 'TDateTime' ) ;
    typeOf( GregorianCalendar ) : System.out.println( 'GregorianCalendar' ) 
  else                            System.out.println( '?' ) ;
  end ;

Only GregorianCalendar is true where previously first two were correct. Which one should be correct or how to check this better? I was testing dt variable declared as TDateTime and sugar.DateTime.

No, sorry. inclining is too fundamental tho hampered types work.

writeLn() is your friend :wink:

You can sue them locally as well as via reference, yes.

Good q. this is a corner case. that the compiler maybe deposit handle. In theory, al three case items should resolve to the same thing, and the compiler should give you an error about that. I’ll log an issue.

—marc

Thanks, logged as bugs://72593 — for the “case type of”

Thanks, logged as bugs://72594 — for the .ctor issue

bugs://72593 got closed with status fixed.

bugs://72594 got closed with status fixed.