This repository was archived by the owner on Apr 14, 2020. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +24
-2
lines changed Expand file tree Collapse file tree 2 files changed +24
-2
lines changed Original file line number Diff line number Diff line change @@ -97,8 +97,6 @@ impl Renamer {
97
97
let mut names = module. dataDefinitions . iter ( )
98
98
. flat_map ( |data| data. constructors . iter ( ) . map ( |ctor| ctor. name ) )
99
99
. chain ( module. newtypes . iter ( ) . map ( |newtype| newtype. constructor_name ) )
100
- . chain ( module. instances . iter ( )
101
- . flat_map ( |instance| binding_groups ( instance. bindings . as_slice ( ) ) . map ( |binds| binds[ 0 ] . name ) ) )
102
100
. chain ( module. classes . iter ( ) . flat_map ( |class|
103
101
Some ( class. name ) . move_iter ( )
104
102
. chain ( class. declarations . iter ( ) . map ( |decl| decl. name ) )
@@ -107,6 +105,12 @@ impl Renamer {
107
105
for name in names {
108
106
self . declare_global ( name, uid) ;
109
107
}
108
+ for instance in module. instances . iter ( ) {
109
+ let class_uid = self . get_name ( instance. classname ) . uid ;
110
+ for binds in binding_groups ( instance. bindings . as_slice ( ) ) {
111
+ self . declare_global ( binds[ 0 ] . name , class_uid) ;
112
+ }
113
+ }
110
114
}
111
115
112
116
fn rename_bindings ( & mut self , bindings : ~[ Binding < InternedStr > ] , is_global : bool ) -> ~[ Binding < Name > ] {
Original file line number Diff line number Diff line change @@ -1046,6 +1046,24 @@ main = (test (0 :: Int) 2) && not (test (1 :: Int) 0)")
1046
1046
. unwrap_or_else( |err| fail ! ( "{}" , err) ) ;
1047
1047
assert_eq ! ( result, Some ( ConstructorResult ( 0 , Vec :: new( ) ) ) ) ;
1048
1048
}
1049
+ #[ test]
1050
+ fn implement_class( ) {
1051
+ let result = execute_main_string(
1052
+ r"
1053
+ import Prelude
1054
+ data AB = A | B
1055
+
1056
+ instance Eq AB where
1057
+ (==) A A = True
1058
+ (==) B B = True
1059
+ (==) _ _ = False
1060
+
1061
+ test x y = x == y
1062
+
1063
+ main = A == B && test A A" )
1064
+ . unwrap_or_else( |err| fail ! ( "{}" , err) ) ;
1065
+ assert_eq ! ( result, Some ( ConstructorResult ( 1 , Vec :: new( ) ) ) ) ;
1066
+ }
1049
1067
1050
1068
#[ test]
1051
1069
fn deriving_eq( ) {
You can’t perform that action at this time.
0 commit comments