summaryrefslogtreecommitdiff
path: root/Build/source/utils/asymptote/exp.h
diff options
context:
space:
mode:
Diffstat (limited to 'Build/source/utils/asymptote/exp.h')
-rw-r--r--Build/source/utils/asymptote/exp.h23
1 files changed, 17 insertions, 6 deletions
diff --git a/Build/source/utils/asymptote/exp.h b/Build/source/utils/asymptote/exp.h
index 38a72cba7f5..af24523b6df 100644
--- a/Build/source/utils/asymptote/exp.h
+++ b/Build/source/utils/asymptote/exp.h
@@ -21,7 +21,7 @@ namespace trans {
class coenv;
class coder;
-class label_t;
+struct label_t;
typedef label_t *label;
class application;
@@ -661,11 +661,18 @@ struct argument {
class arglist : public gc {
public:
typedef mem::vector<argument> argvector;
+
argvector args;
argument rest;
+ // As the language allows named arguments after rest arguments, store the
+ // index of the rest argument in order to ensure proper left-to-right
+ // execution.
+ static const size_t DUMMY_REST_POSITION = 9999;
+ size_t restPosition;
+
arglist()
- : args(), rest() {}
+ : args(), rest(), restPosition(DUMMY_REST_POSITION) {}
virtual ~arglist() {}
@@ -679,11 +686,10 @@ public:
}
virtual void add(argument a) {
- if (rest.val) {
- // TODO: Handle keyword arguments after rest with proper left-to-right
- // ordering.
+ if (rest.val && !a.name) {
em.error(a.val->getPos());
- em << "argument after rest argument";
+ em << "unnamed argument after rest argument";
+ return;
}
args.push_back(a);
}
@@ -697,8 +703,13 @@ public:
if (rest.val) {
em.error(a.val->getPos());
em << "additional rest argument";
+ return;
}
+
rest = a;
+
+ assert(restPosition == DUMMY_REST_POSITION);
+ restPosition = size();
}
virtual void prettyprint(ostream &out, Int indent);