Mercury Bugs - mercury
View Issue Details
0000231mercuryBugpublic2011-11-22 16:302014-10-09 12:48
Assigned To 
PlatformOSOS Version
Product Version 
Target VersionFixed in Version 
Summary0000231: No way to specify instantiatedness of char type
DescriptionThere is currently no way to specify the instantiatedness of a char type, e.g.:

:- inst whitespace ---> ' '; '\t'; '\n'.

The above instantiatednesses are represented as atoms, but since instantiatednesses of character values are internally represented as type char_const(), this leads to mode errors such as:

Final instantiatedness of `HeadVar__1' was `bound('\t' ; '\n' ; ' ')',
expected final instantiatedness was `bound('\t' ; '\n' ; ' ')'.

Attached is a patch which fixes this bug.
TagsNo tags attached.
Attached Files? char_inst.m (222) 2011-11-22 16:30
patch mercury-compiler-char-inst.patch (1,974) 2011-11-22 16:31

2014-10-09 12:48   
Applying the patch as-is would be unsafe. If you try to switch on the variable following the call to is_whitespace, e.g.

( C = (' '), ...
; C = ('\t'), ...
; C = ('\n'), ...

The inst of C is represented as a list of cons/3 functors and the cases as `char_const' functors. Switch detection does not see them as equivalent so replaces the disjunction by `fail'. I assume other parts of the compiler may have similar problems.

Issue History
2011-11-22 16:30colandermanNew Issue
2011-11-22 16:30colandermanFile Added: char_inst.m
2011-11-22 16:31colandermanFile Added: mercury-compiler-char-inst.patch
2014-10-09 12:48wangpNote Added: 0000795