Bug 244018
| Summary: | 'a\n' is considered as a variable | ||
|---|---|---|---|
| Product: | WebKit | Reporter: | 845043157 |
| Component: | JavaScriptCore | Assignee: | Nobody <webkit-unassigned> |
| Status: | NEW | ||
| Severity: | Normal | CC: | karlcow, saam, webkit-bug-importer, ysuzuki |
| Priority: | P2 | Keywords: | InRadar |
| Version: | Safari 15 | ||
| Hardware: | All | ||
| OS: | All | ||
845043157
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 | ||
|---|---|---|
| Add attachment proposed patch, testcase, etc. |
Karl Dubost
Safari, Firefox and Chrome return the same error message.
Karl Dubost
but indeed Firefox and Chrome normalizes the output to avoid the return.
Karl Dubost
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
'\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
Yes agreed.
But how do we help the developer to discover the error. :) That's where I was coming from.
845043157
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
<rdar://problem/99064631>