(dev2.0) Inherited type constructor issue
See original GitHub issueThis is compiling just fine with the master branch, but not in dev2.0:
open System.Collections.Generic
type ConcurrentDictionary<'TKey, 'TValue when 'TKey: equality> =
inherit Dictionary<'TKey, 'TValue>
new () = { inherit Dictionary<'TKey, 'TValue>() }
new (comparer: IEqualityComparer<'TKey>) = { inherit Dictionary<'TKey, 'TValue>(comparer) }
member x.TryAdd (key:'TKey, value:'TValue) = x.[key] <- value; true
Here is the result, the constructors are messed up, the return is not in the right place:
import { tryGetValue, comparerFromEqualityComparer } from "./fable-core.2.0.0-alpha-020/Util";
import { createMutable } from "./fable-core.2.0.0-alpha-020/Map";
export function ConcurrentDictionary$00602$$$$002Ector() {
new Map([]);
return new ConcurrentDictionary$00602();
}
export function ConcurrentDictionary$00602$$$$002Ector$$1(comparer) {
createMutable([], comparerFromEqualityComparer(comparer));
return new ConcurrentDictionary$00602();
}
export function ConcurrentDictionary$00602$$TryAdd(x, key, value) {
x.set(key, value);
return true;
}
Issue Analytics
- State:
- Created 5 years ago
- Reactions:1
- Comments:12 (10 by maintainers)
Top Results From Across the Web
Delphi XE2 - Inheriting class not calling base ...
When creating a class that inherits from another class, shouldn't it be true that when the derived class is created the base classes's ......
Read more >c++ - Why are constructors not inherited?
There can't be any proper inheritance of constructors in C ++, because the constructor of a derived class needs to perform additional actions ......
Read more >CHANGES — automaton 1.7.2.dev2 documentation
1.2.0¶. Add a state-space machine building example; Ensure state space can also pass on_enter/exit callbacks; Updated from global requirements ...
Read more >Problems with overriding and template function
I've tried using a virtual function in the base class to access ... ftree(void) {name[0] = parent[0] = child[0] = 0;} // default...
Read more >SYCL™ 2020 Specification (revision 7) - Khronos Registry
The terminology used for SYCL inherits historically from OpenCL with some ... Type T has at least one eligible copy constructor, move constructor, ......
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Closing as the suggested alternative seems to work.
Hmm, the REPL gives me something like this:
Probably this is working due to a happy coincidence of not compiling to ES5, using a JS engine that accepts inheritance from native types with classes, and the autogeneration of the class constructor. But the secondary constructors look faulty, and this will definitely not work with a custom comparer 😕