Index: /trunk/ProjectFortress/src/com/sun/fortress/exceptions/FortressException.java
===================================================================
--- /trunk/ProjectFortress/src/com/sun/fortress/exceptions/FortressException.java (revision 3586)
+++ /trunk/ProjectFortress/src/com/sun/fortress/exceptions/FortressException.java (revision 3835)
@@ -23,4 +23,5 @@
 import java.util.ArrayList;
 
+import edu.rice.cs.plt.tuple.Option;
 import com.sun.fortress.interpreter.evaluator.Environment;
 import com.sun.fortress.nodes_util.ErrorMsgMaker;
@@ -111,4 +112,14 @@
     public FortressException(Iterable<? extends StaticError> errors) {
         this.staticErrors = errors;
+    }
+
+    public Option<HasAt> getLoc() {
+        if ( this.where.isEmpty() )
+            return Option.none();
+        else return Option.wrap(this.where.get(0));
+    }
+
+    public String getOriginalMessage() {
+        return super.getMessage();
     }
 
Index: /trunk/ProjectFortress/src/com/sun/fortress/scala_src/typechecker/STypeChecker.scala
===================================================================
--- /trunk/ProjectFortress/src/com/sun/fortress/scala_src/typechecker/STypeChecker.scala (revision 3834)
+++ /trunk/ProjectFortress/src/com/sun/fortress/scala_src/typechecker/STypeChecker.scala (revision 3835)
@@ -44,5 +44,6 @@
 import com.sun.fortress.exceptions.StaticError
 import com.sun.fortress.exceptions.StaticError.errorMsg
-import com.sun.fortress.exceptions.TypeError
+import com.sun.fortress.exceptions.ProgramError
+import com.sun.fortress.exceptions.ProgramError.error
 import com.sun.fortress.nodes._
 import com.sun.fortress.nodes_util.NodeFactory
@@ -131,4 +132,7 @@
   protected def signal(hasAt:HasAt, msg:String) =
     errors.signal(msg, hasAt)
+
+  private def syntaxError(hasAt:HasAt, msg:String) =
+    error(hasAt, msg)
 
   /**
@@ -642,6 +646,13 @@
   // ------------------------------------------------------------------------
 
-
-  def check(node:Node):Node = node match {
+  def typecheck(node:Node):Node =
+    try { check(node) }
+    catch { case e:ProgramError =>
+              errors.errors = List[StaticError]()
+              errors.signal(e.getOriginalMessage, e.getLoc.unwrap)
+              node
+          }
+
+  private def check(node:Node):Node = node match {
     case SComponent(info, name, imports, decls, isNative, exports)  =>
       SComponent(info, name, imports,
@@ -1143,9 +1154,9 @@
           case SExponentiationMI(_,_,_) => exponent match {
             case None => exponent = Some(item)
-            case Some(e) => signal(item, "Two consecutive ^s.")
+            case Some(e) => syntaxError(item, "Two consecutive ^s.")
           }
           case SSubscriptingMI(_,_,_,_) => exponent match {
             case Some(e) =>
-              signal(item, "Exponentiation followed by subscripting is illegal.")
+              syntaxError(item, "Exponentiation followed by subscripting is illegal.")
             case None =>
           }
@@ -1169,12 +1180,12 @@
         case SParenthesisDelimitedMI(_,e) => isArrows(checkExpr(e))
         case SNonParenthesisDelimitedMI(_,e) => isArrows(checkExpr(e))
-        case _ =>
+        case _ => false
       }
       def expectParenedExprItem(item: MathItem) =
         if ( ! isParenedExprItem(item) )
-          signal(item, "Argument to function must be parenthesized.")
+          syntaxError(item, "Argument to function must be parenthesized.")
       def expectExprMI(item: MathItem) =
         if ( ! isExprMI(item) )
-          signal(item, "Item at this location must be an expression, not an operator.")
+          syntaxError(item, "Item at this location must be an expression, not an operator.")
       // items is not an empty list.
       def associateMathItems(first: Expr,
@@ -1188,10 +1199,10 @@
         // find the left-most function
         val (prefix, others) = items.span((e:MathItem) =>
-                                          !isFunctionItem(e).asInstanceOf[Boolean])
+                                          !isFunctionItem(e))
         others match {
           case fn::arg::suffix => arg match {
             // It is a static error if either the argument is not parenthesized,
             case SNonParenthesisDelimitedMI(_,e) =>
-              signal(e, "Tightly juxtaposed expression should be parenthesized.")
+              syntaxError(e, "Tightly juxtaposed expression should be parenthesized.")
               (first, Nil)
             case SParenthesisDelimitedMI(i,e) => {
@@ -1200,5 +1211,5 @@
                 case third::more =>
                   if ( ! isExprMI(third) )
-                    signal(third, "An expression is expected.")
+                    syntaxError(third, "An expression is expected.")
                 case _ =>
               }
@@ -1227,5 +1238,5 @@
               left.last.asInstanceOf[ExprMI].getExpr
             else {
-              signal(left.last, "An expression is expected.")
+              syntaxError(left.last, "An expression is expected.")
               first
             }
@@ -1248,5 +1259,5 @@
                                               toJavaList(sargs))
               case _ =>
-                signal(item, "Non-expression element is expected.")
+                syntaxError(item, "Non-expression element is expected.")
                 head
             }
@@ -1289,5 +1300,5 @@
             val newTail = tail.map( (e:MathItem) =>
                                     if ( ! isExprMI(e) ) {
-                                      signal(e, "An expression is expected.")
+                                      syntaxError(e, "An expression is expected.")
                                       ExprFactory.makeVoidLiteralExpr(span)
                                     } else e.asInstanceOf[ExprMI].getExpr )
Index: /trunk/ProjectFortress/src/com/sun/fortress/compiler/typechecker/TypeChecker.java
===================================================================
--- /trunk/ProjectFortress/src/com/sun/fortress/compiler/typechecker/TypeChecker.java (revision 3829)
+++ /trunk/ProjectFortress/src/com/sun/fortress/compiler/typechecker/TypeChecker.java (revision 3835)
@@ -432,8 +432,7 @@
                 }
                 else{
-                    String err_message = "Two consecutive ^s";
+                    String err_message = "Two consecutive ^s.";
                     StaticError err=TypeError.make(err_message,
-                                                                       new Span(NodeUtil.getSpan((ASTNode)exponent.unwrap()),
-                                                                                NodeUtil.getSpan(that)).toString());
+                                                   NodeUtil.getSpan(that).toString());
                     return new TypeCheckerResult(that,err);
                 }
@@ -446,8 +445,7 @@
                 }
                 else{
-                    String err_message = "Exponentiation followed by subscripting is illegal";
+                    String err_message = "Exponentiation followed by subscripting is illegal.";
                     StaticError err=TypeError.make(err_message,
-                                                                       new Span(NodeUtil.getSpan((ASTNode)exponent.unwrap()),
-                                                                                NodeUtil.getSpan(that)).toString());
+                                                   NodeUtil.getSpan(that).toString());
                     exponent = Option.none();
                     return new TypeCheckerResult(that,err);
Index: /trunk/ProjectFortress/src/com/sun/fortress/compiler/StaticChecker.java
===================================================================
--- /trunk/ProjectFortress/src/com/sun/fortress/compiler/StaticChecker.java (revision 3829)
+++ /trunk/ProjectFortress/src/com/sun/fortress/compiler/StaticChecker.java (revision 3835)
@@ -222,5 +222,5 @@
                 ConstraintUtil.useScalaFormulas();
                 STypeChecker typeChecker = STypeCheckerFactory.make(component, traitTable, typeEnv, typeAnalyzer);
-                component_ast = typeChecker.check(component_ast);
+                component_ast = typeChecker.typecheck(component_ast);
                 component = IndexBuilder.builder.buildComponentIndex((Component)component_ast,
                     System.currentTimeMillis());
Index: /unk/ProjectFortress/not_working_static_tests/DXXExpThenSubscript.fss
===================================================================
--- /trunk/ProjectFortress/not_working_static_tests/DXXExpThenSubscript.fss (revision 3550)
+++  (revision )
@@ -1,24 +1,0 @@
-(*******************************************************************************
-    Copyright 2009 Sun Microsystems, Inc.,
-    4150 Network Circle, Santa Clara, California 95054, U.S.A.
-    All rights reserved.
-
-    U.S. Government Rights - Commercial software.
-    Government users are subject to the Sun Microsystems, Inc. standard
-    license agreement and applicable provisions of the FAR and its supplements.
-
-    Use is subject to license terms.
-
-    This distribution may include materials developed by third parties.
-
-    Sun, Sun Microsystems, the Sun logo and Java are trademarks or registered
-    trademarks of Sun Microsystems, Inc. in the U.S. and other countries.
- ******************************************************************************)
-
-component DXXExpThenSubscript
-  export Executable
-  run():() = ()
-  blah(a:ZZ32,b:ZZ32,c:ZZ32): ZZ32 = do
-   (a^b[c])
-  end
-end
Index: /unk/ProjectFortress/not_working_static_tests/DXXDoubleExponentiation.fss
===================================================================
--- /trunk/ProjectFortress/not_working_static_tests/DXXDoubleExponentiation.fss (revision 3550)
+++  (revision )
@@ -1,24 +1,0 @@
-(*******************************************************************************
-    Copyright 2009 Sun Microsystems, Inc.,
-    4150 Network Circle, Santa Clara, California 95054, U.S.A.
-    All rights reserved.
-
-    U.S. Government Rights - Commercial software.
-    Government users are subject to the Sun Microsystems, Inc. standard
-    license agreement and applicable provisions of the FAR and its supplements.
-
-    Use is subject to license terms.
-
-    This distribution may include materials developed by third parties.
-
-    Sun, Sun Microsystems, the Sun logo and Java are trademarks or registered
-    trademarks of Sun Microsystems, Inc. in the U.S. and other countries.
- ******************************************************************************)
-
-component DXXDoubleExponentiation
-  export Executable
-  run():() = ()
-  blah(a:ZZ32,b:ZZ32,c:ZZ32): ZZ32 = do
-   (a^b^c)
-  end
-end
Index: /trunk/ProjectFortress/compiler_tests/XXX1k.test
===================================================================
--- /trunk/ProjectFortress/compiler_tests/XXX1k.test (revision 3835)
+++ /trunk/ProjectFortress/compiler_tests/XXX1k.test (revision 3835)
@@ -0,0 +1,23 @@
+#    Copyright 2009 Sun Microsystems, Inc.,
+#    4150 Network Circle, Santa Clara, California 95054, U.S.A.
+#    All rights reserved.
+#
+#    U.S. Government Rights - Commercial software.
+#    Government users are subject to the Sun Microsystems, Inc. standard
+#    license agreement and applicable provisions of the FAR and its supplements.
+#
+#    Use is subject to license terms.
+#
+#    This distribution may include materials developed by third parties.
+#
+#    Sun, Sun Microsystems, the Sun logo and Java are trademarks or registered
+#    trademarks of Sun Microsystems, Inc. in the U.S. and other countries.
+
+tests=Compiled1.k
+STATIC_TESTS_DIR=${FORTRESS_AUTOHOME}/ProjectFortress/compiler_tests
+compile
+compile_err_equals=\
+${STATIC_TESTS_DIR}/Compiled1.k.fss:22:8:\n\
+\ Exponentiation followed by subscripting is illegal.\n\
+File Compiled1.k.fss has 1 error.\n
+compile_out_equals=
Index: /trunk/ProjectFortress/compiler_tests/Compiled1.j.fss
===================================================================
--- /trunk/ProjectFortress/compiler_tests/Compiled1.j.fss (revision 3835)
+++ /trunk/ProjectFortress/compiler_tests/Compiled1.j.fss (revision 3835)
@@ -0,0 +1,24 @@
+(*******************************************************************************
+    Copyright 2009 Sun Microsystems, Inc.,
+    4150 Network Circle, Santa Clara, California 95054, U.S.A.
+    All rights reserved.
+
+    U.S. Government Rights - Commercial software.
+    Government users are subject to the Sun Microsystems, Inc. standard
+    license agreement and applicable provisions of the FAR and its supplements.
+
+    Use is subject to license terms.
+
+    This distribution may include materials developed by third parties.
+
+    Sun, Sun Microsystems, the Sun logo and Java are trademarks or registered
+    trademarks of Sun Microsystems, Inc. in the U.S. and other countries.
+ ******************************************************************************)
+
+component Compiled1.j
+  export Executable
+  run():() = ()
+  blah(a:ZZ32,b:ZZ32,c:ZZ32): ZZ32 = do
+   (a^b^c)
+  end
+end
Index: /trunk/ProjectFortress/compiler_tests/XXX1j.test
===================================================================
--- /trunk/ProjectFortress/compiler_tests/XXX1j.test (revision 3835)
+++ /trunk/ProjectFortress/compiler_tests/XXX1j.test (revision 3835)
@@ -0,0 +1,23 @@
+#    Copyright 2009 Sun Microsystems, Inc.,
+#    4150 Network Circle, Santa Clara, California 95054, U.S.A.
+#    All rights reserved.
+#
+#    U.S. Government Rights - Commercial software.
+#    Government users are subject to the Sun Microsystems, Inc. standard
+#    license agreement and applicable provisions of the FAR and its supplements.
+#
+#    Use is subject to license terms.
+#
+#    This distribution may include materials developed by third parties.
+#
+#    Sun, Sun Microsystems, the Sun logo and Java are trademarks or registered
+#    trademarks of Sun Microsystems, Inc. in the U.S. and other countries.
+
+tests=Compiled1.j
+STATIC_TESTS_DIR=${FORTRESS_AUTOHOME}/ProjectFortress/compiler_tests
+compile
+compile_err_equals=\
+${STATIC_TESTS_DIR}/Compiled1.j.fss:22:8:\n\
+\ Two consecutive ^s.\n\
+File Compiled1.j.fss has 1 error.\n
+compile_out_equals=
Index: /trunk/ProjectFortress/compiler_tests/Compiled1.k.fss
===================================================================
--- /trunk/ProjectFortress/compiler_tests/Compiled1.k.fss (revision 3835)
+++ /trunk/ProjectFortress/compiler_tests/Compiled1.k.fss (revision 3835)
@@ -0,0 +1,24 @@
+(*******************************************************************************
+    Copyright 2009 Sun Microsystems, Inc.,
+    4150 Network Circle, Santa Clara, California 95054, U.S.A.
+    All rights reserved.
+
+    U.S. Government Rights - Commercial software.
+    Government users are subject to the Sun Microsystems, Inc. standard
+    license agreement and applicable provisions of the FAR and its supplements.
+
+    Use is subject to license terms.
+
+    This distribution may include materials developed by third parties.
+
+    Sun, Sun Microsystems, the Sun logo and Java are trademarks or registered
+    trademarks of Sun Microsystems, Inc. in the U.S. and other countries.
+ ******************************************************************************)
+
+component Compiled1.k
+  export Executable
+  run():() = ()
+  blah(a:ZZ32,b:ZZ32,c:ZZ32): ZZ32 = do
+   (a^b[c])
+  end
+end
