Commit ec033c3
committed
Fix elaboration of function definitions with nested function types
Since commit ea3a41b, `elab_type_declarator` has a special case for function definitions, causing it to include the function parameters in the returned updated typing environment. However, this special case was wrong for nested function types such as
```
int (*f(int y))(int x) { ... }
```
`f` is a function taking an `y` parameter and returning a function `(x: int) -> int`. The special case causes both `x` and `y` to be included in the returned environment, while only `y` should be.
This commit makes sure that the special case for function definitions applies only to the outermost function type, i.e. the innermost `Cabs.PROTO` declarator.
A similar issue was handled correctly in the `Cabs.PROTO_OLD` case, so this commit tries to use the same code structure in the `PROTO` and `PROTO_OLD` cases.1 parent 3f217e3 commit ec033c3
3 files changed
+25
-18
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
| 23 | + | |
23 | 24 | | |
24 | 25 | | |
25 | 26 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
924 | 924 | | |
925 | 925 | | |
926 | 926 | | |
927 | | - | |
928 | | - | |
929 | | - | |
930 | | - | |
931 | | - | |
932 | | - | |
933 | | - | |
934 | | - | |
| 927 | + | |
| 928 | + | |
| 929 | + | |
| 930 | + | |
| 931 | + | |
| 932 | + | |
| 933 | + | |
| 934 | + | |
| 935 | + | |
| 936 | + | |
| 937 | + | |
| 938 | + | |
935 | 939 | | |
936 | 940 | | |
937 | 941 | | |
| 942 | + | |
938 | 943 | | |
939 | | - | |
940 | | - | |
941 | | - | |
942 | | - | |
943 | | - | |
944 | | - | |
945 | | - | |
946 | | - | |
| 944 | + | |
| 945 | + | |
| 946 | + | |
| 947 | + | |
| 948 | + | |
| 949 | + | |
| 950 | + | |
| 951 | + | |
947 | 952 | | |
948 | | - | |
| 953 | + | |
| 954 | + | |
949 | 955 | | |
950 | 956 | | |
951 | 957 | | |
| |||
0 commit comments