Domiii / dbux

Dbux is an Integrated Debugging Environment (IDbE) and Omniscient Debugger that makes JavaScript application's run-time behavior come alive, visible and interactive.
https://domiii.github.io/dbux
Apache License 2.0
162 stars 13 forks source link

[Bug] SyntaxError: Identifier '_class' has already been declared #774

Open dmaretskyi opened 1 year ago

dmaretskyi commented 1 year ago

Bug Report

Bug Summary

Getting SyntaxError: Identifier '_class' has already been declared after adding a class declaration

Steps To Reproduce

  1. Open the built-in tutorial excercises
  2. Add a class declaration to the excercise source file
  3. Run DBUX

    Not crash.

    Actual behavior

    Crashes with an error SyntaxError: Identifier '_class' has already been declared.

    Attachments

    Relevant Code

    class Foo {}

    Dbux Output Log

    [Dbux ActionGroupType] Missing UserActionTypes in groupByActionType: PracticeSessionChanged, TestRunFinished, NewExerciseProgress, ExerciseProgressChanged, RunFile, RuntimeServerStatusChanged, ShowHelp, SelectTraceById, TreeViewOther, TreeViewCollapseChangeOther, TDValueRender, TDExecutionsGroupModeChanged, TDTraceUse, TDDebugUse, TDAsyncUse, TDAsyncGoToForkParent, TDAsyncGoToScheduler, DataFlowViewSearchModeChanged, DataFlowViewFilterModeChanged, DataFlowSelectTrace, DecorationVisibilityChanged, NavBarButtonsVisibilityChanged, ErrorLogNotificationVisibilityChanged, GlobalDebugAppUse, GlobalConsoleUse, GlobalProgramsUse, GlobalPackageSortModeChanged, SearchModeChanged, CallGraphVisibilityChanged, CallGraphGraphDocumentModeChanged, AsyncCallGraphTrace, AsyncCallGraphSchedulerTrace, AsyncCallGraphValueTrace, AsyncCallGraphError, StopProjectRunner, ProjectViewsVisibilityChanged, CheckSystem, ShowOutputChannel, ShowApplicationEntryFile, OpenWebsite, ShowExerciseIntroductionView, NewApplications, PathwaysVisibilityChanged, ProjectViewListModeChanged
    [Dbux dbux-code] Starting Dbux v0.7.9 (mode=production)...
    [Dbux projectControl] Initializing dbux-projects: projectsRoot = "/Users/dmaretskyi/.vscode/extensions/domi.dbux-code-0.7.9/dbux_projects", dependencyRoot = "/Users/dmaretskyi/.vscode/extensions/domi.dbux-code-0.7.9", samplesRoot = "/Users/dmaretskyi/.vscode/extensions/domi.dbux-code-0.7.9/samples"
    [Dbux PracticeManager] getDbuxPath(), relativePath='@dbux/cli/bin/dbux.js', getDbuxRoot()='/Users/dmaretskyi/.vscode/extensions/domi.dbux-code-0.7.9', config={"dependencyRoot":"/Users/dmaretskyi/.vscode/extensions/domi.dbux-code-0.7.9","projectsRoot":"/Users/dmaretskyi/.vscode/extensions/domi.dbux-code-0.7.9/dbux_projects","samplesRoot":"/Users/dmaretskyi/.vscode/extensions/domi.dbux-code-0.7.9/samples","dbuxLanguage":"en"}
    [Dbux installUtil] Checking library dependencies. Found 0 missing: 
    [Dbux TraceDecoConfig] Missing decoration config for trace types: BranchStatement, BranchExpression, BranchPush, BranchPop, BranchDecision, ResumeAsync, Finally, Catch, TryExit, FinallyExit, Yield, ResumeGen, PatternAssignment, PatternWriteVar, PatternWriteAndDeclareVar, PatternWriteME, Meta
    [Dbux exerciseProgresses] entry does not have `_id` prop (only reports once): [object Object]
    [Dbux Project todomvc-es6] [reloadExercises] found 11 in "undefined"
    [Dbux Project node-fetch] [reloadExercises] found 1 in "undefined"
    [Dbux Project javascript-algorithms] [reloadExercises] found 3 in "undefined"
    [Dbux Project getting-started] [reloadExercises] found 11 in "undefined"
    [Dbux Project express] [reloadExercises] found 22 in "undefined"
    [Dbux Project async-js] [reloadExercises] found 2 in "undefined"
    [Dbux Project 2048] [reloadExercises] found 4 in "undefined"
    [Dbux PracticeManager] Cannot find exercise of id or name:express#20 in chapter#3 (express). Make sure exerciseIds in "exerciseList.json" are correct.
    [Dbux PracticeManager] Cannot find exercise of id or name:express#21 in chapter#3 (express). Make sure exerciseIds in "exerciseList.json" are correct.
    [Dbux Project javascript-algorithms] [reloadExercises] found 313 in "javascript-algorithms-all"
    [Dbux Call Graph HostWrapper] client connected. - Starting host...
    [Dbux Call Graph] silenced postMessage after Host shutdown: [{"messageType":2,"componentId":32,"commandName":"_publicInternal.dispose","args":[],"callId":47},{"messageType":2,"componentId":31,"commandName":"_publicInternal.dispose","args":[],"callId":48},{"messageType":2,"componentId":30,"commandName":"_publicInternal.dispose","args":[],"callId":49},{"messageType":2,"componentId":29,"commandName":"_publicInternal.dispose","args":[],"callId":50},{"messageType":2,"componentId":28,"commandName":"_publicInternal.dispose","args":[],"callId":51},{"messageType":2,"componentId":27,"commandName":"_publicInternal.dispose","args":[],"callId":52},{"messageType":2,"componentId":26,"commandName":"_publicInternal.dispose","args":[],"callId":53},{"messageType":2,"componentId":25,"commandName":"_publicInternal.dispose","args":[],"callId":54},{"messageType":2,"componentId":24,"commandName":"_publicInternal.dispose","args":[],"callId":55},{"messageType":2,"componentId":23,"commandName":"_publicInternal.dispose","args":[],"callId":56},{"messageType":2,"componentId":22,"commandName":"_publicInternal.dispose","args":[],"callId":57},{"messageType":2,"componentId":21,"commandName":"_publicInternal.dispose","args":[],"callId":58},{"messageType":2,"componentId":20,"commandName":"_publicInternal.dispose","args":[],"callId":59},{"messageType":2,"componentId":19,"commandName":"_publicInternal.dispose","args":[],"callId":60},{"messageType":2,"componentId":18,"commandName":"_publicInternal.dispose","args":[],"callId":61},{"messageType":2,"componentId":17,"commandName":"_publicInternal.dispose","args":[],"callId":62},{"messageType":2,"componentId":16,"commandName":"_publicInternal.dispose","args":[],"callId":63},{"messageType":2,"componentId":15,"commandName":"_publicInternal.dispose","args":[],"callId":64},{"messageType":2,"componentId":14,"commandName":"_publicInternal.dispose","args":[],"callId":65},{"messageType":2,"componentId":13,"commandName":"_publicInternal.dispose","args":[],"callId":66},{"messageType":2,"componentId":12,"commandName":"_publicInternal.dispose","args":[],"callId":67},{"messageType":2,"componentId":11,"commandName":"_publicInternal.dispose","args":[],"callId":68},{"messageType":2,"componentId":10,"commandName":"_publicInternal.dispose","args":[],"callId":69},{"messageType":2,"componentId":9,"commandName":"_publicInternal.dispose","args":[],"callId":70},{"messageType":2,"componentId":8,"commandName":"_publicInternal.dispose","args":[],"callId":71},{"messageType":2,"componentId":7,"commandName":"_publicInternal.dispose","args":[],"callId":72},{"messageType":2,"componentId":6,"commandName":"_publicInternal.dispose","args":[],"callId":73},{"messageType":2,"componentId":5,"commandName":"_publicInternal.dispose","args":[],"callId":74},{"messageType":2,"componentId":4,"commandName":"_publicInternal.dispose","args":[],"callId":75},{"messageType":2,"componentId":33,"commandName":"_publicInternal.dispose","args":[],"callId":76},{"messageType":2,"componentId":3,"commandName":"_publicInternal.dispose","args":[],"callId":77},{"messageType":2,"componentId":2,"commandName":"_publicInternal.dispose","args":[],"callId":78},{"messageType":2,"componentId":1,"commandName":"_publicInternal.dispose","args":[],"callId":79}]
    [Dbux installUtil] Checking library dependencies. Found 0 missing: 
    [Dbux exec] > $ "node" --version
    [Dbux exec]   ("node" EXIT: code=0, signal=null)
    [Dbux checkSystem] checkSystem() result: Dbux requires the following programs to be installed and available on your system in order to run smoothly. Please make sure, you have all of them installed.
    
    ✓  shell
        found at "/bin/bash"
    ✓  node
        found at "/Users/dmaretskyi/.nodenv/shims/node" (v16.17.1 satisfies 16)
    ✓  npm
        found at "/Users/dmaretskyi/.nodenv/shims/npm"
    
    SUCCESS! All system dependencies seem to be in order.
    [Dbux net/listener] server listening on port :3374...
    [Dbux PracticeManager] getDbuxPath(), relativePath='@dbux/cli/dist/linkOwnDependencies.js', getDbuxRoot()='/Users/dmaretskyi/.vscode/extensions/domi.dbux-code-0.7.9', config={"dependencyRoot":"/Users/dmaretskyi/.vscode/extensions/domi.dbux-code-0.7.9","projectsRoot":"/Users/dmaretskyi/.vscode/extensions/domi.dbux-code-0.7.9/dbux_projects","samplesRoot":"/Users/dmaretskyi/.vscode/extensions/domi.dbux-code-0.7.9/samples","dbuxLanguage":"en"}
    [Dbux PracticeManager] getDbuxPath(), relativePath='@dbux/cli/bin/dbux.js', getDbuxRoot()='/Users/dmaretskyi/.vscode/extensions/domi.dbux-code-0.7.9', config={"dependencyRoot":"/Users/dmaretskyi/.vscode/extensions/domi.dbux-code-0.7.9","projectsRoot":"/Users/dmaretskyi/.vscode/extensions/domi.dbux-code-0.7.9/dbux_projects","samplesRoot":"/Users/dmaretskyi/.vscode/extensions/domi.dbux-code-0.7.9/samples","dbuxLanguage":"en"}
    

    Dbux Runtime (Console) Log

    The default interactive shell is now zsh.
    To update your account to use zsh, please run `chsh -s /bin/zsh`.
    For more details, please visit https://support.apple.com/kb/HT208050.
    "node" --enable-source-maps --stack-trace-limit=10bash-3.2$ "node" --enable-source-maps --stack-trace-limit=1000 --enable-source-maps -r /Users/dmaretskyi/.vscode/extensions/domi.dbux-code-0.7.9/node_modules/@dbux/cli/dist/linkOwnDependencies.js "/Users/dmaretskyi/.vscode/extensions/domi.dbux-code-0.7.9/node_modules/@dbux/cli/bin/dbux.js" run --esnext --pw=.* "/Users/dmaretskyi/.vscode/extensions/domi.LongestWordLength/for-bad.js" -- ting-started/find 
    [Dbux] run:  /Users/dmaretskyi/.nodenv/versions/16.17.1/bin/node /Users/dmaretskyi/.vscode/extensions/domi.dbux-code-0.7.9/dbux_projects/getting-started/findLongestWordLength/for-bad.js
    [Dbux] [moduleFilter] REGISTER ~/.vscode/extensions/domi.dbux-code-0.7.9/dbux_projects/getting-started/findLongestWordLength/for-bad.js (file)
    [@babel/register] cacheRoot=/Users/dmaretskyi/.vscode/extensions/domi.dbux-code-0.7.9/dbux_projects/getting-started, cacheDir=/Users/dmaretskyi/.vscode/extensions/domi.dbux-code-0.7.9/dbux_projects/getting-started/node_modules/.cache/@babel/register
    [@babel/register] Cache miss [FileModified] for "/Users/dmaretskyi/.vscode/extensions/domi.dbux-code-0.7.9/dbux_projects/getting-started/findLongestWordLength/for-bad.js"
    [@dbux/cli] command failed
      [Caused By] SyntaxError: Identifier '_class' has already been declared
        at Object.compileFunction (node:vm:360:18)
        ... 21 lines matching cause stack trace ...
        at node:internal/main/run_main_module:17:47 {
      name: 'NestedError',
      cause: SyntaxError: Identifier '_class' has already been declared
          at Object.compileFunction (node:vm:360:18)
          at wrapSafe (node:internal/modules/cjs/loader:1055:15)
          at Module._compile (node:internal/modules/cjs/loader:1090:27)
          at Module._compile (/Users/dmaretskyi/.vscode/extensions/domi.dbux-code-0.7.9/node_modules/pirates/lib/index.js:119:24)
          at Module._extensions..js (node:internal/modules/cjs/loader:1180:10)
          at Object.newLoader [as .js] (/Users/dmaretskyi/.vscode/extensions/domi.dbux-code-0.7.9/node_modules/pirates/lib/index.js:123:7)
          at Module.load (node:internal/modules/cjs/loader:1004:32)
          at Function.Module._load (node:internal/modules/cjs/loader:839:12)
          at Module.require (node:internal/modules/cjs/loader:1028:19)
          at require (node:internal/modules/cjs/helpers:102:18)
          at requireDynamic (/Users/dmaretskyi/.vscode/extensions/domi.dbux-code-0.7.9/node_modules/@dbux/cli/dist/commands/run.js:1:9685)
          at /Users/dmaretskyi/.vscode/extensions/domi.dbux-code-0.7.9/node_modules/@dbux/cli/dist/commands/run.js:1:7593
          at Object.handler (/Users/dmaretskyi/.vscode/extensions/domi.dbux-code-0.7.9/node_modules/@dbux/cli/dist/commands/run.js:1:8177)
          at Object.runCommand (/Users/dmaretskyi/.vscode/extensions/domi.dbux-code-0.7.9/node_modules/yargs/build/index.cjs:446:48)
          at Object.parseArgs [as _parseArgs] (/Users/dmaretskyi/.vscode/extensions/domi.dbux-code-0.7.9/node_modules/yargs/build/index.cjs:2697:57)
          at Object.get [as argv] (/Users/dmaretskyi/.vscode/extensions/domi.dbux-code-0.7.9/node_modules/yargs/build/index.cjs:2651:25)
          at Object.<anonymous> (/Users/dmaretskyi/.vscode/extensions/domi.dbux-code-0.7.9/node_modules/@dbux/cli/bin/dbux.js:22:3)
          at Module._compile (node:internal/modules/cjs/loader:1126:14)
          at Object.Module._extensions..js (node:internal/modules/cjs/loader:1180:10)
          at Module.load (node:internal/modules/cjs/loader:1004:32)
          at Function.Module._load (node:internal/modules/cjs/loader:839:12)
          at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)
          at node:internal/main/run_main_module:17:47
    }
    [@dbux/cli] waiting 20s for process to finish...
    exiting...
    Trace: [Dbux [@dbux/runtime]] NOTE: process.exit(-1) was called by the application.
        at E (/Users/dmaretskyi/.vscode/extensions/domi.dbux-code-0.7.9/node_modules/@dbux/runtime/dist/index-node.js:2:4345)
        at /Users/dmaretskyi/.vscode/extensions/domi.dbux-code-0.7.9/node_modules/@dbux/runtime/dist/index-node.js:2:3652
        at process.exit (/Users/dmaretskyi/.vscode/extensions/domi.dbux-code-0.7.9/node_modules/@dbux/runtime/dist/index-node.js:2:437447)
        at /Users/dmaretskyi/.vscode/extensions/domi.dbux-code-0.7.9/node_modules/@dbux/cli/dist/commands/run.js:1:8544
    [Dbux [@dbux/runtime]] Dbux is trying to delay shutdown (process.exit) by 60s...
    [Dbux [@dbux/runtime]] exiting now.

    Screenshots

    System (please complete the following information):

    • OS: macos
    • Dbux VSCode Extension version: 0.7.9
    • Affected Dbux Packages (+ version numbers):
      ➜  domi.dbux-code-0.7.9 npm list   
    dbux-code@0.7.9 /Users/dmaretskyi/.vscode/extensions/domi.dbux-code-0.7.9
    ├── @babel/plugin-proposal-class-properties@7.18.6
    ├── @dbux/babel-plugin@0.7.9
    ├── @dbux/cli@0.7.9
    ├── @dbux/common-node@0.7.9
    ├── @dbux/common@0.7.9
    ├── @dbux/data@0.7.9
    ├── @dbux/graph-common@0.7.9
    ├── @dbux/graph-host@0.7.9
    ├── @dbux/projects@0.7.9
    ├── @dbux/runtime@0.7.9
    ├── @types/glob@7.2.0
    ├── @types/node@16.18.40
    ├── @types/vscode@1.81.0
    ├── firebase@9.23.0
    ├── glob@7.2.3
    ├── i18next@19.9.2
    ├── lockfile@1.0.4
    ├── lodash@4.17.21
    ├── moment@2.29.4
    ├── nanoevents@2.0.0
    ├── open@7.4.2
    ├── serialize-javascript@5.0.1
    ├── socket.io@4.7.2
    ├── strip-ansi@7.1.0
    ├── strip-color@0.1.0
    ├── typescript@3.9.10
    ├── uuid@8.3.2
    ├── vsce@2.15.0
    └── vscode-test@1.6.1
    • "@babel/plugin-proposal-class-properties": "^7.18.6"

    • node 16

    Additional context

    After installing the vscode extension I was getting an error about @babel/plugin-proposal-class-properties package missing. So I've installed it manually in the tutorial excercises workspace:

    "@babel/plugin-proposal-class-properties": "^7.18.6"
dmaretskyi commented 1 year ago

I've also dumped the source after transformation with the dbux plugin:

var _defineProperty = require("@babel/runtime/helpers/defineProperty");
var _dbux = _dbux_init(
  (typeof __dbux__ !== "undefined" && __dbux__) || require("@dbux/runtime")
);
var _cid = _dbux.getProgramContextId();
var _al = _dbux.getArgLength,
  _af = _dbux.arrayFrom,
  _uot = _dbux.unitOfType,
  _diph = _dbux.DefaultInitializerPlaceholder,
  _pI = _dbux.pushImmediate,
  _pF = _dbux.popFunction,
  _pFI = _dbux.popFunctionInterruptable,
  _par = _dbux.registerParams,
  _tr = _dbux.traceReturn,
  _tra = _dbux.traceReturnAsync,
  _tt = _dbux.traceThrow,
  _tid = _dbux.newTraceId,
  _td = _dbux.traceDeclaration,
  _te = _dbux.traceExpression,
  _tev = _dbux.traceExpressionVar,
  _twv = _dbux.traceWriteVar,
  _tct = _dbux.traceCatch,
  _tctI = _dbux.traceCatchInterruptable,
  _tf = _dbux.traceFinally,
  _tfI = _dbux.traceFinallyInterruptable,
  _tme = _dbux.traceExpressionME,
  _tmeo = _dbux.traceExpressionMEOptional,
  _twme = _dbux.traceWriteME,
  _tdme = _dbux.traceDeleteME,
  _tue = _dbux.traceUpdateExpressionVar,
  _tume = _dbux.traceUpdateExpressionME,
  _bce = _dbux.traceBCE,
  _a = _dbux.traceArg,
  _tsa = _dbux.traceSpreadArg,
  _tcr = _dbux.traceCallResult,
  _tae = _dbux.traceArrayExpression,
  _toe = _dbux.traceObjectExpression,
  _tfi = _dbux.traceForIn,
  _tc = _dbux.traceClass,
  _ti = _dbux.traceInstance,
  _aw = _dbux.preAwait,
  _aw2 = _dbux.wrapAwait,
  _aw3 = _dbux.postAwait,
  _yi = _dbux.preYield,
  _yi2 = _dbux.wrapYield,
  _yi3 = _dbux.postYield,
  _tp = _dbux.tracePattern,
  _apu = _dbux.addPurpose;
try {
  var _class;
  var _t3_, _t4_;
  class _class {
    constructor() {
      _ti(this, (_t3_ = _tid(3)), []);
    }
  }
  _class = _class;
  _defineProperty(Foo, "_dbux_class", function () {
    _tc(_class, (_t4_ = _tid(4)), [], []);
  });
  _class._dbux_class(), delete _class._dbux_class;
  _dbux.t(5);
} finally {
  _dbux.popProgram();
}
function _dbux_init(dbuxRuntime) {
  if (!dbuxRuntime.initProgram) {
    throw new Error(
      '[@dbux/runtime] "initProgram" unavailable in "for-bad.js"'
    );
  }
  return dbuxRuntime.initProgram(
    {
      program: {
        _staticId: 1,
        loc: {
          start: { line: 1, column: 0, index: 0 },
          end: { line: 2, column: 0, index: 14 },
        },
        type: 1,
        name: "for-bad.js",
        displayName: "for-bad.js",
        fileName: "for-bad.js",
        filePath:
          "/Users/dmaretskyi/.vscode/extensions/domi.dbux-code-0.7.9/dbux_projects/getting-started/findLongestWordLength/for-bad.js",
        programIndex: 1,
      },
      contexts: [
        {
          _staticId: 1,
          loc: {
            start: { line: 1, column: 0, index: 0 },
            end: { line: 2, column: 0, index: 14 },
          },
          type: 1,
          name: "for-bad.js",
          displayName: "for-bad.js",
          fileName: "for-bad.js",
          filePath:
            "/Users/dmaretskyi/.vscode/extensions/domi.dbux-code-0.7.9/dbux_projects/getting-started/findLongestWordLength/for-bad.js",
          programIndex: 1,
        },
      ],
      traces: [
        {
          loc: {
            start: { line: 1, column: 0, index: 0 },
            end: { line: 1, column: 0, index: 0 },
          },
          _traceId: 1,
          _staticContextId: 1,
          type: 1,
        },
        {
          loc: {
            start: { line: 2, column: 0, index: 14 },
            end: { line: 2, column: 0, index: 14 },
          },
          _traceId: 2,
          _staticContextId: 1,
          type: 2,
        },
        {
          displayName: "{}",
          loc: {
            start: { line: 1, column: 10, index: 10 },
            end: { line: 1, column: 12, index: 12 },
          },
          _traceId: 3,
          _staticContextId: 1,
          type: 45,
          data: { privateMethods: [] },
          dataNode: { isNew: true },
        },
        {
          displayName: "class Foo {}",
          loc: {
            start: { line: 1, column: 0, index: 0 },
            end: { line: 1, column: 12, index: 12 },
          },
          _traceId: 4,
          _staticContextId: 1,
          type: 43,
          data: { name: "Foo", staticMethods: [], publicMethods: [] },
          dataNode: { isNew: true },
        },
        {
          loc: {
            start: { line: 2, column: 0, index: 14 },
            end: { line: 2, column: 0, index: 14 },
          },
          _traceId: 5,
          _staticContextId: 1,
          type: 22,
        },
      ],
      loops: [],
    },
    {}
  );
}
dmaretskyi commented 1 year ago

Elimiminating the usage of @babel/plugin-proposal-class-properties seems to fix the issue for me