Giter VIP home page Giter VIP logo

Comments (2)

ibokuri avatar ibokuri commented on August 25, 2024 1

Ah! Looks like you found two bugs for the price of one here 😂

The first bug is the assignment of default struct values. It should be casted to the field's type as you suggested. However, instead of using @as (which actually won't work since default is a pointer, not a value), we can use @ptrCast(*const field.field_type, default_ptr).*, which is what std.json uses. default should probably also be renamed to default_ptr to make things clearer.

The second bug is in the test deserializer's deserializeOptional method. Its call to visitSome was incorrect. It was passing in the interface type (Self.@"getty.Deserializer"), not an interface value (self.deserializer()).

The lesson here is I should've written some darn tests for optional values 😅

from getty.

Namek avatar Namek commented on August 25, 2024

For more context, when the optional field has no default value specified AND the patch mentioned above is applied then I get only this part of the errors:

W:\dev\definitive_dialoguer\.gyro\getty-getty-zig-github.com-d032ff42\pkg\src\lib.zig:41:9: error: concept `getty.Deserializer` was not satisfied: missing `context` field
        @compileError("concept `" ++ concept ++ "` was not satisfied: " ++ msg);
        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
W:\dev\definitive_dialoguer\.gyro\getty-getty-zig-github.com-d032ff42\pkg\src\de\concepts\deserializer.zig:10:25: note: called from here
            concepts.err(concept, "missing `context` field");
            ~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
W:\dev\definitive_dialoguer\.gyro\getty-getty-zig-github.com-d032ff42\pkg\src\de\interfaces\visitor.zig:137:47: note: called from here
                concepts.@"getty.Deserializer"(@TypeOf(deserializer));
                ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~

from getty.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.