Skip to content

Generate error when referencing uninitialized variables #6

Description

@itssamuelrowe

Consider the following program:

function main(...arguments)
    var text
    if random() % 2 == 0
        text = 'even'
    print(text)

In the example shown above, text remains uninitialized when random() returns an odd number. Although this is not a problem for this simple example, but it definitely could cause bugs. Therefore, the compiler should report such errors.

Such errors can be found during static analysis in the resolution phase. The zen_Symbol_t structure can be extended to include flags. A flag which indicates the initialization status of a local variable can be used to detect the errors at zen_SymbolResolutionListener_onExitFunctionDeclaration().

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions