[m-dev.] diff: fix bug in inter-module optimization
Simon Taylor
stayl at cs.mu.OZ.AU
Sun Jan 21 14:05:28 AEDT 2001
This change has been committed on the main and release branches.
Estimated hours taken: 0.5
compiler/typecheck.m:
Fix a bug which caused a spurious type error when compiling
the compiler with --intermodule-optimization.
tests/valid/Mmakefile:
tests/valid/intermod_record.m:
tests/valid/intermod_record2.m:
Test case.
Index: compiler/typecheck.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/typecheck.m,v
retrieving revision 1.296
diff -u -u -r1.296 typecheck.m
--- compiler/typecheck.m 2001/01/15 07:15:34 1.296
+++ compiler/typecheck.m 2001/01/21 02:37:43
@@ -3689,9 +3689,11 @@
% has supplied type or mode declarations, the
% goal should only contain an application of the
% field access function, not constructor applications
- % or function calls.
+ % or function calls. The clauses in `.opt' files will
+ % already have been expanded into unifications.
%
- TypeCheckInfo ^ is_field_access_function = yes
+ TypeCheckInfo ^ is_field_access_function = yes,
+ TypeCheckInfo ^ import_status \= opt_imported
->
(
builtin_field_access_function_type(TypeCheckInfo,
Index: tests/valid/Mmakefile
===================================================================
RCS file: /home/mercury1/repository/tests/valid/Mmakefile,v
retrieving revision 1.81
diff -u -u -r1.81 Mmakefile
--- tests/valid/Mmakefile 2001/01/05 06:57:19 1.81
+++ tests/valid/Mmakefile 2001/01/20 02:07:21
@@ -83,6 +83,7 @@
intermod_nested_module.m \
intermod_nested_uniq.m \
intermod_quote.m \
+ intermod_record.m \
intermod_test.m \
intermod_typeclass.m \
intermod_type_spec.m \
@@ -241,6 +242,8 @@
MCFLAGS-intermod_nested_uniq2 = --intermodule-optimization
MCFLAGS-intermod_quote = --intermodule-optimization
MCFLAGS-intermod_quote2 = --intermodule-optimization
+MCFLAGS-intermod_record = --intermodule-optimization
+MCFLAGS-intermod_record2 = --intermodule-optimization
MCFLAGS-intermod_test = --intermodule-optimization
MCFLAGS-intermod_test2 = --intermodule-optimization
MCFLAGS-intermod_typeclass = --intermodule-optimization
Index: tests/valid/intermod_record.m
===================================================================
RCS file: intermod_record.m
diff -N intermod_record.m
--- /dev/null Sun Jan 21 13:35:30 2001
+++ intermod_record.m Sat Jan 20 12:59:24 2001
@@ -0,0 +1,26 @@
+% This is a regression test for a bug in inter-module optimization of
+% field access functions which resulted in the following error message:
+%
+% intermod_record2.opt:005: In clause for function `intermod_record2:field/1':
+% intermod_record2.opt:005: in argument 1 of clause head:
+% intermod_record2.opt:005: error: wrong number of arguments (1; should be 1)
+% intermod_record2.opt:005: in use of constructor `intermod_record2:record'.
+%
+%
+% The problem was that the compiler expects the clauses automatically
+% introduced for field access functions to only contain a call to the field
+% access function which will later be expanded into unifications, The
+% clauses written to `.opt' files are already expanded.
+%
+:- module intermod_record.
+
+:- interface.
+
+:- import_module intermod_record2.
+
+:- func use_field(record) = int.
+
+:- implementation.
+
+use_field(R) = field(R).
+
Index: tests/valid/intermod_record2.m
===================================================================
RCS file: intermod_record2.m
diff -N intermod_record2.m
--- /dev/null Sun Jan 21 13:35:30 2001
+++ intermod_record2.m Sat Jan 20 13:00:00 2001
@@ -0,0 +1,15 @@
+:- module intermod_record2.
+
+:- interface.
+
+:- type record.
+
+:- func field(record) = int.
+
+:- implementation.
+
+:- type record
+ ---> record(
+ field :: int
+ ).
+
--------------------------------------------------------------------------
mercury-developers mailing list
Post messages to: mercury-developers at cs.mu.oz.au
Administrative Queries: owner-mercury-developers at cs.mu.oz.au
Subscriptions: mercury-developers-request at cs.mu.oz.au
--------------------------------------------------------------------------
More information about the developers
mailing list