Skip to content

duration type equality not implemented #2941

Closed
@Chriscbr

Description

@Chriscbr

I tried this:

assert(5s == 5s);

This happened:

ERROR: assertion failed: '($stdlib.std.Duration.fromSeconds(5) === $stdlib.std.Duration.fromSeconds(5))'

target/equality.wsim.574164.tmp/.wing/preflight.js:8
     constructor(scope, id) {
       super(scope, id);
>>     {((cond) => {if (!cond) throw new Error(`assertion failed: '($stdlib.std.Duration.fromSeconds(5) === $stdlib.std.Duration.fromSeconds(5))'`)})(($stdlib.std.Duration.fromSeconds(5) === $stdlib.std.Duration.fromSeconds(5)))};
     }
   }

I expected this:

It compiles

Is there a workaround?

Convert the durations to seconds and then compare:

assert(5s.seconds == 5s.seconds);

Component

Compiler

Wing Version

0.19.14

Wing Console Version

No response

Node.js Version

18.14.1

Platform(s)

MacOS

Anything else?

No response

Community Notes

  • Please vote by adding a 👍 reaction to the issue to help us prioritize.
  • If you are interested to work on this issue, please leave a comment.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    Status

    ✅ Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions