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

Failure to escape JavaScript keywords like "true", "false", and "null" in module names #39595

Closed
henrichen opened this issue Dec 2, 2019 · 0 comments
Labels
area-web Use area-web for Dart web related issues, including the DDC and dart2js compilers and JS interop. P3 A lower priority bug or feature request web-dev-compiler

Comments

@henrichen
Copy link

henrichen commented Dec 2, 2019

Dart version: Dart VM version: 2.6.1 (Mon Nov 11 13:12:24 2019 +0100) on "macos_x64"

I have dart files named true.dart, false.dart, and if.dart, etc. and import them in my another file, say, abc.dart.
I am writing a web application which use abc.dart and I test it using
"pub run build_runner serve test:8081 -c myweb"

And it complains in chrome developer console when visit my web application http://localhost:8081/myweb/index.html

In the generated abc.ddc.js file, I saw following generated codes, and it complains :
Uncaught SyntaxError: Unexpected token 'true'

 ...
  const true = Object.create(dart.library);
  const $if = Object.create(dart.library);
  const false = Object.create(dart.library);
 ...

It seems Dart codegen tool fail to escape keywords true and false but does escape the keyword if with a prefix $ sign and generate const $if . I am not sure if there are still other keywords that are not escaped when doing codegen.

I can workaround this issue by rename my true.dart file to another name, say mytrue.dart.

@henrichen henrichen changed the title Fail to escape key word "true" and "false" in generated xxx.ddc.js Fail to escape keywords "true" and "false" in generated xxx.ddc.js Dec 2, 2019
@srawlins srawlins added area-web Use area-web for Dart web related issues, including the DDC and dart2js compilers and JS interop. web-dev-compiler labels Dec 2, 2019
@sigmundch sigmundch added the P3 A lower priority bug or feature request label Sep 23, 2020
@nshahan nshahan changed the title Fail to escape keywords "true" and "false" in generated xxx.ddc.js Failure to escape JavaScript keywords like "true", "false", and "null" in module names Jun 27, 2022
renggli added a commit to renggli/dart-more that referenced this issue Feb 24, 2023
copybara-service bot pushed a commit that referenced this issue May 18, 2023
Issue: #52431
Issue: #39595
Change-Id: Iae9c02ad632264d1eb14fb0958f714b4faee55b4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/304262
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-web Use area-web for Dart web related issues, including the DDC and dart2js compilers and JS interop. P3 A lower priority bug or feature request web-dev-compiler
Projects
None yet
Development

No branches or pull requests

3 participants