[GH-ISSUE #67] Error while renaming a variable. (TypeError: Duplicate declaration) #32

Closed
opened 2026-03-03 13:52:22 +03:00 by kerem · 14 comments
Owner

Originally created by @Anooxy17 on GitHub (Aug 28, 2024).
Original GitHub issue: https://github.com/jehna/humanify/issues/67

Console output:

[2024-08-28 21:12:49]  Renaming global
[2024-08-28 21:12:49]  Context:     throw CustomError.C(null);
      }
      return {
        us: ______________inputString[7],
        Cp: b
      };
    }
  }
  class Image {
    constructor() {
      this.Sg = this.Tg = this.ya = null;

[2024-08-28 21:12:49]  Renamed to inputString
[2024-08-28 21:12:49]  Processing: 55%
[2024-08-28 21:12:49]  Processing: 100%

C:\Users\ktepe\AppData\Roaming\npm\node_modules\humanifyjs\node_modules\@babel\core\lib\transformation\file\file.js:195
    return new _Error(msg);
           ^

TypeError: Duplicate declaration "Ya"

    at File.buildCodeFrameError (C:\Users\ktepe\AppData\Roaming\npm\node_modules\humanifyjs\node_modules\@babel\core\lib\transformation\file\file.js:195:12)
    at Scope.checkBlockScopedCollisions (C:\Users\ktepe\AppData\Roaming\npm\node_modules\humanifyjs\node_modules\@babel\traverse\lib\scope\index.js:408:22)
    at Scope.registerBinding (C:\Users\ktepe\AppData\Roaming\npm\node_modules\humanifyjs\node_modules\@babel\traverse\lib\scope\index.js:544:16)
    at Scope.registerDeclaration (C:\Users\ktepe\AppData\Roaming\npm\node_modules\humanifyjs\node_modules\@babel\traverse\lib\scope\index.js:500:12)
    at Object.BlockScoped (C:\Users\ktepe\AppData\Roaming\npm\node_modules\humanifyjs\node_modules\@babel\traverse\lib\scope\index.js:259:12)
    at Object.newFn (C:\Users\ktepe\AppData\Roaming\npm\node_modules\humanifyjs\node_modules\@babel\traverse\lib\visitors.js:207:17)
    at NodePath._call (C:\Users\ktepe\AppData\Roaming\npm\node_modules\humanifyjs\node_modules\@babel\traverse\lib\path\context.js:49:20)
    at NodePath.call (C:\Users\ktepe\AppData\Roaming\npm\node_modules\humanifyjs\node_modules\@babel\traverse\lib\path\context.js:35:15)
    at NodePath.visit (C:\Users\ktepe\AppData\Roaming\npm\node_modules\humanifyjs\node_modules\@babel\traverse\lib\path\context.js:85:31)
    at TraversalContext.visitQueue (C:\Users\ktepe\AppData\Roaming\npm\node_modules\humanifyjs\node_modules\@babel\traverse\lib\context.js:89:16)
    at TraversalContext.visitMultiple (C:\Users\ktepe\AppData\Roaming\npm\node_modules\humanifyjs\node_modules\@babel\traverse\lib\context.js:61:17)
    at TraversalContext.visit (C:\Users\ktepe\AppData\Roaming\npm\node_modules\humanifyjs\node_modules\@babel\traverse\lib\context.js:110:19)
    at traverseNode (C:\Users\ktepe\AppData\Roaming\npm\node_modules\humanifyjs\node_modules\@babel\traverse\lib\traverse-node.js:22:17)
    at NodePath.visit (C:\Users\ktepe\AppData\Roaming\npm\node_modules\humanifyjs\node_modules\@babel\traverse\lib\path\context.js:91:52)
    at TraversalContext.visitQueue (C:\Users\ktepe\AppData\Roaming\npm\node_modules\humanifyjs\node_modules\@babel\traverse\lib\context.js:89:16)
    at TraversalContext.visitSingle (C:\Users\ktepe\AppData\Roaming\npm\node_modules\humanifyjs\node_modules\@babel\traverse\lib\context.js:65:19)
    at TraversalContext.visit (C:\Users\ktepe\AppData\Roaming\npm\node_modules\humanifyjs\node_modules\@babel\traverse\lib\context.js:112:19)
    at traverseNode (C:\Users\ktepe\AppData\Roaming\npm\node_modules\humanifyjs\node_modules\@babel\traverse\lib\traverse-node.js:22:17)
    at NodePath.visit (C:\Users\ktepe\AppData\Roaming\npm\node_modules\humanifyjs\node_modules\@babel\traverse\lib\path\context.js:91:52)
    at TraversalContext.visitQueue (C:\Users\ktepe\AppData\Roaming\npm\node_modules\humanifyjs\node_modules\@babel\traverse\lib\context.js:89:16)
    at TraversalContext.visitSingle (C:\Users\ktepe\AppData\Roaming\npm\node_modules\humanifyjs\node_modules\@babel\traverse\lib\context.js:65:19)
    at TraversalContext.visit (C:\Users\ktepe\AppData\Roaming\npm\node_modules\humanifyjs\node_modules\@babel\traverse\lib\context.js:112:19)
    at traverseNode (C:\Users\ktepe\AppData\Roaming\npm\node_modules\humanifyjs\node_modules\@babel\traverse\lib\traverse-node.js:22:17)
    at NodePath.visit (C:\Users\ktepe\AppData\Roaming\npm\node_modules\humanifyjs\node_modules\@babel\traverse\lib\path\context.js:91:52)
    at TraversalContext.visitQueue (C:\Users\ktepe\AppData\Roaming\npm\node_modules\humanifyjs\node_modules\@babel\traverse\lib\context.js:89:16)
    at TraversalContext.visitSingle (C:\Users\ktepe\AppData\Roaming\npm\node_modules\humanifyjs\node_modules\@babel\traverse\lib\context.js:65:19)
    at TraversalContext.visit (C:\Users\ktepe\AppData\Roaming\npm\node_modules\humanifyjs\node_modules\@babel\traverse\lib\context.js:112:19)
    at traverseNode (C:\Users\ktepe\AppData\Roaming\npm\node_modules\humanifyjs\node_modules\@babel\traverse\lib\traverse-node.js:22:17)
    at NodePath.visit (C:\Users\ktepe\AppData\Roaming\npm\node_modules\humanifyjs\node_modules\@babel\traverse\lib\path\context.js:91:52)
    at TraversalContext.visitQueue (C:\Users\ktepe\AppData\Roaming\npm\node_modules\humanifyjs\node_modules\@babel\traverse\lib\context.js:89:16)
    at TraversalContext.visitMultiple (C:\Users\ktepe\AppData\Roaming\npm\node_modules\humanifyjs\node_modules\@babel\traverse\lib\context.js:61:17)
    at TraversalContext.visit (C:\Users\ktepe\AppData\Roaming\npm\node_modules\humanifyjs\node_modules\@babel\traverse\lib\context.js:110:19)
    at traverseNode (C:\Users\ktepe\AppData\Roaming\npm\node_modules\humanifyjs\node_modules\@babel\traverse\lib\traverse-node.js:22:17)
    at traverse (C:\Users\ktepe\AppData\Roaming\npm\node_modules\humanifyjs\node_modules\@babel\traverse\lib\index.js:53:34)
    at NodePath.traverse (C:\Users\ktepe\AppData\Roaming\npm\node_modules\humanifyjs\node_modules\@babel\traverse\lib\path\index.js:119:24)
    at Scope.crawl (C:\Users\ktepe\AppData\Roaming\npm\node_modules\humanifyjs\node_modules\@babel\traverse\lib\scope\index.js:704:10)
    at Scope.init (C:\Users\ktepe\AppData\Roaming\npm\node_modules\humanifyjs\node_modules\@babel\traverse\lib\scope\index.js:675:12)
    at NodePath.setScope (C:\Users\ktepe\AppData\Roaming\npm\node_modules\humanifyjs\node_modules\@babel\traverse\lib\path\context.js:123:53)
    at NodePath.setContext (C:\Users\ktepe\AppData\Roaming\npm\node_modules\humanifyjs\node_modules\@babel\traverse\lib\path\context.js:135:8)
    at new File (C:\Users\ktepe\AppData\Roaming\npm\node_modules\humanifyjs\node_modules\@babel\core\lib\transformation\file\file.js:90:8)
    at normalizeFile (C:\Users\ktepe\AppData\Roaming\npm\node_modules\humanifyjs\node_modules\@babel\core\lib\transformation\normalize-file.js:98:10)
    at normalizeFile.next (<anonymous>)
    at run (C:\Users\ktepe\AppData\Roaming\npm\node_modules\humanifyjs\node_modules\@babel\core\lib\transformation\index.js:21:50)
    at run.next (<anonymous>)
    at C:\Users\ktepe\AppData\Roaming\npm\node_modules\humanifyjs\node_modules\@babel\core\lib\transform-ast.js:23:33
    at Generator.next (<anonymous>)
    at step (C:\Users\ktepe\AppData\Roaming\npm\node_modules\humanifyjs\node_modules\gensync\index.js:261:32)
    at C:\Users\ktepe\AppData\Roaming\npm\node_modules\humanifyjs\node_modules\gensync\index.js:273:13
    at async.call.result.err.err (C:\Users\ktepe\AppData\Roaming\npm\node_modules\humanifyjs\node_modules\gensync\index.js:223:11)
    at C:\Users\ktepe\AppData\Roaming\npm\node_modules\humanifyjs\node_modules\gensync\index.js:50:45
Originally created by @Anooxy17 on GitHub (Aug 28, 2024). Original GitHub issue: https://github.com/jehna/humanify/issues/67 Console output: ``` [2024-08-28 21:12:49] Renaming global [2024-08-28 21:12:49] Context: throw CustomError.C(null); } return { us: ______________inputString[7], Cp: b }; } } class Image { constructor() { this.Sg = this.Tg = this.ya = null; [2024-08-28 21:12:49] Renamed to inputString [2024-08-28 21:12:49] Processing: 55% [2024-08-28 21:12:49] Processing: 100% C:\Users\ktepe\AppData\Roaming\npm\node_modules\humanifyjs\node_modules\@babel\core\lib\transformation\file\file.js:195 return new _Error(msg); ^ TypeError: Duplicate declaration "Ya" at File.buildCodeFrameError (C:\Users\ktepe\AppData\Roaming\npm\node_modules\humanifyjs\node_modules\@babel\core\lib\transformation\file\file.js:195:12) at Scope.checkBlockScopedCollisions (C:\Users\ktepe\AppData\Roaming\npm\node_modules\humanifyjs\node_modules\@babel\traverse\lib\scope\index.js:408:22) at Scope.registerBinding (C:\Users\ktepe\AppData\Roaming\npm\node_modules\humanifyjs\node_modules\@babel\traverse\lib\scope\index.js:544:16) at Scope.registerDeclaration (C:\Users\ktepe\AppData\Roaming\npm\node_modules\humanifyjs\node_modules\@babel\traverse\lib\scope\index.js:500:12) at Object.BlockScoped (C:\Users\ktepe\AppData\Roaming\npm\node_modules\humanifyjs\node_modules\@babel\traverse\lib\scope\index.js:259:12) at Object.newFn (C:\Users\ktepe\AppData\Roaming\npm\node_modules\humanifyjs\node_modules\@babel\traverse\lib\visitors.js:207:17) at NodePath._call (C:\Users\ktepe\AppData\Roaming\npm\node_modules\humanifyjs\node_modules\@babel\traverse\lib\path\context.js:49:20) at NodePath.call (C:\Users\ktepe\AppData\Roaming\npm\node_modules\humanifyjs\node_modules\@babel\traverse\lib\path\context.js:35:15) at NodePath.visit (C:\Users\ktepe\AppData\Roaming\npm\node_modules\humanifyjs\node_modules\@babel\traverse\lib\path\context.js:85:31) at TraversalContext.visitQueue (C:\Users\ktepe\AppData\Roaming\npm\node_modules\humanifyjs\node_modules\@babel\traverse\lib\context.js:89:16) at TraversalContext.visitMultiple (C:\Users\ktepe\AppData\Roaming\npm\node_modules\humanifyjs\node_modules\@babel\traverse\lib\context.js:61:17) at TraversalContext.visit (C:\Users\ktepe\AppData\Roaming\npm\node_modules\humanifyjs\node_modules\@babel\traverse\lib\context.js:110:19) at traverseNode (C:\Users\ktepe\AppData\Roaming\npm\node_modules\humanifyjs\node_modules\@babel\traverse\lib\traverse-node.js:22:17) at NodePath.visit (C:\Users\ktepe\AppData\Roaming\npm\node_modules\humanifyjs\node_modules\@babel\traverse\lib\path\context.js:91:52) at TraversalContext.visitQueue (C:\Users\ktepe\AppData\Roaming\npm\node_modules\humanifyjs\node_modules\@babel\traverse\lib\context.js:89:16) at TraversalContext.visitSingle (C:\Users\ktepe\AppData\Roaming\npm\node_modules\humanifyjs\node_modules\@babel\traverse\lib\context.js:65:19) at TraversalContext.visit (C:\Users\ktepe\AppData\Roaming\npm\node_modules\humanifyjs\node_modules\@babel\traverse\lib\context.js:112:19) at traverseNode (C:\Users\ktepe\AppData\Roaming\npm\node_modules\humanifyjs\node_modules\@babel\traverse\lib\traverse-node.js:22:17) at NodePath.visit (C:\Users\ktepe\AppData\Roaming\npm\node_modules\humanifyjs\node_modules\@babel\traverse\lib\path\context.js:91:52) at TraversalContext.visitQueue (C:\Users\ktepe\AppData\Roaming\npm\node_modules\humanifyjs\node_modules\@babel\traverse\lib\context.js:89:16) at TraversalContext.visitSingle (C:\Users\ktepe\AppData\Roaming\npm\node_modules\humanifyjs\node_modules\@babel\traverse\lib\context.js:65:19) at TraversalContext.visit (C:\Users\ktepe\AppData\Roaming\npm\node_modules\humanifyjs\node_modules\@babel\traverse\lib\context.js:112:19) at traverseNode (C:\Users\ktepe\AppData\Roaming\npm\node_modules\humanifyjs\node_modules\@babel\traverse\lib\traverse-node.js:22:17) at NodePath.visit (C:\Users\ktepe\AppData\Roaming\npm\node_modules\humanifyjs\node_modules\@babel\traverse\lib\path\context.js:91:52) at TraversalContext.visitQueue (C:\Users\ktepe\AppData\Roaming\npm\node_modules\humanifyjs\node_modules\@babel\traverse\lib\context.js:89:16) at TraversalContext.visitSingle (C:\Users\ktepe\AppData\Roaming\npm\node_modules\humanifyjs\node_modules\@babel\traverse\lib\context.js:65:19) at TraversalContext.visit (C:\Users\ktepe\AppData\Roaming\npm\node_modules\humanifyjs\node_modules\@babel\traverse\lib\context.js:112:19) at traverseNode (C:\Users\ktepe\AppData\Roaming\npm\node_modules\humanifyjs\node_modules\@babel\traverse\lib\traverse-node.js:22:17) at NodePath.visit (C:\Users\ktepe\AppData\Roaming\npm\node_modules\humanifyjs\node_modules\@babel\traverse\lib\path\context.js:91:52) at TraversalContext.visitQueue (C:\Users\ktepe\AppData\Roaming\npm\node_modules\humanifyjs\node_modules\@babel\traverse\lib\context.js:89:16) at TraversalContext.visitMultiple (C:\Users\ktepe\AppData\Roaming\npm\node_modules\humanifyjs\node_modules\@babel\traverse\lib\context.js:61:17) at TraversalContext.visit (C:\Users\ktepe\AppData\Roaming\npm\node_modules\humanifyjs\node_modules\@babel\traverse\lib\context.js:110:19) at traverseNode (C:\Users\ktepe\AppData\Roaming\npm\node_modules\humanifyjs\node_modules\@babel\traverse\lib\traverse-node.js:22:17) at traverse (C:\Users\ktepe\AppData\Roaming\npm\node_modules\humanifyjs\node_modules\@babel\traverse\lib\index.js:53:34) at NodePath.traverse (C:\Users\ktepe\AppData\Roaming\npm\node_modules\humanifyjs\node_modules\@babel\traverse\lib\path\index.js:119:24) at Scope.crawl (C:\Users\ktepe\AppData\Roaming\npm\node_modules\humanifyjs\node_modules\@babel\traverse\lib\scope\index.js:704:10) at Scope.init (C:\Users\ktepe\AppData\Roaming\npm\node_modules\humanifyjs\node_modules\@babel\traverse\lib\scope\index.js:675:12) at NodePath.setScope (C:\Users\ktepe\AppData\Roaming\npm\node_modules\humanifyjs\node_modules\@babel\traverse\lib\path\context.js:123:53) at NodePath.setContext (C:\Users\ktepe\AppData\Roaming\npm\node_modules\humanifyjs\node_modules\@babel\traverse\lib\path\context.js:135:8) at new File (C:\Users\ktepe\AppData\Roaming\npm\node_modules\humanifyjs\node_modules\@babel\core\lib\transformation\file\file.js:90:8) at normalizeFile (C:\Users\ktepe\AppData\Roaming\npm\node_modules\humanifyjs\node_modules\@babel\core\lib\transformation\normalize-file.js:98:10) at normalizeFile.next (<anonymous>) at run (C:\Users\ktepe\AppData\Roaming\npm\node_modules\humanifyjs\node_modules\@babel\core\lib\transformation\index.js:21:50) at run.next (<anonymous>) at C:\Users\ktepe\AppData\Roaming\npm\node_modules\humanifyjs\node_modules\@babel\core\lib\transform-ast.js:23:33 at Generator.next (<anonymous>) at step (C:\Users\ktepe\AppData\Roaming\npm\node_modules\humanifyjs\node_modules\gensync\index.js:261:32) at C:\Users\ktepe\AppData\Roaming\npm\node_modules\humanifyjs\node_modules\gensync\index.js:273:13 at async.call.result.err.err (C:\Users\ktepe\AppData\Roaming\npm\node_modules\humanifyjs\node_modules\gensync\index.js:223:11) at C:\Users\ktepe\AppData\Roaming\npm\node_modules\humanifyjs\node_modules\gensync\index.js:50:45 ```
kerem closed this issue 2026-03-03 13:52:22 +03:00
Author
Owner

@0xdevalias commented on GitHub (Aug 29, 2024):

See also:

<!-- gh-comment-id:2316472945 --> @0xdevalias commented on GitHub (Aug 29, 2024): See also: - https://github.com/jehna/humanify/issues/8 - https://github.com/jehna/humanify/issues/20
Author
Owner

@brianjenkins94 commented on GitHub (Oct 18, 2024):

Is there a workaround or anything for this? Or is this blocked by the effort to understand how to perform the rename without collision?

I would be totally okay if it just became variable$1.

<!-- gh-comment-id:2422878669 --> @brianjenkins94 commented on GitHub (Oct 18, 2024): Is there a workaround or anything for this? Or is this blocked by the effort to understand how to perform the rename without collision? I would be totally okay if it just became `variable$1`.
Author
Owner

@jehna commented on GitHub (Oct 18, 2024):

@brianjenkins94 did you try with v2.1.3 yet? It should have a better logic against invalid identifiers

<!-- gh-comment-id:2422957795 --> @jehna commented on GitHub (Oct 18, 2024): @brianjenkins94 did you try with v2.1.3 yet? It should have a better logic against invalid identifiers
Author
Owner

@jehna commented on GitHub (Oct 18, 2024):

If the identifier conflicts with another identifier that's not generated by Humanify, then there's no valid fix yet.

I wonder what should be done in case of an identifier that we cannot rename? A quick solution would be to prefix it with an underscore

<!-- gh-comment-id:2422962154 --> @jehna commented on GitHub (Oct 18, 2024): If the identifier conflicts with another identifier that's not generated by Humanify, then there's no valid fix yet. I wonder what should be done in case of an identifier that we cannot rename? A quick solution would be to prefix it with an underscore
Author
Owner

@jehna commented on GitHub (Oct 18, 2024):

I suppose the best solution could be that Humanify would retry with a prompt like:

Rename a function ..., here is a list of names that you cannot use: ${failedIdentifiers}
<!-- gh-comment-id:2422973837 --> @jehna commented on GitHub (Oct 18, 2024): I suppose the best solution could be that Humanify would retry with a prompt like: ``` Rename a function ..., here is a list of names that you cannot use: ${failedIdentifiers} ```
Author
Owner

@brianjenkins94 commented on GitHub (Oct 18, 2024):

Yes, I am using humanify v2.1.3 with:

  "overrides": {
    "humanifyjs": {
      "webcrack": "latest"
    }
  }

which resolves to webcrack v2.14.1.

If the identifier conflicts with another identifier that's not generated by Humanify, then there's no valid fix yet.

I don't think that's the problem I'm having, all my variables are named v1, p1, etc.

I wonder what should be done in case of an identifier that we cannot rename? A quick solution would be to prefix it with an underscore

That's what I was saying, if it could just add a $1 suffix, like esbuild does to avoid collisions.

here's my repo:

https://github.com/brianjenkins94/reverse-engineered-nodebox

<!-- gh-comment-id:2422990106 --> @brianjenkins94 commented on GitHub (Oct 18, 2024): Yes, I am using `humanify` v2.1.3 with: ``` "overrides": { "humanifyjs": { "webcrack": "latest" } } ``` which resolves to `webcrack` v2.14.1. > If the identifier conflicts with another identifier that's not generated by Humanify, then there's no valid fix yet. I don't think that's the problem I'm having, all my variables are named `v1`, `p1`, etc. > I wonder what should be done in case of an identifier that we cannot rename? A quick solution would be to prefix it with an underscore That's what I was saying, if it could just add a `$1` suffix, like `esbuild` does to avoid collisions. here's my repo: https://github.com/brianjenkins94/reverse-engineered-nodebox
Author
Owner

@jehna commented on GitHub (Oct 18, 2024):

Okay, I think I found the issue. Fixing this now

<!-- gh-comment-id:2423079812 --> @jehna commented on GitHub (Oct 18, 2024): Okay, I think I found the issue. Fixing this now
Author
Owner

@brianjenkins94 commented on GitHub (Oct 18, 2024):

I updated my test harness so I can test against the main branch. I'll see if it gets further this time.

Aside: Can I run humanify against multiple files simultaneously? Or would that run the risk of making requests too fast?

<!-- gh-comment-id:2423237826 --> @brianjenkins94 commented on GitHub (Oct 18, 2024): I updated my test harness so I can test against the main branch. I'll see if it gets further this time. Aside: Can I run humanify against multiple files simultaneously? Or would that run the risk of making requests too fast?
Author
Owner

@jehna commented on GitHub (Oct 18, 2024):

Just released v2.2.0, should fix this issue for now.

Can I run humanify against multiple files simultaneously? Or would that run the risk of making requests too fast?

I'd say it depends solely on your OpenAI subscription level. Unfortunately there's not that good rate limit throttling/retry logic built into Humanify yet.

<!-- gh-comment-id:2423246304 --> @jehna commented on GitHub (Oct 18, 2024): Just released `v2.2.0`, should fix this issue for now. > Can I run humanify against multiple files simultaneously? Or would that run the risk of making requests too fast? I'd say it depends solely on your OpenAI subscription level. Unfortunately there's not that good rate limit throttling/retry logic built into Humanify yet.
Author
Owner

@jehna commented on GitHub (Oct 18, 2024):

Added some thoughts about parallelism to issue #167

<!-- gh-comment-id:2423261393 --> @jehna commented on GitHub (Oct 18, 2024): Added some thoughts about parallelism to issue #167
Author
Owner

@0xdevalias commented on GitHub (Oct 20, 2024):

Unfortunately there's not that good rate limit throttling/retry logic built into Humanify yet.

Added some thoughts about parallelism to issue #167

See also:

<!-- gh-comment-id:2424388571 --> @0xdevalias commented on GitHub (Oct 20, 2024): > Unfortunately there's not that good rate limit throttling/retry logic built into Humanify yet. > Added some thoughts about parallelism to issue #167 See also: - https://github.com/jehna/humanify/issues/2 - https://github.com/jehna/humanify/issues/139
Author
Owner

@0xdevalias commented on GitHub (Oct 20, 2024):

I suppose the best solution could be that Humanify would retry with a prompt like:

Rename a function ..., here is a list of names that you cannot use: ${failedIdentifiers}

@jehna That's what's been proposed in the past, eg.

Also it can happen that a variable gets renamed but another one with the same name already exists in the scope, or the code gets split up in such a way that not all references are renamed.

Off the top of my head, if it's not easily solved via tweaking the prompt, you could potentially have it do a 'refinement/feedback round' where you provide feedback to the LLM + get it to correct the issues (which could be repeated up to X times) eg.

The following variables were already defined in the scope, so we can't use the names you chose. Please choose a new name for them so that they don't clash:

  • X
  • Y
  • Z

Originally posted by @0xdevalias in https://github.com/jehna/humanify/issues/8#issuecomment-1853022637

https://github.com/jehna/humanify/pull/164 feels a bit like a workaround rather than an optimal solution.

<!-- gh-comment-id:2424402134 --> @0xdevalias commented on GitHub (Oct 20, 2024): > I suppose the best solution could be that Humanify would retry with a prompt like: > > ``` > Rename a function ..., here is a list of names that you cannot use: ${failedIdentifiers} > ``` @jehna That's what's been proposed in the past, eg. > > Also it can happen that a variable gets renamed but another one with the same name already exists in the scope, or the code gets split up in such a way that not all references are renamed. > > Off the top of my head, if it's not easily solved via tweaking the prompt, you could potentially have it do a 'refinement/feedback round' where you provide feedback to the LLM + get it to correct the issues (which could be repeated up to X times) eg. > > > The following variables were already defined in the scope, so we can't use the names you chose. Please choose a new name for them so that they don't clash: > > > > - X > > - Y > > - Z > > _Originally posted by @0xdevalias in https://github.com/jehna/humanify/issues/8#issuecomment-1853022637_ https://github.com/jehna/humanify/pull/164 feels a bit like a workaround rather than an optimal solution.
Author
Owner

@0xdevalias commented on GitHub (Oct 20, 2024):

Related context (from secondary comment on another issue):

Also it can happen that a variable gets renamed but another one with the same name already exists in the scope, or the code gets split up in such a way that not all references are renamed.
Maybe use babel's scope-aware rename that also handles these conflicts (have to find a way of getting rid of the _ prefix): astexplorer.net#/gist/7283141e13dab314521744603a95e9b7/05b11370db8d5ef257550b2916b87d6e72e4eb1d

Originally posted by @j4k0xb in https://github.com/jehna/humanify/issues/8

<!-- gh-comment-id:2424403952 --> @0xdevalias commented on GitHub (Oct 20, 2024): Related context (from secondary comment on another issue): > Also it can happen that a variable gets renamed but another one with the same name already exists in the scope, or the code gets split up in such a way that not all references are renamed. > Maybe use babel's scope-aware rename that also handles these conflicts (have to find a way of getting rid of the `_` prefix): [astexplorer.net#/gist/7283141e13dab314521744603a95e9b7/05b11370db8d5ef257550b2916b87d6e72e4eb1d](https://astexplorer.net/#/gist/7283141e13dab314521744603a95e9b7/05b11370db8d5ef257550b2916b87d6e72e4eb1d) > >_Originally posted by @j4k0xb in https://github.com/jehna/humanify/issues/8_
Author
Owner

@brianjenkins94 commented on GitHub (Oct 21, 2024):

Aside: Can I run humanify against multiple files simultaneously? Or would that run the risk of making requests too fast?

In trying to produce benchmark results for #172, I have determined that simultaneous runs cause 429s and cause the application to crash.

Just closing the loop.

<!-- gh-comment-id:2427685842 --> @brianjenkins94 commented on GitHub (Oct 21, 2024): > Aside: Can I run humanify against multiple files simultaneously? Or would that run the risk of making requests too fast? In trying to produce benchmark results for #172, I have determined that simultaneous runs cause 429s and cause the application to crash. Just closing the loop.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/humanify#32
No description provided.