For example, if you do:
(car (lst))You will receive the following communication:
WARNING (from Naomi Nag) The expression (lst) calls the non-defined function lst with no arguments. While this is legal Scheme, you probably didn't mean to do this.
(define fred)will produce:
Error: define statement "(define fred)" is of the form (define EXPR) it must have the form (define VARIABLE EXPR) or (define FORM EXPR) In file: /users/users3/fac/pop/output.scm This error report was prepared for Robin Popplestone by Jeremiah Jolt, your compile-time helper.
UMASS Scheme is implemented on top of the Sussex Poplog system. This means in effect that errors can be detected either in UMASS Scheme or in Poplog. As a general rule, run-time errors are detected by Poplog, while compile-time errors are detected by UMASS Scheme. The following is a typical compile-time error:
=> (if 234)
Error: Badly formed "if" expression (if 234) In file: /users/users3/fac/pop/poplocal/local/Scheme/output.scm In or around line 12: (if 234) Setscheme =>However run-time errors occurring in many primitive functions will appear in a somewhat different form, usually with a short capitalised error message.
(define (test x) (+ x #f) ) (test 4) Error: NUMBER(S) NEEDED Culprits: #f, 0, In file: /users/users3/fac/pop/poplocal/local/Scheme/errors.scm
Example:
(car '(2 3) '(4 5)) Error: Calling function 'car' with wrong number (2) of arguments, it needs 1 In file: /users/users3/fac/pop/poplocal/local/Scheme/errors.scm Value = (4 5) This error report was prepared for Robin Popplestone by Jeremiah Jolt, your compile-time helper.
This error is reported by a function which converts a POP-11 function for use by Scheme. If it appears, it is a system error.
This error arises when an open string quote is unmatched by a closing string quote. Consequently it can be quite hard to find. Look in your "output.scm" file to see which functions the Scheme system has compiled. The one immediately following probably contains the offending quote.
Alternatively you can locate it by compiling sub-ranges of your source file.
This error message is rather unhelpful - I need to improve it. But it always arises from an illegal combination that begins with #. For example
#rgives:
Error: Unknown character name # In file: /users/users3/fac/pop/poplocal/local/Scheme/errors.scm
In a "dotted list" only one item is permitted after the dot. So, for example:
'(2 . 3 4)Gives
Error: Improperly formed dotted list . 3 4 In file: /users/users3/fac/pop/poplocal/local/Scheme/errors.scm
This message means that Scheme has started reading an expression but has come to the "end-of-input-stream" marker before the expression is complete. For example:
(+ 2 3gives the error
Error: End of input encountered while reading Scheme expression,probably a missing close parenthesis In file: /users/users3/fac/pop/poplocal/local/Scheme/errors.scm
This error is superceded by the "cannot apply object" message.
This arises when Scheme finds some kind of expression when it is expecting a variable.
(lambda (3) (x+y)) Error: trying to declare expression '3' as variable In file: /users/users3/fac/pop/poplocal/local/Scheme/errors.scm In or around line 167: (lambda (3) (x+y))
(lambda ((+ x 2)) (x+y)) Error: trying to declare expression '(+ x 2)' as variable In file: /users/users3/fac/pop/poplocal/local/Scheme/errors.scm In or around line 176: (lambda ((+ x 2)) (x+y))
This arises from using a reserved symbol such as 'if' or 'define' as a variable.
(lambda (if) (+ if 2)) Error: Trying to use the reserved symbol 'if as variable In file: /users/users3/fac/pop/poplocal/local/Scheme/errors.scm In or around line 189: (lambda (if) (+ if 2))
(+ 10 define) Error: Trying to use the reserved symbol 'define as variable In file: /users/users3/fac/pop/poplocal/local/Scheme/output.scm In or around line 15: (+ y define)
This means that a a non-functional object X has been used as a function. For example
(2 3) Error: Manifest non-function F in expression
In file: F
In or around line L: E
Are you missing a quotation sign (') ?
This means that the compiler has tried to compile an expression E in which what should be the function F is obviously not a function. For example
(2 34) Error: Manifest non-function 2 in expression (2 34) Are you missing a quotation sign (') ? In file: /users/users3/fac/pop/poplocal/local/Scheme/errors.scm In or around line 225: (2 34)
This means that Scheme has tried to evaluate an expression with a non-function in the function position. This happens when it is not obvious to the compiler that the expression was wrong, and so it was not caught by the "Manifest non-function" error-check above. For example, the compiler can't in general tell that the expression (f 5 7) is erroneous, so you get
(define f '(3 4)) (f 5 7)giving
Error: Cannot apply object (3 4) as function In file: /users/users3/fac/pop/poplocal/local/Scheme/errors.scmThis often arises from the use of excessive parentheses - for example:
(car(x))
This means that Scheme has encountered a mal-formed expression sequence S, usually an empty function-body or begin. For example:
(lambda (x)) Error: wrong form for expression sequence () In file: /users/users3/fac/pop/poplocal/local/Scheme/errors.scm In or around line 272: (lambda (x)) (begin) Error: wrong form for expression sequence () In file: /users/users3/fac/pop/poplocal/local/Scheme/errors.scm In or around line 278: (begin)
This can only occur if you use explicitly the special form quote as in the following
(quote 2 3) Error: Wrong form for quoted expression "(quote 2 3)" In file: /users/users3/fac/pop/poplocal/local/Scheme/errors.scm
This arises if the quasi-quote facility is used directly with
This means that the function F has been given the wrong number of
arguments at run time. This will happen with user-defined functions,
and system functions that are written in Scheme. True primitives will
give the "Calling function...wrong number..." message described above
Often this will have been picked up by Naomi Nag,
with a warning message at compile time, but not always (for example
Naomi doesn't know about map_list requiring a function that takes one
argument).
For example
This means that a lambda or let expression has a repeated variable
A in a context L in which repetition is not allowed.
None of these messages can appear - my type-checking ideas for Scheme
will surface in Lean-and-Mean aka POP2000.
A define statement can
only have have the forms (define VARIABLE EXPR) or (define FORM EXPR)
This means that you have omitted part of a define statement.
For example
This means that you have something wrongly placed in a define
statement.
(define 2 fred)
You are not allowed to redefine the meaning of a special form.
The define statement D has been given extra components. The allowable
forms are
An example of such an error is:
The :-special form which should have just one argument has been
used with more than one.
An if expression can have either 2 or 3 arguments.
The forms of a case expression in Scheme are
This error message appears when one of the actual cases of a case
expression is badly formed.
There must always be a list of the possible values for a particular
case.
We don't use the do expression in this course...
(quasiquote 2 3)
Error: Wrong form for quasi-quoted expression "(quasiquote 2 3)"
In file: /users/users3/fac/pop/poplocal/local/Scheme/errors.scm
(define (fred x) (+ x 3))
(fred 3 4)
Error: function " fred " called with wrong number of arguments
In file: /users/users3/fac/pop/poplocal/local/Scheme/errors.scm
(lambda (x x) (+ x 4))
Error: lambda expression has illegal repeated variable "x " in "(x x)"
In file: /users/users3/fac/pop/poplocal/local/Scheme/errors.scm
Compiling argument list ending at line 336:
(x x)
In or around line 336: (lambda (x x) (+ x 4))
(let ((x 43) (x 4))(+ x y))
Error: let expression has illegal repeated variable "x " in "(x x)"
In file: /users/users3/fac/pop/poplocal/local/Scheme/errors.scm
Compiling argument list ending at line <false>:
(x x)
In or around line 351: (let ((x 43) (x 4)) (+ x y))
(define fred)
Error: define statement "(define fred)" is of the form (define EXPR)
it must have the form (define VARIABLE EXPR) or (define FORM EXPR)
In file: /users/users3/fac/pop/poplocal/local/Scheme/errors.scm
(define if 45)
Error: Attempting to redefine special form 'if
In file: /users/users3/fac/pop/poplocal/local/Scheme/errors.scm
While defining 'if '
(define variable expression)
(define form expression_sequence)
where form is
(function arg1..argn)
(define fred 34 joe 67)
Error: too many forms in define statement:
(define fred 34 joe 67)
In file: /users/users3/fac/pop/poplocal/local/Scheme/errors.scm
While defining 'fred '
This means that a call of the "assertion checker" special form :-
has failed to produce the true object #t.
(:- (= 3 45))
Error: Failed assertion check (:- (= 3 45))
In file: /users/users3/fac/pop/poplocal/local/Scheme/errors.scm
(:- 3 4)
Error: Special form :- should take one argument in (:- 3 4)
In file: /users/users3/fac/pop/poplocal/local/Scheme/errors.scm
(if condition expr1 expr2)
(if condition expr1)
Any other form is illegal. For example:
(if x)
Error: Badly formed "if" expression (if x)
In file: /courses/cs200/cs287/cs287/public_html/errors.scm
In or around line 433: (if x)
Likewise if we have too many arguments for if.
(if (< x 2) 3 4 5)
Error: Badly formed "if" expression (if (< x 2) 3 4 5)
In file: /courses/cs200/cs287/cs287/public_html/errors.scm
In or around line 439: (if (< x 2) 3 4 5)
(case expr case1...casen)
(case expr case1...casen (else expression_sequence))
where casei has the form
((keys) expression_seq),
and keys consists of a sequence of literal values.
An example of correct usage is:
(example
'(case (* 2 3)
((2 3 5 7) 'prime)
((1 4 6 8 9) 'composite))
'composite)
(example
'(case (car '(c d))
((a e i o u) 'vowel)
((w y) 'semivowel)
(else 'consonant))
'consonant)
An example of the error message is
(case 2)
Error: case expr "(case 2)" needs actual cases
In file: /courses/cs200/cs287/cs287/public_html/errors.scm
In or around line 489: (case 2)
(case x 2 3)
Error: Wrong form for key-value pair "2" in (case ...) expression
(case x 2 3)
In file: /courses/cs200/cs287/cs287/public_html/errors.scm
In or around line 501: (case x 2 3)
(case x (3 4))
Error: list of values needed instead of "3" in key-value pair "(3 4)" in
(case..)expression
(case x (3 4))
In file: /courses/cs200/cs287/cs287/public_html/errors.scm
In or around line 508: (case x (3 4))
For a specification of cond follow this link.
(cond 1 2 3 )
Error: Wrong form for condition-value pair "1" in (cond ...) expression
(cond 1 2 3)
In file: /courses/cs200/cs287/cs287/public_html/errors.scm
Compiling (
This can happen if you miscount your parentheses in a cond or case statement,
or otherwise:
(if (< x 2) 45 (else 34))
Error: "else" apparently used as a function in (else 34). Badly formed
cond or case?
In file: /courses/cs200/cs287/cs287/public_html/errors.scm
In or around line 555: (if (< x 2) 45 (else 34))
(let (+ 2 3))
Error: Missing binding or body in let expr
(let (+ 2 3))
In file: /courses/cs200/cs287/cs287/public_html/errors.scm
(let (x 4) (+ 3 4))
Error: Badly formed binding x in bindings (x 4)
In file: /courses/cs200/cs287/cs287/public_html/errors.scm
In or around line 583: (let (x 4) (+ 3 4))
(let ((3 x) (4 y)) (+ x y))
Error: Variable needed instead of "3" in binding "(3 x)" in bindings "((3
x) (4 y))"
In file: /courses/cs200/cs287/cs287/public_html/errors.scm
In or around line 594: (let ((3 x) (4 y)) (+ x y))
This error report was prepared for Robin Popplestone
(let ((x 3 4) (y 6)) (+ a 2))
Error: Binding "(x 3 4)" is not of form (<var> <expr>)
In file: /courses/cs200/cs287/cs287/public_html/errors.scm
In or around line 608: (let ((x 3 4) (y 6)) (+ a 2))
(let x 3)
Error: Bindings x should be a list
In file: /courses/cs200/cs287/cs287/public_html/errors.scm
In or around line 604: (let x 3)
(set! variable expr
(set! x 3 4) Error: Wrong form "(set! x 3 4)" for "set!" statement In file: /courses/cs200/cs287/cs287/public_html/errors.scm Compiling expression ending at line 625: (set! x 3 4)
The set! construct only supports assignment to a variable named by a symbol. For example:
(set! 4 x)will produce the error:
Error: Non-atom 4 cannot be bound by "set!" in (set! 4 x) In file: Compiling expression ending at line 5: (set! 4 x)
I can't find any circumstance in which this error-message would appear.
(map car)
Error: map called with 1 args, it needs at least 2 In file:
The error message for character comparisons, and other character ops. Evaluating
(char #\A #\B)produces the error message:
Error: Wrong number of arguments for char In file: Value = <_char 65
The read function was given the wrong number of arguments.
This button switches the Scheme system into a mode suitable for system debugging, so it should normally be left inactive. Its effect is to cause errors to be reported by the POP-11 error reporting function, which doesn't format the error message by replacing '%p' occurring in an error message by a value, and which reports all functions on the call-stack, not just those defined in Scheme. For example, a call of
(car 1 2)with the "Report POP-11 functions" button set produces:
;;; MISHAP - Calling function '%p' with wrong number (%p) of arguments, it needs %p ;;; INVOLVING: 'car' 2 1 ;;; FILE : /users/users3/fac/pop/poplocal/local/Scheme/errors.scm LINE NUMBER: 35 ;;; DOING : mishap_GDB apply_checking exec_scm compile_Scheme schemecompile scheme_compile apply runproc charin read_sexpr compile_Scheme schemecompile scheme_compile pop_setpop_compiler Type of error = Expression_RT
instead of
Error: Calling function 'car' with wrong number (2) of arguments, it needs 1 In file: /users/users3/fac/pop/poplocal/local/Scheme/errors.scm Value = 2 This error report was prepared for Robin Popplestone by Jeremiah Jolt, your compile-time helper.