Skip to content

Incorrect multiplicity computation in Multi-way If

Summary

A theoretically linear program using multi-way if fails to compile with multiplicity issues.

Steps to reproduce

{-# LANGUAGE LinearTypes #-}
{-# LANGUAGE MultiWayIf #-}

module T23814 where

f :: Bool -> Int %1 -> Int
f b x =
  if
    | b -> x
    | otherwise -> x
$ hadrian/build test --only="T23814"
T23814.hs:7:5: error: [GHC-18872]
    • Couldn't match type ‘Many’ with ‘One’
        arising from multiplicity of ‘x’
    • In an equation for ‘f’:
          f b x
            = if | b -> x
                 | otherwise -> x

*** unexpected failure for T23814(normal)

Performance Metrics (test environment: local):


None collected.


Unexpected results from:
TEST="T23814"

[...]

Unexpected failures:
   /tmp/nix-shell.0E0tuG/ghctest-8vvo1e_f/test   spaces/testsuite/tests/linear/should_compile/T23814.run  T23814 [exit code non-0] (normal)

Expected behavior

The program T23814 should compile.

Environment

  • GHC version used: Tested on master (6eab07b26ee46813683a8409871132d740805ec6)
  • Operating System: Linux Ubuntu 22.04
  • System Architecture: x86_64
Edited by Thomas BAGREL
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information