[Swift-commit] r2440 - in trunk: src/org/griphyn/vdl/engine tests/language-behaviour

noreply at svn.ci.uchicago.edu noreply at svn.ci.uchicago.edu
Mon Jan 12 12:15:52 CST 2009


Author: benc
Date: 2009-01-12 12:15:51 -0600 (Mon, 12 Jan 2009)
New Revision: 2440

Added:
   trunk/tests/language-behaviour/027-single-character-typename.swift
   trunk/tests/language-behaviour/028-double-character-typename.swift
Modified:
   trunk/src/org/griphyn/vdl/engine/Karajan.java
Log:
fix bug 164 - some parts of the compiler were assuming that type names were at least 2 characters long

Modified: trunk/src/org/griphyn/vdl/engine/Karajan.java
===================================================================
--- trunk/src/org/griphyn/vdl/engine/Karajan.java	2009-01-12 18:04:36 UTC (rev 2439)
+++ trunk/src/org/griphyn/vdl/engine/Karajan.java	2009-01-12 18:15:51 UTC (rev 2440)
@@ -367,7 +367,7 @@
 	}
 	
 	void checkIsTypeDefined(String type) throws CompilationException {		
-		while (type.substring(type.length() - 2).equals("[]"))
+		while (type.length() > 2 && type.substring(type.length() - 2).equals("[]"))
 			type = type.substring(0, type.length() - 2);		
 		if (!type.equals("int") && !type.equals("float") && !type.equals("string") 
 				&& !type.equals("boolean") && !type.equals("external")) {
@@ -648,7 +648,7 @@
 			foreachST.setAttribute("in", inST);
 			
 			String inType = datatype(inST);
-			if (!inType.substring(inType.length() - 2).equals("[]"))
+			if (inType.length() < 2 || !inType.substring(inType.length() - 2).equals("[]"))
 				throw new CompilationException("You can iterate through an array structure only");
 			String varType = inType.substring(0, inType.length() - 2);			
 			innerScope.addVariable(foreach.getVar(), varType);

Added: trunk/tests/language-behaviour/027-single-character-typename.swift
===================================================================
--- trunk/tests/language-behaviour/027-single-character-typename.swift	                        (rev 0)
+++ trunk/tests/language-behaviour/027-single-character-typename.swift	2009-01-12 18:15:51 UTC (rev 2440)
@@ -0,0 +1,3 @@
+type q;
+q i;
+

Added: trunk/tests/language-behaviour/028-double-character-typename.swift
===================================================================
--- trunk/tests/language-behaviour/028-double-character-typename.swift	                        (rev 0)
+++ trunk/tests/language-behaviour/028-double-character-typename.swift	2009-01-12 18:15:51 UTC (rev 2440)
@@ -0,0 +1,4 @@
+type qq;
+
+qq i;
+




More information about the Swift-commit mailing list