The Amount constructor parses String arguments with |StringNumericLiteral| and throws a RangeError if parsing fails. The algorithm then contains a branch that checks whether the parsed mathematical value is ~not-a-number~ and, if so, stores the Number value NaN. The intention is clear enough, but that branch is actually unreachable: |StringNumericLiteral| does not match "NaN". Thus, new Amount("NaN") throws a RangeError before checking for ~not-a-number~.
Comparing with how Number arguments are handled in the constructor, notice the asymmetry:
new Amount(NaN); // Amount with value NaN
new Amount("NaN"); // RangeError
The Amount constructor parses String arguments with
|StringNumericLiteral|and throws aRangeErrorif parsing fails. The algorithm then contains a branch that checks whether the parsed mathematical value is~not-a-number~and, if so, stores the Number valueNaN. The intention is clear enough, but that branch is actually unreachable:|StringNumericLiteral|does not match"NaN". Thus,new Amount("NaN")throws aRangeErrorbefore checking for~not-a-number~.Comparing with how Number arguments are handled in the constructor, notice the asymmetry: