Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: decimal:fromString() panics #43377

Open
MohamedSabthar opened this issue Sep 11, 2024 · 1 comment
Open

[Bug]: decimal:fromString() panics #43377

MohamedSabthar opened this issue Sep 11, 2024 · 1 comment
Labels
Lang/LangLib Related to ballerina/lang.* modules Priority/High Team/jBallerina All the issues related to BIR, JVM backend code generation and runtime Type/Bug

Comments

@MohamedSabthar
Copy link
Member

Description

public function main() {
    error|decimal val = decimal:fromString("ENT 12 N 0000");
}

The above code panic instead of returning an error.

Getting:

error: {ballerina}DecimalExponentError {"message":"too many exponents found in decimal value 'ENT 12 N 0000'"}
        at ballerina.lang.decimal.0:fromString(decimal.bal:206)
           bytes:main(bytes.bal:3)

Steps to Reproduce

No response

Affected Version(s)

No response

OS, DB, other environment details and versions

No response

Related area

-> Runtime

Related issue(s) (optional)

No response

Suggested label(s) (optional)

No response

Suggested assignee(s) (optional)

No response

@MohamedSabthar MohamedSabthar added Type/Bug Lang/LangLib Related to ballerina/lang.* modules labels Sep 11, 2024
@ballerina-bot ballerina-bot added the Team/jBallerina All the issues related to BIR, JVM backend code generation and runtime label Sep 11, 2024
@SasinduDilshara
Copy link
Contributor

As a workaround you can use the

public function main() {
    error|decimal val = trap decimal:fromString("ENT 12 N 0000");
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Lang/LangLib Related to ballerina/lang.* modules Priority/High Team/jBallerina All the issues related to BIR, JVM backend code generation and runtime Type/Bug
Projects
None yet
Development

No branches or pull requests

4 participants