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

Fix undefined / unused variables in spec text. #1403

Merged
merged 2 commits into from
Mar 1, 2021

Conversation

cjtenny
Copy link
Collaborator

@cjtenny cjtenny commented Feb 28, 2021

Fix a number of small bugs where variables in spec text are used without being
defined, defined without being used; a wide range of small bugs exposed by a
quick-and-dirty linter I wrote. Common culprits look like:

  • Referencing undefined calendar instead of someObject.[[Calendar]]
  • Set thing to ? Create... instead of Let thing be ? Create...

@cjtenny cjtenny requested review from Ms2ger and ptomato February 28, 2021 08:15
@codecov
Copy link

codecov bot commented Feb 28, 2021

Codecov Report

Merging #1403 (3436c8d) into main (69e73f7) will increase coverage by 0.00%.
The diff coverage is 100.00%.

Impacted file tree graph

@@           Coverage Diff           @@
##             main    #1403   +/-   ##
=======================================
  Coverage   95.70%   95.70%           
=======================================
  Files          19       19           
  Lines       11147    11149    +2     
  Branches     1812     1812           
=======================================
+ Hits        10668    10670    +2     
  Misses        476      476           
  Partials        3        3           
Flag Coverage Δ
test262 48.64% <100.00%> (+0.02%) ⬆️
tests 91.50% <100.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
polyfill/lib/ecmascript.mjs 95.97% <100.00%> (+<0.01%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 69e73f7...3436c8d. Read the comment docs.

Fix a number of small bugs where variables in spec text are used without being
defined, defined without being used; a wide range of small bugs exposed by a
quick-and-dirty linter I wrote. Common culprits look like:

- Referencing undefined _calendar_ instead of _someObject_.[[Calendar]]
- Set _thing_ to ? Create... instead of Let _thing_ be ? Create...
@cjtenny cjtenny force-pushed the cjtenny/spec-vardecl-errs branch from cde52aa to a275020 Compare February 28, 2021 08:19
spec/abstractops.html Outdated Show resolved Hide resolved
Co-authored-by: Jordan Harband <[email protected]>
1. Set _fractionString_ to the longest possible substring of _decimalPart_ starting at position 0 and not ending with the code unit 0x0030 (DIGIT ZERO).
1. Let _fractionString_ be the longest possible substring of _decimalPart_ starting at position 0 and not ending with the code unit 0x0030 (DIGIT ZERO).
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hah, the linter I wrote did not understand that this definition doesn't apply to the use 4 lines down (it's just a scope walk, no control flow). Oops, there's still a bug here, but fixing in #1405 .

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ecmarkup has a linter built in; it might be nice to improve that (or replace it with your linter, if that’s a better direction). cc @bakkot

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This proposal is actually using the linter already!

Re: scope analysis, I've started down that path, but there's a whole bunch of special cases which I've been slowly cleaning up. PRs welcome!

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I handled all of those cases I found in the temporal proposal, which is to say fewer than exist in ecma262, but my current linter is a messy python script thrown together as I encountered things - you probably don't want it in its current state. It was designed as a one-off because I saw recurring issues from what I presume were rebases + copy&paste.

That being said, when I get some extra time I'd love to upstream more of its functionality to ecmarkup; mind giving me some code pointers (IRC?) when I get around to it? I went with the quick python hack because poking around the ecmarkup code left me with some questions.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure! I'm bakkot on IRC in #tc39 and #tc39-delegates; feel free to ping me whenever.

Copy link
Collaborator

@ptomato ptomato left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was a great idea!

@@ -759,7 +759,7 @@ <h1>ValidateTemporalDuration ( _years_, _months_, _weeks_, _days_, _hours_, _min
</emu-clause>

<emu-clause id="sec-temporal-defaulttemporallargestunit" aoid="DefaultTemporalLargestUnit">
<h1>DefaultTemporalLargestUnit ( _years_, _months_, _weeks_, _days_, _hours_, _minutes_, _seconds_, _milliseconds_, _microseconds_, _nanoseconds_ )</h1>
<h1>DefaultTemporalLargestUnit ( _years_, _months_, _weeks_, _days_, _hours_, _minutes_, _seconds_, _milliseconds_, _microseconds_ )</h1>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I mean yeah but... this is slightly unintuitive... I guess it's OK.

@ptomato ptomato merged commit c08a457 into main Mar 1, 2021
@ptomato ptomato deleted the cjtenny/spec-vardecl-errs branch March 1, 2021 20:31
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

Successfully merging this pull request may close these issues.

5 participants