Skip to content

Compiler crash when a procedure has #optional_ok and no declared result #5107

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
VoidStarCaster opened this issue May 3, 2025 · 3 comments
Closed
Labels
frontend replicated We were able to replicate the bug.

Comments

@VoidStarCaster
Copy link

Context

  • Operating System & Odin Version:
    Odin: dev-2025-05:30c6fea9e
    OS: Windows 10 Professional (version: 22H2), build 19045.5737
    CPU: AMD Ryzen 7 7700 8-Core Processor
    RAM: 31849 MiB
    Backend: LLVM 20.1.0

Expected Behavior

The compiler should display "Error: A procedure type with the #optional_ok tag requires 2 return values, got 0"

Current Behavior

The compiler crashes in check_expr.cpp:8148, in check_call_expr()

Failure Information (for bugs)

Steps to Reproduce

package main

my_func :: proc() #optional_ok
{

}

main :: proc()
{
	my_func()
}

But calling my_func(0) will prevent the crash from happening

@Kelimion
Copy link
Member

Kelimion commented May 3, 2025

I've confirmed the crash.

When you say my_func(0) prevents the crash from happening, would that be because the compiler tells you the following, which is what you'd expect without the (0)?

W:/Scratch/scratch.odin(3:12) Error: A procedure type with the #optional_ok tag requires 2 return values, got 0 
	my_func :: proc() #optional_ok { 
	           ^~~~~^ 
W:/Scratch/scratch.odin(8:2) Error: Too many arguments for 'my_func', expected 0 arguments, got 1 
	my_func(0) 
	^~~~~~~~~^ 

@Kelimion Kelimion added frontend replicated We were able to replicate the bug. labels May 3, 2025
@Kelimion
Copy link
Member

Kelimion commented May 3, 2025

Fixed.

@VoidStarCaster
Copy link
Author

When you say my_func(0) prevents the crash from happening, would that be because the compiler tells you the following, which is what you'd expect without the (0)?

Yes exactly, sorry if it was confusing, it just seems weird that it completely prevented the crash.

Fixed.

That was fast, thanks !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
frontend replicated We were able to replicate the bug.
Projects
None yet
Development

No branches or pull requests

2 participants