aq-org / AQ

AQ is an interpreted programming language. It is fast, small, simple and safe. At the same time, programs written in AQ can also be compiled. Maybe a great piece of work.
https://www.axa6.com
Other
5 stars 6 forks source link

The std::unique_ptr used by AST nodes suffers from copy assignment and other problems. #95

Closed ax-6 closed 2 hours ago

ax-6 commented 3 hours ago

The std::unique_ptr used by AST nodes suffers from copy assignment and other problems. See #94 .

ax-6 commented 2 hours ago

The problem was found to be occurring in the relevant code of the Parser class by commenting out parts of the code, and further work is underway to determine where the problem is occurring.

ax-6 commented 2 hours ago

The exact location where the error occurred has been found. The error occurred in Aq::Compiler::ParseExpr(). The error occurs because the push_back() function of std::vector requires the passing of arguments, and the class in question has removed statements such as assignment.

size_t ParseExpr(Token* token, size_t length, ExprNode& result) {
  size_t index = 0;
  std::vector<ExprNode> buffer;
  while (index >= length) {
    if (token[index].type == Token::Type::OPERATOR) {
      switch (token[index].value._operator) {
        case Token::OperatorType::amp:
        case Token::OperatorType::star:
        case Token::OperatorType::plus:
        case Token::OperatorType::plusplus:
        case Token::OperatorType::minus:
        case Token::OperatorType::minusminus:
        case Token::OperatorType::tilde:
        case Token::OperatorType::exclaim:
        default:
          break;
      }
    } else if (token[index].type == Token::Type::IDENTIFIER) {
      VarNode varnode;
      varnode.SetVarNode(token[index]);
      buffer.push_back(varnode); // ERROR
    }
  }
}
ax-6 commented 2 hours ago

Another issue was also found where the function was not setting the namespace properly. This will be fixed in the fix for this issue.