Skip to content

Remove expression variant from isInteger, isFloat etc. for consistency #531

Closed

Description

@dcodeIO

Currently, most static type evaluation builtins take either a type argument or an argument, but the second case is unsound in that the expression is evaluated for its type but ultimately ignored. For example, the following code will never execute the expression because the call's result is supposed to evaluate to a constant with no place to put the expression:

var a: i32 = 0;
if (isInteger(a = 1)) {
  // a is 0
}
// a is 0

I therefore propose to remove the second case. Or does anyone actually have to use the second case for a good reason, somewhere?

Activity

  1. jtenner commented on Mar 8, 2019

    @jtenner
    Contributor

    Argument for using expressions in the macro: running AS code transpiled to Javascript can function like AS can. Downside, we lose type information about float VS integer etc

  2. dcodeIO commented on Mar 8, 2019

    @dcodeIO
    MemberAuthor

    Hmm. Well. The obvious alternative is to emit an error or a warning if the expression has side effects. Doesn't eliminate the unsoundness, though.

  3. changed the title [-]isInteger, isFloat etc. inconsistency[/-] [+]Remove expression variant from isInteger, isFloat etc. for consistency[/+] on May 27, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions