Ticket #179 (closed defect: fixed)

Opened 5 years ago

Last modified 5 years ago

ddc: Bad code generated for statement containing nothing but a curried function.

Reported by: Tac-Tics Owned by: erikd
Priority: blocker Milestone: 0.1.3
Component: Core to Sea Translation Version:
Keywords: PANIC Cc:

Description

With the following code:

foo :: () -> ()
foo () = ()

main () = do 
  foo 
  ()

The compiler panics with:

~/Desktop$ ddc Main.ds
[1 of 1] Compiling Main
cc1: warnings being treated as errors
./Main.ddc.c: In function ‘Main_main’:
./Main.ddc.c:67: error: implicit declaration of function ‘_curry0’
ddc: PANIC in Main.Invoke
        invokeSeaCompiler: compilation of C file failed.
            pathC = ./Main.ddc.c
        
        Please report this bug to the maintainers at:
            http://trac.haskell.org/ddc
            or by emailing disciple-cafe@googlegroups.com

~/Desktop$ 

Change History

Changed 5 years ago by Tac-Tics

It looks like it only occurs for top-level definitions. Making 'foo' local compiles and runs without a problem:

main () = do 
  foo :: () -> ()
  foo () = ()
  foo 
  ()

Changed 5 years ago by Tac-Tics

  • component changed from Build System to Core to Sea Translation

Changed 5 years ago by erikd

  • milestone set to 0.1.3

Changed 5 years ago by erikd

  • priority changed from normal to blocker

Changed 5 years ago by Tac-Tics

  • owner set to Tac-Tics

The problem appears to be a missing case statement in src/Sea/Thunk.hs.

As far as I can tell, the XCurry constructor is intended to be an intermediary form of the final C tree. All instances of XCurry must be removed from the tree by the end or the outputted C code will fail to compile.

The case on line 83 of src/Sea/Thunk.hs is the only case where XCurry are mentioned, and thus, the only place where they might be removed. However, they are only removed when they appear as a child of an SAssign constructor. When a top-level function appears on a line by itself, this must not be the case, and so the default case on line 118 catches it instead. The default case passes the value along untouched, including the maligning XCurry constructor.

Changed 5 years ago by erikd

  • summary changed from ddc: PANIC in Main.Invoke to ddc: Bad code generated for statement containing nothing but a curried function.

Changing the code to this:

foo :: () -> ()
foo () = ()

main ()
 = do	x = foo
	()

fixes the problem. Thats a clue.

In the original problem code the first line of main() is a statement (ie no assignment) consisting of a curried function. Since there is no assignment (ie to a variable) the curried function cannot be be used. Therefore the statement can just be droppped.

Changed 5 years ago by erikd

  • owner changed from Tac-Tics to erikd

Changed 5 years ago by erikd

  • status changed from new to closed
  • resolution set to fixed

Fixed in:

Sun May  2 21:47:24 EST 2010  Erik de Castro Lopo <erikd@mega-nerd.com>
* Fix #179 : Bad code for statement containing nothing but a curried function.
Note: See TracTickets for help on using tickets.