File tree Expand file tree Collapse file tree 4 files changed +35
-2
lines changed
Expand file tree Collapse file tree 4 files changed +35
-2
lines changed Original file line number Diff line number Diff line change @@ -1574,7 +1574,8 @@ export class Compiler extends DiagnosticEmitter {
15741574 /** Force compilation of stdlib alternative if a builtin. */
15751575 forceStdAlternative : bool = false
15761576 ) : bool {
1577- if ( instance . is ( CommonFlags . Compiled ) ) return ! instance . is ( CommonFlags . Errored ) ;
1577+ if ( instance . is ( CommonFlags . Errored ) ) return false ;
1578+ if ( instance . is ( CommonFlags . Compiled ) ) return true ;
15781579
15791580 if ( ! forceStdAlternative ) {
15801581 if ( instance . hasDecorator ( DecoratorFlags . Builtin ) ) return true ;
Original file line number Diff line number Diff line change @@ -3850,7 +3850,15 @@ export class Function extends TypedElement {
38503850 flow . setLocalFlag ( local . index , LocalFlags . Initialized ) ;
38513851 }
38523852 }
3853- registerConcreteElement ( program , this ) ;
3853+ if ( program . instancesByName . has ( this . internalName ) ) {
3854+ program . error (
3855+ DiagnosticCode . Duplicate_function_implementation ,
3856+ prototype . declaration . name . range
3857+ ) ;
3858+ this . set ( CommonFlags . Errored ) ;
3859+ } else {
3860+ registerConcreteElement ( program , this ) ;
3861+ }
38543862 }
38553863
38563864 /** Gets the types of additional locals that are not parameters. */
Original file line number Diff line number Diff line change 1+ {
2+ "asc_flags" : [],
3+ "stderr" : [
4+ " EOF" ,
5+ " TS2300: Duplicate identifier 'inner'." ,
6+ " TS2393: Duplicate function implementation."
7+ ]
8+ }
Original file line number Diff line number Diff line change 1+ // Duplicate named function declarations in the same scope should
2+ // produce a diagnostic instead of crashing the compiler.
3+
4+ export function testMixed1 ( ) : void {
5+ const inner = function ( ) : void { } ;
6+ function inner ( ) : void { }
7+ inner ( ) ;
8+ }
9+
10+ export function test ( ) : void {
11+ function inner ( ) : void { }
12+ function inner ( ) : void { }
13+ inner ( ) ;
14+ }
15+
16+ ERROR ( "EOF" ) ;
You can’t perform that action at this time.
0 commit comments