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
Squashed commit of the following:
commit 4bc40d9
Author: Andrea Faulds <[email protected]>
Date: Sun Mar 20 02:20:28 2016 +0000
Update spec for invalid numeric strings
commit 2461e4f
Author: Andrea Faulds <[email protected]>
Date: Wed Feb 24 16:53:26 2016 +0000
Updated tests for invalid numeric strings
Copy file name to clipboardExpand all lines: spec/10-expressions.md
+50-40Lines changed: 50 additions & 40 deletions
Original file line number
Diff line number
Diff line change
@@ -1528,12 +1528,12 @@ left-hand operand to the power of the right-hand one.
1528
1528
If either of the operands have an object type supporting `**` operation,
1529
1529
then the object semantics defines the result. The left operand is checked first.
1530
1530
1531
-
If either or both operands have non-numeric types, their values are converted to type `int`
1532
-
or `float`, as appropriate. If both operands have non-negative integer
1533
-
values and the result can be represented as an `int`, the result has type
1534
-
`int`; otherwise, the result has type `float`.
1535
-
1536
-
**Examples**
1531
+
If either or both operands have non-numeric types, their values are converted
1532
+
to type `int`or `float`, as appropriate. If both operands have non-negative
1533
+
integer values and the result can be represented as an `int`, the result has
1534
+
type `int`; otherwise, the result has type `float`. If either or both operands
1535
+
were leading-numeric or non-numeric strings, a non-fatal error must be produced
1536
+
for each. **Examples**
1537
1537
1538
1538
```PHP
1539
1539
2**3; // int with value 8
@@ -1752,7 +1752,8 @@ leading-numeric string, the string is first converted to an `int` or
1752
1752
`float`, as appropriate, after which it is handled as an arithmetic
1753
1753
operand. The trailing non-numeric characters in leading-numeric strings
1754
1754
are ignored. With a non-numeric string, the result has type `int` and
1755
-
value 0.
1755
+
value 0. If the string was leading-numeric or non-numeric, a non-fatal error
1756
+
MUST be produced.
1756
1757
1757
1758
For a unary `~` operator used with a string, the result is the string with each byte
1758
1759
being bitwise complement of the corresponding byte of the source string.
@@ -2080,28 +2081,33 @@ The right-hand operand of operator `/` and operator `%` must not be zero.
2080
2081
If either of the operands is an object supporting the operation, the result is
2081
2082
defined by that object's semantics, with the left operand checked first.
2082
2083
2083
-
The binary `*` operator produces the product of its operands. If either
2084
-
or both operands have non-numeric types, their values are converted to
2085
-
type `int` or `float`, as appropriate. Then if either operand has type
2086
-
`float`, the other is converted to that type, and the result has type
2087
-
`float`. Otherwise, both operands have type `int`, in which case, if the
2088
-
resulting value can be represented in type `int` that is the result type.
2089
-
Otherwise, the result would have type `float`.
2084
+
The binary `*` operator produces the product of its operands. If either or both
2085
+
operands have non-numeric types, their values are converted to type `int` or
2086
+
`float`, as appropriate. If either or both operands were leading-numeric or
2087
+
non-numeric strings, a non-fatal error MUST be produced for each. Then if
2088
+
either operand has type `float`, the other is converted to that type, and the
2089
+
result has type `float`. Otherwise, both operands have type `int`, in which
2090
+
case, if the resulting value can be represented in type `int` that is the
2091
+
result type. Otherwise, the result would have type `float`.
2090
2092
2091
2093
Division by zero results in a non-fatal error. If the value of the numerator is positive, the result value is `INF`. If the value of the numerator is negative, the result value is `-INF`. If the value of the numerator is zero, the result value is `NAN`.
2092
2094
2093
2095
The binary `/` operator produces the quotient from dividing the left-hand
2094
-
operand by the right-hand one. If either or both operands have
2095
-
non-numeric types, their values are converted to type `int` or `float`, as
2096
-
appropriate. Then if either operand has type `float`, the other is
2097
-
converted to that type, and the result has type `float`. Otherwise, both
2098
-
operands have type `int`, in which case, if the mathematical value of the
2099
-
computation can be preserved using type `int`, that is the result type;
2100
-
otherwise, the type of the result is `float`.
2096
+
operand by the right-hand one. If either or both operands have non-numeric
2097
+
types, their values are converted to type `int` or `float`, as appropriate. If
2098
+
either or both operands were leading-numeric or non-numeric strings, a
2099
+
non-fatal error must be produced for each. Then if either operand has type
2100
+
`float`, the other is converted to that type, and the result has type `float`.
2101
+
Otherwise, both operands have type `int`, in which case, if the mathematical
2102
+
value of the computation can be preserved using type `int`, that is the result
2103
+
type; otherwise, the type of the result is `float`.
2101
2104
2102
2105
The binary `%` operator produces the remainder from dividing the left-hand
2103
-
operand by the right-hand one. If the type of both operands is not `int`,
2104
-
their values are converted to that type. The result has type `int`. If the right-hand operand has value zero, an exception of type `DivisionByZeroError` is thrown.
2106
+
operand by the right-hand one. If the type of both operands is not `int`, their
2107
+
values are converted to that type. If either or both operands were
2108
+
leading-numeric or non-numeric strings, a non-fatal error MUST be produced for
2109
+
each. The result has type `int`. If the right-hand operand has value zero, an
2110
+
exception of type `DivisionByZeroError` is thrown.
2105
2111
2106
2112
These operators associate left-to-right.
2107
2113
@@ -2150,15 +2156,15 @@ If either of the operands is an object supporting the operation, the result is
2150
2156
defined by that object's semantics, with the left operand checked first.
2151
2157
2152
2158
For non-array operands, the binary `+` operator produces the sum of those
2153
-
operands, while the binary `-` operator produces the difference of its
2154
-
operands when subtracting the right-hand operand from the left-hand one.
2155
-
If either or both operands have non-array, non-numeric types, their
2156
-
values are converted to type `int` or `float`, as appropriate. Then if
2157
-
either operand has type `float`, the other is converted to that type, and
2158
-
the result has type `float`. Otherwise, both operands have type `int`, in
2159
-
which case, if the resulting value can be represented in type `int` that
2160
-
is the result type.
2161
-
Otherwise, the result would have type `float`.
2159
+
operands, while the binary `-` operator produces the difference of its operands
2160
+
when subtracting the right-hand operand from the left-hand one. If either or
2161
+
both operands have non-array, non-numeric types, their values are converted to
2162
+
type `int` or `float`, as appropriate. If either or both operands were
2163
+
leading-numeric or non-numeric strings, a non-fatal error MUST be produced for
2164
+
each. Then if either operand has type `float`, the other is converted to that
2165
+
type, and the result has type `float`. Otherwise, both operands have type
2166
+
`int`, in which case, if the resulting value can be represented in type`int`
2167
+
that is the result type. Otherwise, the result would have type `float`.
2162
2168
2163
2169
If both operands have array type, the binary `+` operator produces a new
2164
2170
array that is the union of the two operands. The result is a copy of the
@@ -2226,8 +2232,9 @@ zero bits are shifted on from the right end. Given the expression
2226
2232
`e2` positions. Bits shifted off the right end are discarded, and the sign
2227
2233
bit is propagated from the left end.
2228
2234
2229
-
If either operand does not have type `int`, its value is first converted
2230
-
to that type.
2235
+
If either operand does not have type `int`, its value is first converted to
2236
+
that type. If either or both operands were leading-numeric or non-numeric
2237
+
strings, a non-fatal error MUST be produced for each.
2231
2238
2232
2239
The type of the result is `int`, and the value of the result is that after
2233
2240
the shifting is complete. The values of `e1` and `e2` are unchanged.
@@ -2465,8 +2472,9 @@ Each of the operands must have scalar-compatible type.
2465
2472
If either of the operands is an object supporting the operation, the result is
2466
2473
defined by that object's semantics, with the left operand checked first.
2467
2474
2468
-
If either operand does not have type `int`, its value is first converted
2469
-
to that type.
2475
+
If either operand does not have type `int`, its value is first converted to
2476
+
that type. If either or both operands were leading-numeric or non-numeric
2477
+
strings, a non-fatal error MUST be produced for each.
2470
2478
2471
2479
The result of this operator is the bitwise-AND of the two operands, and
2472
2480
the type of that result is `int`.
@@ -2509,8 +2517,9 @@ Each of the operands must have scalar-compatible type.
2509
2517
If either of the operands is an object supporting the operation, the result is
2510
2518
defined by that object's semantics, with the left operand checked first.
2511
2519
2512
-
If either operand does not have type `int`, its value is first converted
2513
-
to that type.
2520
+
If either operand does not have type `int`, its value is first converted to
2521
+
that type. If either or both operands were leading-numeric or non-numeric
2522
+
strings, a non-fatal error MUST be produced for each.
2514
2523
2515
2524
The result of this operator is the bitwise exclusive-OR of the two
2516
2525
operands, and the type of that result is `int`.
@@ -2555,8 +2564,9 @@ Each of the operands must have scalar-compatible type.
2555
2564
If either of the operands is an object supporting the operation, the result is
2556
2565
defined by that object's semantics, with the left operand checked first.
2557
2566
2558
-
If either operand does not have type `int`, its value is first converted
2559
-
to that type.
2567
+
If either operand does not have type `int`, its value is first converted to
2568
+
that type. If either or both operands were leading-numeric or non-numeric
2569
+
strings, a non-fatal error MUST be produced for each.
2560
2570
2561
2571
The result of this operator is the bitwise inclusive-OR of the two
0 commit comments