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

assigning literal arrays to ARRAY[..] OF STRING in the implementation-body is broken #1435

Open
mhasel opened this issue Mar 17, 2025 · 0 comments
Labels
bug Something isn't working

Comments

@mhasel
Copy link
Member

mhasel commented Mar 17, 2025

Describe the bug
When trying to assign a literal string-array (e.g. ['a', 'b', 'c'] to an ARRAY[0..2] OF STRING, inkwell will panic with the following message:

thread '<unnamed>' panicked at /home/michael/.cargo/registry/src/index.crates.io-6f17d22bba15001f/inkwell-0.2.0/src/values/enums.rs:278:13:
Found PointerValue(PointerValue { ptr_value: Value { name: "utf08_literal_0", address: 0x7672c800d5f0, is_const: true, is_null: false, is_undef: false, llvm_value: "@utf08_literal_0 = private unnamed_addr constant [2 x i8] c\"g\\00\"", llvm_type: "[2 x i8]*" } }) but expected the ArrayValue variant

To Reproduce
Steps to reproduce the behavior:

Compile the following example:

FUNCTION main 
VAR
    arr: ARRAY[0..2] OF STRING;
    arr2: ARRAY[0..2] OF DINT;
END_VAR
    arr := ['a', 'b', 'c'];
    arr2 := [1, 2, 3];
END_FUNCTION

Expected behavior
The string-array should be overwritten with the values in the literal array.

Additional context
The code works fine for the ARRAY[..] OF DINT.

@mhasel mhasel added the bug Something isn't working label Mar 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant