« Bugzilla Issues Index

#75 — S15.4.4.5 should ensure steps 5 and 6 are executed in correct order

S15.4.4.5_A3.1_T2 tests the execution of step 5 with different objects than strings. However it does not ensure steps 5 and 6 of the algorithm are executed in exactly this order:
5. Let sep be ToString(separator).
6. If len is zero, return the empty String.

Implementors may try to skip step 5 if the length is zero instead of calling ToString(separator), which may trigger side effects. For example Opera skips step 5 in this case.

Simple test case to cover this scenario:
try {
var object = {toString: function() {throw "error"}};
$ERROR('#X.X: var object = {toString: function() {throw "error"}}; [].join(object) throw "error". Actual: ' + ([].join(object)));
catch (e) {
if (e !== "error") {
$ERROR('#X.X: var object = {toString: function() {throw "error"}}; [].join(object) throw "error". Actual: ' + (e));

Mark, sounds like the test here is valid; just needs to be made a bit more accurate.