2024-07-18 09:29 AEST

View Issue Details Jump to Notes ]
IDProjectCategoryView StatusLast Update
0000001mercuryBugpublic2007-09-25 11:54
Assigned To 
Product Version 
Target VersionFixed in Version 
Summary0000001: non-instructive error message: 'unused' mode requires explicit lambda expression

the attached code demonstrates a not quite instructive error message.

While the predicate main2/2 compiles fine, main/2 does not, because I try to directly pass/curry an argument in 'unused' mode.

One solution is to automatically infer the correct mode when currying, another is to make the error message more specific.

Thanks, O.
Additional Informationbug.m:019: In clause for `main(in, out)':
bug.m:019: in argument 1 of call to predicate `call_int_modifier'/3:
bug.m:019: mode error: variable `V_7' has instantiatedness `free',
bug.m:019: expected instantiatedness for non-local variables of lambda goals
bug.m:019: is `ground'.
TagsNo tags attached.
Attached Files
  • ? file icon bug.m (615 bytes) 2007-09-17 11:18




obo (reporter)

Oh, in fact, changing main2 to something more useful -- i.e. passing the 'unused' value from outside (to pass type information) is prohibited for the same reasons: non-local vars ought to have ground inst.

:- pred main2(mytype::unused, int::in, int::out) is det.
main2(X, In, Out) :-
    (pred(I::in, O::out) is det :- add(X, I, O)),
    In, Out).

I'm failing to work around it using (ground) type_desc:

:- import_module type_desc.

:- pred main3(mytype::unused, int::in, int::out) is det.
main3(X, In, Out) :-
  XType = type_of(X),
    (pred(I::in, O::out) is det :-
      has_type(NewX, XType),
      add(NewX, I, O)),
    In, Out).

bug.m:037: In clause for predicate `main3'/3:
bug.m:037: in argument 1 of call to predicate `add'/3:
bug.m:037: type error: variable `NewX' has type `(some [T] T)',
bug.m:037: expected type was `(bug2.mytype)'.

Is there a way to construct a free variable with a specific type? My guess is that this is the core restriction of the current mode checker...


juliensf (administrator)

We will take a look at it.

-Issue History
Date Modified Username Field Change
2007-09-17 11:18 obo New Issue
2007-09-17 11:18 obo File Added: bug.m
2007-09-17 11:56 obo Note Added: 0000001
2007-09-25 11:54 juliensf Note Added: 0000005
2007-09-25 11:54 juliensf Status new => acknowledged
+Issue History