@@ -353,7 +353,6 @@ function REPLServer(prompt,
353353 this . allowBlockingCompletions = ! ! options . allowBlockingCompletions ;
354354 this . useColors = ! ! options . useColors ;
355355 this . _domain = options . domain || domain . create ( ) ;
356- this . _completeDomain = domain . create ( ) ;
357356 this . useGlobal = ! ! useGlobal ;
358357 this . ignoreUndefined = ! ! ignoreUndefined ;
359358 this . replMode = replMode || module . exports . REPL_MODE_SLOPPY ;
@@ -671,8 +670,6 @@ function REPLServer(prompt,
671670 }
672671
673672 self . eval = self . _domain . bind ( eval_ ) ;
674- self . completeEval = self . _completeDomain . bind ( eval_ ) ;
675- self . _completeDomain . on ( 'error' , ( err ) => { } ) ;
676673
677674 self . _domain . on ( 'error' , function debugDomainError ( e ) {
678675 debug ( 'domain error' ) ;
@@ -1543,10 +1540,10 @@ function complete(line, callback) {
15431540 return completionGroupsLoaded ( ) ;
15441541 }
15451542
1546- return includesProxiesOrGetters (
1543+ return potentiallySideEffectfulAccess (
15471544 completeTargetAst . body [ 0 ] . expression ,
15481545 parsableCompleteTarget ,
1549- this . completeEval ,
1546+ this . eval ,
15501547 this . context ,
15511548 ( includes ) => {
15521549 if ( includes ) {
@@ -1563,7 +1560,7 @@ function complete(line, callback) {
15631560
15641561 const memberGroups = [ ] ;
15651562 const evalExpr = `try { ${ expr } } catch {}` ;
1566- this . completeEval ( evalExpr , this . context , getREPLResourceName ( ) , ( e , obj ) => {
1563+ this . eval ( evalExpr , this . context , getREPLResourceName ( ) , ( e , obj ) => {
15671564 try {
15681565 reclusiveCatchPromise ( obj ) ;
15691566 let p ;
@@ -1756,10 +1753,11 @@ function findExpressionCompleteTarget(code) {
17561753}
17571754
17581755/**
1759- * Utility used to determine if an expression includes object getters or proxies .
1756+ * Utility to determine if accessing a given expression could have side effects .
17601757 *
1761- * Example: given `obj.foo`, the function lets you know if `foo` has a getter function
1762- * associated to it, or if `obj` is a proxy
1758+ * Example: given `obj.foo`, this function checks if accessing `foo` may trigger a getter,
1759+ * or if any part of the chain is a Proxy, or if evaluating the property could cause side effects.
1760+ * This is used to avoid triggering user code or side effects during tab completion.
17631761 * @param {any } expr The expression, in AST format to analyze
17641762 * @param {string } exprStr The string representation of the expression
17651763 * @param {(str: string, ctx: any, resourceName: string, cb: (error, evaled) => void) => void } evalFn
@@ -1768,15 +1766,19 @@ function findExpressionCompleteTarget(code) {
17681766 * @param {(includes: boolean) => void } callback Callback that will be called with the result of the operation
17691767 * @returns {void }
17701768 */
1771- function includesProxiesOrGetters ( expr , exprStr , evalFn , ctx , callback ) {
1769+ function potentiallySideEffectfulAccess ( expr , exprStr , evalFn , ctx , callback ) {
17721770 if ( expr ?. type !== 'MemberExpression' ) {
17731771 // If the expression is not a member one for obvious reasons no getters are involved
17741772 return callback ( false ) ;
17751773 }
17761774
1775+ if ( expr . object . type === 'CallExpression' || expr . property . type === 'CallExpression' ) {
1776+ return callback ( true ) ;
1777+ }
1778+
17771779 if ( expr . object . type === 'MemberExpression' ) {
17781780 // The object itself is a member expression, so we need to recurse (e.g. the expression is `obj.foo.bar`)
1779- return includesProxiesOrGetters (
1781+ return potentiallySideEffectfulAccess (
17801782 expr . object ,
17811783 exprStr . slice ( 0 , expr . object . end ) ,
17821784 evalFn ,
0 commit comments