Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Completion record linting doesn't work quite right with parentheses #529

Open
ptomato opened this issue Jun 16, 2023 · 9 comments
Open

Completion record linting doesn't work quite right with parentheses #529

ptomato opened this issue Jun 16, 2023 · 9 comments

Comments

@ptomato
Copy link
Contributor

ptomato commented Jun 16, 2023

In Temporal I have an operation RoundDuration which returns "either a normal completion containing a Record with fields [[DurationRecord]] (a Duration Record) and [[Total]] (a mathematical value), or a throw completion". I'm trying to access one of the fields on the returned Record without making an intermediate binding:

  1. Let result be (? RoundDuration(arguments)).[[DurationRecord]].

This results in the error "RoundDuration returns a Completion Record, but is not consumed as if it does" from ecmarkup.

Changing it to this makes the error go away:

  1. Let roundRecord be ? RoundDuration(arguments).
  2. Set result to roundRecord.[[DurationRecord]].
ptomato added a commit to tc39/proposal-temporal that referenced this issue Jun 16, 2023
This needs some changes in callers because of a bug in Ecmarkup (see
tc39/ecmarkup#529), but I think the change is
probably for the better anyway.
@ljharb
Copy link
Member

ljharb commented Jun 16, 2023

Why are the parens needed at all in the first case? The question mark should attach to the AO call, not the field value.

@bakkot
Copy link
Contributor

bakkot commented Jun 16, 2023

The question mark should attach to the AO call, not the field value.

... Why? That's not the obvious-to-me parse of that expression. (Compare e.g. ! a().b in JS.)

ptomato added a commit to tc39/proposal-temporal that referenced this issue Jun 16, 2023
This needs some changes in callers because of a bug in Ecmarkup (see
tc39/ecmarkup#529), but I think the change is
probably for the better anyway.
@jmdyck
Copy link
Contributor

jmdyck commented Jun 16, 2023

There are two examples in the spec where the operand of ? is a field-extraction, both in InnerModuleEvaluation:

  • return ? _module_.[[EvaluationError]]
  • return ? _requiredModule_.[[EvaluationError]]

In each case, the intended parse is
return ? (_foo_.[[EvaluationError]])
not
return (? _foo_).[[EvaluationError]]

@bakkot
Copy link
Contributor

bakkot commented Jun 16, 2023

I think I can fix this easily enough, but to be honest the extra binding seems like a good thing from a readability point of view, so I'm probably not going to prioritize it right away.

@ljharb
Copy link
Member

ljharb commented Jun 17, 2023

@bakkot because i don’t expect completion records to be stored in record fields, but i do expect them to be the result of an AO call. I don’t think JS has a comparison because completion records are so weird a concept.

@bakkot
Copy link
Contributor

bakkot commented Jun 17, 2023

Completion records can be stored in record fields. They're just a value like any other.

@ljharb
Copy link
Member

ljharb commented Jun 17, 2023

Sure, that's just not something we ever do, afaik, hence my expectation.

@jmdyck
Copy link
Contributor

jmdyck commented Jun 18, 2023

I already gave an example where we do that: the [[EvaluationError]] field of a Cyclic Module Record is a throw completion or ~empty~.

@ljharb
Copy link
Member

ljharb commented Jun 18, 2023

Ah, fair enough. My expectation still holds, and using parens should ofc work, and i agree the separate alias is cleaner.

ptomato added a commit to tc39/proposal-temporal that referenced this issue Jun 20, 2023
This needs some changes in callers because of a bug in Ecmarkup (see
tc39/ecmarkup#529), but I think the change is
probably for the better anyway.
Ms2ger pushed a commit to tc39/proposal-temporal that referenced this issue Jun 21, 2023
This needs some changes in callers because of a bug in Ecmarkup (see
tc39/ecmarkup#529), but I think the change is
probably for the better anyway.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants