From fcb80484487eadfcdf700940de65cc6e23fa3099 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fredrik=20H=C3=BCbinette=20=28Hubbe=29?= <hubbe@hubbe.net> Date: Thu, 22 May 1997 16:27:33 -0700 Subject: [PATCH] return on void expressions now gives an error Rev: src/las.c:1.34 Rev: src/testsuite.in:1.43 --- src/las.c | 6 +++++- src/testsuite.in | 3 ++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/las.c b/src/las.c index f71e13c3b4..4597137111 100644 --- a/src/las.c +++ b/src/las.c @@ -4,7 +4,7 @@ ||| See the files COPYING and DISCLAIMER for more information. \*/ #include "global.h" -RCSID("$Id: las.c,v 1.33 1997/05/19 23:31:01 hubbe Exp $"); +RCSID("$Id: las.c,v 1.34 1997/05/22 23:27:32 hubbe Exp $"); #include "language.h" #include "interpret.h" @@ -1278,6 +1278,10 @@ void fix_type_field(node *n) break; case F_RETURN: + if(CAR(n)->type == void_type_string) + { + yyerror("You cannot return a void expression"); + } if(local_variables && local_variables->current_return_type && !match_types(local_variables->current_return_type,CAR(n)->type) && diff --git a/src/testsuite.in b/src/testsuite.in index 80fca88e51..513d39f9fa 100644 --- a/src/testsuite.in +++ b/src/testsuite.in @@ -1,9 +1,10 @@ -test_true([["$Id: testsuite.in,v 1.42 1997/05/20 01:06:45 hubbe Exp $"]]) +test_true([["$Id: testsuite.in,v 1.43 1997/05/22 23:27:33 hubbe Exp $"]]) test_eq(1e1,10.0) test_eq(1E1,10.0) test_eq(1e+1,10.0) test_eq(1.1e1,11.0) test_eq(1e-1,0.1) +test_compile_error([[void foo() { return destruct(this_object()); }]]) test_any([[class foo { constant x=17; }; class bar { inherit foo; constant x=18; }; return bar()->x;]],18) test_program([[inline string foo(string s){ while(s[0] == ' ' || s[0] == '\t') s = s[1..]; return(s); } string a() { return foo(" bar"); }]]) test_true([[lambda(function f) {return 1;}(object_program(this_object()));]]) -- GitLab