Skip to content

Fix false naming escaping in JavaScript #1952

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 2 commits into from
Mar 15, 2023
Merged

Conversation

rudolf101
Copy link
Member

@rudolf101 rudolf101 commented Mar 14, 2023

Description

Fixes #1940

How to test

Manual tests

Various scenarios have been tested. You can find the examples in the folder `/utbot-js/samples' and try to run UTBot.

Self-check list

  • I've set the proper labels for my PR (at least, for category and component).
  • PR title and description are clear and intelligible.
  • I've added enough comments to my code, particularly in hard-to-understand areas.
  • The functionality I've repaired, changed or added is covered with automated tests.
  • Manual tests have been provided optionally.
  • The documentation for the functionality I've been working on is up-to-date.

@rudolf101 rudolf101 added comp-codegen Issue is related to code generator lang-javascript Issue is related to JavaScript support ctg-bug-fix PR is fixing a bug labels Mar 14, 2023
@rudolf101 rudolf101 requested a review from Markoutte March 14, 2023 17:57
@rudolf101 rudolf101 changed the title Fixed false naming escaping in JavaScript Fix false naming escaping in JavaScript Mar 14, 2023
@@ -409,8 +408,7 @@ internal class CgJsRenderer(context: CgRendererContext, printer: CgPrinter = CgP
print("${exception.name.escapeNamePossibleKeyword()}: ${exception.type}")
}

override fun escapeNamePossibleKeywordImpl(s: String): String =
if (isLanguageKeyword(s, context.cgLanguageAssistant)) "`$s`" else s
override fun escapeNamePossibleKeywordImpl(s: String): String = ""
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why is empty string return?

Copy link
Member Author

Choose a reason for hiding this comment

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

This is a mockup for API, JavaScript does not support keyword escaping for function calls

Copy link
Collaborator

Choose a reason for hiding this comment

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

I ran with this patch the code that has the problem and got this:

it("testDouble1", function ()
 {
    let  = new fileUnderTest.Na("\n\t\n")
    
    let  = .()
    
    (0, )
}
)

Copy link
Collaborator

Choose a reason for hiding this comment

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

Oops, my bad, will be properly fixed soon

@rudolf101 rudolf101 requested a review from Markoutte March 15, 2023 09:03
Copy link
Collaborator

@Markoutte Markoutte left a comment

Choose a reason for hiding this comment

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

I reopened conversation. Please, see the problem I have

@rudolf101 rudolf101 merged commit 50f7fa5 into main Mar 15, 2023
@rudolf101 rudolf101 deleted the sergeyl/js-false-escaping-fix branch March 15, 2023 15:03
denis-fokin pushed a commit that referenced this pull request Mar 16, 2023
@alisevych alisevych added this to the 2023.03 Release milestone Mar 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
comp-codegen Issue is related to code generator ctg-bug-fix PR is fixing a bug lang-javascript Issue is related to JavaScript support
Projects
None yet
Development

Successfully merging this pull request may close these issues.

JS. Function call has extra apostrophes
4 participants