Fix to null.m() bug

svn: r1433
This commit is contained in:
Kathy Gray 2005-11-29 08:15:41 +00:00
parent ed870594bf
commit 8f1898eda7
3 changed files with 19 additions and 7 deletions

View File

@ -2007,6 +2007,8 @@
(cond
;List of methods found
((list? call-exp) call-exp)
((eq? call-exp 'null)
(prim-call-error call-exp name src level))
((array-type? call-exp)
(set! exp-type call-exp)
(get-method-records name-string
@ -2769,11 +2771,13 @@
(t (type->ext-name exp)))
(raise-error
n
(format "attempted to call method ~a on ~a which does not have methods. ~nOnly values with ~a types have methods"
n t
(case level
((beginner intermediate) "class or interface")
(else "class, interface, or array")))
(if (eq? exp 'null)
(format "Attempted to call method ~a directly on null. The null value does not have any methods." n)
(format "Attempted to call method ~a on ~a which does not have methods. ~nOnly values with ~a types have methods"
n t
(case level
((beginner intermediate) "class or interface")
(else "class, interface, or array"))))
n src)))
;no-method-error: symbol symbol type id src -> void

View File

@ -9,8 +9,10 @@
;make-error: 'a string 'a src -> void
(define (make-error-pass parm)
(lambda (kind message so src)
(raise-syntax-error 'Error #;kind message (make-so so src parm))))
(lambda (_ message syn-obj src)
(raise (make-exn:fail:syntax (string->immutable-string message)
(current-continuation-marks) (list-immutable (make-so syn-obj src parm))))))
;make-so: symbol src (-> location) -> syntax-object
(define (make-so id src parm)

View File

@ -4,6 +4,12 @@
(prepare-for-tests "Advanced")
;;Execution tests without errors
(interact-test
'advanced
'("null.m()")
'(error)
"Calling a method on null")
(execute-test
"public class Something {