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 value to view type that is object field generates wrong code #22905

Open
sxq112358 opened this issue Nov 2, 2023 · 1 comment
Open
Assignees

Comments

@sxq112358
Copy link

Description

In generated c code, the field is of pointer type, while the assignment statement is trying to assign the value directly to the pointer

{.experimental:"views".}
type InnerVar2 = object
    value:var float
proc test_inner_var2=
    var i = 0.0
    var a = InnerVar2(value:i)
    a.value = 123.456
    echo i

test_inner_var2()

Nim Version

Nim Compiler Version 2.1.1 [Linux: amd64]
Compiled at 2023-11-02
Copyright (c) 2006-2023 by Andreas Rumpf

git hash: 40e33de
active boot switches: -d:release

Current Output

error: incompatible types when assigning to type 'NF *' {aka 'double *'} from type 'double'
  101 |         nimln_(107);    a.value = 123.456;
      |                                   ^~~~~~~
Error: execution of an external compiler program 'gcc -c  -w -fmax-errors=3 -pthread   -I'/home/umidazo/.choosenim/toolchains/nim-#devel/lib' -I/mnt/e/Workspace/nim -o /home/umidazo/.cache/nim/test_common_d/@mtest_common.nim.c.o /home/umidazo/.cache/nim/test_common_d/@mtest_common.nim.c' failed with exit code: 1

Expected Output

123.456

Possible Solution

No response

Additional Information

No response

@metagn
Copy link
Collaborator

metagn commented Nov 4, 2023

(a.value) = 123.456 works

@ringabout ringabout self-assigned this Dec 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants