From 5584d032c84db39b92936c814e61475311866d09 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=A9mie=20Astor?= Date: Wed, 15 Jul 2020 23:37:18 +0200 Subject: [PATCH] :art: Improve pattern match scoping --- src/parse/check.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/parse/check.c b/src/parse/check.c index 40506c40..e904d781 100644 --- a/src/parse/check.c +++ b/src/parse/check.c @@ -1246,8 +1246,6 @@ ANN static m_bool case_loop(const Env env, const Stmt_Match stmt) { } ANN static m_bool _check_stmt_match(const Env env, const Stmt_Match stmt) { - if(stmt->where) - CHECK_BB(check_stmt(env, stmt->where)) CHECK_OB(check_exp(env, stmt->cond)) MATCH_INI(env->scope) const m_bool ret = case_loop(env, stmt); @@ -1255,10 +1253,16 @@ ANN static m_bool _check_stmt_match(const Env env, const Stmt_Match stmt) { return ret; } -ANN static m_bool check_stmt_match(const Env env, const Stmt_Match stmt) { +ANN static inline m_bool handle_where(const Env env, const Stmt_Match stmt) { + if(stmt->where) + CHECK_BB(check_stmt(env, stmt->where)) RET_NSPC(_check_stmt_match(env, stmt)) } +ANN static m_bool check_stmt_match(const Env env, const Stmt_Match stmt) { + RET_NSPC(handle_where(env, stmt)) +} + #define check_stmt_while check_stmt_flow #define check_stmt_until check_stmt_flow #define check_stmt_pp dummy_func -- 2.43.0