translateDomainExpressionCrossScope scope _ nsid (L1.L1DomainVariableRef ss sdName) =
  case (M.lookup sdName . siDomainIDMap) scope of
    Nothing ->
      fail ("Cannot find scoped domain variable " ++ BSC.unpack (L1.l1ScopedIdBS sdName) ++ " referenced at " ++
            show ss ++ " in scope " ++ show scope)
    Just scopedDomain ->
      return $ (L2.L2DomainVariableRef ss scopedDomain, scope)
translateDomainExpressionCrossScope scope _ nsid (L1.L1DomainVariableRef ss sdName) =
  case (M.lookup sdName . siDomainIDMap) scope of
    Nothing ->
      fail ("Cannot find scoped domain variable " ++ BSC.unpack (L1.l1ScopedIdBS sdName) ++ " referenced at " ++
            show ss ++ " in scope " ++ show scope)
    Just scopedDomain ->
      return $ (L2.L2DomainVariableRef ss scopedDomain, scope)
translateDomainExpressionCrossScope scope _ nsid (L1.L1DomainVariableRef ss sdName) =
  case (M.lookup sdName . siDomainIDMap) scope of
    Nothing ->
      fail ("Cannot find scoped domain variable " ++ BSC.unpack (L1.l1ScopedIdBS sdName) ++ " referenced at " ++
            show ss ++ " in scope " ++ show scope)
    Just scopedDomain ->
      return $ (L2.L2DomainVariableRef ss scopedDomain, scope)