Hegel: Incorrect type inference of strict equality operator

Created on 30 May 2020  路  4Comments  路  Source: JSMonk/hegel

https://hegel.js.org/try#GYVwdgxgLglg9mABDAzgUQLYAcoE8DKUATjGAOYAUAhgJSIDeAUIi8sItYgLw+IDkfOk1YjERAKZQQRJMRDjmrAL6NFLCVJmJgVADYoFKxhAQooydNjzcLmHAWKlKfABbjduuIKA

The a parameter should be considered as a string.

PS probably for not strict equality there is also a bug

bug

Most helpful comment

I think that a bug is here at 181 line. I tried to fix it like that: if refinementedVariants has length of 1, then it is not a union, so refinementedType should be subtype of refinementedVariants[0]. But it didn't work :(

Screenshot 2020-05-30 at 20 57 55

All 4 comments

I think that a bug is here at 181 line. I tried to fix it like that: if refinementedVariants has length of 1, then it is not a union, so refinementedType should be subtype of refinementedVariants[0]. But it didn't work :(

Screenshot 2020-05-30 at 20 57 55

This has nothing to do with refinement, it is an inference bug. This yields the same error.

function isEmptyString(a) {
    a === '';
}

const isEmpty = isEmptyString('hello')

In reality a shouldn't even be inferred as string, it should be unknown or unconstrained generic.

Ops yep you are right, my fault, I'm going to rename the issue

It will be fixed in the next release.
Thank you for the issue.
You are awesome :3

Was this page helpful?
0 / 5 - 0 ratings

Related issues

thecotne picture thecotne  路  5Comments

devhammed picture devhammed  路  3Comments

Finesse picture Finesse  路  5Comments

mohsen1 picture mohsen1  路  5Comments

thecotne picture thecotne  路  4Comments