propertyHelper.js calls String after deleting the global, breaking String/prop-desc.js

Open Beginner friendly
#5,191 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
82/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
javascript
Domain
testing-qa

Research direction

The bug is in harness/propertyHelper.js: isConfigurable deletes the global String before _isCanonicalNumericIndexString calls String(n) (around lines 156 and 182). Read how the other primordials are captured at the top of that file and follow the same pattern, then use that reference in the helper. Confirm with the exact command in the report: js -f harness/sta.js -f harness/assert.js -f harness/propertyHelper.js -f test/built-ins/String/prop-desc.js, which should run without the ReferenceError.

Written by the indexing model from the issue text.

Description

test/built-ins/String/prop-desc.js fails with ReferenceError: String is not defined at 2a1ade303f72d3de80565c921d685222405c32ce, the merge commit for #4551. I reproduced it with the original Test262 files and the SpiderMonkey shell, without the Firefox test importer.

From the Test262 checkout at that revision, run:

js -f harness/sta.js -f harness/assert.js -f harness/propertyHelper.js \
   -f test/built-ins/String/prop-desc.js

The test expects verifyProperty(this, "String", …) to complete successfully. Instead, the shell reports:

ReferenceError: String is not defined
  _isCanonicalNumericIndexString@harness/propertyHelper.js:156:3
  isConfigurable@harness/propertyHelper.js:182:37
  verifyProperty@harness/propertyHelper.js:130:31
  @test/built-ins/String/prop-desc.js:14:15

isConfigurable deletes the global String property as part of the configurability check. It then calls _isCanonicalNumericIndexString before checking whether the receiver is a TypedArray. That helper calls String(n) after the global binding has been deleted.

Capturing the original String alongside the other primordials in propertyHelper.js and using that reference in _isCanonicalNumericIndexString made the same command pass locally.

Dominant language
JavaScript
Stars
2.9k
Forks
571
Avg merge
1d 22h
Merged PRs (30d)
13

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from tc39/test262

All issues in tc39/test262

Similar issues

More JavaScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.