[mercury-users] strange mmc behavior
Fergus Henderson
fjh at cs.mu.OZ.AU
Thu Jul 26 07:32:33 AEST 2001
On 25-Jul-2001, Holger Krug <hkrug at rationalizer.com> wrote:
> In modifying mercury-extras/lex I experienced some strange compiler
> behavior. The modification of lex consists in introducing higher-order
> functions into the lexemes. This makes it necessary to introduce
> complicated modes for arguments containing lexemes. The problem I encountered
> was the following:
>
> :- module lex.
>
> :- implementation.
>
> :- pred live_lexeme_in_accepting_state(list(live_lexeme(Tok)),
> annotated_token(Tok)).
> :- mode live_lexeme_in_accepting_state(in(live_lexeme_list),
> out(annotated_token)) is semidet.
>
> live_lexeme_in_accepting_state([L | Ls], Token) :- % line 412
> ( if in_accepting_state(L) % line 413
> then Token = L ^ clxm_token
> else live_lexeme_in_accepting_state(Ls, Token) % line 415
> ).
>
> If the called predicate `in_accepting_state' is placed in module `lex'
> all works fine. Difficulties arise immediately when I place
> `in_accepting_state' into the separate sub-module `lex__lexeme'. In
> this case the following error occurs:
>
> lex.m:415: In clause for `live_lexeme_in_accepting_state(in((lex:live_lexeme_list)), out((lex:annotated_token)))':
> lex.m:415: mode error in conjunction. The next 2 error messages
> lex.m:415: indicate possible causes of this error.
> lex.m:413: In clause for `live_lexeme_in_accepting_state(in((lex:live_lexeme_list)), out((lex:annotated_token)))':
> lex.m:413: in argument 1 of call to predicate `lex:lexeme:in_accepting_state/1':
> lex.m:413: mode error: variable `L' has instantiatedness `bound((lex:lexeme):compiled_lexeme(bound((lex:ignore) ; lex:t((func((ground -> ground)) = (free -> ground) is det))), ground, ground))',
> lex.m:413: expected instantiatedness was `(lex:live_lexeme)'.
> lex.m:412: In clause for `live_lexeme_in_accepting_state(in((lex:live_lexeme_list)), out((lex:annotated_token)))':
> lex.m:412: in argument 2 of clause head:
> lex.m:412: mode error in unification of `HeadVar__2' and `Token'.
> lex.m:412: Variable `HeadVar__2' has instantiatedness `free',
> lex.m:412: variable `Token' has instantiatedness `free'.
>
> What is strange in that error message is that both modes:
> `(lex:live_lexeme)'
> and
> `bound((lex:lexeme):compiled_lexeme(bound((lex:ignore) ; lex:t((func((ground -> ground)) = (free -> ground) is det))), ground, ground))'
> are exactly the same !
Those are insts, not modes.
Are you sure they are the same? You didn't post the definitions of the
live_lexeme inst or the live_lexeme_list inst.
> The second part of the error message:
> "mode error in unification of `HeadVar__2' and `Token'"
> I also cannot understand.
This second part of the error message is not the real problem.
It just indicates that it can't unify the second argument with the
variable `Token' until `Token' is bound, and in this case `Token' never
got bound, because of the error reported earlier.
--
Fergus Henderson <fjh at cs.mu.oz.au> | "I have always known that the pursuit
The University of Melbourne | of excellence is a lethal habit"
WWW: <http://www.cs.mu.oz.au/~fjh> | -- the last words of T. S. Garp.
--------------------------------------------------------------------------
mercury-users mailing list
post: mercury-users at cs.mu.oz.au
administrative address: owner-mercury-users at cs.mu.oz.au
unsubscribe: Address: mercury-users-request at cs.mu.oz.au Message: unsubscribe
subscribe: Address: mercury-users-request at cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------
More information about the users
mailing list