<commit_before>#include "checkSemantics.h"
#include "expr.h"

static void checkFnCall(FnCall* fncall) {
  
}

static void checkAssignOp(AssignOp* assign) {
  if (assign->left->isConst() || assign->left->isParam()) {
    USR_FATAL(assign, "Assigning to a constant expression");
  }
}

void CheckSemantics::preProcessExpr(Expr* expr) {
  FnCall* fncall = dynamic_cast<FnCall*>(expr);
  if (fncall) checkFnCall(fncall);

  AssignOp* assign = dynamic_cast<AssignOp*>(expr);
  if (assign){
    //printf("Assignment expression.\n"); 
    if (!dynamic_cast<DefExpr*>(expr->parentExpr)) { // initialization okay
      checkAssignOp(assign);
    }
  }

  if (DefExpr* defExpr = dynamic_cast<DefExpr*>(expr)) {
    if (defExpr->sym->isParam()) {
      if (!dynamic_cast<IntLiteral*>(defExpr->init)) {
        USR_FATAL(defExpr, "Initializing parameter to a variable expression.");
      }
    }
  }
}

<commit_msg>Fixed a minor bug I let slip through in which uninitialized params were flagged as being initialized with variables.<commit_after>#include "checkSemantics.h"
#include "expr.h"

static void checkFnCall(FnCall* fncall) {
  
}

static void checkAssignOp(AssignOp* assign) {
  if (assign->left->isConst() || assign->left->isParam()) {
    USR_FATAL(assign, "Assigning to a constant expression");
  }
}

void CheckSemantics::preProcessExpr(Expr* expr) {
  FnCall* fncall = dynamic_cast<FnCall*>(expr);
  if (fncall) checkFnCall(fncall);

  AssignOp* assign = dynamic_cast<AssignOp*>(expr);
  if (assign){
    //printf("Assignment expression.\n"); 
    if (!dynamic_cast<DefExpr*>(expr->parentExpr)) { // initialization okay
      checkAssignOp(assign);
    }
  }

  if (DefExpr* defExpr = dynamic_cast<DefExpr*>(expr)) {
    if (defExpr->sym->isParam()) {
      if (defExpr->init && !dynamic_cast<IntLiteral*>(defExpr->init)) {
        USR_FATAL(defExpr, "Initializing parameter to a variable expression.");
      }
    }
  }
}


{'fraction_non_alphanumeric': 0.15093360995850622, 'fraction_numerical': 0.0, 'mean_word_length': 4.199460916442049, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 30, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6704275', 'n_tokens_mistral': 639, 'n_tokens_neox': 626, 'n_words': 133}