B-Lang-org/bsc

bsc crash when bs method arg name annotation doesn't match method arity

Aperta

#420 aperta il 2 ott 2021

 (4 commenti) (0 reazioni) (0 assegnatari)Haskell (178 fork)batch import
ICEerror-messagesgood first issue

Metriche repository

Star
 (1108 stelle)
Metriche merge PR
 (Merge medio 17g 1h) (18 PR mergiate in 30 g)

Descrizione

if the arg_names annotation in a classic interface declaration has fewer names than the method has arguments, bsc crashes without any useful information:

bsc -verilog BugMethodArgNamesArity.bs
Prelude.!!: index too large

BugMethodArgNamesArity.bs is:

package BugMethodArgNamesArity where

interface ArityBug =
    foo :: Bool -> Bool -> Action {-# arg_names = [bar] #-}

{-# verilog mkArityBug #-}
mkArityBug :: Module ArityBug
mkArityBug = module
    interface
        foo _ _ = _

this specific crash occurs when !! is used in the definition of i' inside iExpandMethodLam at IExpand.hs:1065, although at least the !! in the definition of m_origion_type below has the exact same problem.

iirc the IExpand state monad handles errors, so it should be possible to check in iExpandMethodLam and emit a more informative error with a reasonable position; failing that, a quick-hack ICE with a position would also work.

Guida contributor