File tree Expand file tree Collapse file tree 4 files changed +35
-0
lines changed
test/form/samples/simplify-return-expression Expand file tree Collapse file tree 4 files changed +35
-0
lines changed Original file line number Diff line number Diff line change @@ -86,6 +86,7 @@ export default class Identifier extends NodeBase implements PatternNode {
8686 recursionTracker : ImmutableEntityPathTracker ,
8787 origin : DeoptimizableEntity
8888 ) : LiteralValueOrUnknown {
89+ if ( ! this . bound ) this . bind ( ) ;
8990 if ( this . variable !== null ) {
9091 return this . variable . getLiteralValueAtPath ( path , recursionTracker , origin ) ;
9192 }
@@ -97,6 +98,7 @@ export default class Identifier extends NodeBase implements PatternNode {
9798 recursionTracker : ImmutableEntityPathTracker ,
9899 origin : DeoptimizableEntity
99100 ) {
101+ if ( ! this . bound ) this . bind ( ) ;
100102 if ( this . variable !== null ) {
101103 return this . variable . getReturnExpressionWhenCalledAtPath ( path , recursionTracker , origin ) ;
102104 }
Original file line number Diff line number Diff line change 1+ module . exports = {
2+ description : 'Simplifies conditionals in return expression'
3+ } ;
Original file line number Diff line number Diff line change 1+ const test = ( ) => {
2+ console . log ( foo ( ) ) ;
3+ console . log ( bar ( ) ) ;
4+ } ;
5+
6+ const foo = ( ) => {
7+ return A ;
8+ } ;
9+
10+ const bar = ( ) => {
11+ return A ;
12+ } ;
13+
14+ export { test } ;
Original file line number Diff line number Diff line change 1+ export const test = ( ) => {
2+ console . log ( foo ( ) ) ;
3+ console . log ( bar ( ) ) ;
4+ } ;
5+
6+ const foo = ( ) => {
7+ return BUILD ? A : B ;
8+ } ;
9+
10+ const bar = ( ) => {
11+ return getBuild ( ) ? A : B ;
12+ } ;
13+
14+ const getBuild = ( ) => BUILD ;
15+
16+ const BUILD = true ;
You can’t perform that action at this time.
0 commit comments