fix(lang): avoid infinite loop when calling assert()

The current code doesn't function properly:
- assert are never activated
- even if activated would result in infinite loop

Since the code is broken and blocks other use-cases
this commit turns assert into noop. A proper solution
for asserts will be part of #2830

Fixes #4981

Closes #4983
This commit is contained in:
Pawel Kozlowski 2015-10-28 18:21:47 +01:00
parent c90e1920f5
commit 5c48236f61
1 changed files with 2 additions and 5 deletions

View File

@ -37,18 +37,15 @@ export function getTypeNameForDebugging(type: Type): string {
export var Math = _global.Math;
export var Date = _global.Date;
var assertionsEnabled_ = typeof _global['assert'] !== 'undefined';
export function assertionsEnabled(): boolean {
return assertionsEnabled_;
return false;
}
// TODO: remove calls to assert in production environment
// Note: Can't just export this and import in in other files
// as `assert` is a reserved keyword in Dart
_global.assert = function assert(condition) {
if (assertionsEnabled_) {
_global['assert'].call(condition);
}
// TODO: to be fixed properly via #2830, noop for now
};
// This function is needed only to properly support Dart's const expressions