From 1530bf21edd6b475ef545a2360481ef70022e354 Mon Sep 17 00:00:00 2001 From: vsc Date: Wed, 20 Nov 2002 05:17:26 +0000 Subject: [PATCH] compiler should check for variables first! git-svn-id: https://yap.svn.sf.net/svnroot/yap/trunk@694 b08c6af1-5177-4d33-ba66-4b1c6b8b522a --- C/compiler.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/C/compiler.c b/C/compiler.c index a206c8928..e0572dec5 100644 --- a/C/compiler.c +++ b/C/compiler.c @@ -1127,8 +1127,12 @@ c_goal(Term Goal, int mod) if (IsApplTerm(Goal) && FunctorOfTerm(Goal) == FunctorModule) { Term M = ArgOfTerm(1, Goal); - if (!IsVarTerm(M) && !IsAtomTerm(M)) { - Yap_Error_TYPE = TYPE_ERROR_ATOM; + if (IsVarTerm(M) || !IsAtomTerm(M)) { + if (IsVarTerm(M)) { + Yap_Error_TYPE = INSTANTIATION_ERROR; + } else { + Yap_Error_TYPE = TYPE_ERROR_ATOM; + } Yap_Error_Term = M; Yap_ErrorMessage = "in module name"; save_machine_regs(); @@ -1137,10 +1141,11 @@ c_goal(Term Goal, int mod) Goal = ArgOfTerm(2, Goal); mod = Yap_LookupModule(M); } - if (IsNumTerm(Goal)) { + if (IsVarTerm(Goal)) { + Goal = Yap_MkApplTerm(FunctorCall, 1, &Goal); + } else if (IsNumTerm(Goal)) { FAIL("goal can not be a number", TYPE_ERROR_CALLABLE, Goal); - } - else if (IsRefTerm(Goal)) { + } else if (IsRefTerm(Goal)) { Yap_Error_TYPE = TYPE_ERROR_DBREF; Yap_Error_Term = Goal; FAIL("goal argument in static procedure can not be a data base reference", TYPE_ERROR_CALLABLE, Goal); @@ -1148,9 +1153,6 @@ c_goal(Term Goal, int mod) else if (IsPairTerm(Goal)) { Goal = Yap_MkApplTerm(FunctorCall, 1, &Goal); } - else if (IsVarTerm(Goal)) { - Goal = Yap_MkApplTerm(FunctorCall, 1, &Goal); - } if (IsAtomTerm(Goal)) { Atom atom = AtomOfTerm(Goal);