cognate icon indicating copy to clipboard operation
cognate copied to clipboard

compiler crash

Open 404Dev-404 opened this issue 7 months ago • 4 comments
trafficstars

i was reading the tutorial at https://cognate-lang.github.io/learn/ and tried to compile the code:

Let Even? (Zero? Modulo 2);
Let Evens Filter (Even?) Range 1 100;
Print Evens;

(literally just one of the examples without the lowercase words)

and got an error:

➜  ~ cognac test.cog && ./test
           ______                        ______
          / ____/___  ____ _____  ____ _/ ____/
         / /   / __ \/ __ `/ __ \/ __ `/ /
        / /___/ /_/ / /_/ / / / / /_/ / /___
        \____/\____/\__, /_/ /_/\__,_/\____/
                   /____/
                          Cognate Compiler



          ___  _
         / _ \| |__    _ __   ___
        | | | | '_ \  | '_ \ / _ \
        | |_| | | | | | | | | (_) |
         \___/|_| |_| |_| |_|\___/

        ERROR ERROR ERROR ERROR ERROR ERROR ERROR ERROR

        The compiler has reached an unreachable state!
        This error is my fault not yours, so give
        yourself a pat on the back for finding a bug
        in the compiler - then submit a bug report!

        To make this easier, I'm including a handy
        backtrace:

cognac(+0x63ad) [0x60d213f263ad]
cognac(push_register_front+0x37) [0x60d213f27341]
cognac(shorten_references+0x3f) [0x60d213f2746f]
cognac(main+0x136) [0x60d213f2d3cf]
/usr/lib/libc.so.6(+0x27488) [0x785777c02488]
/usr/lib/libc.so.6(__libc_start_main+0x8c) [0x785777c0254c]
cognac(_start+0x25) [0x60d213f243a5]


^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^Cc[1]    269180 IOT instruction (core dumped)  cognac test.cog

(the ^Cs are from me trying to quit the compiler)

im running Arch Linux on kernel 6.13.8-zen1-1-zen

404Dev-404 avatar Apr 06 '25 00:04 404Dev-404

Hello! I can't speak for the compiler error, but I just noticed the code in the example has a slight typo.Even? is already a block, and so the code should be:

Let Even? be (Zero? Modulo 2);
Let Evens be Filter Even? over Range 1 to 100;
Print Evens;

Tested on the JavaScript implementation with the online playground.

hedyhli avatar Apr 06 '25 01:04 hedyhli

the tutorial (https://cognate-lang.github.io/learn/) puts parentheses around Even? Image

404Dev-404 avatar Apr 06 '25 04:04 404Dev-404

Right, I meant to say the code in the tutorial might be in error.

hedyhli avatar Apr 06 '25 04:04 hedyhli

Ah of course this is in shorten_references. I've fixed the example on the website, and I'll try and patch the compiler in the next few weeks.

StavromulaBeta avatar Apr 26 '25 11:04 StavromulaBeta