2024-06-24 08:11 AEST

View Issue Details Jump to Notes ]
IDProjectCategoryView StatusLast Update
0000381mercuryBugpublic2015-07-15 12:07
Assigned To 
PlatformSome Lenovo i5 laptop or otherOSLinux MintOS Version15
Product Version 
Target VersionFixed in Version 
Summary0000381: Compiler deals poorly with '.' character constants.
DescriptionUnifying variables with '.' causes compiler to fail with "operator precedence error".
Steps To ReproduceCompile attached code. If line 10 is not commented out (as uploaded) the compiler will explode. If line 10 is commented out, the compiler is happy.
Additional InformationMercury Compiler, version rotd-2015-02-20, on x86_64-unknown-linux-gnu
TagsNo tags attached.
Attached Files
  • ? file icon bug.m (401 bytes) 2015-03-01 00:09




mark (administrator)

Mercury has no specific lexical syntax for character literals - they are just terms with arity 0, whose identifiers have length 1.

Single lower case characters are valid identifiers, and so are all operators defined in the operator table. Any other character needs to be enclosed in single-quotes to be a valid identifier, otherwise it won't be treated as a character literal.

Single-character operators in the operator table don't need the quotes, as they are already valid identifiers. However, operators in this table never have arity zero, so they won't be treated as character literals anyway, unless parentheses are used to override the operator table in the usual way. That is the problem in bug.m.

Hence this issue is not a bug, it is intended behaviour. However, it is a common problem for users, and if Mercury had specific syntax for character literals this common problem would be avoided. So perhaps this issue should be considered a feature request for character literal syntax?

-Issue History
Date Modified Username Field Change
2015-03-01 00:09 ttmrichter New Issue
2015-03-01 00:09 ttmrichter File Added: bug.m
2015-07-15 12:07 mark Note Added: 0000844
+Issue History