From b68380f09b1926f4aea89b14b52bb442d5b002de Mon Sep 17 00:00:00 2001 From: nc-x Date: Sat, 17 Aug 2019 23:15:47 +0530 Subject: [PATCH] fixes #11872; include now gives a proper error message for all invalid infix operators (#11965) --- compiler/semstmts.nim | 2 ++ tests/modules/tincludeas.nim | 6 ++++++ 2 files changed, 8 insertions(+) create mode 100644 tests/modules/tincludeas.nim diff --git a/compiler/semstmts.nim b/compiler/semstmts.nim index ba88a6359b..07aaf0ecaf 100644 --- a/compiler/semstmts.nim +++ b/compiler/semstmts.nim @@ -2035,6 +2035,8 @@ proc evalInclude(c: PContext, n: PNode): PNode = for i in 0 ..< sonsLen(n): var imp: PNode let it = n.sons[i] + if it.kind == nkInfix and it.len == 3 and it[0].ident.s != "/": + localError(c.config, it.info, "Cannot use '" & it[0].ident.s & "' in 'include'.") if it.kind == nkInfix and it.len == 3 and it[2].kind == nkBracket: let sep = it[0] let dir = it[1] diff --git a/tests/modules/tincludeas.nim b/tests/modules/tincludeas.nim new file mode 100644 index 0000000000..b82e38b149 --- /dev/null +++ b/tests/modules/tincludeas.nim @@ -0,0 +1,6 @@ +discard """ + errormsg: "Cannot use 'as' in 'include'." + line: 6 +""" + +include foobar as foo