@@ -3404,6 +3404,38 @@ def test_compilation_database(self):
3404
3404
self .run_process ([EMCC , 'a.c' , '-MJ' , 'hello.json' , '-c' , '-o' , 'test.o' ])
3405
3405
self .assertContained ('"file": "a.c", "output": "test.o"' , read_file ('hello.json' ))
3406
3406
3407
+ def test_duplicate_js_functions (self ):
3408
+ create_file ('duplicated_func.c' , '''
3409
+ #include <stdio.h>
3410
+ extern int duplicatedFunc();
3411
+
3412
+ int main() {
3413
+ int res = duplicatedFunc();
3414
+ printf("*%d*\\ n", res);
3415
+ return 0;
3416
+ }
3417
+ ''' )
3418
+ create_file ('duplicated_func_1.js' , '''
3419
+ mergeInto(LibraryManager.library, {
3420
+ duplicatedFunc : function() {
3421
+ return 1;
3422
+ }
3423
+ }, { noOverride: true }
3424
+ );
3425
+ ''' )
3426
+ create_file ('duplicated_func_2.js' , '''
3427
+ mergeInto(LibraryManager.library, {
3428
+ duplicatedFunc : function() {
3429
+ return 2;
3430
+ }
3431
+ }, { noOverride: true }
3432
+ );
3433
+ ''' )
3434
+
3435
+ self .emcc_args += ['--js-library' , 'duplicated_func_1.js' , '--js-library' , 'duplicated_func_2.js' ]
3436
+ err = self .expect_fail ([EMCC , 'duplicated_func.c' ] + self .get_emcc_args ())
3437
+ self .assertContained ('error: Symbol re-definition in JavaScript library: duplicatedFunc. Do not use noOverride if this is intended' , err )
3438
+
3407
3439
def test_js_lib_quoted_key (self ):
3408
3440
create_file ('lib.js' , r'''
3409
3441
mergeInto(LibraryManager.library, {
0 commit comments