Merge branch 'master' into westmann/aql_update
diff --git a/asterix-app/src/test/resources/AQLTS/queries/utf-8.aql b/asterix-app/src/test/resources/AQLTS/queries/utf-8.aql
new file mode 100644
index 0000000..b9c58ea
--- /dev/null
+++ b/asterix-app/src/test/resources/AQLTS/queries/utf-8.aql
@@ -0,0 +1,3 @@
+string-to-codepoint("äöß");
+string-to-codepoint("迎");
+/* currently fails (issue 277) string-to-codepoint("欢")  */
diff --git a/asterix-app/src/test/resources/AQLTS/queries/variables.aql b/asterix-app/src/test/resources/AQLTS/queries/variables.aql
new file mode 100644
index 0000000..57bfa6b
--- /dev/null
+++ b/asterix-app/src/test/resources/AQLTS/queries/variables.aql
@@ -0,0 +1,4 @@
+let $a:=1
+let $b:=1
+return
+  $b-$a
diff --git a/asterix-app/src/test/resources/runtimets/queries/user-defined-functions/udf30/udf30.1.query.aql b/asterix-app/src/test/resources/runtimets/queries/user-defined-functions/udf30/udf30.1.query.aql
new file mode 100644
index 0000000..ffe6981
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/user-defined-functions/udf30/udf30.1.query.aql
@@ -0,0 +1,14 @@
+/*
+ * Description  : Declare a UDF and try to use the function parameter outside
+ *                of the function.
+ * Expected Res : Failure
+ * Date         : Apr 10th 2013
+ */
+
+declare function abc($y) {
+ let $x:=3
+ return $x
+};
+
+let $z:=$y
+return $z
diff --git a/asterix-app/src/test/resources/runtimets/testsuite.xml b/asterix-app/src/test/resources/runtimets/testsuite.xml
index 18ec161..fca38cc 100644
--- a/asterix-app/src/test/resources/runtimets/testsuite.xml
+++ b/asterix-app/src/test/resources/runtimets/testsuite.xml
@@ -4202,6 +4202,12 @@
       </compilation-unit>
     </test-case>
     <test-case FilePath="user-defined-functions">
+      <compilation-unit name="udf30">
+        <output-dir compare="Text">udf30</output-dir>
+        <expected-error>edu.uci.ics.asterix.common.exceptions.AsterixException</expected-error>
+      </compilation-unit>
+    </test-case>
+    <test-case FilePath="user-defined-functions">
       <compilation-unit name="f01">
         <output-dir compare="Text">f01</output-dir>
         <expected-error>edu.uci.ics.asterix.common.exceptions.AsterixException</expected-error> 
diff --git a/asterix-aql/src/main/javacc/AQL.jj b/asterix-aql/src/main/javacc/AQL.jj
index 87a442d..2a5f534 100644
--- a/asterix-aql/src/main/javacc/AQL.jj
+++ b/asterix-aql/src/main/javacc/AQL.jj
@@ -1117,6 +1117,7 @@
       signature = new FunctionSignature(defaultDataverse, functionName, paramList.size());
       getCurrentScope().addFunctionDescriptor(signature, false);
       funcDecl = new FunctionDecl(signature, paramList, funcBody);
+      removeCurrentScope();
       return funcDecl;
     }
 }
@@ -1535,7 +1536,7 @@
 	VarIdentifier var = new VarIdentifier();
 }
 {
-      <VARIABLE>
+  <VARIABLE>
     {
      String varName = token.image; 
      Identifier ident = lookupSymbol(varName);
@@ -1560,7 +1561,7 @@
 	VarIdentifier var = new VarIdentifier();
 }
 {
-      <VARIABLE>
+  <VARIABLE>
     {
      Identifier ident = lookupSymbol(token.image);
      if(ident != null) { // exist such ident
@@ -2200,7 +2201,7 @@
 <DEFAULT>
 TOKEN :
 {
-	<VARIABLE : "$" <IDENTIFIER> >
+	<VARIABLE : "$" (<LETTER>)+ (<LETTER> | <DIGIT> | "_")* >
 }
 
 SKIP: