Skip to content

Commit a6cca0e

Browse files
[MIN] XQuery: error message.
1 parent b48318a commit a6cca0e

File tree

3 files changed

+17
-15
lines changed

3 files changed

+17
-15
lines changed

basex-core/src/main/java/org/basex/query/QueryCompiler.java

+4-1
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,10 @@ private void compile() throws QueryException {
127127
private static Scope circCheck(final Scope[] comp) throws QueryException {
128128
if(comp.length > 1) {
129129
for(final Scope scp : comp) {
130-
if(scp instanceof StaticVar) throw circVarError((StaticVar) scp);
130+
if(scp instanceof StaticVar) {
131+
final StaticVar var = (StaticVar) scp;
132+
//throw CIRCVAR_X.get(var.info, var.id());
133+
}
131134
}
132135
}
133136
return comp[0];

basex-core/src/main/java/org/basex/query/QueryError.java

-9
Original file line numberDiff line numberDiff line change
@@ -1590,15 +1590,6 @@ public static QueryException valueError(final Type type, final byte[] value,
15901590
return INVALUE_X_X.get(info, type, value);
15911591
}
15921592

1593-
/**
1594-
* Throws an exception for circular static variables.
1595-
* @param var variable expression
1596-
* @return never
1597-
*/
1598-
public static QueryException circVarError(final StaticVar var) {
1599-
return CIRCVAR_X.get(var.info, var);
1600-
}
1601-
16021593
/**
16031594
* Chops the specified value to a maximum size.
16041595
* @param value value

basex-core/src/main/java/org/basex/query/var/StaticVar.java

+13-5
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,8 @@ public final class StaticVar extends StaticDecl {
4949

5050
@Override
5151
public void compile(final QueryContext qc) throws QueryException {
52-
if(expr == null) throw VAREMPTY_X.get(info, '$' + Token.string(name.string()));
53-
if(dontEnter) throw circVarError(this);
52+
if(expr == null) throw VAREMPTY_X.get(info, name());
53+
if(dontEnter) throw CIRCVAR_X.get(info, name());
5454

5555
if(!compiled) {
5656
dontEnter = true;
@@ -80,12 +80,12 @@ public void compile(final QueryContext qc) throws QueryException {
8080
* @throws QueryException query exception
8181
*/
8282
Value value(final QueryContext qc) throws QueryException {
83-
if(dontEnter) throw circVarError(this);
83+
if(dontEnter) throw CIRCVAR_X.get(info, name());
8484

8585
if(lazy) {
8686
if(!compiled) throw Util.notExpected(this + " was not compiled.");
8787
} else {
88-
if(expr == null) throw VAREMPTY_X.get(info, this);
88+
if(expr == null) throw VAREMPTY_X.get(info, name());
8989
}
9090

9191
if(val != null) return val;
@@ -150,7 +150,7 @@ public boolean visit(final ASTVisitor visitor) {
150150
@Override
151151
public String toString() {
152152
final TokenBuilder tb = new TokenBuilder(DECLARE).add(' ').addExt(anns);
153-
tb.add(VARIABLE).add(' ').add(DOLLAR).add(name.string());
153+
tb.add(VARIABLE).add(' ').add(name());
154154
if(type != null) tb.add(' ').add(AS).add(' ').addExt(type);
155155
if(external) tb.add(' ').add(EXTERNAL);
156156
if(expr != null) tb.add(' ').add(ASSIGN).add(' ').addExt(expr);
@@ -162,6 +162,14 @@ public byte[] id() {
162162
return Token.concat(new byte[] { '$' }, name.id());
163163
}
164164

165+
/**
166+
* Returns the name of the variable.
167+
* @return name
168+
*/
169+
private String name() {
170+
return new TokenBuilder().add(DOLLAR).add(name.string()).toString();
171+
}
172+
165173
/**
166174
* Checks if the expression bound to this variable has the given flag.
167175
* @param flag flag to check for

0 commit comments

Comments
 (0)