Project

Profile

Help

Revision 6780c74b

Added by Michael Kay about 7 years ago

Fix bug 2232 (two forwards references to global variable)

View differences:

latest9.5/hej/net/sf/saxon/query/QueryModule.java
983 983
                    // the variable declaration hasn't yet been read, because of the limited provision
984 984
                    // for cyclic imports. In XQuery 3.0 forwards references are more generally allowed.
985 985
                    if (getLanguageVersion().equals(DecimalValue.THREE)) {
986
                        UndeclaredVariable uvar = new UndeclaredVariable();
987
                        uvar.setVariableQName(qName);
988
                        VariableReference ref = new VariableReference();
989
                        uvar.registerReference(ref);
990
                        undeclaredVariables.put(qName, uvar);
991
                        return ref;
986
                        UndeclaredVariable uvar = undeclaredVariables.get(qName);
987
                        if (uvar != null) {
988
                            // second or subsequent reference to the as-yet-undeclared variable
989
                            VariableReference ref = new VariableReference();
990
                            uvar.registerReference(ref);
991
                            return ref;
992
                        } else {
993
                            // first reference to the as-yet-undeclared variable
994
                            uvar = new UndeclaredVariable();
995
                            uvar.setVariableQName(qName);
996
                            VariableReference ref = new VariableReference();
997
                            uvar.registerReference(ref);
998
                            undeclaredVariables.put(qName, uvar);
999
                            return ref;
1000
                        }
1001
//                        UndeclaredVariable uvar = new UndeclaredVariable();
1002
//                        uvar.setVariableQName(qName);
1003
//                        VariableReference ref = new VariableReference();
1004
//                        uvar.registerReference(ref);
1005
//                        undeclaredVariables.put(qName, uvar);
1006
//                        return ref;
992 1007
                    } else {
993 1008
                        XPathException err = new XPathException("Variable $" + qName.getDisplayName() + " has not been declared");
994 1009
                        err.setErrorCode("XPST0008");

Also available in: Unified diff