008: nodup.hs が renRhs の未実装でエラー

↑up

現象

$ ./test-compile.sh testcases/nodup.hs
source file: testcases/nodup.hs
dst dir: /nodup
doCompile ... done.
implicitPrelude ... done.
doCompile ... bunnyc: renRhs not yet implemented. 

(略)

CallStack (from HasCallStack):
  error, called at src/Rename.hs:416:3 in main:Rename

調査ログ

2020-04-15 (Wed)

renRhs の未実装で引っかかっているのは、以下(trace の出力を手で整形したもの):

GuardedRhs
[
 ( [ExpStmt (InfixExp (VarExp (Name {origName = "y", namePos = (3,19), isConName = False}))
            (Name {origName = "==", namePos = (3,21), isConName = False})
            (VarExp (Name {origName = "x", namePos = (3,24), isConName = False})))
   ]
 , FunAppExp (VarExp (Name {origName = "nodups", namePos = (3,31), isConName = False}))
             (ParExp (InfixExp (VarExp (Name {origName = "x", namePos = (3,39), isConName = False}))
                               (Name {origName = ":", namePos = (3,40), isConName = True})
                               (VarExp (Name {origName = "xs", namePos = (3,41), isConName = False}))
                     )
             )

  )
,([ExpStmt (VarExp (Name {origName = "otherwise", namePos = (4,19), isConName = False}))]
 ,InfixExp (VarExp (Name {origName = "y", namePos = (4,31), isConName = False}))
           (Name {origName = ":", namePos = (4,33), isConName = True})
           (FunAppExp (VarExp (Name {origName = "nodups", namePos = (4,35), isConName = False}))
                      (ParExp (InfixExp (VarExp (Name {origName = "x", namePos = (4,43), isConName = False}))
                                        (Name {origName = ":", namePos = (4,44), isConName = True})
                                        (VarExp (Name {origName = "xs", namePos = (4,45), isConName = False})))
                      )
           )
 )
]
[]

実装、解決

nodup.hs で出現する単純な guarded rhs を if then else if ... の列に変換するコードを renRhs に追加、nodup.hs は通るようになった⇒ sample144

ただ、ごく単純なケースのみしか対応していないので、それについては別の Issue とした。