Skip to content

[Bug]: InherentTypeViolation when assigning int values to float fields in structured configurables #44565

@warunalakshitha

Description

@warunalakshitha

Description

import ballerina/io;

configurable Product p = ?;

configurable Cricketer cricketer = ?;
type Product record {
    string name;
    float price;
};

type Cricketer readonly & record {|
    string name;
    float strikeRate;
    float battingAverage;
|};

public function main() {
    io:println("Product: ", p.name);
    io:println("Price: ", p.price);
}

Config.Toml

[p]
name = "Book"
price = 12


[cricketer]
name = "waruna"
strikeRate = 91.5
battingAverage = 45

Getting
error: {ballerina/lang.map}InherentTypeViolation {"message":"invalid value for record field 'price': expected value of type 'float', found 'int'"}
at ballerina.lang.__internal.0:getConfigurableValue(configurable.bal:40)

Steps to Reproduce

No response

Affected Version(s)

No response

OS, DB, other environment details and versions

No response

Related area

-> Compilation

Related issue(s) (optional)

No response

Suggested label(s) (optional)

No response

Suggested assignee(s) (optional)

No response

Metadata

Metadata

Labels

Area/ConfigurableRuntime configurable related issues

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions