From 8035a66152444a22484f276d725dab40ee5336de Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Thu, 11 Sep 2025 14:44:23 +0100 Subject: [PATCH] Flag non-compiling rule conditions when running DRC. Also, clear custom rules after an error before trying to reload just implicit rules. --- pcbnew/drc/drc_engine.cpp | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/pcbnew/drc/drc_engine.cpp b/pcbnew/drc/drc_engine.cpp index 59a67c6fb4..78422d4f91 100644 --- a/pcbnew/drc/drc_engine.cpp +++ b/pcbnew/drc/drc_engine.cpp @@ -527,10 +527,9 @@ void DRC_ENGINE::loadRules( const wxFileName& aPath ) void DRC_ENGINE::compileRules() { if( m_logReporter ) - { - m_logReporter->Report( ( wxString::Format( wxT( "Compiling Rules (%d rules): " ), - (int) m_rules.size() ) ) ); - } + m_logReporter->Report( wxT( "Compiling Rules" ) ); + + REPORTER error_semaphore; for( std::shared_ptr& rule : m_rules ) { @@ -539,9 +538,12 @@ void DRC_ENGINE::compileRules() if( rule->m_Condition && !rule->m_Condition->GetExpression().IsEmpty() ) { condition = rule->m_Condition; - condition->Compile( nullptr ); + condition->Compile( &error_semaphore ); } + if( error_semaphore.HasMessageOfSeverity( RPT_SEVERITY_ERROR ) ) + THROW_PARSE_ERROR( wxT( "Parse error" ), rule->m_Name, rule->m_Condition->GetExpression(), 0, 0 ); + for( const DRC_CONSTRAINT& constraint : rule->m_Constraints ) { if( !m_constraintMap.count( constraint.m_Type ) ) @@ -594,6 +596,8 @@ void DRC_ENGINE::InitEngine( const wxFileName& aRulePath ) } catch( PARSE_ERROR& original_parse_error ) { + m_rules.clear(); + try // try again with just our implicit rules { loadImplicitRules();