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

Left shift by negative amount causes analyzer crash #33481

mkustermann opened this Issue Jun 18, 2018 · 2 comments


None yet
4 participants
Copy link

mkustermann commented Jun 18, 2018

% cat test.dart
 class X { final x; const X(this.x); }

 void main() {
   print(const X(1 << -1).x);

% dartanalyzer  test.dart     
Analyzing test.dart...                                                                       
Unhandled exception:                                                                               
Invalid argument(s): -1                                                                                
#0      int._shlFromInt (dart:core/runtime/libintegers.dart:465:53)                   
#1      int.<< (dart:core/runtime/libintegers.dart:60:39)                                     
#2      IntState.shiftLeft (package:analyzer/src/dart/constant/value.dart:2288:33)                  
#3      DartObjectImpl.shiftLeft (package:analyzer/src/dart/constant/value.dart:638:40)
#4      DartObjectComputer.shiftLeft (package:analyzer/src/dart/constant/evaluation.dart:1991:28)
#5      ConstantVisitor.visitBinaryExpression (package:analyzer/src/dart/constant/evaluation.dart:1291:34)
#6      BinaryExpressionImpl.accept (package:analyzer/src/dart/ast/ast.dart:1215:49)            
#7      ConstantVisitor._valueOf (package:analyzer/src/dart/constant/evaluation.dart:1672:49)
#8      ConstantEvaluationEngine.evaluateConstructorCall (package:analyzer/src/dart/constant/evaluation.dart:446:45)
#9      ConstantVerifier.visitInstanceCreationExpression (package:analyzer/src/generated/resolver.dart:1667:26)                           
#10     InstanceCreationExpressionImpl.accept (package:analyzer/src/dart/ast/ast.dart:6577:15)                                       
#11     PropertyAccessImpl.visitChildren (package:analyzer/src/dart/ast/ast.dart:9167:14)                             
#12     RecursiveAstVisitor.visitPropertyAccess (package:analyzer/dart/ast/visitor.dart:1079:10)                         
% dartanalyzer --version
dartanalyzer version 2.0.0-dev.63.0

This comment has been minimized.

Copy link
Member Author

mkustermann commented Jun 19, 2018

Actually there are 3 issues with integers:

  • left shift by negative shifter: Crash
  • right shift by negative shifter: Crash
  • modulos of 0: MissingCompileTimeError

I'll add at test for this and mark it in the status files.

dart-bot pushed a commit that referenced this issue Jun 19, 2018

[VM] Catch errors for integer operations in kernel2kernel constant ev…

Issue #33481

Closes #33469

Change-Id: I7ca9825a0aa5f062732a759b4dd116e716a0d1b3
Reviewed-by: Vyacheslav Egorov <>

@bwilkerson bwilkerson added the type-bug label Aug 28, 2018

@bwilkerson bwilkerson added this to the Dart2.1 milestone Aug 28, 2018

@scheglov scheglov self-assigned this Sep 5, 2018


This comment has been minimized.

Copy link

scheglov commented Sep 5, 2018

@scheglov scheglov closed this Sep 5, 2018

dart-bot pushed a commit that referenced this issue Sep 5, 2018

Fix constant computing for negative shift left/right and remainder.

Bug: #33481
Change-Id: I0cc1b07b222f1fe739df6c720d7357a2453ee1b9
Reviewed-by: Brian Wilkerson <>
Commit-Queue: Konstantin Shcheglov <>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.