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

Lexer: “unexpected indentation” with yield followed by implicit object #5054

Closed
izotos opened this issue May 5, 2018 · 4 comments
Closed
Labels

Comments

@izotos
Copy link

izotos commented May 5, 2018

Possible bug or unintended behavior:

gen = ->
    yield
      k: 'v'

/#try link

Expected Behavior

Compile same as:

gen = ->
    yield k: 'v'
# or
gen = ->
    yield {
        k: 'v'
    }

Current Behavior

Gives compile error:

[stdin]:3:1: error: unexpected indentation
      k: 'v'
^^^^^^

Context

I was expecting to use yield same as functions and statements like return or throw. This type of syntax is quite handy when returning multi key objects.

Environment

  • CoffeeScript version: 2.3.0
  • Node.js version: 8.4.0
@GeoffreyBooth
Copy link
Collaborator

Related to #4532 most directly, and also #4783 and #4599 and #4605. @helixbass any thoughts?

@GeoffreyBooth GeoffreyBooth changed the title Unexpected compile error unexpected indentation when yielding Lexer: “unexpected indentation” with yield followed by implicit object May 22, 2018
@helixbass
Copy link
Collaborator

@GeoffreyBooth yup makes sense to me that yield would follow the same pattern as return/throw/export default, opened #5072

@GeoffreyBooth
Copy link
Collaborator

Well that was fast. Does it make any sense to do the same for await? Not sure when you’d be awaiting an object, but it feels like the syntax should be the same for yield, await, throw, return etc.

@helixbass
Copy link
Collaborator

@GeoffreyBooth ya agreed I'm not sure if you'd ever await an object, but no harm allowing it syntactically, updated #5072

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

No branches or pull requests

3 participants