We're updating the issue view to help you get more done. 

Self-host: Protocol prefixing broken for three- (or more) segment namespaces

Description

There is a protocol-prefix method in core.cljc (and also, in compiler.cljc) which employs .replace. In Java, this ends up replacing all occurrences of the old character with the new character, while in JavaScript, the same call only replaces the first character.

This results in breakage if attempting to make use of protocols in three- (or more) segment namespaces under self-host as the resulting emitted JavaScript will have some . characters in the namespace not converted to $ characters as desired.

Take for example the following REPL interaction

1 2 3 4 5 cljs.user=> (ns three.seg.core) nil three.seg.core=> (defprotocol IFoo (baz [x])) nil three.seg.core=> (deftype Foo [z] three.seg.core/IFoo (baz [x] z))

This will work fine in, say, noderepljs, where a line like the following appears in the emitted JavaScript:

1 three.seg.core.Foo.prototype.three$seg$core$IFoo$ = true;

but in a self-host REPL, this will cause JavaScript to be emitted that looks like this:

1 three.seg.core.Foo.prototype.three$seg.core$IFoo$ = true;

which will fail to be evaluated properly.

Environment

None

Status

Assignee

David Nolen

Reporter

Mike Fikes

Labels

Approval

None

Patch

None

Affects versions

1.7.145

Priority

Minor