svenssonjoel / Sense-VM

Sense-VM has changed name to SynchronVM and is available in a new repository https://github.com/SynchronVM/SynchronVM
MIT License
5 stars 1 forks source link

Monomorphiser eliminates main #16

Open Abhiroop opened 3 years ago

Abhiroop commented 3 years ago
f p = p

g p = f p

main = g 1

The main function is eliminated and we get:

*** Exception: No main function present!

CallStack (from HasCallStack):
  error, called at /Users/abhiroopsarkar/C/Sense-VM/frontend/CamIoT/src/Desugaring/Desugar.hs:33:27 in main:Desugaring.Desugar
Abhiroop commented 3 years ago

A possible fix from @Rewbert

In Renaming.hs

    DTypeSig id t       -> do
        b <- isRenamed id
        if b
            then do ds' <- renameDef ds
                    return $ DTypeSig id t : ds'
            else do id' <- fresh
                    inEnv (id, id') (do ds' <- renameDef ds 
                                        return $ DTypeSig id' t : ds')

and in Desugar.hs Line #114 and and #115

desugarMain m [AST.DTypeSig _ _, def]    = desugarMain m [def]