z-pattern-matching / z

Pattern Matching for Javascript
https://z-pattern-matching.github.io/
Apache License 2.0
1.72k stars 50 forks source link

Matching on types incorrectly identifies an object as a String #53

Closed dkvasnicka closed 6 years ago

dkvasnicka commented 6 years ago

Just tried the following on Node.js v9.8.0:

▶ node
> const { matches } = require('z')
undefined
> matches({ x: 3 })((x = String) => `${x} is a String`, (x = Object) => 'Object')
'[object Object] is a String'
> const _ = require('lodash')
undefined
> _.isString({x: 3})
false
leonardiwagner commented 6 years ago

Thank you for pointing this bug @dkvasnicka !

sorry for the late response, but the good news is that is fixed, I just published the new z 1.0.9 version with your example working now, please update and let me now any problems, thanks!

dkvasnicka commented 6 years ago

Thanks for the fix! The use case where I wanted to use this is no longer relevant for me but as soon as I need pattern matching again I'll be sure to give it another go.