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

KCL parser should allow if expr after |> #4335

Open
adamchalmers opened this issue Oct 28, 2024 · 2 comments
Open

KCL parser should allow if expr after |> #4335

adamchalmers opened this issue Oct 28, 2024 · 2 comments
Labels
ast Issues / features relevant to ast and parser. kcl Language and compiler features

Comments

@adamchalmers
Copy link
Collaborator

adamchalmers commented Oct 28, 2024

This KCL program parses:

fn f = (i) =>  { return i + 1}

0 |> f(%)

This equivalent program doesn't:

fn f = (i) =>  { return i + 1}

- 0 |> f(%)
+ 0 |> if true {
+   f(%)
+ } else {
+   f(%)
+ }

Because the parser defines a pipeline expression as some expression followed by 1 or more CallExpression, and in the second example, it's followed by an IfExpression. Clearly the pipeline expression parser should allow this too.

Thanks @lf94 for leading me to this.

@adamchalmers adamchalmers added ast Issues / features relevant to ast and parser. kcl Language and compiler features labels Oct 28, 2024
@guptaarnav
Copy link
Collaborator

I think an IfExpression should be a valid expression in a pipeline expression if each clause (not including the conditional) is a CallExpression. Should this be more permissive such that a valid IfExpression in a pipeline expression is one where each clause (not including the conditional) is an expression that contains substitution operator?

@jtran
Copy link
Collaborator

jtran commented Nov 3, 2024

This might not be compatible with the new proposal KittyCAD/kcl-experiments#15.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ast Issues / features relevant to ast and parser. kcl Language and compiler features
Projects
None yet
Development

No branches or pull requests

3 participants