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

Data corruption in write.json when compiled #1276

Open
jinyus opened this issue Oct 1, 2023 · 3 comments
Open

Data corruption in write.json when compiled #1276

jinyus opened this issue Oct 1, 2023 · 3 comments
Assignees
Labels
bug Something isn't working stale

Comments

@jinyus
Copy link

jinyus commented Oct 1, 2023

write.json seems to be changing keys that starts with an underscore _ . This only happens when executing the bytecode.

Minimal reproduction (repo):

git clone https://github.com/jinyus/arturo_bug_demo.git ;
cd arturo_bug_demo ;
./run.sh
Code
posts: read.json "./posts.json"

allPostIDs: map.with:'i posts 'p [
    #[
        "_id": get p "_id",
        "_index": i,
    ]
]

print write.json ø allPostIDs

Ouput:

Running arturo demo.art (correct)

[
    {
        "_id": "h5cwwbua",
        "_index": 0
    },
    {
        "_id": "jf0da9ku",
        "_index": 1
    }
]

Running arturo -x demo.art.bcode (modifying the key)

[
    {
        "id": "h5cwwbua",
        "index": 0
    },
    {
        "id": "jf0da9ku",
        "index": 1
    }
]
@jinyus jinyus added the bug Something isn't working label Oct 1, 2023
@drkameleon
Copy link
Collaborator

That's very interesting and tricky! I'll try to trigger it and will let you know.

This specific thing aside, one word of caution:

The ability to export-to and execute Bytecode directly has been around for quite some time, but I honestly haven't worked on it too much... so, even though it is there, I haven't really used it as a feature in production code. (to be interpreted as: I don't feel very confident about it, yet)

That being said, you're more than welcome to post all issues you come across, related to... anything. Since this is the only way to help the project make some progress! 😉 🚀

@RickBarretto
Copy link
Collaborator

Hmmm... Curious
Inspecting the bytecode, we have got this:

[ :bytecode
        ================================
         DATA
        ================================
        0: ./posts.json :string
        1: json :attribute
        2: read :word
        3: posts :label
        4: [ :block
                # :symbol
                [ :block
                        _id :label
                        get :word
                        p :word
                        _id :string
                        _index :label
                        i :word
                ]
        ]
        5: p :literal
        6: i :literal
        7: with :attributelabel
        8: allPostIDs :label
        9: write :word

        ================================
         CODE
        ================================
        push0
        constbt
        attr1
        call2
        store3
        eol                 #5
        push4
        eol                 #10
        push5
        load3
        push6
        attr7
        map
        storl8
        eol                 #12
        constn
        constbt
        attr1
        call9
        print
        end
]

Copy link

stale bot commented Jun 7, 2024

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Jun 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working stale
Projects
None yet
Development

No branches or pull requests

3 participants