Skip to content

Commit

Permalink
Simplify error message.
Browse files Browse the repository at this point in the history
  • Loading branch information
InsertCreativityHere committed Jan 14, 2025
1 parent f28ad12 commit 47a0803
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 14 deletions.
14 changes: 4 additions & 10 deletions cpp/src/Slice/Parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1191,10 +1191,8 @@ Slice::Container::createClassDef(const string& name, int id, const ClassDefPtr&
}
else
{
bool declared = dynamic_pointer_cast<InterfaceDecl>(matches.front()) != nullptr;
ostringstream os;
os << "class '" << name << "' was previously " << (declared ? "declared" : "defined") << " as "
<< prependA(matches.front()->kindOf());
os << "class '" << name << "' was previously defined as " << prependA(matches.front()->kindOf());
_unit->error(os.str());
}
return nullptr;
Expand Down Expand Up @@ -1253,10 +1251,8 @@ Slice::Container::createClassDecl(const string& name)
}
else
{
bool declared = dynamic_pointer_cast<InterfaceDecl>(matches.front()) != nullptr;
ostringstream os;
os << "class '" << name << "' was previously " << (declared ? "declared" : "defined") << " as "
<< prependA(matches.front()->kindOf());
os << "class '" << name << "' was previously defined as " << prependA(matches.front()->kindOf());
_unit->error(os.str());
}
return nullptr;
Expand Down Expand Up @@ -1340,8 +1336,7 @@ Slice::Container::createInterfaceDef(const string& name, const InterfaceList& ba
{
bool declared = dynamic_pointer_cast<ClassDecl>(matches.front()) != nullptr;
ostringstream os;
os << "interface '" << name << "' was previously " << (declared ? "declared" : "defined") << " as "
<< prependA(matches.front()->kindOf());
os << "interface '" << name << "' was previously defined as " << prependA(matches.front()->kindOf());
_unit->error(os.str());
}
return nullptr;
Expand Down Expand Up @@ -1404,8 +1399,7 @@ Slice::Container::createInterfaceDecl(const string& name)
{
bool declared = dynamic_pointer_cast<ClassDecl>(matches.front()) != nullptr;
ostringstream os;
os << "interface '" << name << "' was previously " << (declared ? "declared" : "defined") << " as "
<< prependA(matches.front()->kindOf());
os << "interface '" << name << "' was previously defined as " << prependA(matches.front()->kindOf());
_unit->error(os.str());
}
return nullptr;
Expand Down
8 changes: 4 additions & 4 deletions cpp/test/Slice/errorDetection/InterfaceMismatch.err
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
InterfaceMismatch.ice:9: class 'Foo1' was previously declared as an interface
InterfaceMismatch.ice:10: class 'Foo1' was previously declared as an interface
InterfaceMismatch.ice:9: class 'Foo1' was previously defined as an interface
InterfaceMismatch.ice:10: class 'Foo1' was previously defined as an interface
InterfaceMismatch.ice:13: class 'Foo2' was previously defined as an interface
InterfaceMismatch.ice:16: interface 'Foo3' was previously declared as a class
InterfaceMismatch.ice:17: interface 'Foo3' was previously declared as a class
InterfaceMismatch.ice:16: interface 'Foo3' was previously defined as a class
InterfaceMismatch.ice:17: interface 'Foo3' was previously defined as a class
InterfaceMismatch.ice:20: interface 'Foo4' was previously defined as a class

0 comments on commit 47a0803

Please sign in to comment.