From 249e0bd4ac5d4c5cab98aef311b85be3c31cff87 Mon Sep 17 00:00:00 2001 From: Pelle Johnsen Date: Wed, 11 Nov 2020 07:58:53 +0000 Subject: [PATCH] [glsl-in] Make sure functions ends with return --- src/front/glsl/parser.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/front/glsl/parser.rs b/src/front/glsl/parser.rs index 69827f9637..341ef58bc9 100644 --- a/src/front/glsl/parser.rs +++ b/src/front/glsl/parser.rs @@ -1092,12 +1092,17 @@ pomelo! { } } - function_definition ::= function_prototype(mut f) compound_statement_no_new_scope(cs) { + function_definition ::= function_prototype(mut f) compound_statement_no_new_scope(mut cs) { std::mem::swap(&mut f.expressions, &mut extra.context.expressions); std::mem::swap(&mut f.local_variables, &mut extra.context.local_variables); extra.context.clear_scopes(); extra.context.lookup_global_var_exps.clear(); extra.context.typifier = Typifier::new(); + // make sure function ends with return + match cs.last() { + Some(Statement::Return {..}) => {} + _ => {cs.push(Statement::Return { value:None });} + } f.body = cs; f.fill_global_use(&extra.module.global_variables); f