Skip to content

Conversation

@xor-shift
Copy link

@xor-shift xor-shift commented Nov 22, 2025

apologies if this wasn't an oversight and if there was some reason behind the lack of a return but i couldn't find any indications towards that

previously, the following code would fail to compile:

export fn main() callconv(.spirv_kernel) void {
    asm volatile (
        \\ %f32 = OpTypeFloat 32
        \\ %foo = OpConstant %f32 0
    );
}

with the following output:

test2.zig:1:8: error: failed to assemble SPIR-V inline assembly
export fn main() callconv(.spirv_kernel) void {
~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
test2.zig:1:8: note: cannot parse literal constant

OpConstant with a floating point type argument fails to assemble with no
disagnostics provided as there's (what seems to be) a missing return.
@alexrp
Copy link
Member

alexrp commented Nov 22, 2025

cc @alichraghi

@DialecticalMaterialist
Copy link
Contributor

Does this even compile? You are returning a return statement when it reaches the else branch.

@DialecticalMaterialist
Copy link
Contributor

And from a quick glance parseContextDependentFloat does not even return a value. Since it appends the operand inside of the function.

@xor-shift
Copy link
Author

it does compile, noreturn (the type of a return statement) can be coerced into any type afaik.

the issue with the function is not that it doesn't return some value, it's the fact that it falls down to ass.fail

@DialecticalMaterialist
Copy link
Contributor

I see, my bad then.

@xor-shift
Copy link
Author

oops, i didn't think new commits would get reflected here

@xor-shift
Copy link
Author

sorry about that..

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants