Skip to content

[book] Type Inference (type rules) algorithm #36

Description

@storenth

From the book at Number Types

The location where the L appears is unimportant. If one of the values is Long, the resulting expression is Long.

Not true, there is an actual result in case I move L val to the different place:

fun main() {
  val i = Int.MAX_VALUE
  println(i + i + 0L)  // overflow, because of math rule
}

type-rule

Anyway, can you explain Type Inference (type rules) algo or point me to an authoritative resource?

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

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions