Ticket #178 (closed defect: duplicate)

Opened 4 years ago

Last modified 4 years ago

PANIC in Core.Reconstruct reconX/Prim due to using boxInt32 where a polymorphic function is expected.

Reported by: erikd Owned by:
Priority: blocker Milestone: 0.1.3
Component: Core Transforms Version:
Keywords: Cc:

Description

Trying to write a neater wrapper (something which accepts normal boxed parameters) for System.Network. Have this:

connect :: String -> Int32 -> Int32
connect hostname portnum
  | SChunk hn <- hostname.flatten
  = boxInt32 $ System.Network.connect hn.danger_string (unboxInt32 portnum)

Trying to compile it results in:

ddc: PANIC in Core.Reconstruct
        reconX/Prim: no match for prim{Box} %rTS2

Change History

Changed 4 years ago by erikd

In src/Core/Reconstruct.hs, the match against this fails:

	| MBox 		<- prim
	, [XType r, x]	<- xs
	= do	rx	<- reconX x
		return	( reconBoxType r $ t4_2 $ rx
			, tPure)
		

because the length of list xs is 1 instead of 2.

I therefore suspect this is actually a bug elsewhere.

Changed 4 years ago by erikd

Backtracing it, I found where the possibly bad MBox was being generated in src/Core/Prim.hs, in this function:

-- do the flat rewrite
primX1 tt xx
	-- direct use of boxing function
	| Just parts				<- flattenAppsEff xx
	, (XVar v t : psArgs)			<- parts
	, isBoxFunctionV v
	= XPrim MBox psArgs

Changed 4 years ago by erikd

This is strange, if I replace the '$' with parens:

connect :: String -> Int32 -> Int32
connect hostname portnum
  | SChunk hn <- hostname.flatten
  = boxInt32 (System.Network.connect hn.danger_string (unboxInt32 portnum))

it compiles.

Changed 4 years ago by erikd

  • status changed from new to closed
  • resolution set to duplicate
  • summary changed from PANIC in Core.Reconstruct reconX/Prim: no match for prim{Box} %rTS2 to PANIC in Core.Reconstruct reconX/Prim due to using boxInt32 where a polymorphic function is expected.

During desugaring, the problematic function becomes:

Data.Function.($) boxInt32 (System.Network.connect ....)

Chatted to Ben in IRC and he said that the problem here is that Data.Function.($) is a polymorphic function and boxInt32 isn't polymorphic, but has a strict type of Int32# -> Int32. From IRC:

<benl23> Something like   boxInt32 $ .... whatever   is always going to be wrong
<m3ga> i'll see if I can make the compiler throw an error instead.
<benl23> I wouldn't worry about it. It's just another instance of #67
<benl23> I should add a kind of unboxed values like in GHC
<benl23> and make use of $ with unboxed data a type error

Closing this as a duplicate of #67.

Note: See TracTickets for help on using tickets.