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

Fix interface view package mismatch #334

Merged
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Merge branch 'master' into 324-interface-view-package-mismatch
  • Loading branch information
Schottkyc137 committed Aug 7, 2024
commit 1ad1495a927ddfc0f9abe40cff3a6e97f62d6c02
105 changes: 105 additions & 0 deletions vhdl_lang/src/analysis/tests/view_declarations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -512,3 +512,108 @@ end architecture;
);
check_no_diagnostics(&builder.analyze());
}

#[test]
fn arrays_of_views_with_matching_type() {
let mut builder = LibraryBuilder::with_standard(VHDL2019);
builder.code(
"libname",
"\
package test_pkg is
type test_t is record
a : bit;
end record;

view vone of test_t is
a : in;
end view;

type test_array is array (natural range <>) of test_t;
end package;

use work.test_pkg.all;

entity test_sub_entity is
port (
my_if : view vone;
my_array_if: view (vone) of test_array(0 to 1)
);
end entity;
",
);
check_no_diagnostics(&builder.analyze());
}

#[test]
fn arrays_of_views_with_non_matching_type() {
let mut builder = LibraryBuilder::with_standard(VHDL2019);
let code = builder.code(
"libname",
"\
package test_pkg is
type test_t is record
a : bit;
end record;

view vone of test_t is
a : in;
end view;

type test_array is array (natural range <>) of bit;
end package;

use work.test_pkg.all;

entity test_sub_entity is
port (
my_if : view vone;
my_array_if: view (vone) of test_array(0 to 1)
);
end entity;
",
);
check_diagnostics(
builder.analyze(),
vec![Diagnostic::new(
code.s1("test_array(0 to 1)").s1("test_array"),
"Array element type 'BIT' must match record type 'test_t' declared for the view",
ErrorCode::TypeMismatch,
)],
)
}

#[test]
fn arrays_of_views_that_are_not_arrays() {
let mut builder = LibraryBuilder::with_standard(VHDL2019);
let code = builder.code(
"libname",
"\
package test_pkg is
type test_t is record
a : bit;
end record;

view vone of test_t is
a : in;
end view;
end package;

use work.test_pkg.all;

entity test_sub_entity is
port (
my_if : view vone;
my_array_if: view (vone) of test_t
);
end entity;
",
);
check_diagnostics(
builder.analyze(),
vec![Diagnostic::new(
code.s1("view (vone) of test_t").s1("test_t"),
"Subtype must be an array",
ErrorCode::TypeMismatch,
)],
)
}
You are viewing a condensed version of this merge commit. You can view the full changes here.