mirror of
				https://github.com/rm-dr/daisy
				synced 2025-11-04 06:23:14 -08:00 
			
		
		
		
	Fixed unary "+" bug
This commit is contained in:
		@@ -34,7 +34,7 @@ fn lookback_signs(
 | 
				
			|||||||
			match (&a, &b) {
 | 
								match (&a, &b) {
 | 
				
			||||||
				(PreToken::PreOperator(_, sa), PreToken::PreOperator(l,sb))
 | 
									(PreToken::PreOperator(_, sa), PreToken::PreOperator(l,sb))
 | 
				
			||||||
				=> {
 | 
									=> {
 | 
				
			||||||
					if sb == "-" && {
 | 
										if {
 | 
				
			||||||
						let o = Operator::from_string(sa);
 | 
											let o = Operator::from_string(sa);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
						o.is_some() &&
 | 
											o.is_some() &&
 | 
				
			||||||
@@ -43,12 +43,14 @@ fn lookback_signs(
 | 
				
			|||||||
							!o.as_ref().unwrap().is_left_associative()
 | 
												!o.as_ref().unwrap().is_left_associative()
 | 
				
			||||||
						)
 | 
											)
 | 
				
			||||||
					} {
 | 
										} {
 | 
				
			||||||
						g.insert(i-1, PreToken::PreOperator(*l, String::from("neg")));
 | 
											if sb == "-" {
 | 
				
			||||||
						g.insert(i-1, a);
 | 
												g.insert(i-1, PreToken::PreOperator(*l, String::from("neg")));
 | 
				
			||||||
					} else if sb == "+" {
 | 
												g.insert(i-1, a);
 | 
				
			||||||
						g.insert(i-1, a);
 | 
											} else if sb == "+" {
 | 
				
			||||||
						i -= 1; // g is now shorter, we don't need to advance i.
 | 
												g.insert(i-1, a);
 | 
				
			||||||
						// This nullifies the i += 1 at the end of the loop.
 | 
												i -= 1; // g is now shorter, we don't need to advance i.
 | 
				
			||||||
 | 
												// This nullifies the i += 1 at the end of the loop.
 | 
				
			||||||
 | 
											} else { g.insert(i-1, b); g.insert(i-1, a); }
 | 
				
			||||||
					} else { g.insert(i-1, b); g.insert(i-1, a); }
 | 
										} else { g.insert(i-1, b); g.insert(i-1, a); }
 | 
				
			||||||
				},
 | 
									},
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user