Mercury Bugs - mercury
View Issue Details
0000313mercuryBugpublic2014-01-28 06:082014-01-28 09:45
Reporterlpimmes 
Assigned To 
PriorityhighSeveritymajorReproducibilityalways
StatusclosedResolutionno change required 
PlatformOSosxOS Version10.9.1
Product Version 
Target VersionFixed in Version 
Summary0000313: array module declared, but compiler complains
Description:- pred main(io, io).
:- mode main(di, uo) is det.

:- implementation.
:- import_module array, int, list, string.

:- func rodCut(array, int, int, int) = int.
:- mode rodCut(in, in, in, in) = out is det.
Steps To Reproducerodcut 495>mmc --make --fully-strict -E -v -O 0 --use-subdirs rodcut

rodcut.m:046: In definition of function `rodcut.rodCut'/6:
rodcut.m:046: error: undefined type `array'/0.
TagsNo tags attached.
Attached Files

Notes
(0000615)
pbone   
2014-01-28 09:44   
The type "array" doesn't exist, at all. The type "array(T)" however does. These types are parametric, they can take another type as a parameter. This can be a type variable such as T, or it can be a concrete type or another parameterised type. My guess is that you want to use the type "int" as array/1's parameter. That would make your "array of integers" type "array(int)".

The relevant part of the reference manual may help:http://www.mercurylang.org/information/doc-release/mercury_ref/Types.html#Types and http://www.mercurylang.org/information/doc-release/mercury_ref/Discriminated-unions.html#Discriminated-unions
(0000616)
juliensf   
2014-01-28 09:45   
The compiler is correct, the array module does *not* define the type array/0. It does define
the type array/1. Your function declaration should most probably have been:


    : func rodCut(array(T), int, int, int) = int.

where T is whatever the element type of the array (or indeed just a type variable if
the function is supposed to be polymorphic.
(0000617)
pbone   
2014-01-28 09:45   
This is not a bug, it's a misunderstanding.

Issue History
2014-01-28 06:08lpimmesNew Issue
2014-01-28 09:44pboneNote Added: 0000615
2014-01-28 09:45juliensfNote Added: 0000616
2014-01-28 09:45pboneNote Added: 0000617
2014-01-28 09:45pboneStatusnew => closed
2014-01-28 09:45pboneResolutionopen => no change required