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

Makes finalVarOrType mandatory for the typedef #270

Closed
DartBot opened this issue Oct 31, 2011 · 12 comments
Closed

Makes finalVarOrType mandatory for the typedef #270

DartBot opened this issue Oct 31, 2011 · 12 comments
Labels
area-language Dart language related items (some items might be better tracked at github.com/dart-lang/language). closed-obsolete Closed as the reported issue is no longer relevant P2 A bug or feature request we're likely to work on type-enhancement A request for a change that isn't a bug

Comments

@DartBot
Copy link

DartBot commented Oct 31, 2011

This issue was originally filed by boost...@gmail.com


typedef use formalParameterList for declare an alias of function type.
But this rule surprise many users.
For example.

int f( int x ) => x ;
typedef int type( int ) ;

void main()
{
    type t = f ;
    t("a") ; // no static type warning is issued.
}

This is because int is treated as an identifier in simpleFormalParameter.
So int is just a name of parameter and its type is Dynamic.

But most user who don't read spec expect above typedef to annotate that the static type of parameter is int.
That's why they surprise the above code doesn't issue a static type warning.

To solve this issue, I propose to make finalVarOrType in mandatory for the typedef.
Under the proposed change, above typedef must be rewritten as
typedef int f( var int ) ;

This makes it apparent for all users that int is just a name of parameter and its type is Dynamic since it use var.

@floitschG
Copy link
Contributor

Removed Type-Defect label.
Added Type-Enhancement, Area-Language, Triaged labels.

@gbracha
Copy link
Contributor

gbracha commented Nov 3, 2011

typedefs need to be extended to cover type aliases in general. I'd like to see a different syntax of function type aliases. We'll see what can be done.


Set owner to @gbracha.
Added Accepted label.

@anders-sandholm
Copy link
Contributor

Added apr30-triage label.

@anders-sandholm
Copy link
Contributor

Removed apr30-triage label.

@anders-sandholm
Copy link
Contributor

Added triage1 label.

@anders-sandholm
Copy link
Contributor

Added this to the M1 milestone.
Removed triage1 label.

@gbracha
Copy link
Contributor

gbracha commented Aug 15, 2012

We've decided that, post M1, we will generalize typedef to allow aliasing for arbitrary types. Details TBD. Reclassifying this accordingly.


Removed this from the M1 milestone.
Added this to the Later milestone.

@lrhn
Copy link
Member

lrhn commented Aug 28, 2013

We now have mixin-application typedefs.
Still no type aliases, though (e.g. "typedef IntList = List<int>"), which would be great!

@kasperl
Copy link

kasperl commented Jul 10, 2014

Removed this from the Later milestone.
Added Oldschool-Milestone-Later label.

@kasperl
Copy link

kasperl commented Aug 4, 2014

Removed Oldschool-Milestone-Later label.

@DartBot DartBot added Type-Enhancement area-language Dart language related items (some items might be better tracked at github.com/dart-lang/language). labels Aug 4, 2014
@kevmoo kevmoo added P2 A bug or feature request we're likely to work on type-enhancement A request for a change that isn't a bug and removed accepted type-enhancement A request for a change that isn't a bug labels Feb 29, 2016
@lrhn
Copy link
Member

lrhn commented Sep 1, 2016

Closed incorrect issue, this one is still open.

@lrhn lrhn reopened this Sep 1, 2016
@matanlurey matanlurey added the closed-obsolete Closed as the reported issue is no longer relevant label Jun 19, 2018
@matanlurey
Copy link
Contributor

This is stale now that we have the new function syntax.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-language Dart language related items (some items might be better tracked at github.com/dart-lang/language). closed-obsolete Closed as the reported issue is no longer relevant P2 A bug or feature request we're likely to work on type-enhancement A request for a change that isn't a bug
Projects
None yet
Development

No branches or pull requests

8 participants