NEW244018
'a\n' is considered as a variable
https://bugs.webkit.org/show_bug.cgi?id=244018
Summary 'a\n' is considered as a variable
845043157
Reported 2022-08-16 20:22:34 PDT
Run the program: var a=1; a (); JSC: TypeError:a is not a function V8 & SpiderMonkey: TypeError:a is not a function In the error message,'a/n' is output as the variable name but the really variable name is 'a'.I think it may be a bug.
Attachments
Karl Dubost
Comment 1 2022-08-16 21:19:46 PDT
Safari, Firefox and Chrome return the same error message.
Karl Dubost
Comment 2 2022-08-16 21:56:46 PDT
but indeed Firefox and Chrome normalizes the output to avoid the return.
Karl Dubost
Comment 3 2022-08-16 21:59:24 PDT
Full Safari output ``` TypeError: a is not a function. (In 'a ()', 'a ' is 1) ``` I wonder if it would be better to actually shows the output as: ``` TypeError: a\n is not a function. (In 'a\n()', 'a\n' is 1) ```
845043157
Comment 4 2022-08-18 01:27:59 PDT
'\n' is illegal in variable name and function name.'var a\nb=1' will throw a SyntaxError.So print 'TypeError: a\n is not a function.' may be not a good idea.It regard 'a\n' as a variable name. But '\n' is meaningless in the end of variable name and function name and will be ignored. If running the following program: var a =1; print(a); print(a ); a=2; print(a); print(a ); It output: 1 1 2 2 So during compilation,'\n' in the end of variable name and function name will be ignored.The '\n' of variable name 'a\n' will be ignored and 'a\n' is regarded as 'a'. I think 'TypeError:a is not a function' is better.
Karl Dubost
Comment 5 2022-08-18 01:57:45 PDT
Yes agreed. But how do we help the developer to discover the error. :) That's where I was coming from.
845043157
Comment 6 2022-08-18 03:58:19 PDT
All I know is that I can report the bug in this website.Isn't it the bug tracking system for JSC?
Radar WebKit Bug Importer
Comment 7 2022-08-23 20:23:18 PDT
Note You need to log in before you can comment on or make changes to this bug.