New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Find a way to provide the line that doesn't compile in the compilation error #178
Comments
Can you give an example of errors that don't make it clear where they are produced? |
FAILED: src/main_app/input_reader/CMakeFiles/input_reader.dir/Parser.cpp.o
/home/emmanuel/Rápido/JetBrains/Toolbox/clion/bin/cmake/linux/x64/bin/cmake -E __run_co_compile --launcher=/usr/bin/ccache --cppcheck="/usr/bin/cppcheck;--template=gcc;--enable=style,performance,warning,portability;--inline-suppr;--suppress=cppcheckError;--suppress=internalAstError;--suppress=unmatchedSuppression;--suppress=passedByValue;--suppress=syntaxError;--suppress=preprocessorErrorDirective;--inconclusive;--std=c++20;--error-exitcode=2" --source=/fast/emmanuel/Projects/GitHub/ConstraintBasedSimulator/code/src/main_app/input_reader/Parser.cpp -- /usr/bin/g++-10 -DLEXY_HAS_UNICODE_DATABASE=1 -DSAMPLE_LIBRARY_STATIC_DEFINE -DSPDLOG_COMPILED_LIB -DSPDLOG_FMT_EXTERNAL -I/fast/emmanuel/Projects/GitHub/ConstraintBasedSimulator/code/include -I/fast/emmanuel/Projects/GitHub/ConstraintBasedSimulator/code/cmake-build-release-gcc-10/include -isystem /fast/emmanuel/Projects/GitHub/ConstraintBasedSimulator/code/cmake-build-release-gcc-10/_deps/spdlog-src/include -isystem /fast/emmanuel/Projects/GitHub/ConstraintBasedSimulator/code/cmake-build-release-gcc-10/_deps/fmt-src/include -isystem /fast/emmanuel/Projects/GitHub/ConstraintBasedSimulator/code/cmake-build-release-gcc-10/_deps/lexy-src/src/../include -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=3 -fstack-protector-strong -fcf-protection -fstack-clash-protection -D_GLIBCXX_ASSERTIONS -O3 -DNDEBUG -std=c++2a -flto=auto -fno-fat-lto-objects -fvisibility=hidden -fvisibility-inlines-hidden -fdiagnostics-color=always -fdiagnostics-color=always -fsanitize=address,undefined -Wall -Wextra -Wshadow -Wnon-virtual-dtor -Wold-style-cast -Wcast-align -Wunused -Woverloaded-virtual -Wpedantic -Wconversion -Wsign-conversion -Wnull-dereference -Wdouble-promotion -Wformat=2 -Wimplicit-fallthrough -Wmisleading-indentation -Wduplicated-cond -Wduplicated-branches -Wlogical-op -Wuseless-cast -Werror -Wno-readability-redundant-member-init -pthread -MD -MT src/main_app/input_reader/CMakeFiles/input_reader.dir/Parser.cpp.o -MF src/main_app/input_reader/CMakeFiles/input_reader.dir/Parser.cpp.o.d -o src/main_app/input_reader/CMakeFiles/input_reader.dir/Parser.cpp.o -c /fast/emmanuel/Projects/GitHub/ConstraintBasedSimulator/code/src/main_app/input_reader/Parser.cpp
Checking /fast/emmanuel/Projects/GitHub/ConstraintBasedSimulator/code/src/main_app/input_reader/Parser.cpp ...
Checking /fast/emmanuel/Projects/GitHub/ConstraintBasedSimulator/code/src/main_app/input_reader/Parser.cpp: LEXY_HAS_UNICODE_DATABASE=1;SAMPLE_LIBRARY_STATIC_DEFINE=1;SPDLOG_COMPILED_LIB=1;SPDLOG_FMT_EXTERNAL=1;_FORTIFY_SOURCE=3;_GLIBCXX_ASSERTIONS=1;NDEBUG=1...
In file included from /fast/emmanuel/Projects/GitHub/ConstraintBasedSimulator/code/cmake-build-release-gcc-10/_deps/lexy-src/include/lexy/dsl/base.hpp:9,
from /fast/emmanuel/Projects/GitHub/ConstraintBasedSimulator/code/cmake-build-release-gcc-10/_deps/lexy-src/include/lexy/action/base.hpp:11,
from /fast/emmanuel/Projects/GitHub/ConstraintBasedSimulator/code/cmake-build-release-gcc-10/_deps/lexy-src/include/lexy/action/parse.hpp:8,
from /fast/emmanuel/Projects/GitHub/ConstraintBasedSimulator/code/include/main_app/input_reader/LexyComponents.hpp:8,
from /fast/emmanuel/Projects/GitHub/ConstraintBasedSimulator/code/include/main_app/input_reader/Parser.hpp:6,
from /fast/emmanuel/Projects/GitHub/ConstraintBasedSimulator/code/src/main_app/input_reader/Parser.cpp:1:
/fast/emmanuel/Projects/GitHub/ConstraintBasedSimulator/code/cmake-build-release-gcc-10/_deps/lexy-src/include/lexy/grammar.hpp: In instantiation of ‘constexpr void lexy::_sfinae_sink<Production, Sink>::operator()(Args&& ...) [with Args = {input_reader::internal::ast::PropertyIdentifier}; Production = input_reader::internal::parser::FunctionConstraint; Sink = lexy::_as_aggregate<input_reader::internal::ast::FunctionConstraint>::_sink]’:
/fast/emmanuel/Projects/GitHub/ConstraintBasedSimulator/code/cmake-build-release-gcc-10/_deps/lexy-src/include/lexy/dsl/base.hpp:178:17: required from ‘static constexpr std::true_type lexy::sink_parser::parse(Context&, Reader&, Sink&, Args&& ...) [with Context = lexy::_pc<lexy::_ph<lexy::_br8>, void, input_reader::internal::parser::FunctionConstraint, input_reader::internal::parser::SimulationState>; Reader = lexy::_br8; Sink = lexy::_sfinae_sink<input_reader::internal::parser::FunctionConstraint, lexy::_as_aggregate<input_reader::internal::ast::FunctionConstraint>::_sink>; Args = {input_reader::internal::ast::PropertyIdentifier}; std::true_type = std::integral_constant<bool, true>]’
/fast/emmanuel/Projects/GitHub/ConstraintBasedSimulator/code/cmake-build-release-gcc-10/_deps/lexy-src/include/lexy/action/base.hpp:190:39: required from ‘static constexpr bool lexy::_detail::context_finish_parser<NextParser>::parse(Context&, Reader&, SubContext&, Args&& ...) [with Context = lexy::_pc<lexy::_ph<lexy::_br8>, void, input_reader::internal::parser::FunctionConstraint, input_reader::internal::parser::SimulationState>; Reader = lexy::_br8; SubContext = lexy::_pc<lexy::_ph<lexy::_br8>, void, input_reader::internal::parser::PropertyIdentifier, input_reader::internal::parser::SimulationState>; Args = {lexy::_sfinae_sink<input_reader::internal::parser::FunctionConstraint, lexy::_as_aggregate<input_reader::internal::ast::FunctionConstraint>::_sink>&}; NextParser = lexy::sink_parser]’
/fast/emmanuel/Projects/GitHub/ConstraintBasedSimulator/code/cmake-build-release-gcc-10/_deps/lexy-src/include/lexy/dsl/production.hpp:66:43: required from ‘static constexpr bool lexyd::_prd<Production>::p<NextParser>::parse(Context&, Reader&, Args&& ...) [with Context = lexy::_pc<lexy::_ph<lexy::_br8>, void, input_reader::internal::parser::FunctionConstraint, input_reader::internal::parser::SimulationState>; Reader = lexy::_br8; Args = {lexy::_sfinae_sink<input_reader::internal::parser::FunctionConstraint, lexy::_as_aggregate<input_reader::internal::ast::FunctionConstraint>::_sink>&}; NextParser = lexy::sink_parser; Production = input_reader::internal::parser::PropertyIdentifier]’
/fast/emmanuel/Projects/GitHub/ConstraintBasedSimulator/code/cmake-build-release-gcc-10/_deps/lexy-src/include/lexy/dsl/list.hpp:79:66: required from ‘static constexpr bool lexyd::_lst<Item, Sep>::p<NextParser>::parse(Context&, Reader&, Args&& ...) [with Context = lexy::_pc<lexy::_ph<lexy::_br8>, void, input_reader::internal::parser::FunctionConstraint, input_reader::internal::parser::SimulationState>; Reader = lexy::_br8; Args = {}; NextParser = lexyd::token_base<lexyd::_lit<char, '-', '>'>, lexyd::branch_base>::p<lexyd::_mem<lexy::_mem_ptr_fn<&input_reader::internal::ast::FunctionConstraint::identifier>, lexyd::_prd<input_reader::internal::parser::Identifier> >::p<lexy::_detail::final_parser> >; Item = lexyd::_prd<input_reader::internal::parser::PropertyIdentifier>; Sep = lexyd::_sep<lexyd::_comma, void>]’
/fast/emmanuel/Projects/GitHub/ConstraintBasedSimulator/code/cmake-build-release-gcc-10/_deps/lexy-src/include/lexy/dsl/whitespace.hpp:188:33: required from ‘static constexpr bool lexy::_detail::automatic_ws_parser<NextParser>::parse(Context&, Reader&, Args&& ...) [with Context = lexy::_pc<lexy::_ph<lexy::_br8>, void, input_reader::internal::parser::FunctionConstraint, input_reader::internal::parser::SimulationState>; Reader = lexy::_br8; Args = {}; NextParser = lexyd::_lst<lexyd::_prd<input_reader::internal::parser::PropertyIdentifier>, lexyd::_sep<lexyd::_comma, void> >::p<lexyd::token_base<lexyd::_lit<char, '-', '>'>, lexyd::branch_base>::p<lexyd::_mem<lexy::_mem_ptr_fn<&input_reader::internal::ast::FunctionConstraint::identifier>, lexyd::_prd<input_reader::internal::parser::Identifier> >::p<lexy::_detail::final_parser> > >]’
/fast/emmanuel/Projects/GitHub/ConstraintBasedSimulator/code/cmake-build-release-gcc-10/_deps/lexy-src/include/lexy/dsl/token.hpp:111:75: [ skipping 32 instantiation contexts, use -ftemplate-backtrace-limit=0 to disable ]
/fast/emmanuel/Projects/GitHub/ConstraintBasedSimulator/code/cmake-build-release-gcc-10/_deps/lexy-src/include/lexy/dsl/whitespace.hpp:188:33: required from ‘static constexpr bool lexy::_detail::automatic_ws_parser<NextParser>::parse(Context&, Reader&, Args&& ...) [with Context = lexy::_pc<lexy::_ph<lexy::_br8>, void, input_reader::internal::parser::SimulationState, input_reader::internal::parser::SimulationState>; Reader = lexy::_br8; Args = {}; NextParser = lexyd::_optt<lexyd::_eof, lexyd::_lstt<lexyd::_eof, lexyd::_prd<input_reader::internal::parser::Statement>, void, lexyd::_reco<void, lexyd::_eof> > >::p<lexy::_detail::final_parser>]’
/fast/emmanuel/Projects/GitHub/ConstraintBasedSimulator/code/cmake-build-release-gcc-10/_deps/lexy-src/include/lexy/action/base.hpp:209:37: required from ‘constexpr auto lexy::_do_action(lexy::_pc<Handler, State, Production>&, Reader&) [with Handler = lexy::_ph<lexy::_br8>; State = void; Production = input_reader::internal::parser::SimulationState; Reader = lexy::_br8; typename std::conditional<_production_defines_whitespace<Production>, Production, void>::type = input_reader::internal::parser::SimulationState]’
/fast/emmanuel/Projects/GitHub/ConstraintBasedSimulator/code/cmake-build-release-gcc-10/_deps/lexy-src/include/lexy/action/base.hpp:229:34: required from ‘constexpr auto lexy::do_action(Handler&&, State*, Reader&) [with Production = input_reader::internal::parser::SimulationState; Result = lexy::parse_action<void, lexy::buffer<lexy::utf8_encoding, void>, lexy_ext::_report_error<lexy::stderr_output_iterator> >::result_type; Handler = lexy::_ph<lexy::_br8>; State = void; Reader = lexy::_br8]’
/fast/emmanuel/Projects/GitHub/ConstraintBasedSimulator/code/cmake-build-release-gcc-10/_deps/lexy-src/include/lexy/action/parse.hpp:164:56: required from ‘constexpr auto lexy::parse_action<State, Input, ErrorCallback>::operator()(Production, const Input&) const [with Production = input_reader::internal::parser::SimulationState; State = void; Input = lexy::buffer<lexy::utf8_encoding, void>; ErrorCallback = lexy_ext::_report_error<lexy::stderr_output_iterator>]’
/fast/emmanuel/Projects/GitHub/ConstraintBasedSimulator/code/cmake-build-release-gcc-10/_deps/lexy-src/include/lexy/action/parse.hpp:173:62: required from ‘constexpr auto lexy::parse(const Input&, const ErrorCallback&) [with Production = input_reader::internal::parser::SimulationState; Input = lexy::buffer<lexy::utf8_encoding, void>; ErrorCallback = lexy_ext::_report_error<lexy::stderr_output_iterator>]’
/fast/emmanuel/Projects/GitHub/ConstraintBasedSimulator/code/src/main_app/input_reader/Parser.cpp:7:101: required from here
/fast/emmanuel/Projects/GitHub/ConstraintBasedSimulator/code/cmake-build-release-gcc-10/_deps/lexy-src/include/lexy/grammar.hpp:274:36: error: static assertion failed: missing value sink callback overload for production
274 | static_assert(_detail::error<Production, Args...>,
| ~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
/fast/emmanuel/Projects/GitHub/ConstraintBasedSimulator/code/cmake-build-release-gcc-10/_deps/lexy-src/include/lexy/grammar.hpp:276:14: error: no match for call to ‘(lexy::_as_aggregate<input_reader::internal::ast::FunctionConstraint>::_sink) (input_reader::internal::ast::PropertyIdentifier)’
276 | _sink(LEXY_FWD(args)...);
| ~~~~~^~~~~~~~~~~~~~~~~~~
In file included from /fast/emmanuel/Projects/GitHub/ConstraintBasedSimulator/code/cmake-build-release-gcc-10/_deps/lexy-src/include/lexy/callback.hpp:8,
from /fast/emmanuel/Projects/GitHub/ConstraintBasedSimulator/code/include/main_app/input_reader/LexyComponents.hpp:9,
from /fast/emmanuel/Projects/GitHub/ConstraintBasedSimulator/code/include/main_app/input_reader/Parser.hpp:6,
from /fast/emmanuel/Projects/GitHub/ConstraintBasedSimulator/code/src/main_app/input_reader/Parser.cpp:1:
/fast/emmanuel/Projects/GitHub/ConstraintBasedSimulator/code/cmake-build-release-gcc-10/_deps/lexy-src/include/lexy/callback/aggregate.hpp:50:24: note: candidate: ‘template<class Fn, class Value> constexpr void lexy::_as_aggregate<T>::_sink::operator()(lexy::member<Fn>, Value&&) [with Fn = Fn; Value = Value; T = input_reader::internal::ast::FunctionConstraint]’
50 | constexpr void operator()(lexy::member<Fn>, Value&& value)
| ^~~~~~~~
/fast/emmanuel/Projects/GitHub/ConstraintBasedSimulator/code/cmake-build-release-gcc-10/_deps/lexy-src/include/lexy/callback/aggregate.hpp:50:24: note: template argument deduction/substitution failed:
In file included from /fast/emmanuel/Projects/GitHub/ConstraintBasedSimulator/code/cmake-build-release-gcc-10/_deps/lexy-src/include/lexy/dsl/base.hpp:9,
from /fast/emmanuel/Projects/GitHub/ConstraintBasedSimulator/code/cmake-build-release-gcc-10/_deps/lexy-src/include/lexy/action/base.hpp:11,
from /fast/emmanuel/Projects/GitHub/ConstraintBasedSimulator/code/cmake-build-release-gcc-10/_deps/lexy-src/include/lexy/action/parse.hpp:8,
from /fast/emmanuel/Projects/GitHub/ConstraintBasedSimulator/code/include/main_app/input_reader/LexyComponents.hpp:8,
from /fast/emmanuel/Projects/GitHub/ConstraintBasedSimulator/code/include/main_app/input_reader/Parser.hpp:6,
from /fast/emmanuel/Projects/GitHub/ConstraintBasedSimulator/code/src/main_app/input_reader/Parser.cpp:1:
/fast/emmanuel/Projects/GitHub/ConstraintBasedSimulator/code/cmake-build-release-gcc-10/_deps/lexy-src/include/lexy/grammar.hpp:276:14: note: mismatched types ‘lexy::member<Fn>’ and ‘input_reader::internal::ast::PropertyIdentifier’
276 | _sink(LEXY_FWD(args)...);
| ~~~~~^~~~~~~~~~~~~~~~~~~
cc1plus: note: unrecognized command-line option ‘-Wno-readability-redundant-member-init’ may have been intended to silence earlier diagnostics
ninja: build stopped: subcommand failed.
Produced by the code (relevant parts): namespace ast {
using Identifier = std::string;
struct FunctionConstraint {
Identifier identifier;
};
}
namespace parser {
struct PropertyIdentifier {
struct InvalidPropertyIdentifier {
static LEXY_CONSTEVAL auto name() { return "property identifier is not time or distance"; }
};
static constexpr auto types
= lexy::symbol_table<ast::PropertyIdentifier>
.map(timeIdentifierReserved, ast::PropertyIdentifier::TIME_PROPERTY)
.map(timeShortIdentifierReserved, ast::PropertyIdentifier::TIME_PROPERTY)
.map(distanceIdentifierReserved, ast::PropertyIdentifier::DISTANCE_PROPERTY)
.map(distanceShortIdentifierReserved, ast::PropertyIdentifier::DISTANCE_PROPERTY);
static constexpr auto rule = [] {
return dsl::symbol<types> | dsl::error<InvalidPropertyIdentifier>;
}();
static constexpr auto value = lexy::construct<ast::PropertyIdentifier>;
};
struct FunctionConstraint {
static constexpr auto rule = [] {
auto ws = dsl::whitespace(dsl::ascii::space);
auto condition = dsl::peek(functionReserved
+ ws + dsl::list(dsl::p<PropertyIdentifier>, dsl::sep(dsl::comma))
+ ws + arrowReserved + ws + dsl::p<Identifier>);
auto identifier = (dsl::member<&ast::FunctionConstraint::identifier> = dsl::p<Identifier>);
return condition >> (functionReserved + dsl::list(dsl::p<PropertyIdentifier>, dsl::sep(dsl::comma)) + arrowReserved + identifier);
}();
static constexpr auto value = lexy::as_aggregate<ast::FunctionConstraint>;
};
} Formal language (relevant parts):
I know it is telling me that it cannot construct the FunctionConstraint, but it would be nice if it told me what line failed and what it is actually doing. Even for simple errors it is very convoluted, having to decipher the type of the parameters to a static_assert to guess what could have failed. |
Yeah, that's C++ for you, there isn't a lot I can do there. clang's error messages are a nicer: https://godbolt.org/z/on6EoG8E8
If you look at the first line there, it tells you which production fails and what values are being produced. With some effort, I can change that to:
That way, you'll also get the name of the rule that produced a value. However, it probably requires C++20. I can see what I can do about GCC. |
I'm not quite sure, but I think that adding more complex requirements to the type parameters (something like concepts does) of different components, maybe it would show the error directly on the user defined type. I feel like the library simply assumes that the user defined type is correct and fails internally, instead it should check all assumptions directly on the user defined type before using it.
I have no problem with that.
Thanks! |
I am having trouble finding where compilation errors are happening using this library. I usually end up adding small components (single elements of a production) of the formal language one at a time. Is there a way to link the compilation error with the original code that produced it?
The text was updated successfully, but these errors were encountered: