Selaa lähdekoodia

Error messages for duplicate modifiers

* Added error message for duplicate Abstract/Final/Override/NoDebug modifier on functions/methods
* Adjusted error message for duplicate Abstract/Final modifier on types
HurryStarfish 6 vuotta sitten
vanhempi
commit
a2e0834a2f
1 muutettua tiedostoa jossa 12 lisäystä ja 6 poistoa
  1. 12 6
      parser.bmx

+ 12 - 6
parser.bmx

@@ -2731,9 +2731,11 @@ End Rem
 			attrs :| (fdecl.attrs & DECL_API_FLAGS)
 		End If
 		
+		Local declaredAttrs:Int
 		While True
 			If CParse( "nodebug" ) Then
-				attrs :| DECL_NODEBUG
+				If declaredAttrs & DECL_NODEBUG Then Err "Duplicate modifier 'NoDebug'"
+				declaredAttrs :| DECL_NODEBUG
 				Continue
 			End If
 				
@@ -2741,7 +2743,8 @@ End Rem
 				If Not classDecl Then
 					Err "Final cannot be used with global functions"
 				End If
-				attrs:|DECL_FINAL
+				If declaredAttrs & DECL_FINAL Then Err "Duplicate modifier 'Final'"
+				declaredAttrs :| DECL_FINAL
 				Continue
 			End If
 			
@@ -2754,7 +2757,8 @@ End Rem
 					Err "Abstract methods cannot appear in final types"
 				End If
 				
-				attrs:|DECL_ABSTRACT
+				If declaredAttrs & DECL_ABSTRACT Then Err "Duplicate modifier 'Abstract'"
+				declaredAttrs :| DECL_ABSTRACT
 				Continue
 			End If
 			
@@ -2762,12 +2766,14 @@ End Rem
 				If Not classDecl Then
 					Err "Override cannot be used with global functions"
 				End If
-				attrs :| DECL_OVERRIDE
+				If declaredAttrs & DECL_OVERRIDE Then Err "Duplicate modifier 'Override'"
+				declaredAttrs :| DECL_OVERRIDE
 				Continue
 			End If
 				
 			Exit
 		Wend
+		attrs :| declaredAttrs
 
 		'meta data for functions/methods
 		meta = ParseMetaData()
@@ -3132,7 +3138,7 @@ End Rem
 				End If
 				
 				If attrs & DECL_FINAL
-					Err "Duplicate type attribute."
+					Err "Duplicate modifier 'Final'."
 				End If
 
 				If attrs & DECL_ABSTRACT
@@ -3152,7 +3158,7 @@ End Rem
 				EndIf
 				
 				If attrs & DECL_ABSTRACT
-					Err "Duplicate type attribute."
+					Err "Duplicate modifier 'Abstract'."
 				End If
 				
 				If attrs & DECL_FINAL