File tree Expand file tree Collapse file tree 2 files changed +23
-1
lines changed Expand file tree Collapse file tree 2 files changed +23
-1
lines changed Original file line number Diff line number Diff line change @@ -112,7 +112,7 @@ const tests = [
112
112
} ,
113
113
{
114
114
name : "Optional call of root function" ,
115
- body ( ) {
115
+ body ( ) {
116
116
assert . areEqual ( 42 , eval ?. ( "42" ) ) ;
117
117
118
118
globalThis . doNotUseThisBadGlobalFunction = ( ) => 42 ;
@@ -142,7 +142,9 @@ const tests = [
142
142
const obj = {
143
143
fn : ( ) => 42 ,
144
144
} ;
145
+ assert . areEqual ( 42 , eval ( "obj.fn?.()" ) ) ;
145
146
assert . areEqual ( 42 , eval ( "obj?.fn?.()" ) ) ;
147
+ assert . areEqual ( 42 , eval ( "obj?.fn()" ) ) ;
146
148
} ,
147
149
} ,
148
150
{
Original file line number Diff line number Diff line change @@ -96,6 +96,26 @@ const tests = [
96
96
body ( ) {
97
97
assert . areEqual ( 0 , "" ?. length , "Expected empty string length" ) ;
98
98
}
99
+ } ,
100
+ {
101
+ name : "Unused opt-chain result should not crash jit" ,
102
+ body ( ) {
103
+ assert . areEqual ( undefined , eval ( `boo?.();` ) ) ;
104
+ assert . areEqual ( "result" , eval ( `boo?.(); "result"` ) ) ;
105
+ }
106
+ } ,
107
+ {
108
+ name : "Return register works with opt-chain" ,
109
+ body ( ) {
110
+ function shouldReturnUndefined ( ) {
111
+ return simpleObj . null ?. ( ) ;
112
+ }
113
+ function shouldReturn2 ( ) {
114
+ return "12" ?. length ;
115
+ }
116
+ assert . areEqual ( undefined , shouldReturnUndefined ( ) ) ;
117
+ assert . areEqual ( 2 , shouldReturn2 ( ) ) ;
118
+ }
99
119
}
100
120
] ;
101
121
You can’t perform that action at this time.
0 commit comments