Skip to content

[Bug] Type checking with typeof directly always results in true expressions #733

@KawaiiBakemono

Description

@KawaiiBakemono

Is there an existing issue for this?

  • I have searched the existing issues

I am following the documentation's guide

  • I have read the documentation

This issue exists in the latest version

  • I am using the latest version

Current Behavior

Type checking always results in true expressions due to improper brace insertion in the code generator. For example:

var x: num = 123;

if (typeof(x) != num) {
    print("This will always print!");
}

Output:

This will always print!

Finished execution with exit code 0.

Expected Behavior

Unequal expressions should result in false.

var x: num = 123;

if (typeof(x) != num) {
    print("This should never print");
}

Steps To Reproduce

  1. Define a variable of any type (ex. var x: num = 1;)
  2. Create an if statement to check if the typeof the previously defined variable is not equal to the type it was defined as (ex. if (x != num) { ... })

Workarounds

Currently, to have functional type checking, you must creating a variable that is solely the typeof the variable you are attempting to check (in this case a num), like so:

var x: num = 123;
var checker: type = typeof(num);

if (x != checker) {
    print("Works as expected.");
}

Environment

  • Kipper: 0.12.1
  • Environment: Vivaldi 7.6.3797.56 (Playground)
  • Operating System: Arch Linux

Metadata

Metadata

Assignees

Labels

bugBug or issue in the language or APIhigh priorityHigh priority issue, discussion or pull request

Type

Projects

Status

In Progress

Relationships

None yet

Development

No branches or pull requests

Issue actions