    {-# LANGUAGE Safe #-}

    -- |
    -- Copyright: (c) 2011 National Institute of Aerospace / Galois, Inc.
    --
    -- Custom functions to report error messages to users.
    module Copilot.Compile.C99.Error
        ( impossible
        , errorEmptyStruct
        , errorZeroLengthArray
        )
      where

    -- | Report an error due to a bug in Copilot.
    impossible :: String -- ^ Name of the function in which the error was detected.
               -> String -- ^ Name of the package in which the function is located.
               -> a
    impossible :: forall a. String -> String -> a
    impossible String
    function String
    package =
      String -> a
    forall a. HasCallStack => String -> a
    error (String -> a) -> String -> a
    forall a b. (a -> b) -> a -> b
    $ String
    "Impossible error in function "
        String -> String -> String
    forall a. [a] -> [a] -> [a]
    ++ String
    function String -> String -> String
    forall a. [a] -> [a] -> [a]
    ++ String
    ", in package " String -> String -> String
    forall a. [a] -> [a] -> [a]
    ++ String
    package
        String -> String -> String
    forall a. [a] -> [a] -> [a]
    ++ String
    ". Please file an issue at "
        String -> String -> String
    forall a. [a] -> [a] -> [a]
    ++ String
    "https://github.com/Copilot-Language/copilot/issues"
        String -> String -> String
    forall a. [a] -> [a] -> [a]
    ++ String
    " or email the maintainers at <ivan.perezdominguez@nasa.gov>"

    -- | Report an error when attempting to compile a zero-length array to C99.
    -- C99 does not support zero-length arrays, so Copilot cannot compile
    -- specifications that use them.
    errorZeroLengthArray :: a
    errorZeroLengthArray :: forall a. a
    errorZeroLengthArray =
      String -> a
    forall a. HasCallStack => String -> a
    error String
    "copilot-c99: Cannot compile zero-length arrays to C99.\n"

    -- | Report an error when attempting to compile an empty struct to C99.
    -- C99 does not support empty structs, so Copilot cannot compile
    -- specifications that use them.
    errorEmptyStruct :: a
    errorEmptyStruct :: forall a. a
    errorEmptyStruct =
      String -> a
    forall a. HasCallStack => String -> a
    error String
    "copilot-c99: Cannot compile empty structs to C99.\n"