Mercury Bugs - mercury
View Issue Details
0000001mercuryBugpublic2007-09-17 11:182007-09-25 11:54
Reporterobo 
Assigned To 
PrioritynormalSeverityminorReproducibilityalways
StatusacknowledgedResolutionopen 
PlatformOSOS Version
Product Version 
Target VersionFixed in Version 
Summary0000001: non-instructive error message: 'unused' mode requires explicit lambda expression
DescriptionHi.

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? bug.m (615) 2007-09-17 11:18
https://bugs.mercurylang.org/file_download.php?file_id=1&type=bug

Notes
(0000001)
obo   
2007-09-17 11:56   
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) :-
  call_int_modifier(
    (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),
  call_int_modifier(
    (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...
(0000005)
juliensf   
2007-09-25 11:54   
We will take a look at it.

Issue History
2007-09-17 11:18oboNew Issue
2007-09-17 11:18oboFile Added: bug.m
2007-09-17 11:56oboNote Added: 0000001
2007-09-25 11:54juliensfNote Added: 0000005
2007-09-25 11:54juliensfStatusnew => acknowledged