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

@typeInfo returns private decls even when T is external #10731

Closed
nektro opened this issue Jan 30, 2022 · 2 comments · Fixed by #16547
Closed

@typeInfo returns private decls even when T is external #10731

nektro opened this issue Jan 30, 2022 · 2 comments · Fixed by #16547
Labels
bug Observed behavior contradicts documented or intended behavior frontend Tokenization, parsing, AstGen, Sema, and Liveness. miscompilation The compiler reports success but produces semantically incorrect code.
Milestone

Comments

@nektro
Copy link
Contributor

nektro commented Jan 30, 2022

Zig Version

0.10.0-dev.477+aa902c704

Steps to Reproduce

const std = @import("std");
const other = @import("./other.zig");

test {
    const ti = @typeInfo(other);
    const decls = ti.Struct.decls;

    try std.testing.expectEqual(2, decls.len);
    try std.testing.expectEqualStrings("Enum", decls[0].name);
    try std.testing.expectEqualStrings("Struct", decls[1].name);
}
const std = @import("std");

pub const Enum = enum {
    a,
    b,
    c,
};

pub const Struct = struct {
    foo: i32,
};

Expected Behavior

All 1 tests passed.

Actual Behavior

Test [0/1] test ""... expected 2, found 3
Test [1/1] test ""... FAIL (TestExpectedEqual)
@nektro nektro added the bug Observed behavior contradicts documented or intended behavior label Jan 30, 2022
@Vexu Vexu added the stage1 The process of building from source via WebAssembly and the C backend. label Jan 30, 2022
@Vexu Vexu added this to the 0.11.0 milestone Jan 30, 2022
@Vexu Vexu removed the stage1 The process of building from source via WebAssembly and the C backend. label Feb 2, 2023
@andrewrk andrewrk modified the milestones: 0.13.0, 0.11.0 Apr 10, 2023
@andrewrk andrewrk added miscompilation The compiler reports success but produces semantically incorrect code. frontend Tokenization, parsing, AstGen, Sema, and Liveness. labels Apr 10, 2023
@andrewrk
Copy link
Member

Intended behavior is for @typeInfo to always return only public decls, no matter where the callsite of @typeInfo is.

g-w1 added a commit to g-w1/zig that referenced this issue Jul 25, 2023
g-w1 added a commit to g-w1/zig that referenced this issue Jul 25, 2023
g-w1 added a commit to g-w1/zig that referenced this issue Jul 25, 2023
@g-w1
Copy link
Contributor

g-w1 commented Jul 25, 2023

I made a breaking change to the language in #16547 , (removing is_pub), but this seems warranted because only public decls are allowed in @typeInfo.

g-w1 added a commit to g-w1/zig that referenced this issue Jul 25, 2023
g-w1 added a commit to g-w1/zig that referenced this issue Jul 25, 2023
fixes ziglang#10731
Thanks @nektro for previous work in ziglang#14878

This change creates a small breaking change:
It removes the `is_pub` field of a decl in `@typeInfo`
g-w1 added a commit to g-w1/zig that referenced this issue Jul 25, 2023
fixes ziglang#10731
Thanks @nektro for previous work in ziglang#14878

This change creates a small breaking change:
It removes the `is_pub` field of a decl in `@typeInfo`
g-w1 added a commit to g-w1/zig that referenced this issue Jul 25, 2023
fixes ziglang#10731
Thanks @nektro for previous work in ziglang#14878

This change creates a small breaking change:
It removes the `is_pub` field of a decl in `@typeInfo`
andrewrk pushed a commit that referenced this issue Jul 25, 2023
fixes #10731
Thanks @nektro for previous work in #14878

This change creates a small breaking change:
It removes the `is_pub` field of a decl in `@typeInfo`
cactusbento pushed a commit to cactusbento/zig that referenced this issue Jul 25, 2023
fixes ziglang#10731
Thanks @nektro for previous work in ziglang#14878

This change creates a small breaking change:
It removes the `is_pub` field of a decl in `@typeInfo`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Observed behavior contradicts documented or intended behavior frontend Tokenization, parsing, AstGen, Sema, and Liveness. miscompilation The compiler reports success but produces semantically incorrect code.
Projects
None yet
4 participants