-
Notifications
You must be signed in to change notification settings - Fork 159
Closed
Description
Experimenting with some very simple custom function examples, I'm getting a surprising error:
$ node --trace-warnings min.js
{�}
(node:50144) TypeError: Invalid value used in weak set
at WeakSet.add (<anonymous>)
at lookupVariableRef (/home/tjc/.nvm/versions/node/v22.2.0/lib/node_modules/messageformat/lib/data-model/resolve-variable.js:63:23)
at resolveVariableRef (/home/tjc/.nvm/versions/node/v22.2.0/lib/node_modules/messageformat/lib/data-model/resolve-variable.js:71:19)
at resolveExpression (/home/tjc/.nvm/versions/node/v22.2.0/lib/node_modules/messageformat/lib/data-model/resolve-expression.js:18:65)
at MessageFormat.format (/home/tjc/.nvm/versions/node/v22.2.0/lib/node_modules/messageformat/lib/messageformat.js:55:72)
at Object.<anonymous> (/home/tjc/messageformat-scratch/min.js:23:19)
at Module._compile (node:internal/modules/cjs/loader:1434:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1518:10)
at Module.load (node:internal/modules/cjs/loader:1249:32)
at Module._load (node:internal/modules/cjs/loader:1065:12)
$ node --version
v22.2.0
The contents of min.js are:
const messageformat = require('messageformat')
function adjective(locales, options, value) {
return "a word";
}
const message = ".local $color = {orange :adjective} \
{{{$color}}} \
"
mf = new messageformat.MessageFormat(message, 'en', { functions : { adjective } } )
const result = mf.format();
console.log(result);
The definition of the function adjective() is not correct, since it returns a string instead of an object that has (at least) a toString() method. However, I would expect a different error message.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels