Skip to content

Polyfill vs. spec mismatch in PrepareTemporalFields #1963

@justingrant

Description

@justingrant

The spec for PrepareTemporalFields says:

  1. Assert: Type(fields) is Object.

But the polyfill for this AO treats non-Object values as OK.

  PrepareTemporalFields: (bag, fields) => {
    if (ES.Type(bag) !== 'Object') return false;

Why does the polyfill accept a non-Object parameter without throwing while the spec says that that a non-Object parameter is disallowed?

I assume this is a bug, but wanted to make sure before PR-ing a change. And assuming it's a bug, I assume that the spec is correct but the polyfill is wrong?

Tracking the git blame on this change was fun because this AO has changed its name many times, but looks like this return false case was introduced in #346 by @ptomato when the name of the AO was ValidDateTimeFrom, which then was changed to ToRecord, and which finally ended up as PrepareTemporalFields. At least that's what I think the provenance was! 🤷‍♂️

BTW this was exposed by the TS work that @jens-ox is doing over in js-temporal/temporal-polyfill#103 to remove unexpected undefineds from the TS codebase.

Metadata

Metadata

Assignees

No one assigned

    Labels

    no-spec-textPR can be ignored by implementorsnon-prod-polyfillTHIS POLYFILL IS NOT FOR PRODUCTION USE!

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions