summaryrefslogtreecommitdiff
path: root/dhall_core
diff options
context:
space:
mode:
authorNadrieril2019-03-24 14:05:16 +0100
committerNadrieril2019-03-24 14:05:16 +0100
commit6c1a739687f706cf6630c55f8d53c92aacaf6e3d (patch)
tree9fd95a35fe35cd532cd869f4c6f0db6585482225 /dhall_core
parentdc8497a1b659bff4e261a0d7f05f56d21c6d2448 (diff)
Disallow builtins as bound variables
Diffstat (limited to 'dhall_core')
-rw-r--r--dhall_core/src/parser.rs16
1 files changed, 12 insertions, 4 deletions
diff --git a/dhall_core/src/parser.rs b/dhall_core/src/parser.rs
index 3f53c49..4f26b0f 100644
--- a/dhall_core/src/parser.rs
+++ b/dhall_core/src/parser.rs
@@ -266,6 +266,14 @@ make_parser! {
[simple_label(l)] => l,
[quoted_label(l)] => l,
));
+ rule!(unreserved_label<Label>; children!(
+ [label(l)] => {
+ if Builtin::parse(&String::from(&l)).is_some() {
+ Err(format!("Builtin names are not allowed as bound variables"))?
+ }
+ l
+ },
+ ));
rule!(double_quote_literal<ParsedText>; children!(
[double_quote_chunk(chunks..)] => {
@@ -493,7 +501,7 @@ make_parser! {
));
rule!(lambda_expression<ParsedExpr> as expression; children!(
- [label(l), expression(typ), expression(body)] => {
+ [unreserved_label(l), expression(typ), expression(body)] => {
bx(Expr::Lam(l, typ, body))
}
));
@@ -511,12 +519,12 @@ make_parser! {
));
rule!(let_binding<(Label, Option<ParsedExpr>, ParsedExpr)>; children!(
- [label(name), expression(annot), expression(expr)] => (name, Some(annot), expr),
- [label(name), expression(expr)] => (name, None, expr),
+ [unreserved_label(name), expression(annot), expression(expr)] => (name, Some(annot), expr),
+ [unreserved_label(name), expression(expr)] => (name, None, expr),
));
rule!(forall_expression<ParsedExpr> as expression; children!(
- [label(l), expression(typ), expression(body)] => {
+ [unreserved_label(l), expression(typ), expression(body)] => {
bx(Expr::Pi(l, typ, body))
}
));