B-Lang-org/bsc
bsc crash when bs method arg name annotation doesn't match method arity
开放
#420 创建于 2021年10月2日
ICEerror-messagesgood first issue
仓库指标
- 星标
- (1,108 个星标)
- PR 合并指标
- (平均合并 17天 1小时) (30 天内合并 18 个 PR)
描述
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.