ソースを参照

Fixed property getter and setter have different types.

Mark Sibly 8 年 前
コミット
e74f1c61b3
2 ファイル変更8 行追加14 行削除
  1. 5 2
      src/mx2cc/property.monkey2
  2. 3 12
      src/mx2cc/test.monkey2

+ 5 - 2
src/mx2cc/property.monkey2

@@ -39,7 +39,7 @@ Class PropertyList Extends FuncList
 	
 	Method OnSemant:SNode() Override
 	
-		type=Type.VoidType
+		type=Null
 		
 		If pdecl.getFunc
 			Try
@@ -56,12 +56,15 @@ Class PropertyList Extends FuncList
 			Try
 				setFunc=New FuncValue( pdecl.setFunc,scope,Null,Null )
 				setFunc.Semant()
-				If type=Type.VoidType type=setFunc.ftype.argTypes[0]
+				If type And Not type.Equals( setFunc.ftype.argTypes[0] ) Throw New SemantEx( "Property '"+pdecl.ident+"' getter and setter have different types" )
+				If Not type type=setFunc.ftype.argTypes[0]
 				PushFunc( setFunc )
 			Catch ex:SemantEx
 			End
 		Endif
 		
+		If Not type SemantError( "PropertyList.OnSemant()" )
+		
 		Return Self
 	End
 	

+ 3 - 12
src/mx2cc/test.monkey2

@@ -1,19 +1,10 @@
 
 #Import "<reflection>"
 
-Struct S
-	Field x:int
-
-End
-
-Function F:S Ptr()
-	Return null
-End
-
-Function F2:Int ptr()
-	Return Null
+Class C
+	Property Update( value:Int )
+	End
 End
 
 Function Main()
-	
 End