B-Lang-org/bsc

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

オープン

#420 opened on 2021/10/02

 (4 件のコメント) (0 件のリアクション) (0 人の担当者)Haskell (178 件のフォーク)batch import
ICEerror-messagesgood first issue

Repository metrics

Stars
 (1,108 個のスター)
PR merge metrics
 (平均マージ 17d 1h) (30d で 18 merged PRs)

説明

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.

コントリビューターガイド