endojs / Jessie

Tiny subset of JavaScript for ocap-safe universal mobile code
Apache License 2.0
279 stars 16 forks source link

Disallow `await` in non-plain assignment operations #89

Closed mhofman closed 1 year ago

mhofman commented 1 year ago

A non plain assignment operation aka anything different than lhs = expr (e.g. lhs += expr) evaluates the lhs before evaluating the expr.

These evaluation semantics may be surprising if the expr contains an await. Furthermore Jessie currently disallows the equivalent deconstructed behavior (lhs = lhs + await expr).

mhofman commented 1 year ago

I think it'd be sufficient to check for parent.operator === '=' in the current AssignementOperation check: https://github.com/endojs/Jessie/blob/fc7c40e3208f8ecfb54e295f664800fbb0bfda90/packages/eslint-plugin/lib/rules/no-nested-await.js#L59-L62

WDYT @michaelfig ?