Skip to content
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

Codegen does not support true globals #142

Open
eldesh opened this issue Oct 13, 2022 · 1 comment
Open

Codegen does not support true globals #142

eldesh opened this issue Oct 13, 2022 · 1 comment
Labels
crash An internal compiler error or (compiler) runtime crash panic A panic within the compiler

Comments

@eldesh
Copy link

eldesh commented Oct 13, 2022

I found an issue it seems to be a compiler bug.
A typing error is raised from the compiler for the following code.

Environment

  • os: debian
  • ante: 0.1.1 (commit: 139cf8c)

Code

s : u32 = 8

g () =
  Range 0 s

g ()

Error

$ ante main.an
thread 'main' panicked at '- inst1 (v2, v3 = call fn0(v1, v0)): arg 1 (v0) has type i8, expected i32
', src/cranelift_backend/context.rs:193:13
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
@jfecher jfecher added panic A panic within the compiler crash An internal compiler error or (compiler) runtime crash labels Oct 13, 2022
@jfecher jfecher changed the title Typing to Range fails Incorrect defaulting to i8 during codegen Oct 13, 2022
@jfecher
Copy link
Owner

jfecher commented Oct 13, 2022

Thank you, looks like this is a codegen error translating an incorrect type for Range : i32 - i8 -> Range rather than i32 - i32 -> Range. Interestingly, it only fails in the cranelift pass (running with --backend llvm works) so it may be local to there.
Nevermind - this is from the lack of globals in the current codegen pass. In the future ante may need another design pass on how top-down evaluation is performed as a script and yet still allows use-before-declaration for functions/globals which may depend on other globals, but for now adding non-extern globals to codegen should alleviate most concerns. Llvm only compiles this code because it inlines the constant value without checking that it was actually local to a different function (main).

@jfecher jfecher changed the title Incorrect defaulting to i8 during codegen Codegen does not support true globals Oct 14, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
crash An internal compiler error or (compiler) runtime crash panic A panic within the compiler
Projects
None yet
Development

No branches or pull requests

2 participants