Skip to content

Lambda scopes are broken #37

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

Closed
ghost opened this issue Apr 15, 2017 · 4 comments
Closed

Lambda scopes are broken #37

ghost opened this issue Apr 15, 2017 · 4 comments
Labels

Comments

@ghost
Copy link

ghost commented Apr 15, 2017

Repro code:

#import "fmt.odin";

main :: proc()
{
  using fmt;

  x := 0;

  Q_rsqrt_v2 := proc(num: f32) -> f32 {
    x := num * 0.5;
    y := num;
    i := transmute(i32)y;
    i = 0x5f3759df - i >> 1;
    y = transmute(f32)i;
    y *= 1.5 - x * y * y;
    return y;
  };

  printf("%v\n", Q_rsqrt_v2(2));
}

Generates errors:

main.odin(10:3) Redeclaration of `x` in this scope at main.odin(7:2)
main.odin(10:8) Undeclared name: num
main.odin(11:8) Undeclared name: num
main.odin(13:3) Assignment count mismatch `1` = `0`
main.odin(14:3) Assignment count mismatch `1` = `0`

Change Q_rsqrt_v2 := to Q_rsqrt_v2 :: and it works as it should.

@gingerBill
Copy link
Member

Fixed!

@ghost
Copy link
Author

ghost commented Apr 16, 2017

@gingerBill Can confirm! Thank you! 👍

@gingerBill
Copy link
Member

It was a scoping and declaration issue that I didn't handle correctly.

@ghost
Copy link
Author

ghost commented Apr 16, 2017

@gingerBill btw, feel free to change my issue's titles if they not reflect actual problems :)

@gingerBill gingerBill changed the title Lambdas are currently broken Lambda scopes are broken Apr 16, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant