You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Exception message for assert(0) depends on whitespace #30872
Under Node 10 and Node 12, generating an exception from an assertion failure returns a different assertion failure message depending on differences in whitespace. It seems that with a certain whitespace configuration we see the Node 8 assertion failure message 0 == true, other configurations will generate the Node 10 message The expression evaluated to a falsy value. This issue only seems to affect the exception message, all other behaviour seems consistent.
This will affect anything that runs minified source.
I have included a simple reproduction of the issue here
It looks like the expression parse is intentionally started at the line start. Modifying it from start to the actual offset seems to fix these cases, but not sure if it breaks others.
@himself65@pd4d10 is correct about that. The start is set to zero to include assert or what ever name the user named it. It would otherwise only show ok().
I am currently looking into it (there is an easy solution but that would waste a lot of CPU time, so I am trying to find a proper fix).
Activity
BridgeAR commentedon Dec 9, 2019
@AndrewFinlay thank you for the report. This should indeed not fail to create the better error message.
pd4d10 commentedon Dec 10, 2019
The left curly bracket without a line break before
assertwould cause this issue:It looks like the expression parse is intentionally started at the line start. Modifying it from start to the actual offset seems to fix these cases, but not sure if it breaks others.
node/lib/assert.js
Lines 235 to 239 in 7629fb2
himself65 commentedon Dec 10, 2019
@pd4d10 no
node/lib/assert.js
Lines 239 to 242 in 7629fb2
this line will throw error with message
Unexpected token (1:2)and thecodearehimself65 commentedon Dec 10, 2019
and this
codewill not throw errorBridgeAR commentedon Dec 10, 2019
@himself65 @pd4d10 is correct about that. The start is set to zero to include
assertor what ever name the user named it. It would otherwise only showok().I am currently looking into it (there is an easy solution but that would waste a lot of CPU time, so I am trying to find a proper fix).