Skip to content

Variable scope differs between messages and terms #372

Open
@eemeli

Description

@eemeli

I find it surprising that this happens (playground link):

const bundle = new FluentBundle('en-US', { useIsolating: false })
bundle.addMessages(ftl`
  msg = { $foo ->
    [foo] FOO
   *[other] BAR
  }
  -term = { $foo ->
    [foo] FOO
   *[other] BAR
  }
  test = {msg} {-term}
`)
const test = bundle.getMessage('test')
bundle.format(test, { foo: 'foo' }) // 'FOO BAR'

Essentially, it looks like the argument scope is handled differently by {msg} and {-term} references, with the former getting access to the parent scope, and the latter not. Is this a part of the spec, or a bug in the JS implementation? In either case, it might be better if both of these worked the same way -- preferably as messages currently do.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions