Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • S sweet-core
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 62
    • Issues 62
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 4
    • Merge requests 4
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • sweet-js
  • sweet-core
  • Issues
  • #48
Closed
Open
Issue created Oct 30, 2012 by Administrator@rootContributor

A particular case overshadows other cases

Created by: sergi

Compiling the following macro

macro val {
    case $var:ident = $expr => {
        var $var = $expr
    }

    case $var:ident = $x:lit .. $y:lit => {
        var $var = (function() {
            var arr = []
            for (var i = $x; i < $y; i++)
                arr.push(i)
            return arr
        })();
    }
}

// This snippet below doesn't match
val a = 10;
console.log(a);

// This works nicely
val r = 10 .. 25
console.log(r)

produces the error:

/usr/local/lib/node_modules/sweet.js/lib/sweet.js:189
            throw new Error('ASSERT: ' + message);
                  ^
Error: ASSERT: no macro cases matched
    at assert (/usr/local/lib/node_modules/sweet.js/lib/sweet.js:189:19)
    at Object.macroCases [as transformer] (/usr/local/lib/node_modules/sweet.js/lib/sweet.js:4352:13)
    at expand (/usr/local/lib/node_modules/sweet.js/lib/sweet.js:4666:53)
    at Object.parse (/usr/local/lib/node_modules/sweet.js/lib/sweet.js:5077:32)
    at Object.exports.run (/usr/local/lib/node_modules/sweet.js/lib/sjs.js:19:55)
    at Object.<anonymous> (/usr/local/lib/node_modules/sweet.js/bin/sjs:7:23)
    at Module._compile (module.js:449:26)
    at Object.Module._extensions..js (module.js:467:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)

It looks like the case

case $var:ident = $x:lit .. $y:lit => {
        var $var = (function() {
            var arr = []
            for (var i = $x; i < $y; i++)
                arr.push(i)
            return arr
        })();
    }

is somehow overshadowing any other cases in the macro.

Assignee
Assign to
Time tracking