Skip to content

Comparing f32 values with unsuffixed float literals emits invalid LLVM IR #27

Closed

Description

@ehartford

Current behavior

Comparing an f32 value against an unsuffixed float literal emits invalid LLVM IR.

Example:
fn main:
let x: f32 = 3.5
assert(x == 3.5)

with run reports:
LLVM verify error: Both operands to FCmp instruction are not of the same type!
%4 = fcmp oeq float %3, double 3.500000e+00, !dbg !306

LLVM verify function: __with_main
error: code generation failed
error: run failed

Control case

This works:
fn main:
let x: f32 = 3.5
let y: f32 = 3.5
assert(x == y)

So the issue is specifically the mixed comparison against an unsuffixed float literal.

Expected behavior

An unsuffixed float literal in x == 3.5 should either:

  • be coerced to f32 because x is f32, or
  • be rejected cleanly with a front-end type error.

It should not reach LLVM with mismatched float/double operands.

Repro

cat > /tmp/f32_cmp_bug.w << 'EOF2'
fn main:
let x: f32 = 3.5
assert(x == 3.5)
EOF2
with run /tmp/f32_cmp_bug.w

Activity

  1. added
    bug
    error-messages
    on Mar 20, 2026
  2. added a commit that references this issue on Jun 8, 2026
    f93dfec
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugerror-messages

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions