Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 2 additions & 5 deletions fluent-bundle/src/resolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -154,15 +154,12 @@ function resolveVariableReference(
let arg: FluentVariable;
if (scope.params) {
// We're inside a TermReference. It's OK to reference undefined parameters.
if (Object.prototype.hasOwnProperty.call(scope.params, name)) {
if (name in scope.params) {
arg = scope.params[name];
} else {
return new FluentNone(`$${name}`);
}
} else if (
scope.args &&
Object.prototype.hasOwnProperty.call(scope.args, name)
) {
} else if (scope.args && name in scope.args) {
// We're in the top-level Pattern or inside a MessageReference. Missing
// variables references produce ReferenceErrors.
arg = scope.args[name];
Expand Down
14 changes: 7 additions & 7 deletions fluent-bundle/test/object_prototype_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ suite("Interesting Object properties", function () {
const val = bundle.formatPattern(msg.value, {}, errs);
assert.strictEqual(val, "{$constructor}");
assert.strictEqual(errs.length, 1);
assert(errs[0] instanceof ReferenceError); // unknown variable
assert(errs[0] instanceof TypeError); // variable type not supported
});

test("empty args with null prototype", function () {
Expand Down Expand Up @@ -60,7 +60,7 @@ suite("Interesting Object properties", function () {
const val = bundle.formatPattern(msg.value, {}, errs);
assert.strictEqual(val, "{$hasOwnProperty}");
assert.strictEqual(errs.length, 1);
assert(errs[0] instanceof ReferenceError); // unknown variable
assert(errs[0] instanceof TypeError); // variable type not supported
});

test("empty args with null prototype", function () {
Expand Down Expand Up @@ -94,7 +94,7 @@ suite("Interesting Object properties", function () {
const val = bundle.formatPattern(msg.value, {}, errs);
assert.strictEqual(val, "{$isPrototypeOf}");
assert.strictEqual(errs.length, 1);
assert(errs[0] instanceof ReferenceError); // unknown variable
assert(errs[0] instanceof TypeError); // variable type not supported
});

test("empty args with null prototype", function () {
Expand Down Expand Up @@ -128,7 +128,7 @@ suite("Interesting Object properties", function () {
const val = bundle.formatPattern(msg.value, {}, errs);
assert.strictEqual(val, "{$propertyIsEnumerable}");
assert.strictEqual(errs.length, 1);
assert(errs[0] instanceof ReferenceError); // unknown variable
assert(errs[0] instanceof TypeError); // variable type not supported
});

test("empty args with null prototype", function () {
Expand Down Expand Up @@ -166,7 +166,7 @@ suite("Interesting Object properties", function () {
const val = bundle.formatPattern(msg.value, {}, errs);
assert.strictEqual(val, "{$toLocaleString}");
assert.strictEqual(errs.length, 1);
assert(errs[0] instanceof ReferenceError); // unknown variable
assert(errs[0] instanceof TypeError); // variable type not supported
});

test("empty args with null prototype", function () {
Expand Down Expand Up @@ -200,7 +200,7 @@ suite("Interesting Object properties", function () {
const val = bundle.formatPattern(msg.value, {}, errs);
assert.strictEqual(val, "{$toString}");
assert.strictEqual(errs.length, 1);
assert(errs[0] instanceof ReferenceError); // unknown variable
assert(errs[0] instanceof TypeError); // variable type not supported
});

test("empty args with null prototype", function () {
Expand Down Expand Up @@ -234,7 +234,7 @@ suite("Interesting Object properties", function () {
const val = bundle.formatPattern(msg.value, {}, errs);
assert.strictEqual(val, "{$valueOf}");
assert.strictEqual(errs.length, 1);
assert(errs[0] instanceof ReferenceError); // unknown variable
assert(errs[0] instanceof TypeError); // variable type not supported
});

test("empty args with null property", function () {
Expand Down