Skip to content

Conversation

Copy link

Copilot AI commented Dec 27, 2025

Review comment questioned whether the condition for adding + operator before -1 multiplication was incorrect. After analysis, confirmed the current implementation is correct.

The condition correctly adds + when:

  • List is not empty AND
  • Last item is NOT an open bracket or function
// Correctly handles: "5-2" → "5 + -1 * 2"
// Correctly skips: "(-2" → "( -1 * 2" (no + added)
if (!(list.length == 0 || 
      list.length > 0 && 
      (list[list.length - 1].type == "open bracket" || 
       list[list.length - 1].type == "function")))
{
    list.push({ content: "+", type: "operator", ... });
}

No code changes required.


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI changed the title [WIP] Update binary tree implementation based on feedback Confirm correctness of minus sign handling logic in expression parser Dec 27, 2025
Copilot AI requested a review from JoshdRod December 27, 2025 15:25
@JoshdRod JoshdRod closed this Dec 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants