-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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 strict/es5+ octal literal 2x error #46810 #46823
Fix strict/es5+ octal literal 2x error #46810 #46823
Conversation
Signed-off-by: Jay Clark <jay@jayeclark.dev>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like this fix. It's the smallest possible code change. So even though it doesn't fully fix #46810 or address the questionable usefulness of checkGrammarNumericLiteral in the checker, I think it's the most pragmatic change to make.
All you need to do is follow the testing instructions in CONTRIBUTING to update the tests. In a nutshell, gulp runtests-parallel
then gulp baseline-accept
and push a new commit containing the changed files.
Great, thanks so much for the quick feedback! The testing is a bit harder for me (I’m still very junior), so I just wanted to check my fix wasn’t completely off base before I dove into it. :) |
It looks like you've sent a pull request to update our 'lib' files. These files aren't meant to be edited by hand, as they consist of last-known good states of the compiler and are generated from 'src/lib' or possibly our lib generator. Unless this is necessary, consider closing the pull request and sending a separate PR to update 'src/lib' or https://github.com/microsoft/TypeScript-DOM-lib-generator |
Lost a few days being under the weather from getting my COVID booster, but I think I've finally got the tests sorted. I also updated the logic in |
lib/tsserver.js
Outdated
@@ -44098,7 +44098,7 @@ var ts; | |||
} | |||
} | |||
function checkStrictModeNumericLiteral(node) { | |||
if (inStrictMode && node.numericLiteralFlags & 32 /* Octal */) { | |||
if (options.target < 1 /* ES5 */ && inStrictMode && node.numericLiteralFlags & 32 /* Octal */) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updates to lib/
should only happen as part of a separate LKG update; please revert this file
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@RyanCavanaugh Sorry about that, reverting now!
Signed-off-by: Jay Clark <jay@jayeclark.dev>
614dac7
to
ec7511a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The only existing tests that change are of plain JS files. Can you add a TS test, based on the example in the bug? Probably the easiest place to put the new test is in tests/cases/compiler/someNameHere.ts.
Sure thing, sorry for the oversight! |
Closing this out as I've realized I'm still a bit too junior to complete this at the level required. Will try again in a few months when I'm further along in learning CS. |
This is a good fix. Do you mind if I finish it by adding a test + accepting baselines? If you want to finish it yourself in a few months that's fine too. |
@sandersn That would be fine. I meant that I'd try my hand at solving a different issue. I'm stuck on creating the TS test and need to learn the language, repo, and test strategy better before I'd be able to complete it (which realistically I wouldn't be able to spend time on until I'm done with my initial CS coursework in January.) |
@sandersn Thank you so much for your help in closing this out. The added test may have only been a few lines of code, but I really could not wrap my head around how the test suite works in this repo (I've only really worked with jest) and would probably not have gotten there for quite some time. Just so I understand it correctly for the next time I take a stab at an issue here, when adding a TS test all that's needed is to write the code snippet that will be evaluated. When I run the tests, the testing suite will create a .txt file of the errors that are thrown. Presumably these errors will differ from the baselines because something in the Typescript code has been changed/corrected. If the errors look correct, I then run the command to accept the new baselines. TLDR: There is no need to code any assertions into the test regarding what errors are expected (this is where I kept getting hung up), instead the code throws & records the errors in the testing process and the developer evaluates that the errors are correct and adds them to the baselines. |
You got it exactly right. Our system is quite different from unit tests since the assertions are implicit in the baseline output. That means there are a lot of assertions — even ones that the author didn't intentionally put there. |
* Fix strict/es5+ octal literal 2x error microsoft#46810 Signed-off-by: Jay Clark <jay@jayeclark.dev> * Accept baseline test changes Signed-off-by: Jay Clark <jay@jayeclark.dev> * Add test case Co-authored-by: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com>
Signed-off-by: Jay Clark jay@jayeclark.dev
Partially fixes #46810
Fixes the conditional in the binder to only issue an error for octal literals in strict mode if the target is before es5. (If es5 or after, this error becomes redundant.) Also fixes the same issue in tsserver.js
Please verify that:
Backlog
milestone (required)main
branchgulp runtests
locally