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