[m-rev.] diff: fix bug in user event specs

Mark Brown mark at csse.unimelb.edu.au
Fri Feb 23 17:34:23 AEDT 2007


Estimated hours taken: 3
Branches: main

Fix a syntax error in the event set descriptions being generated in the
module layout data.

compiler/prog_event.m:
	Don't put parentheses around the arguments for zero-arity user
	defined types.

tests/debugger/Mercury.options:
tests/debugger/Mmakefile:
tests/debugger/user_event_2.exp:
tests/debugger/user_event_2.inp:
tests/debugger/user_event_2.m:
tests/debugger/user_event_spec_2:
	Test case.

Index: compiler/prog_event.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/prog_event.m,v
retrieving revision 1.9
diff -u -r1.9 prog_event.m
--- compiler/prog_event.m	18 Feb 2007 08:01:55 -0000	1.9
+++ compiler/prog_event.m	23 Feb 2007 06:13:53 -0000
@@ -770,9 +770,16 @@
         Type = defined_type(SymName, ArgTypes, Kind),
         expect(unify(Kind, kind_star), this_file,
             "describe_attr_type: not kind_star"),
-        ArgTypeDescs = string.join_list(", ",
-            list.map(describe_attr_type, ArgTypes)),
-        Desc = sym_name_to_string(SymName) ++ "(" ++ ArgTypeDescs ++ ")"
+        (
+            ArgTypes = [],
+            ArgTypeDescs = ""
+        ;
+            ArgTypes = [_ | _],
+            ArgTypeDescs = "(" ++
+                string.join_list(", ", list.map(describe_attr_type, ArgTypes))
+                ++ ")"
+        ),
+        Desc = sym_name_to_string(SymName) ++ ArgTypeDescs
     ;
         Type = builtin_type(BuiltinType),
         builtin_type_to_string(BuiltinType, Desc)
Index: tests/debugger/Mercury.options
===================================================================
RCS file: /home/mercury1/repository/tests/debugger/Mercury.options,v
retrieving revision 1.21
diff -u -r1.21 Mercury.options
--- tests/debugger/Mercury.options	14 Dec 2006 04:36:00 -0000	1.21
+++ tests/debugger/Mercury.options	23 Feb 2007 06:13:54 -0000
@@ -45,6 +45,8 @@
 
 MCFLAGS-user_event_shallow = --event-set-file-name user_event_spec --trace shallow
 
+MCFLAGS-user_event_2 = --event-set-file-name user_event_spec_2
+
 MCFLAGS-synth_attr = --event-set-file-name synth_attr_spec
 
 # The solver_test test case exercises the printing of a procedure name, and
Index: tests/debugger/Mmakefile
===================================================================
RCS file: /home/mercury1/repository/tests/debugger/Mmakefile,v
retrieving revision 1.129
diff -u -r1.129 Mmakefile
--- tests/debugger/Mmakefile	14 Dec 2006 04:36:00 -0000	1.129
+++ tests/debugger/Mmakefile	23 Feb 2007 06:13:54 -0000
@@ -53,7 +53,8 @@
 	synth_attr			\
 	type_desc_test			\
 	uci_index			\
-	user_event
+	user_event			\
+	user_event_2
 
 # We currently don't pass this test.
 #	deeply_nested_typeinfo
@@ -534,6 +535,10 @@
 
 user_event.out: user_event user_event.inp user_event_spec
 	$(MDB_STD) ./user_event < user_event.inp 2>&1 > user_event.out 2>&1
+
+user_event_2.out: user_event_2 user_event_2.inp user_event_spec_2
+	$(MDB_STD) ./user_event_2 < user_event_2.inp 2>&1 \
+		> user_event_2.out 2>&1
 
 user_event_shallow.out: user_event_shallow user_event_shallow.inp \
 		user_event_spec
Index: tests/debugger/user_event_2.exp
===================================================================
RCS file: tests/debugger/user_event_2.exp
diff -N tests/debugger/user_event_2.exp
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ tests/debugger/user_event_2.exp	23 Feb 2007 06:13:54 -0000
@@ -0,0 +1,9 @@
+      E1:     C1 CALL pred user_event_2.main/2-0 (det) user_event_2.m:10
+mdb> echo on
+Command echo enabled.
+mdb> register --quiet
+mdb> user
+      E2:     C2 USER <event_with_zero_arity_defined_type> pred user_event_2.do_something/3-0 (det) c1; user_event_2.m:16
+mdb> print *
+       arg (attr 0, Data)     	foo(43)
+mdb> continue
Index: tests/debugger/user_event_2.inp
===================================================================
RCS file: tests/debugger/user_event_2.inp
diff -N tests/debugger/user_event_2.inp
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ tests/debugger/user_event_2.inp	23 Feb 2007 06:13:54 -0000
@@ -0,0 +1,5 @@
+echo on
+register --quiet
+user
+print *
+continue
Index: tests/debugger/user_event_2.m
===================================================================
RCS file: tests/debugger/user_event_2.m
diff -N tests/debugger/user_event_2.m
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ tests/debugger/user_event_2.m	23 Feb 2007 06:13:54 -0000
@@ -0,0 +1,17 @@
+:- module user_event_2.
+:- interface.
+:- import_module io.
+:- pred main(io::di, io::uo) is det.
+:- implementation.
+
+:- type foo
+	--->	foo(int).
+
+main(!IO) :-
+	do_something(foo(43), !IO).
+
+:- pred do_something(foo::in, io::di, io::uo) is det.
+
+do_something(Data, !IO) :-
+	event event_with_zero_arity_defined_type(Data).
+
Index: tests/debugger/user_event_spec_2
===================================================================
RCS file: tests/debugger/user_event_spec_2
diff -N tests/debugger/user_event_spec_2
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ tests/debugger/user_event_spec_2	23 Feb 2007 06:13:54 -0000
@@ -0,0 +1,6 @@
+event set user_event_spec_2
+
+event event_with_zero_arity_defined_type(
+	arg:		foo
+)
+
--------------------------------------------------------------------------
mercury-reviews mailing list
Post messages to:       mercury-reviews at csse.unimelb.edu.au
Administrative Queries: owner-mercury-reviews at csse.unimelb.edu.au
Subscriptions:          mercury-reviews-request at csse.unimelb.edu.au
--------------------------------------------------------------------------



More information about the reviews mailing list