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

PseudoKWNegative test appears to conflict with spec? #356

Closed
DartBot opened this issue Nov 6, 2011 · 11 comments
Closed

PseudoKWNegative test appears to conflict with spec? #356

DartBot opened this issue Nov 6, 2011 · 11 comments
Labels
area-language Dart language related items (some items might be better tracked at github.com/dart-lang/language). P1 A high priority bug; for example, a single project is unusable or has many test failures

Comments

@DartBot
Copy link

DartBot commented Nov 6, 2011

This issue was originally filed by jimhug@google.com


This test asserts that 'operator' is not a valid class name because 'operator' it is a built-in identifier. Personally, I like this rule as it will remove some future "Dart Puzzlers" where having a type named 'get' can be used to baffle the naive programmer. I would like to see the rule from this test added to the spec.

However, before I make this test work in frog, I wanted to confirm that this is or is not the desired behavior. Is this a spec bug or a test bug?

@DartBot
Copy link
Author

DartBot commented Nov 6, 2011

This comment was originally written by jimhug@google.com


Marking all test issues as high priority to encourage quick progress on clarifying correct language behavior.


Removed Priority-Medium label.
Added Priority-High label.

@gbracha
Copy link
Contributor

gbracha commented Nov 8, 2011

The spec allows using operator as a type name - though I think that is a horrible style. So, at this stage, this is a bug in the test/ One could also read this bug as a feature request against the language spec.

This plays into the larger issue of why we have the reserved word vs. built-in identifier (popularly known as pseudo-keywords) distinction. It's designed to ease conversion from JS to Dart. How important it is is debatable, given all the ambiguities that arise. One idea I had was to ban the use of built-in ids for user defined types; this has no compatibility implications, and eliminates a large class of problems:

get get() ...
get get get() ...

The VM effectively does this as part of a broader policy that says that top level names canot be built-in ids. That would also be possible, though it would potentially conflict with some JS code (top level function names).


Added Area-Language label.

@DartBot
Copy link
Author

DartBot commented Nov 8, 2011

This comment was originally written by drfibonacci@google.com


Added Triaged label.

@DartBot
Copy link
Author

DartBot commented Nov 9, 2011

This comment was originally written by jimhug@google.com


If I was resolving this issue, here are the choices I would pick (as a bug/feature request vs. the language spec):

  1. Make all keywords true reserved words - and add a couple more likely future ones such as yield and async.
  2. Allow '@' as a prefix on any reserved word to make it a legal identifier. This would provide a canonical renaming scheme for code brought in from JS - as well as code that really wants to use switch as a variable name. I think this is in line with the way that we use @­ on strings currently in the language.

In the meantime, I'd like to see this test fixed - either removed as unspecified behavior or switched from a negative test to a positive one.

@gbracha
Copy link
Contributor

gbracha commented Jan 9, 2012

Lars and I discussed this last month. Banning built-in identifiers as type names is going to be part of the spec soon.

@gbracha
Copy link
Contributor

gbracha commented Jan 10, 2012

Ok, the spec has been updated. It is a compile-time error to use a builtin identifier (aka pseudo-keyword) to name a class, interface or type alias.

@DartBot
Copy link
Author

DartBot commented Jan 12, 2012

This comment was originally written by jimhug@google.com


Spec updated and test suite now fixed to match spec. - http://codereview.chromium.org/9147006


Added Fixed label.

@scheglov
Copy link
Contributor

Is "default" also pseudo keyword?

@DartBot
Copy link
Author

DartBot commented Jan 18, 2012

This comment was originally written by @mhausner


The spec says no. Look for the production BUILT_IN_IDENTIFIER

@scheglov
Copy link
Contributor

Yes, I see what spec says.
I just wonder why include "factory", but don't include "default".

In same way I wonder why "Dynamic" is not allowed to use as type annotation.
I see a lot of generated code which declares function with parameters and return type Dynamic. Is this really not allowed?

From spec:


Static type annotations are used in variable declarations (5) (including formal
parameters (6.2)) and in the return types of functions (6).



cc @gbracha.

@gbracha
Copy link
Contributor

gbracha commented Jan 18, 2012

default is a keyword in ES5, so we can keep it as a reserved word.

Dynamic is allowed as a type annotation. I think the latest tweak tro the spec may have introduced a bug about not using built-in ids as type annotations. That should exclude Dynamic of course.

@DartBot DartBot added Type-Defect P1 A high priority bug; for example, a single project is unusable or has many test failures area-language Dart language related items (some items might be better tracked at github.com/dart-lang/language). labels Jan 18, 2012
copybara-service bot pushed a commit that referenced this issue May 22, 2023
…wn, mockito, native, pool, pub_semver, shelf, sse, stack_trace, stream_channel, string_scanner, term_glyph, test, test_reflective_loader, tools

Revisions updated by `dart tools/rev_sdk_deps.dart`.

clock (https://github.com/dart-lang/clock/compare/fe85908..21caac1):
  21caac1  2023-05-21  Kevin Moore  Update formatting (#52)

collection (https://github.com/dart-lang/collection/compare/db2da48..f949b09):
  f949b09  2023-05-18  Graciliano Monteiro Passos  `CanonicalizedMap`: new `copy`, `toMap` and `toMapOfCanonicalKeys` methods (#261)

file (https://github.com/google/file.dart/compare/f05f5db..5d9a602):
  5d9a602  2023-05-19  Jacob MacDonald  remove no longer necessary override (#223)
  e4eebba  2023-05-19  Jacob MacDonald  release version 7.0.0 (#222)

glob (https://github.com/dart-lang/glob/compare/30f6aba..109121d):
  109121d  2023-05-19  Jacob MacDonald  allow latest file, update to latest dart_flutter_team_lints (#78)

json_rpc_2 (https://github.com/dart-lang/json_rpc_2/compare/800843e..b2ed6bd):
  b2ed6bd  2023-05-22  Devon Carew  blast_repo fixes (#97)

logging (https://github.com/dart-lang/logging/compare/fa2486d..7ba155a):
  7ba155a  2023-05-22  Devon Carew  blast_repo fixes (#141)

markdown (https://github.com/dart-lang/markdown/compare/b951454..bd6ae8d):
  bd6ae8d  2023-05-22  Zhiguang Chen  Table should be able to interrupt other blocks (#545)
  0bc9d0e  2023-05-21  Devon Carew  blast_repo fixes (#544)

mockito (https://github.com/dart-lang/mockito/compare/28f174f..7c6d309):
  7c6d309  2023-05-18  Devon Carew  blast_repo fixes
  2c1b429  2023-05-19  Ilya Yanok  Extend using run-time dummy values to Futures

native (https://github.com/dart-lang/native/compare/3d89166..00832c9):
  00832c9  2023-05-22  Daco Harkes  [c_compiler] Increase test timeout on Windows (#47)
  06408e7  2023-05-22  Daco Harkes  [native_assets_cli] Fix example repostory url (#42)
  c614277  2023-05-19  dependabot[bot]  Bump nttld/setup-ndk (#45)
  67a2d20  2023-05-19  dependabot[bot]  Bump actions/labeler from 4.0.2 to 4.0.3 (#44)
  270700e  2023-05-18  Devon Carew  blast_repo fixes (#43)

pool (https://github.com/dart-lang/pool/compare/86b4f43..a10a0f9):
  a10a0f9  2023-05-22  Devon Carew  blast_repo fixes (#69)

pub_semver (https://github.com/dart-lang/pub_semver/compare/6dd1908..c034352):
  c034352  2023-05-22  Devon Carew  blast_repo fixes (#87)

shelf (https://github.com/dart-lang/shelf/compare/8793687..e7bab95):
  e7bab95  2023-05-19  Devon Carew  blast_repo fixes (#356)

sse (https://github.com/dart-lang/sse/compare/11ba89e..bfcbcd7):
  bfcbcd7  2023-05-19  Devon Carew  blast_repo fixes (#84)

stack_trace (https://github.com/dart-lang/stack_trace/compare/36fa0e1..86f7e30):
  86f7e30  2023-05-19  Devon Carew  blast_repo fixes (#132)

stream_channel (https://github.com/dart-lang/stream_channel/compare/a862e41..b1d3384):
  b1d3384  2023-05-19  Devon Carew  blast_repo fixes (#91)

string_scanner (https://github.com/dart-lang/string_scanner/compare/3bc6e54..6bb314f):
  6bb314f  2023-05-19  Devon Carew  blast_repo fixes (#58)

term_glyph (https://github.com/dart-lang/term_glyph/compare/3de5f1b..9d8956f):
  9d8956f  2023-05-19  Devon Carew  blast_repo fixes (#38)

test (https://github.com/dart-lang/test/compare/cdedf40..309596e):
  309596e4  2023-05-22  Devon Carew  blast_repo fixes (#2019)

test_reflective_loader (https://github.com/dart-lang/test_reflective_loader/compare/d1b763f..40d61b1):
  40d61b1  2023-05-19  Devon Carew  blast_repo fixes (#49)

tools (https://github.com/dart-lang/tools/compare/49da4ca..0eb4141):
  0eb4141  2023-05-18  Elias Yishak  Update usage guide for onboarding users (#90)

Change-Id: Id462318b1ea33bb1a6dea3c426d5306048a2cceb
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/304765
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Auto-Submit: Devon Carew <devoncarew@google.com>
This issue was closed.
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). P1 A high priority bug; for example, a single project is unusable or has many test failures
Projects
None yet
Development

No branches or pull requests

3 participants