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
  • #760
Closed
Open
Issue created Nov 28, 2019 by Heather Soron Kaminski@HeatherSoron

Variable binding (hygiene, gensym) not working in 2-level macros

Variable binding in a 2-layer macro (i.e., a macro that calls another macro) is broken, in several cases I've tested.

Here's a fairly simple one (simpler than what I was using, but still clearly demonstrates the problem):

syntax shallow = function(ctx) {
    let name = ctx.next().value
    let val = ctx.next().value
    return #`let ${name} = ${val}`
}

syntax deep = function(ctx) {
    let name = ctx.next().value
    return #`shallow ${name} 42`
}

shallow foo 42
deep bar

console.log(foo)
console.log(bar)

This should result in the value "42" being printed twice to stdout, but will actually result in a ReferenceError on the second console.log. The reason for this, is that Sweet.js expands it to the following code:

let foo_13 = 42;
let bar_14 = 42;
console.log(foo_13);
console.log(bar);

That deep bar appears to be misbehaving, as the identifier bar is not picked up later on, during the console.log(bar) call.

Assignee
Assign to
Time tracking