google / abstracttext

MediaWiki extension to handle multilingual abstract content
Apache License 2.0
78 stars 10 forks source link

value(true) and value(false) produce errors #21

Closed lucaswerkmeister closed 4 years ago

lucaswerkmeister commented 4 years ago

I assumed that value(true) and value(false) would return their argument, but they produce key_not_found errors instead:

$ node eneyj/src/eneyj.js 
eneyj v0.1.0
language is set to English
Enter .help for help
> value(true)
{
  "Z1K1": "Z15",
  "Z1K2": "Z443",
  "Z1K3": {
    "Z1K1": "Z12",
    "Z12K1": [
      {
        "Z1K1": "Z11",
        "Z11K1": "Z251",
        "Z11K2": "key_not_found"
      }
    ]
  }
}

> value(false)
{
  "Z1K1": "Z15",
  "Z1K2": "Z443",
  "Z1K3": {
    "Z1K1": "Z12",
    "Z12K1": [
      {
        "Z1K1": "Z11",
        "Z11K1": "Z251",
        "Z11K2": "key_not_found"
      }
    ]
  }
}

I noticed this when I was implementing “if” in GraalEneyj, figured that if(value(true), "then", "else") would be a nice test case of a non-constant reference condition, and was surprised to find that eneyj produced "else" rather than "then" as I expected:

> {"Z1K1": "Z7", "Z7K1": "Z31", "K1": {"Z1K1": "Z7", "Z7K1": "Z36", "K1": "Z54"}, "K2": "then", "K3": "else"}
else
vrandezo commented 4 years ago

Yes, can reproduce. I think it's a bug in the implementation of value. Will look at.

vrandezo commented 4 years ago

Thanks for reporting!