mirror of
				https://github.com/ethereum/solidity
				synced 2023-10-03 13:03:40 +00:00 
			
		
		
		
	Merge pull request #14135 from ethereum/fix_null_deref_using_for
Fix null dereference in using for directive when operator name is empty
This commit is contained in:
		
						commit
						29baf3b2ba
					
				| @ -995,11 +995,17 @@ ASTPointer<UsingForDirective> Parser::parseUsingDirective() | |||||||
| 				Token operator_ = m_scanner->currentToken(); | 				Token operator_ = m_scanner->currentToken(); | ||||||
| 				if (!util::contains(userDefinableOperators, operator_)) | 				if (!util::contains(userDefinableOperators, operator_)) | ||||||
| 				{ | 				{ | ||||||
|  | 					string operatorName; | ||||||
|  | 					if (!m_scanner->currentLiteral().empty()) | ||||||
|  | 						operatorName = m_scanner->currentLiteral(); | ||||||
|  | 					else if (char const* tokenString = TokenTraits::toString(operator_)) | ||||||
|  | 						operatorName = string(tokenString); | ||||||
|  | 
 | ||||||
| 					parserError( | 					parserError( | ||||||
| 						4403_error, | 						4403_error, | ||||||
| 						fmt::format( | 						fmt::format( | ||||||
| 							"Not a user-definable operator: {}. Only the following operators can be user-defined: {}", | 							"Not a user-definable operator: {}. Only the following operators can be user-defined: {}", | ||||||
| 							(!m_scanner->currentLiteral().empty() ? m_scanner->currentLiteral() : string(TokenTraits::toString(operator_))), | 							operatorName, | ||||||
| 							util::joinHumanReadable(userDefinableOperators | ranges::views::transform([](Token _t) { return string{TokenTraits::toString(_t)}; })) | 							util::joinHumanReadable(userDefinableOperators | ranges::views::transform([](Token _t) { return string{TokenTraits::toString(_t)}; })) | ||||||
| 						) | 						) | ||||||
| 					); | 					); | ||||||
|  | |||||||
| @ -0,0 +1,7 @@ | |||||||
|  | using {f as ''} for uint; | ||||||
|  | using {f as ""} for int; | ||||||
|  | using {f as hex""} for address; | ||||||
|  | // ---- | ||||||
|  | // ParserError 4403: (12-14): Not a user-definable operator: . Only the following operators can be user-defined: |, &, ^, ~, +, -, *, /, %, ==, !=, <, >, <=, >= | ||||||
|  | // ParserError 4403: (38-40): Not a user-definable operator: . Only the following operators can be user-defined: |, &, ^, ~, +, -, *, /, %, ==, !=, <, >, <=, >= | ||||||
|  | // ParserError 4403: (63-68): Not a user-definable operator: . Only the following operators can be user-defined: |, &, ^, ~, +, -, *, /, %, ==, !=, <, >, <=, >= | ||||||
		Loading…
	
		Reference in New Issue
	
	Block a user