tc39 / tc39/proposal-amount

Adapting `ToIntlMathematicalValue` to not read internal slots

Open
#64 7 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

  • #73 by @jessealama — closed without merging
Dominant language
HTML
Stars
58
Forks
12
Avg merge
2h 35m
Merged PRs (30d)
2

Description

As it stands, the Amount proposal reads internal slots in calls to ToIntlMathematicalValue, which happens when we use Intl.NumberFormat to format an Amount. We thus end up consulting internal slots of an argument of a function, which is problematic for membrance transparency.

How shall we do this? I see two paths forward:

  1. Ensure that ToIntlMathematicalValue ends up working with a String version of the underlying Amount
  2. Checking for .fractionDigits and .unit properties (not internal slots)

(1) would work by changing step 1 ofToIntlMathematicalValue so that the call to ToNumber receive a ~string~ hint rather than a ~number~ hint. This aligns nicely with the work going on in proposal-intl-keep-trailing-zeros.

Option 2 also seems fine. It feels like it aligns well with how Intl.NF(.p.format) works.

Contributor guide

Open the contributing guide

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.

Research direction

Start with the ToIntlMathematicalValue algorithm and the Amount proposal's Intl.NumberFormat integration described in the issue. Compare the string-hint and property-access approaches, including the proposal-intl-keep-trailing-zeros work; done means the chosen behavior is specified without consulting Amount internal slots.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
internationalization
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.