B-Lang-org/bsc

Suggest missing 'valueOf' in error message

開放

#276 建立於 2020年11月8日

 (0 則留言) (0 個反應) (0 位負責人)Haskell (178 個分叉)batch import
error-messagesgood first issue

倉庫指標

星標
 (1,108 顆星)
PR 合併指標
 (平均合併 17天 1小時) (30 天內合併 18 個 PR)

描述

If valueOf is left out of this code:

typedef 32 DataWidth;

function Bit#(DataWidth) fn (Bit#(DataWidth) x);
  //if (valueOf(DataWidth) == 64)
  if (DataWidth == 64)
    return 8;
  else
    return 4;
endfunction

then BSC, noticing that the name DataWidth is capital, looks for a constructor by that name and doesn't find one, so it reports an error about an unbound constructor name:

Error: "Test.bsv", line 5, column 7: (T0003)
  Unbound constructor `DataWidth'

It should be easy for BSC, in this case, to look for the name in the type domain and, if it's found, add a message that this name is a type and maybe a pseudo-function like valueOf is missing.

貢獻者指南