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
  • #376
Closed
Open
Issue created Aug 13, 2014 by Administrator@rootContributor

throwSyntaxError failed to report position if the macro is invoked in the first line

Created by: hax

Test case:

macro.sjs:

macro TEST {
    case { $name } => {
        throwSyntaxError('TestError', 'test error', #{ $name })
    }
}
export TEST

test.sjs:

TEST

(NOTE: if add a blank line before 'TEST', everything is ok)

sjs -m ./macro test.sjs

Expect:

/Users/hax/sweet.js/lib/sweet.js:99
                    throw new SyntaxError(syn.printSyntaxError(source$2, err))
                          ^
SyntaxError: [TestError] test error
1: TEST
   ^
    at expand$2 (/Users/hax/sweet.js/lib/sweet.js:99:27)
    at parse (/Users/hax/sweet.js/lib/sweet.js:135:29)
    at Object.compile (/Users/hax/sweet.js/lib/sweet.js:143:19)
    at Object.exports.run (/Users/hax/sweet.js/lib/sjs.js:85:27)
    at Object.<anonymous> (/Users/hax/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:349:32)
    at Function.Module._load (module.js:305:12)
    at Function.Module.runMain (module.js:490:10)

Actual:

/Users/hax/sweet.js/lib/syntax.js:346
name + '] ' + err.message + '\n' + pre + line + '\n' + Array(offset + pre.leng
                                                                    ^
RangeError: Invalid array length
    at Object.printSyntaxError (/Users/hax/sweet.js/lib/syntax.js:346:94)
    at expand$2 (/Users/hax/sweet.js/lib/sweet.js:99:47)
    at parse (/Users/hax/sweet.js/lib/sweet.js:135:29)
    at Object.compile (/Users/hax/sweet.js/lib/sweet.js:143:19)
    at Object.exports.run (/Users/hax/sweet.js/lib/sjs.js:85:27)
    at Object.<anonymous> (/Users/hax/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:349:32)
    at Function.Module._load (module.js:305:12)
Assignee
Assign to
Time tracking