You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
According to the specifications (3.8.5), the following two should be illegal. Tuple types should not be empty and there should be no trailing comma. However, the implementation seems to allow them.
var t1 : [];
var t2 : [number,];
If they are to be allowed and the specifications are to be revised, let me suggest that the tuple type be generalized in the same way as array literals are, in JS. E.g.
var t: [, number,, string,,];
where t is a 5-tuple whose 2nd element is a number and whose 4th element is string (the other three are unknown --- any).
Sorry, I should have mentioned this. Version 1.9.0, from a (slightly outdated, 6 days ago) git clone, commit f06423b. It seems that the current version (commit 9f6f871) issues the errors that you mentioned, so it seems to have been fixed in the last 6 days. Sorry about the false alarm.
On the other hand, I really wouldn't mind allowing these two and adopting the more liberal view of tuple types that I suggested above. I'm leaving this open, in case somebody wants to think about it...
I think something's wrong with whatever setup you're using to test this. I'm on the same commit and am seeing the errors.
If you want to open a separate suggestion for gapped tuple types, please do, but I'd rather not have this issue tracking it since it's logged as if it were a bug.
The issue seems to be more complicated than I thought. My setup seems to be OK (jake runtests completes successfully).
In fact, I was testing a slightly larger example containing these two lines. With that larger example, there were no errors reported for these two lines, but there were errors in lines following these two. Here's a MWE showing this strange behaviour:
var t1 : [];
var t3 : [number,,];
Now (in the current commit 1156141), although both lines are erroneous, only the second one produces an error message:
binding-patterns.ts(2,18): error TS1110: Type expected.
That's normal behavior. When you have a syntax error, we don't issue type errors. A missing entry in a delimited list is a syntax error, but an empty tuple type is a type error (as you can see this distinction is sometimes a bit arbitrary, but it usually makes sense).
You can see the same behavior e.g.:
vart1 : [];vary=1&;// Syntax error here, so no type error issued on line 1
Activity
RyanCavanaugh commentedon Mar 15, 2016
This is what I get when I compile this:
What version are you running?
nickie commentedon Mar 15, 2016
Sorry, I should have mentioned this. Version 1.9.0, from a (slightly outdated, 6 days ago) git clone, commit f06423b. It seems that the current version (commit 9f6f871) issues the errors that you mentioned, so it seems to have been fixed in the last 6 days. Sorry about the false alarm.
On the other hand, I really wouldn't mind allowing these two and adopting the more liberal view of tuple types that I suggested above. I'm leaving this open, in case somebody wants to think about it...
nickie commentedon Mar 15, 2016
Oops, sorry, I was wrong once again. The problem seems to be still there in the current commit 9f6f871.
RyanCavanaugh commentedon Mar 15, 2016
I think something's wrong with whatever setup you're using to test this. I'm on the same commit and am seeing the errors.
If you want to open a separate suggestion for gapped tuple types, please do, but I'd rather not have this issue tracking it since it's logged as if it were a bug.
nickie commentedon Mar 16, 2016
The issue seems to be more complicated than I thought. My setup seems to be OK (
jake runtestscompletes successfully).In fact, I was testing a slightly larger example containing these two lines. With that larger example, there were no errors reported for these two lines, but there were errors in lines following these two. Here's a MWE showing this strange behaviour:
Now (in the current commit 1156141), although both lines are erroneous, only the second one produces an error message:
RyanCavanaugh commentedon Mar 16, 2016
That's normal behavior. When you have a syntax error, we don't issue type errors. A missing entry in a delimited list is a syntax error, but an empty tuple type is a type error (as you can see this distinction is sometimes a bit arbitrary, but it usually makes sense).
You can see the same behavior e.g.:
nickie commentedon Mar 16, 2016
OK, understood. My mistake then... Issue closed.