Skip to content
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

Is it expected a "+" sign in an object's key field to be translated into a function? #1120

Open
ceremcem opened this issue Jul 3, 2022 · 4 comments

Comments

@ceremcem
Copy link

ceremcem commented Jul 3, 2022

Is this behavior expected:

a = 
  +: "x"
  -: "y"
a = [
  +(function(){
    _: return "x";
  }()), -(function(){
    _: return "y";
  }())
];

I would definitely expect the following output:

a = {
  "+": "x",
  "-": "y"
};
@ceremcem ceremcem changed the title Is it expected transiling a "+" sign in an object's key field into a function? Is it expected a "+" sign in an object's key field to be translated into a function? Nov 25, 2022
@fatherofinvention
Copy link

Isn't LiveScript dead now? It hasn't had a release in over 2.5 years at this point.

@vendethiel
Copy link
Contributor

Definitely.
For the issue at hand, I don't think you can really expect to be able to use operators as object keys.
What you wrote is basically

a = 
  +(: "x")
  -(: "y")

@ceremcem
Copy link
Author

Thanks. Shouldn't this behavior changed? Why would somebody use an operator as an operator while defining an object?

@vendethiel
Copy link
Contributor

vendethiel commented May 18, 2023

Why would somebody use an operator as an operator while defining an object?

You're not defining an object, you're defining an array, like this:

a =
  1
  2

The fact that you can treat a label as an expression is definitely a bit weird, but it's not only in this case:

$ lsc -bce '+:1'
+(function(){
  _: return 1;
}());

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants