1 / 6

Fixing Broken Programs

Fixing Broken Programs. How do you figure out what’s wrong?. Look carefully at the error message. Locate the error Most messages have line numbers Comment out the part of the program where you think the error may be. Then add in little bits at a time, until it breaks again.

derry
Download Presentation

Fixing Broken Programs

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Fixing Broken Programs

  2. How do you figure out what’s wrong? • Look carefully at the error message. • Locate the error • Most messages have line numbers • Comment out the part of the program where you think the error may be. Then add in little bits at a time, until it breaks again. • Try and fix it yourself • Ask some one for help.

  3. Where is the error It also tells what it thinks is wrong. It is not always correct. The error message tells the file and the line number

  4. Line number analysis • Errors are some times on the line indicated • Many times the errors are in the last non-whitespace before the line number listed. This can be several lines above the line number indicated.

  5. Num class errors • When you write a numeral • 5 • 22 • 1567 etc • The system classifies this a value in the Num class • This means it could be Int, Integer, Double, Float , or many other types. • An error that mentions (Num x) could mean you have a numeral without an exact type. Use a type declaration to fix this • r = row [5] • x::Integer • r = row [x] • r = row [5:: Integer] Broken program Fix #2 Fix #1

  6. Constructor errors • Constructors start with a capital letter • We know of at least two- True and False • Types also start with a capital letter: Bool, Integer, Double, etc. • You cannot use a name that starts with a capital letter. • If you see “unexpected Constructor” look for a name that starts with a capital letter.

More Related