question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Example does not run

See original GitHub issue

First example:

fn fib n:
  if n < 2:  n
      else: (n - 1 -> fib) +
            (n - 2 -> fib)

[0:10] -> * fib -> print
$ clio run eg.clio 

 At file "eg.clio" when calling print:

   4 │             (n - 2 -> fib)
   5 │ 
   6 │ [0:10] -> * fib -> print
                          ^ At line 6 char 19

 Exception: BigInt is not defined

Installed as in instruction: npm i -g clio-lang

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:12 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
pouya-eghbalicommented, Apr 29, 2019

Ranges are lazy in Clio, here’s why it prints [object Object] (it shouldn’t, i’ll fix it soon):

  1. [0:10] compiles to
LazyRange({
    start: 0,
    end: 10,
    step: 1,
    get: (i, self) => self.start + self.step * i
})
  1. When you map fib to this LazyRange object it becomes:
LazyRange({
    start: 0,
    end: 10,
    step: 1,
    get: (i, self) => fib(self.start + self.step * i)
})
  1. When you call print on this object, it outputs [object Object] because it is an object. However if you map print to it, it will print the contents correctly. Anyways this isn’t the correct behavior and should be fixed, I’ll look into it, as I said I’m a little busy with the new parser and when I finish I will have more time to fix these issues.

I’m afraid most of these will need rewriting so I prefer if I don’t touch the current built-ins / definitions. Also, thanks for testing Clio and reporting the bugs, makes me happy to see people are interested, hopefully we’ll be able to use Clio in production soon, I have lots of plans for this language.

1reaction
fuzzthinkcommented, Apr 29, 2019

Ah, issue was node was v8.15.0. Works with node v10.14.

But why output is [object Object] when output in online editor prints the array?

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to not run an example using roxygen2? - Stack Overflow
I'm writing a geocoding function right now that relies on having a Bing Maps Key. Obviously I'd rather not publish mine, and the...
Read more >
What to do if your program doesn't run
What to do if your program doesn't run · 1. Look at your output! · 2. Run your compiler with warning messages and...
Read more >
Examples not running | Sololearn: Learn to code for FREE!
When i'm trying to run the given example codes (not the pro ones), it says i have to pay for it. But my...
Read more >
cargo test does not run tests in examples · Issue #6831 - GitHub
The tests can currently be run by calling cargo test --example foo , so this should not be that complicated to implement.
Read more >
Visual Studio Code Frequently Asked Questions
Not only do we write code and work on issues there, we also publish our roadmap ... (for example, the VS Code icon...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found