Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Update parser to allow for inline conditional returns #12

@alexdovzhanyn

Description

@alexdovzhanyn

Currently if you try to write a conditional such as:

if (someCondition) return 'hello'

the compiler will throw a ParseError because it expects to find a block or an expression after the condition, but return is currently not being treated as an "expression". Let's change the parsing for conditional nodes, to allow for returns.

  • Update the parser to make returns work as the expression (for if, else if, and else)
  • Write a test to validate that the return keyword works in a single-line conditional with no curly braces

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestgood first issueGood for newcomershacktoberfestA good issue to work on for Hacktoberfesthelp wantedExtra attention is needed

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions