Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [golo-dev] Compiler hangs when assigning value to uninitialized variable in if block

Hello Vincent, and thank you for using Golo and for the promotion :)

I indeed reproduce the behavior on my linux box with the snapshot
version, so nothing local to your configuration.

Actually, only declaring a non-initialized `var` is enough:

    module Test

    function main = |args| {
      var t
    }

will hang, which is definitely NOT the right behavior :)
Either a syntax error or a implicit `null` initialization would be fine.
Since I think that explicit is better than implicit, I would rather a
syntax error.

I think the problem is in the parser since even
`golo diagnose --stage ast` hangs.

Would you mind opening a issue in github?

BTW, I know it's just a toy function, but a more “golo-ish” version would be:

    var test = match {
      when args: size() > 0 then 1
      otherwise 2
    }

or even a `let` if you don't change the value later (which I recommend
;)


Thanks again for your interest in Golo!

Regards

Yannick

vincent van der leun (2016-10-10 23:34):
>          Hello,
> 
> 
> I've been fascinated by Golo ever since reading about it in Oracle Java Magazine some time ago. I've played around with it for awhile and tweeted multiple times about the language to do some little promotion.
> 
> Now the time's come to try to write my first "real" application in Golo, I'm creating a simple Spark-java webservice powered by Golo and both having fun and learning a lot while doing this.
> 
>  
> As I'm still learning the language, I make some silly noob mistakes.
> 
>  
> I think I managed to crash the compiler (assuming it is not Kaspersky virus scanner yet again that causes problems...). This snippet reproduces the problem:
> 
>  
> module bla
> 
> function main = |args| { var test if args:size() > 0 { test = 1 } else { test = 2 }
> 
> }
> 
>  
> The "golo compile test.golo" command hangs on my Windows 10 desktop computer, running Golo 3.2.0-M4  i.e. it seems to be stuck in an infinite loop.
> 
>  
> It's obvious that I should have RTFM and assigned a value to "test" when declaring it, which indeed solves the crash, but I assume the compiler should not hang when I forget to do that, right?
> 
>  
> Best regards and keep up the good work,
> 
> Vincent
> 
>  

> _______________________________________________
> golo-dev mailing list
> golo-dev@xxxxxxxxxxx
> To change your delivery options, retrieve your password, or unsubscribe from this list, visit
> https://dev.eclipse.org/mailman/listinfo/golo-dev



Back to the top