clio-lang / clio

Clio is a functional, parallel, distributed programming language.
https://clio-lang.org
Apache License 2.0
936 stars 30 forks source link

Branching code in tutorial does not compile #213

Closed Ivo-Balbaert closed 3 years ago

Ivo-Balbaert commented 3 years ago

Describe the bug

The following branching code does not compile:

fn add a b:
  a + b

fn mul a b:
  a * b

export fn main argv:
  [1 2 3] -> *
    add 1 -> console.log
    mul 2 -> console.log

To Reproduce Executing this code with the Playground link on the page gives the error:

[Error: Parsing error at main.clio[4:0]

fn add a b: a + b

fn mul a b: ^

Expecting one of eof, clio but encountered function]

Same error on Windows 10 (clio 0.7.0, node 14.16.1 npm 6.14.12). clio run
Info: Creating build for node

fn add a b: a + b

fn mul a b: ^

Expecting one of eof, clio but encountered function

Same error on Ubuntu 20

Expected behavior Program should compile and print out: [2 3 4] [4 6 8]

**Versions

Additional context The 2nd branching example also does not compile:

fn add a b:
  a + b

fn mul a b:
  a * b

export fn main argv:
  [1 2 3]
    -> *
      add 2
      mul 3
    -> console.log

The compile error is: [Error: Inconsistent indentation] It occurs on the same platforms

pouya-eghbali commented 3 years ago

I removed branching in 0.6 release, it made the compiler unnecessarily complicated. I think this is a very nice feature, but it isn't worth it, as it adds a lot of ambiguity to the code. The same goes for the await blocks that you reported on Telegram.

If you check the documentation for v0.6 these changes are reflected in the documentation, however for some reason they're not in v0.7 documentation. Looks like I forked the wrong documentation version for 0.7, I will fix the docs with 0.8 release.

pouya-eghbali commented 3 years ago

Fixed in 0.8, already in production. Thanks for reporting!

Ivo-Balbaert commented 3 years ago

In the current documentation the branching section is still present:

branching