josdejong/mathjs

null/undefined treated as valid only for left side of comparison operators

Open

#1.391 geöffnet am 31. Jan. 2019

Auf GitHub ansehen
 (11 Kommentare) (0 Reaktionen) (0 zugewiesene Personen)JavaScript (1.298 Forks)batch import
bughelp wanted

Repository-Metriken

Stars
 (13.832 Stars)
PR-Merge-Metriken
 (Keine gemergten PRs in 30 T)

Beschreibung

Using mathjs@5.4.1

When the null value is on the right side, the correct error is thrown (actual: null):

> require('mathjs').eval('1 > null')
TypeError: Unexpected type of argument in function larger (expected: number or Array or DenseMatrix or SparseMatrix or string or boolean or Matrix or BigNumber or Complex or Fraction, actual: null, index: 1)

However, when the null value is on the left side, the error mistakenly identifies the right side as the source of the problem (actual: number):

> require('mathjs').eval('null > 1')
TypeError: Unexpected type of argument in function larger (expected: Array or DenseMatrix or SparseMatrix or Matrix, actual: number, index: 1)

Contributor Guide