Skip to content

Commit

Permalink
[asl] Fix ATCs on types with same structure
Browse files Browse the repository at this point in the history
  • Loading branch information
HadrienRenaud committed Oct 24, 2024
1 parent 0c832f5 commit 431e1ba
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
2 changes: 1 addition & 1 deletion asllib/Typing.ml
Original file line number Diff line number Diff line change
Expand Up @@ -1520,7 +1520,7 @@ module Annotate (C : ANNOTATE_CONFIG) : S = struct
check_atc env t_struct ty_struct ~fail:(fun () ->
fatal_from loc (BadATC (t, ty)))
in
(if Types.subtype_satisfies env t ty' then (ty', e'')
(if Types.subtype_satisfies env t_struct ty_struct then (ty', e'')
else if forbid_atcs then fatal_from loc Error.UnexpectedATC
else (ty', E_ATC (e'', ty_struct) |> here))
|: TypingRule.ATC
Expand Down
20 changes: 17 additions & 3 deletions asllib/tests/atcs.t
Original file line number Diff line number Diff line change
Expand Up @@ -85,12 +85,26 @@ ATCs on other types

$ aslref atcs7.asl

ATCs in types:
$ cat > atcs8.asl <<EOF
> let bv : bits(1 as integer{2}) = Ones(1);
> type A of record{ a: integer};
> type B subtypes A;
> func main () => integer
> begin
> let x: A = B { a = 0 };
> var a: array[10] of B;
> let b = a as array[10] of A;
> return 0;
> end
> EOF

$ aslref atcs8.asl
File atcs8.asl, line 1, characters 14 to 29:

ATCs in types:
$ cat > atcs9.asl <<EOF
> let bv : bits(1 as integer{2}) = Ones(1);
> EOF

$ aslref atcs9.asl
File atcs9.asl, line 1, characters 14 to 29:
ASL Typing error: unexpected ATC.
[1]

0 comments on commit 431e1ba

Please sign in to comment.