Skip to content

Don't crash on non-literal computed property names during getPropertyAssignment #48079

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

Merged
merged 4 commits into from
Mar 7, 2022

Conversation

jakebailey
Copy link
Member

@jakebailey jakebailey commented Mar 1, 2022

getPropertyAssignment is searching for a property with a given text; when it encounters a bad property name, it crashes. Just skip over the bad property name, as it can't be equal to the key being searched for anyway.

This test is weird; the failure mode doesn't look like the bug in this particular harness (but it works).

Test failure:
fourslash-server test tsconfigComputedPropertyError.ts runs correctly
  [.................................................................]

  0 passing (2s)
  1 failing

  1) fourslash-server tests
       tests/cases/fourslash/server/tsconfigComputedPropertyError.ts
         fourslash-server test tsconfigComputedPropertyError.ts runs correctly:
     Error: Debug Failure. False expression: Malformed response: response sequence number did not match request sequence number.

Fixes #47989

@andrewbranch
Copy link
Member

The weird test assertion is fixed in a draft PR here: https://github.com/microsoft/TypeScript/pull/47690/files#diff-704a4f3d94c84abb3971eba0e5ce214e90b99c9eeb30462dc3fd6b823c259ba4

Feel free to copy it because I’m not sure of the fate of that draft.

@jakebailey
Copy link
Member Author

With that change cherry-picked, I do get a reasonable error without the fix:

  1) fourslash-server tests
       tests/cases/fourslash/server/tsconfigComputedPropertyError.ts
         fourslash-server test tsconfigComputedPropertyError.ts runs correctly:
     Error Error processing request. Debug Failure. Text of property name cannot be read from non-literal-valued ComputedPropertyNames
Error: Debug Failure. Text of property name cannot be read from non-literal-valued ComputedPropertyNames
    at getTextOfPropertyName (E:\work\TypeScript\src\compiler\utilities.ts:1006:30)
    at E:\work\TypeScript\src\compiler\utilities.ts:1581:34
    at Array.filter (<anonymous>)

@jakebailey jakebailey merged commit d8b21a8 into microsoft:main Mar 7, 2022
@jakebailey jakebailey deleted the fix-47989 branch March 7, 2022 22:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Author: Team For Milestone Bug PRs that fix a bug with a specific milestone
Projects
None yet
3 participants