Skip to content

Conversation

apple5775
Copy link

For javascript, add ES6 Support for rhino 1.7.15, and support Template Literals as a concatenation/addition of strings. Also includes a few tests for Template Literals in "es6.js" file. Tagged Template Literals are not yet supported.

Copy link
Member

@msridhar msridhar left a comment

Choose a reason for hiding this comment

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

Thank you for this contribution! I have a few comments and questions.

}

@Override
public CAstNode visitTemplateLiteral(TemplateLiteral node, WalkContext arg) {
Copy link
Member

Choose a reason for hiding this comment

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

I can't really understand the logic here; I think we need some comments to explain. Is the code in this method handling just the string concatenation?

Copy link
Author

Choose a reason for hiding this comment

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

This is the code handling the string concatenation. I can add a comment, and also simplify the logic a bit.

Copy link
Member

Choose a reason for hiding this comment

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

Yes, please add comments.

Comment on lines +1632 to +1635
public CAstNode visitTaggedTemplateLiteral(TaggedTemplateLiteral node, WalkContext arg) {
// TODO Auto-generated method stub
return null;
}
Copy link
Member

Choose a reason for hiding this comment

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

I'm concerned this will cause a crash if we get an input with a tagged template literal. If we don't handle this case yet, maybe we should not add this method and just skip visiting the nodes?

Copy link
Member

Choose a reason for hiding this comment

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

Any thoughts on this comment?

} else if (node instanceof SwitchStatement) {
return visitSwitchStatement((SwitchStatement) node, arg);
} else if (node instanceof TaggedTemplateLiteral) {
return visitTaggedTemplateLiteral((TaggedTemplateLiteral) node, arg);
Copy link
Member

Choose a reason for hiding this comment

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

See comment above about not visiting these nodes if we don't yet handle them; or is the issue that we'll get an unexpected node type?

In general, what happens right now when we try to pass an ES6 input to WALA, given that we haven't set the language version? Do we just get a parse error in Rhino?

Copy link
Author

Choose a reason for hiding this comment

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

Right now, it errors based on a Rhino parse error when given an ES6 input without the language version set.

TaggedTemplateLiteral is a separate node type from Rhino. I haven't tested if I could put a "dummy node" instead to prevent a crash, but I was mirroring some of the other unimplemented node types.

Copy link
Member

Choose a reason for hiding this comment

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

Ok. I imagine there are various other ES6 nodes we don't handle yet. I think we should update line 205 to throw some kind of catchable exception (maybe UnsupportedNodeTypeException extends RuntimeException) and document that this type of exception will be thrown if we encounter node types we don't handle. It would be nice to return some kind of valid AST and not crash out in such cases, but I don't really see how we could do that.

CAstCallGraphUtil.dumpCG(B.getCFAContextInterpreter(), B.getPointerAnalysis(), CG);
}

private static final Object[][] assertionsES6Args =
Copy link
Member

Choose a reason for hiding this comment

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

For the test cases where the template substitution has a function call, can we assert that the appropriate call edge(s) are present?

Copy link

github-actions bot commented Apr 27, 2025

Test Results

  713 files  ±0    713 suites  ±0   4h 9m 36s ⏱️ - 1m 9s
  774 tests +1    755 ✅ +1   19 💤 ±0  0 ❌ ±0 
4 528 runs  +6  4 412 ✅ +6  116 💤 ±0  0 ❌ ±0 

Results for commit f3f8869. ± Comparison against base commit de2db46.

♻️ This comment has been updated with latest results.

@liblit
Copy link
Contributor

liblit commented Aug 17, 2025

There has been no new discussion about this PR since April 27, 2025. @apple5775 and @msridhar, do you still expect to reach consensus that this PR is good and ready to merge? Or has this PR been abandoned, in which case we should just close it?

@apple5775
Copy link
Author

@liblit Sorry, I haven't taken the time to go through these yet. I will do my best this week to make the requested changes.

@liblit
Copy link
Contributor

liblit commented Aug 18, 2025

@apple5775 wrote:

I will do my best this week to make the requested changes.

Sure, that's fine. There's no rush. I just want to make sure that we're not forgetting anything that still has the potential to improve WALA. As long as I know you still intend to move this PR forward, I don't care how long it takes to do that.

Copy link

codecov bot commented Sep 2, 2025

Codecov Report

❌ Patch coverage is 86.95652% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 50.21%. Comparing base (de2db46) to head (f3f8869).

Files with missing lines Patch % Lines
.../ibm/wala/cast/js/translator/TypedNodeVisitor.java 66.66% 1 Missing and 1 partial ⚠️
.../wala/cast/js/translator/RhinoToAstTranslator.java 94.11% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff            @@
##             master    #1493   +/-   ##
=========================================
  Coverage     50.20%   50.21%           
- Complexity    12651    12652    +1     
=========================================
  Files          1365     1365           
  Lines         85211    85234   +23     
  Branches      14732    14737    +5     
=========================================
+ Hits          42784    42802   +18     
- Misses        37632    37635    +3     
- Partials       4795     4797    +2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Member

@msridhar msridhar left a comment

Choose a reason for hiding this comment

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

Did another pass and added a couple more comments. Also, some of my previous comments have not yet been addressed. Thanks!

}

@Override
public CAstNode visitTemplateLiteral(TemplateLiteral node, WalkContext arg) {
Copy link
Member

Choose a reason for hiding this comment

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

Yes, please add comments.


@Override
public CAstNode visitTaggedTemplateLiteral(TaggedTemplateLiteral node, WalkContext arg) {
// TODO Auto-generated method stub
Copy link
Member

Choose a reason for hiding this comment

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

Replace with a comment indicating this feature is not yet implemented

Comment on lines +1632 to +1635
public CAstNode visitTaggedTemplateLiteral(TaggedTemplateLiteral node, WalkContext arg) {
// TODO Auto-generated method stub
return null;
}
Copy link
Member

Choose a reason for hiding this comment

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

Any thoughts on this comment?

} else if (node instanceof SwitchStatement) {
return visitSwitchStatement((SwitchStatement) node, arg);
} else if (node instanceof TaggedTemplateLiteral) {
return visitTaggedTemplateLiteral((TaggedTemplateLiteral) node, arg);
Copy link
Member

Choose a reason for hiding this comment

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

Ok. I imagine there are various other ES6 nodes we don't handle yet. I think we should update line 205 to throw some kind of catchable exception (maybe UnsupportedNodeTypeException extends RuntimeException) and document that this type of exception will be thrown if we encounter node types we don't handle. It would be nice to return some kind of valid AST and not crash out in such cases, but I don't really see how we could do that.

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.

3 participants