2
0
Эх сурвалжийг харах

Enum members no longer have 'scope'.

Mark Sibly 7 жил өмнө
parent
commit
66f213e3e0

+ 5 - 1
src/mx2cc/expr.monkey2

@@ -192,6 +192,11 @@ Class MemberExpr Extends Expr
 		
 		Local tvalue:=Cast<TypeValue>( evalue )
 		
+		If Not tvalue And TCast<EnumType>( evalue.type )
+			
+			tvalue=New TypeValue( expr.SemantType( scope ) )
+		Endif
+		
 		If tvalue
 			
 			Local ctype:=TCast<ClassType>( tvalue.ttype )
@@ -206,7 +211,6 @@ Class MemberExpr Extends Expr
 			If Not value Throw New SemantEx( "Type '"+tvalue.ttype.Name+"' has no member named '"+ident+"'" )
 				
 			Return value
-		
 		Endif
 		
 		Local value:=evalue.FindValue( ident )

+ 2 - 0
src/mx2cc/mx2cc.monkey2

@@ -24,6 +24,8 @@ Global opts_time:Bool
 
 Global StartDir:String
 
+'Const TestArgs:="mx2cc makedocs std"
+ 
 'Const TestArgs:="mx2cc makemods -target=ios"' monkey libc"
  
 Const TestArgs:="mx2cc makeapp -clean src/mx2cc/test.monkey2"

+ 10 - 2
src/mx2cc/test.monkey2

@@ -1,6 +1,14 @@
-Namespace test
+
+Namespace myapp
+
+Enum E
+	A,B,C
+End
 
 Function Main()
 	
-	Print "Hello world"
+	Local e:=E.A.B
+	
+	Print Int(e)
+
 End

+ 1 - 1
src/mx2cc/type.monkey2

@@ -74,7 +74,7 @@ Class Type Extends SNode
 	End
 	
 	Method FindType:Type( ident:String ) Virtual
-		Throw New SemantEx( "Type '"+ToString()+"' has no scope" )
+		Throw New SemantEx( "Type '"+ToString()+"' has no inner type named '"+ident+"'" )
 		Return Null
 	End