
How do I track down an reference to an undefined value? My program
must not be using a library correctly because the program makes no
direct use of 'undefined'. Running with +RTS -xc yields:

On 3 March 2010 16:06, Tom Hawkins
How do I track down an reference to an undefined value? My program must not be using a library correctly because the program makes no direct use of 'undefined'. Running with +RTS -xc yields:
Test: Prelude.undefined
Are you matching all patterns? When compiling with -Wall does it make any complaints? -- Ivan Lazar Miljenovic Ivan.Miljenovic@gmail.com IvanMiljenovic.wordpress.com

On Wed, Mar 3, 2010 at 6:07 AM, Ivan Miljenovic
On 3 March 2010 16:06, Tom Hawkins
wrote: How do I track down an reference to an undefined value? My program must not be using a library correctly because the program makes no direct use of 'undefined'. Running with +RTS -xc yields:
Test: Prelude.undefined Are you matching all patterns? When compiling with -Wall does it make any complaints?
-Wall only complains about shadow bindings, defined but not used, and no type signature. But no unmatched patterns.
-- Ivan Lazar Miljenovic Ivan.Miljenovic@gmail.com IvanMiljenovic.wordpress.com

On Wed, Mar 3, 2010 at 6:11 AM, Tom Hawkins
On Wed, Mar 3, 2010 at 6:07 AM, Ivan Miljenovic
wrote: On 3 March 2010 16:06, Tom Hawkins
wrote: How do I track down an reference to an undefined value? My program must not be using a library correctly because the program makes no direct use of 'undefined'. Running with +RTS -xc yields:
Test: Prelude.undefined Are you matching all patterns? When compiling with -Wall does it make any complaints?
-Wall only complains about shadow bindings, defined but not used, and no type signature. But no unmatched patterns.
BTW, I'm using: GHC 6.12.1 bytestring 0.9.1.5 containers 0.3.0.0

2010/3/3 Tom Hawkins
On Wed, Mar 3, 2010 at 6:07 AM, Ivan Miljenovic
-Wall only complains about shadow bindings, defined but not used, and no type signature. But no unmatched patterns.
If you can run your code through the ghc debugger you can get it to break when an undefined exception is raised. The options are :set -fbreak-on-exception or -fbreak-on-error. More info in the documentation at http://www.haskell.org/ghc/docs/latest/html/users_guide/ghci-debugger.html#g... Hope that helps, Alex MDC

On 3 March 2010 16:11, Tom Hawkins
-Wall only complains about shadow bindings, defined but not used, and no type signature. But no unmatched patterns.
Yes it does: one of the options it brings in is -fwarn-incomplete-patterns which tells you if you've missed a pattern match. http://www.haskell.org/ghc/docs/latest/html/users_guide/options-sanity.html -- Ivan Lazar Miljenovic Ivan.Miljenovic@gmail.com IvanMiljenovic.wordpress.com

On Wed, Mar 3, 2010 at 6:15 AM, Ivan Miljenovic
On 3 March 2010 16:11, Tom Hawkins
wrote: -Wall only complains about shadow bindings, defined but not used, and no type signature. But no unmatched patterns.
Yes it does: one of the options it brings in is -fwarn-incomplete-patterns which tells you if you've missed a pattern match.
http://www.haskell.org/ghc/docs/latest/html/users_guide/options-sanity.html
I think he meant that it doesn't because he doesn't have any :)

On Wed, Mar 3, 2010 at 7:15 AM, Ivan Miljenovic
On 3 March 2010 16:11, Tom Hawkins
wrote: -Wall only complains about shadow bindings, defined but not used, and no type signature. But no unmatched patterns.
Yes it does: one of the options it brings in is -fwarn-incomplete-patterns which tells you if you've missed a pattern match.
Sorry, I should have been more clear. When I run the program with -Wall, the only warnings I get are shadow bindings, values defined by not used, and a couple values without a type signature. But I don't get any warnings about either unmatched patterns or overlapping patterns. -Tom

Ivan Miljenovic
Test: Prelude.undefined
Are you matching all patterns? When compiling with -Wall does it make any complaints?
How would this help? 'Prelude.undefined' happens because somewhere you're trying to evaluate a value defined with that particular literal, doesn't it? Using this in a library seems to me to be in poor taste, but grepping the code should reveal it, if you're sure that's where the problem is hiding. I generally replace any 'undefined's with 'error string', with each 'string' unique for that position. -k -- If I haven't seen further, it is by standing in the footprints of giants

On Tue, Mar 2, 2010 at 9:06 PM, Tom Hawkins
How do I track down an reference to an undefined value? My program must not be using a library correctly because the program makes no direct use of 'undefined'. Running with +RTS -xc yields:
Test: Prelude.undefined _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
While the debugger, etc., are very useful tools, I find that often the easiest way to track down this sort of bug is to test your code function-by-function. Make sure each function does what you want it to when run in isolation; this will quickly lead to tracking down the caller of "undefined". (If your code is not structured in a way that allows this sort of testing, you might consider restructuring it to make it more modular.) Alex

On Wed, Mar 3, 2010 at 7:24 AM, Alexander Dunlap
On Tue, Mar 2, 2010 at 9:06 PM, Tom Hawkins
wrote: How do I track down an reference to an undefined value? My program must not be using a library correctly because the program makes no direct use of 'undefined'. Running with +RTS -xc yields:
While the debugger, etc., are very useful tools, I find that often the easiest way to track down this sort of bug is to test your code function-by-function.
The debugger was not that helpful, so I may have to resort to this. Is there any work being done to improve reporting for these type of errors? It seems to be a fairly common problem.

On Wed, Mar 3, 2010 at 10:56 AM, Tom Hawkins
On Wed, Mar 3, 2010 at 7:24 AM, Alexander Dunlap
wrote: On Tue, Mar 2, 2010 at 9:06 PM, Tom Hawkins
wrote: How do I track down an reference to an undefined value? My program must not be using a library correctly because the program makes no direct use of 'undefined'. Running with +RTS -xc yields:
While the debugger, etc., are very useful tools, I find that often the easiest way to track down this sort of bug is to test your code function-by-function.
The debugger was not that helpful, so I may have to resort to this.
Is there any work being done to improve reporting for these type of errors? It seems to be a fairly common problem.
You try the Interlude? http://hackage.haskell.org/package/interlude -- gwern

Tom Hawkins
The debugger was not that helpful, so I may have to resort to this.
Is there any work being done to improve reporting for these type of errors? It seems to be a fairly common problem.
http://hackage.haskell.org/trac/ghc/wiki/ExplicitCallStack -- (c) this sig last receiving data processing entity. Inspect headers for copyright history. All rights reserved. Copying, hiring, renting, performance and/or quoting of this signature prohibited.
participants (8)
-
Achim Schneider
-
Alex MDC
-
Alexander Dunlap
-
Ben Millwood
-
Gwern Branwen
-
Ivan Miljenovic
-
Ketil Malde
-
Tom Hawkins