Skip to content

Commit

Permalink
Print actual argument in argument type error
Browse files Browse the repository at this point in the history
  • Loading branch information
stepancheg committed May 2, 2013
1 parent 1abffc2 commit 0b72ffb
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion compiler/analyzer_op.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ static size_t staticToSizeTOrIntValue(MultiPValue* args, size_t index) {
return (size_t) *((int *)vh->buf);
}
}
argumentError(index, "expecting static SizeT or Int value");
argumentError(index, "expecting static SizeT or Int value", args->values[index]);
}

static TypePtr numericTypeOfValue(MultiPValuePtr x, unsigned index)
Expand Down
10 changes: 10 additions & 0 deletions compiler/error.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,16 @@ inline void error(T const *context, llvm::Twine const &msg)

void argumentError(size_t index, llvm::StringRef msg) CLAY_NORETURN;

template <typename T>
void argumentError(size_t index, llvm::StringRef msg, const T& argument) CLAY_NORETURN;
template <typename T>
void argumentError(size_t index, llvm::StringRef msg, const T& argument) {
string buf;
llvm::raw_string_ostream sout(buf);
sout << "argument " << (index+1) << ": " << msg << ", actual " << argument;
error(sout.str());
}

void arityError(size_t expected, size_t received) CLAY_NORETURN;
void arityError2(size_t minExpected, size_t received) CLAY_NORETURN;

Expand Down
2 changes: 2 additions & 0 deletions compiler/printer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ llvm::raw_ostream &operator<<(llvm::raw_ostream &out, const Object &obj);

llvm::raw_ostream &operator<<(llvm::raw_ostream &out, const Object *obj);

llvm::raw_ostream &operator<<(llvm::raw_ostream &out, PVData const &pv);

template <class T>
llvm::raw_ostream &operator<<(llvm::raw_ostream &out, const Pointer<T> &p)
{
Expand Down

0 comments on commit 0b72ffb

Please sign in to comment.