Skip to content

Commit df2883e

Browse files
committed
---
yaml --- r: 2941 b: refs/heads/master c: 3ca5fff h: refs/heads/master i: 2939: 53a12e4 v: v3
1 parent ddb88cd commit df2883e

File tree

5 files changed

+25
-6
lines changed

5 files changed

+25
-6
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
---
2-
refs/heads/master: ac83e34dc6c2bb3b5f181f923560d810dcdb558c
2+
refs/heads/master: 3ca5fff195cfb37e102d5686bbce4b570eb6fda2

trunk/src/comp/front/extenv.rs

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,13 @@ fn expand_syntax_ext(&ext_ctxt cx,
2323
option::t[str] body) -> @ast::expr {
2424

2525
if (vec::len[@ast::expr](args) != 1u) {
26-
p.err("malformed #env call");
26+
cx.span_err(sp, "malformed #env call");
2727
}
2828

2929
// FIXME: if this was more thorough it would manufacture an
3030
// option::t[str] rather than just an maybe-empty string.
3131

32-
auto var = expr_to_str(p, args.(0));
32+
auto var = expr_to_str(cx, p, args.(0));
3333
alt (generic_os::getenv(var)) {
3434
case (option::none) {
3535
ret make_new_str(p, sp, "");
@@ -42,19 +42,23 @@ fn expand_syntax_ext(&ext_ctxt cx,
4242

4343
// FIXME: duplicate code copied from extfmt:
4444

45-
fn expr_to_str(parser::parser p,
45+
fn expr_to_str(&ext_ctxt cx, parser::parser p,
4646
@ast::expr expr) -> str {
4747
alt (expr.node) {
4848
case (ast::expr_lit(?l, _)) {
4949
alt (l.node) {
5050
case (ast::lit_str(?s)) {
5151
ret s;
5252
}
53+
case (_) {
54+
cx.span_err(l.span, "malformed #env call");
55+
}
5356
}
5457
}
58+
case (_) {
59+
cx.span_err(expr.span, "malformed #env call");
60+
}
5561
}
56-
p.err("malformed #env call");
57-
fail;
5862
}
5963

6064
fn make_new_lit(parser::parser p, common::span sp, ast::lit_ lit)
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
// error-pattern:malformed #env call
2+
3+
fn main() {
4+
#env();
5+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
// error-pattern:malformed #env call
2+
3+
fn main() {
4+
#env(10);
5+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
// error-pattern:malformed #env call
2+
3+
fn main() {
4+
#env("one", "two");
5+
}

0 commit comments

Comments
 (0)