Skip to content

Use of labels causes crash #14

@mattcarabine

Description

@mattcarabine

The following input program will cause Kami to crash:

foo:
   for (i=0; i<10; i++){
    if (i===4){
      break foo;
    }
  }

Output:

$ ./bin/unused test.js
TypeError: handlers[node.type] is not a function
    at exec (/Users/matt/Downloads/node-unused/index.js:35:28)
    at /Users/matt/Downloads/node-unused/index.js:245:9
    at Array.forEach (<anonymous>)
    at unused (/Users/matt/Downloads/node-unused/index.js:244:10)
    at /Users/matt/Downloads/node-unused/bin/unused:38:27
    at Array.forEach (<anonymous>)
    at Object.<anonymous> (/Users/matt/Downloads/node-unused/bin/unused:35:8)
    at Module._compile (internal/modules/cjs/loader.js:721:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:732:10)
    at Module.load (internal/modules/cjs/loader.js:620:32)

This is because LabeledStatements are not handled, see the parsed output from Prisma on http://esprima.org/demo/parse.html for this program.

The fix is to instead handle LabeledStatements within index.js.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions