-
-
Notifications
You must be signed in to change notification settings - Fork 16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Memoize lookup in parse is producing false positives #6
Comments
I suppose the memoization could perhaps work differently as well, avoiding nesting and instead using the key as a concrete property (i.e changing the way the utils work), but as I lack the context I might be missing something on why the memoize memory needs to be a deep object. Performance-wise it might actually be better to have a flat object. It also raises a question about keys that contain |
how can you have 2 keys fc = utils.getPath(this.mem, would you like to provide a PR? |
Yes, I have configured |
This issue relates to the use of memoization in this code: https://github.com/i18next/i18next-icu/blob/master/src/index.js#L47-L59
Namely, given two strings with the following keys,
foo.bar.baz
andfoo.bar
, if parse happens to run first forfoo.bar.baz
, the later lookup forfoo.bar
will produce a false positive (the check on line 54 is truthy, eventhough this particular key has not yet been memoized), which leads to an error at line 58 (fc.format is undefined and not a function).Likely it would be enough to swap the simple truthy check with something a bit more accurate (such as
!fc && typeof fc.format === 'fuction'
).Until then, the only real workaround (without changing keys) is to disable memoization (which is an overhead). Please let me know if you need further details, I can file a PR if needed.
The text was updated successfully, but these errors were encountered: