Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

200
Views
'constructor' is not defined

I am trying to make a programming language (very stupid), and i stumble across this error:

ReferenceError: ' constructor' is not defined.

Here is where the code is (Node JS):

class DLang {
  constructor(code) {
    this.lines = code.split('\n')
  }

  run() {
    let lines = this.lines
    let testingUtils_ = false
    let variables = {}

    for (let i = 0; i < lines.length; i++) {
      if (lines[i] === 'import \'testing/all.dlang\'') {
        testingUtils_ = true
      }

      if (lines[i].includes('(')) {
        let currFunction_ = lines[i].split('(')[0]
        // let text = lines[i].split('(')[1].replace(')', '').replace(/\'/g, '')
        let text
        let value = lines[i]
                    .replace('(', '')
                    .replace(')', '')
                    .replace(currFunction_, '')

        if (value.includes('\'')) {
          text = value
                  .replace(/\'/g, '')
        } else {
          text = variables[value]
        }
  
        // function conditions
        let printCondition_ = (currFunction_ === 'print' && testingUtils_ === true)
  
        if (printCondition_) {
          if (text == undefined) {
            throw ReferenceError(`\'${value}\' is not defined.`)
          } else {
            console.log(text)
          }
        } else if (!printCondition_) {
          throw new ReferenceError(`\'${currFunction_}\' is not defined.`)
        }
      }

      if (lines[i].includes('var', 0)) {
        let final_ = lines[i]
                      .replace('var', '')
                      .replace('=', '')
                      .trim()
                      .split('\'')

        variables[final_[0].trim()] = final_[1]
      }
    }
  }
}

module.exports = DLang

For reference, here is the full error message:

throw new ReferenceError(`\'${currFunction_}\' is not defined.`)
          ^

ReferenceError: '  constructor' is not defined.
    at DLang.run (/Users/name/Desktop/coding/programming_langs/dlang/dlang_source_code/src/index.js:42:17)
    at /Users/name/Desktop/coding/programming_langs/dlang/dlang_source_code/test.js:11:7
    at FSReqCallback.readFileAfterClose [as oncomplete] (node:internal/fs/read_file_context:68:3)

Node.js v17.1.0

Thanks in advance!

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!