new format for pos

This commit is contained in:
Ben Burdette 2020-05-11 16:58:08 -06:00
parent b93c1bf3d6
commit 631642c5b4

View file

@ -64,15 +64,23 @@ namespace nix {
static void dupAttr(const AttrPath & attrPath, const Pos & pos, const Pos & prevPos) static void dupAttr(const AttrPath & attrPath, const Pos & pos, const Pos & prevPos)
{ {
throw ParseError("attribute '%1%' at %2% already defined at %3%", throw ParseError(
showAttrPath(attrPath), pos, prevPos); ErrorInfo {
.hint = hintfmt("attribute '%1%' already defined at %2%",
showAttrPath(attrPath), prevPos),
.nixCode = NixCode { .errPos = pos },
});
} }
static void dupAttr(Symbol attr, const Pos & pos, const Pos & prevPos) static void dupAttr(Symbol attr, const Pos & pos, const Pos & prevPos)
{ {
throw ParseError("attribute '%1%' at %2% already defined at %3%", throw ParseError(
attr, pos, prevPos); ErrorInfo {
.hint = hintfmt("attribute '%1%' already defined at %2%",
attr, prevPos),
.nixCode = NixCode { .errPos = pos },
});
} }
@ -140,8 +148,12 @@ static void addAttr(ExprAttrs * attrs, AttrPath & attrPath,
static void addFormal(const Pos & pos, Formals * formals, const Formal & formal) static void addFormal(const Pos & pos, Formals * formals, const Formal & formal)
{ {
if (!formals->argNames.insert(formal.name).second) if (!formals->argNames.insert(formal.name).second)
throw ParseError("duplicate formal function argument '%1%' at %2%", throw ParseError(
formal.name, pos); ErrorInfo {
.hint = hintfmt("duplicate formal function argument '%1%'",
formal.name),
.nixCode = NixCode { .errPos = pos },
});
formals->formals.push_front(formal); formals->formals.push_front(formal);
} }
@ -327,7 +339,11 @@ expr_function
{ $$ = new ExprWith(CUR_POS, $2, $4); } { $$ = new ExprWith(CUR_POS, $2, $4); }
| LET binds IN expr_function | LET binds IN expr_function
{ if (!$2->dynamicAttrs.empty()) { if (!$2->dynamicAttrs.empty())
throw ParseError("dynamic attributes not allowed in let at %1%", CUR_POS); throw ParseError(
ErrorInfo {
.hint = hintfmt("dynamic attributes not allowed in let"),
.nixCode = NixCode { .errPos = CUR_POS },
});
$$ = new ExprLet($2, $4); $$ = new ExprLet($2, $4);
} }
| expr_if | expr_if
@ -479,8 +495,11 @@ attrs
$$->push_back(AttrName(str->s)); $$->push_back(AttrName(str->s));
delete str; delete str;
} else } else
throw ParseError("dynamic attributes not allowed in inherit at %1%", throw ParseError(
makeCurPos(@2, data)); ErrorInfo {
.hint = hintfmt("dynamic attributes not allowed in inherit"),
.nixCode = NixCode { .errPos = makeCurPos(@2, data) },
});
} }
| { $$ = new AttrPath; } | { $$ = new AttrPath; }
; ;