[m-users.] Question regarding Uncaught Mercury exception.

Harrison Pincket harrisonpincket at gmail.com
Mon May 7 05:41:00 AEST 2018


Hello all,

I'm new to Mercury so I apologize if this question is naive. As a simple
task I am trying to identify a conjugated french verb.

:- type person
      --->  firstSing
      ...
      ;     thirdPlur.

:- pred er_ending(person, string).
:- mode er_ending(in, in) is semidet.
:- mode er_ending(in, out) is det.
:- mode er_ending(out, in) is nondet.

er_ending(firstSing, "e").
er_ending(secondSing, "es").
er_ending(thirdSing, "e").
er_ending(firstPlur, "ons").
er_ending(secondPlur, "ez").
er_ending(thirdPlur, "ent").

This is only part of the program, but when I compile it I get this error:

Uncaught Mercury exception:
Software Error: predicate
`ml_backend.ml_string_switch.ml_generate_string_binary_simple_lookup_switch'/11:
Unexpected: model_non

I think this error may be due to how I am trying to use the predicate
er_ending/2. Sure enough it was! Just before sending this mail I changed
the modes to:

:- pred er_ending(person, string).
:- mode er_ending(in, in) is semidet.
:- mode er_ending(in, out) is det.
:- mode er_ending(out, out) is multi. <-- changed here.

And now it is working just dandy. I think I confused myself by assuming the
second argument was bound when it fact it wasn't. Regardless I think it
would be a good idea to handle the exception or provide helpful error
message. I tried a lot of things before solving it just now. I should note
that I did not receive an exception so long as the string argument of
er_ending was unique in my facts. Commenting out 'er_ending(thirdSing,
"e").' allows the program to compile even with the old mode.

I hope you find this email coherent,

Thanks,
Harrison
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mercurylang.org/archives/users/attachments/20180506/301b2f79/attachment.html>


More information about the users mailing list