Skip to content

In F# 6 fsi, a float -> float function dynamically casts int input to float #12523

@nhirschey

Description

@nhirschey

Repro steps
This could be known but I could not find this in open or closed recent issues. A float function acts like F# does not have static types when operating on integers.

Using dotnet 6.0.101 or 6.0.100

let f x = x + 1.0
let g (x: float) = x ** 2.0

f 1 // evaluates to 2.0
g 2 //  evaluates to 4.0
f 1m // type error expected float but got decimal

// even with assigned values
let z: int = 3 // val z: int = 3
g z              // evaluates to val it: float = 9.0

image

Expected behavior

Type error as you get in F# 5.0

image

Actual behavior

Dynamic instead of static types.

Related information

Provide any related information (optional):

  • Windows 11
  • dotnet 6.0.1XX
  • Editing environment: Seen in fsi command line tool and dotnet interactive notebooks.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions