diff --git a/core/parser/parser.factor b/core/parser/parser.factor index 961fa89d8f..55dd8220db 100755 --- a/core/parser/parser.factor +++ b/core/parser/parser.factor @@ -345,6 +345,11 @@ M: invalid-slot-name summary [ >r tuple parse-tuple-slots r> prefix ] } case 3dup check-slot-shadowing ; +ERROR: not-in-a-method-error ; + +M: not-in-a-method-error summary + drop "call-next-method can only be called in a method definition" ; + ERROR: staging-violation word ; M: staging-violation summary diff --git a/core/syntax/syntax.factor b/core/syntax/syntax.factor index 566f5471f4..b2f063ddf1 100755 --- a/core/syntax/syntax.factor +++ b/core/syntax/syntax.factor @@ -189,8 +189,12 @@ IN: bootstrap.syntax ] define-syntax "call-next-method" [ - current-class get literalize parsed - current-generic get literalize parsed - \ (call-next-method) parsed + current-class get current-generic get + 2dup [ word? ] both? [ + [ literalize parsed ] bi@ + \ (call-next-method) parsed + ] [ + not-in-a-method-error + ] if ] define-syntax ] with-compilation-unit