Skip to content

Commit 19c724e

Browse files
committed
Scope.cloneForTermReference
1 parent f75b9dd commit 19c724e

File tree

2 files changed

+14
-8
lines changed

2 files changed

+14
-8
lines changed

fluent/src/resolver.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -191,9 +191,9 @@ function TermReference(scope, {name, attr, args}) {
191191
return new FluentNone(id);
192192
}
193193

194-
// Every TermReference has its own args.
195-
const [, keyargs] = getArguments(scope, args);
196-
const local = scope.clone(keyargs);
194+
// Every TermReference has its own variables.
195+
const [, params] = getArguments(scope, args);
196+
const local = scope.cloneForTermReference(params);
197197

198198
if (attr) {
199199
const attribute = term.attributes[attr];

fluent/src/scope.js

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,22 @@
11
export default class Scope {
2-
constructor(bundle, errors, args,
3-
insideTermReference = false, dirty = new WeakSet()
2+
constructor(
3+
bundle,
4+
errors,
5+
args,
6+
insideTermReference = false,
7+
dirty = new WeakSet()
48
) {
59
this.bundle = bundle;
610
this.errors = errors;
711
this.args = args;
8-
this.dirty = dirty;
9-
// TermReferences are resolved in a new scope.
12+
13+
// Term references require different variable lookup logic.
1014
this.insideTermReference = insideTermReference;
15+
// Keeps track of visited Patterns. Used to detect cyclic references.
16+
this.dirty = dirty;
1117
}
1218

13-
clone(args) {
19+
cloneForTermReference(args) {
1420
return new Scope(this.bundle, this.errors, args, true, this.dirty);
1521
}
1622

0 commit comments

Comments
 (0)