sharjeelyunus/github-issues-dataset huggingface dataset:
Repository: TypeScript
Issue: Inherited typing for class property initializers
Labels: Suggestion,In Discussion

# Problem

Initializing a class member with things like `{ }`, `null`, `undefined`, or `[]` has unexpected behavior.

``` ts
class Base {
  favorites = ["red", "blue"];
}
class Derived extends Base {
  favorites = [];
  constructor() {
    this.favorites.push('green'); // Can't push string onto never[], wat?
  }
}
```

``` ts
interface Settings {
  size?: number;
  color?: string;
}
class Base {
  settings: Settings = { size: 42 };
}
class Derived extends Base {
  settings = { };
  constructor() {
    if (big) this.settings = { siz: 100 }; // no error, wat?
  }
}
```
# Solution

New rule: When a class property is initialized with exactly `null`, `undefined`, `{ }`, or `[]`, the type of the property is taken from the same property of the _inherited type_ (if one exists), rather than the type of the initializer.

The _inherited type_ is `B & I1 & I2 & ...` where `B` is the base class and `I1`, `I2`, `...` are the `implement`ed interfaces of the class.
# Examples

``` ts
interface Positionable {
  position: string | null;
}
class MyPos implements Positionable {
  position = null;
  setPos(x: string) {
    this.position = x;
  }
  getPos() {
    return this.position.subtr(3); // error detected
  }
}
```

``` ts
class Base {
  items = ['one'];
}
class Derived extends Base {
  items = []; // no longer an implicit any
}
var x = new Derived();
x.items.push(10); // Error as expected
```
# Bad Ideas We Thought Were good

![image](https://cloud.githubusercontent.com/assets/6685088/18022117/1aad819e-6ba1-11e6-9a33-c2beab0051ef.png)

Contextual typing plays poorly with other behavior such as unit type positions. Consider

``` ts
enum E { A, B, C }
class Base {
  thing = E.A;
}
class Derived extends Base {
  thing = E.B;
  change() {
    this.thing = E.C; // Error! wat
  }
}
```

This turns into a big problem because the `E.B` expression is contextually typed by the unit-like type `E.A | E.B | E.C` and so acquires the _specific_ type `E.B` rather than the intended type `E`! Daniel found this break in Azure.

/cc conspirators @DanielRosenwasser @sandersn
Repository: TypeScript
Issue: Allow skipping some generics when calling a function with multiple generics
Labels: Suggestion,In Discussion

Right now in TypeScript it's all or nothing when calling generic methods. You can either skip typing all the generics altogether and they will be inferred from the context (if possible), or you have to manually (re)define all of them. But the reality isn't black and white, there are also shades of gray, where we can infer types for some of the generic parameters, but not others. Currently those have to be unnecessarily verbose by forcing the programmer to explicitly restate them.

Take a look at these 3 cases:

Case 1 - everything can be inferred - no need to call the method with `<>` definition:

``` ts
function case1<A, B, C>(a: A, b: B, c: C): A {}

example(1, '2', true);
```

Compiler knows that:
 A is number
 B is string
 C is boolean

---

Case 2 - nothing can be inferred, so we need to state what A, B and C should be, otherwise they'll default to `{}`:

``` ts
function case2<A, B, C>(): A {}

example<number, string, boolean>();
```

---

Case 3 - the one that's interesting to this feature request - some can be inferred, some can't:

``` ts
function case3<A, B, C>(b: string, c: boolean): A {}

// incorrect type of A - left unspecified:
example('thing'); 

// correct, but unnecessarily verbose - we already know that 'thing' is a string and true is a bool
example<number, string, boolean>('thing', true);
```

Now, typing `string, boolean` in the above example isn't a big deal, but with complex scenarios, say with a method using 5 generics, where you can infer 4 of them, retyping them all seems overly verbose and prone to error.

It would be great if we could have some way to skip re-typing the types that can automatically be inferred. Something like a special `auto` or `inferred` type, so we could write:

``` ts
example<number, auto, auto>('thing', bool);
```

Or maybe even, if we only want to specify those up to a certain point:

``` ts
example<number>('thing', bool);
```

The above "short-hand" notation could perhaps be different to account for function overloads with different number of generics.

Having such a feature would solve newcomers encountering problems such as this one: http://stackoverflow.com/questions/38687965/typescript-generics-argument-type-inference/38688143
Repository: go
Issue: runtime: profile goroutine creation
Labels: NeedsDecision

Most unbounded Go memory leaks I've encountered have been due to goroutine leaks. When diagnosing these leaks, it would be helpful to know what function call stack led to the creation of the goroutines so we can link the goroutines back to the non-stdlib code that created them—_why_ the goroutine exists, in addition to its start PC. This is the same vein in which the current heap profiles include the stack that allocated the memory rather than just the PC and type of the allocation.

Related proposal for file descriptor profiling: #16379

---

A popular way to leak goroutines is by making http requests and not closing the response body. That problem could be targeted more specifically with a good static analysis tool, similar to vet's new -lostcancel check. Both approaches would be helpful.
Repository: go
Issue: x/playground: GOSSAFUNC mode
Labels: NeedsDecision

Maybe with a button to switch it on.

It would be useful for posting issues regarding compiler outputs in discussions.

PS. This is not a bug or feature request regarding programs written in Go so I think it's fine to ignore answering the following questions.

> Please answer these questions before submitting your issue. Thanks!
Repository: rust
Issue: Rustdoc generates docs for hidden methods in impls
Labels: T-rustdoc,A-trait-system,A-impl-trait,C-bug

I've seen #34025, but in the following case `rustdoc` still generates documentation for `hidden()` in the `impl Bar for Foo` (but as `tymethod` instead of `method`). It works correctly if `hidden()` is also marked as hidden in the trait _definition_.

``` rust
pub struct Foo;

pub trait Bar {
    fn test();
    fn hidden();
}

impl Bar for Foo {
    fn test() {}
    #[doc(hidden)] fn hidden() {}
}
```

`rustc -V`:
`rustc 1.13.0-nightly (e9bc1bac8 2016-08-24)`
Repository: opencv
Issue: GRIP: The Graphically Represented Image Processing engine
Labels: RFC

I would like to share one cool user facing implementation of OpenCV in a nicely bundled up application.
I'm the developer behind [GRIP](https://github.com/WPIRoboticsProjects/GRIP) and would like to share with everyone.

The goal of this project was to build an application that non-experts could use to construct
computer vision algorithms, and more experienced users could use to develop algorithms
faster. Given the time constraints imposed by robotics challenges like the FIRST Robotics
Competition, computer vision is often underutilized by even the most experienced players.
We used Java and OpenCV to implement a user interface to make rapidly developing
vision systems easier. As a result, many teams successfully used our software in the 2016
FIRST Robotics Competition. We believe that our application could be used for further
applications in research and education.

We will be adding code generation within the next month for Java, Python and C++.

Its currently being developed with a focus on FIRST Robotics but can be useful in a variety of fields.

Is there a better place to post this? Is there somewhere that people may find this too useful?
[GRIP-MQP.pdf](https://github.com/opencv/opencv/files/440782/GRIP-MQP.pdf)
Repository: rust
Issue: redundant E0210 (coherence) after E0120 (blanket Drop impl)
Labels: A-diagnostics,T-compiler,D-verbose

```
$ cargo script -e 'trait Trait {}      impl<T: Trait> Drop for T { fn drop(&mut self) { } }'
   Compiling expr v0.1.0 (file:///Users/alex/.multirust/toolchains/beta/cargo/.cargo/script-cache/expr-223e68b0943558e6)
error[E0120]: the Drop trait may only be implemented on structures
 --> /Users/alex/.multirust/toolchains/beta/cargo/.cargo/script-cache/expr-223e68b0943558e6/expr.rs:5:41
  |
5 | {trait Trait {} impl<T: Trait> Drop for T { fn drop(&mut self) { } }}
  |                                         ^ implementing Drop requires a struct

error[E0210]: type parameter `T` must be used as the type parameter for some local type (e.g. `MyStruct<T>`); only traits defined in the current crate can be implemented for a type parameter
 --> /Users/alex/.multirust/toolchains/beta/cargo/.cargo/script-cache/expr-223e68b0943558e6/expr.rs:5:17
  |
5 | {trait Trait {} impl<T: Trait> Drop for T { fn drop(&mut self) { } }}
  |                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error: aborting due to 2 previous errors

error: Could not compile `expr`.
```
Repository: go
Issue: x/image: packages to render TrueType fonts
Labels: Proposal,Proposal-Accepted

github.com/golang/freetype already exists, but its license (the Freetype license) differs from the Go standard library, and code in the stdlib or under golang.org/x cannot depend on out-of-tree code.

I propose to add two new packages in the golang.org/x/image repo that together lets you use TTFs to draw text. There are existing packages under golang.org/x/image/font that can draw bitmap fonts, but this would be the first golang.org/x package that draws vector fonts.

The golang.org/x/image/vector package rasterizes 2-D vector graphics: filled and stroked polygons and Bézier curves. 2-D vector graphics (and the scope of this package) encompasses more than just fonts, but this package will rasterize the glyphs of a vector font such as TrueType. It'd be comparable to the github.com/golang/freetype/raster package, but not based on the Freetype code.

The golang.org/x/image/font/sfnt package parses sfnt font formats, including TrueType (.ttf) and OpenType (.otf). It will implement the existing golang.org/x/image/font font.Face interface for font format agnostic text drawing. It'd be comparable to the github.com/golang/freetype/truetype package, but not based on the Freetype code.

A proof of concept (as a single "package main" instead of two separate packages) exists in a separate repository, https://github.com/google/font-go, which is in turn based on https://github.com/google/font-rs and the accompanying article (https://medium.com/@raphlinus/inside-the-fastest-font-renderer-in-the-world-75ae5270c445) by Raph Levien of Google. Roughly speaking, font.go would become package sfnt, and raster.go and acc*.{go,s} would become package vector.
Repository: node
Issue: Lexical variable declarations (`let`, `const`) unusable in repl if error thrown during declaration/first assignment
Labels: repl,vm

- **Version**: v.6.3.1
- **Platform**: Linux (Ubuntu 14.04)
- **Subsystem**: `repl` (I think)

<!-- Enter your issue details below this comment. -->

```
let s = Set();
```

gives `TypeError: Constructor Set requires 'new'`.

However, after this:

```
s
```

gives `ReferenceError: s is not defined`

and

```
let s = new Set();
```

gives `TypeError: Identifier 's' has already been declared`.

I'm not sure whether this is a real bug or it's expected behaviour, but it sure does seem unusual that `s` becomes unusable from this point in in the repl.

This isn't a problem when running `node` on a js file because the TypeError simply terminates execution.
Repository: youtube-dl
Issue: [awaan] Add support for login
Labels: account-needed

Hi. Could you add support for awaan.ae videos that require login with password and username?Thanks in advance!
Repository: rust
Issue: odd span with unused import generated by macro
Labels: A-lints,A-macros,C-bug

I noticed this in a much more complex macro (it was recursive), but I minimized it:

``` rust
macro_rules! m { ($($i:ident)*) => { use $($i)::*; } }

m!(std cmp);
```

```
warning: unused import, #[warn(unused_imports)] on by default
 --> /Users/alex/.multirust/toolchains/beta/cargo/.cargo/script-cache/expr-8aedeaeb93034069/expr.rs:5:64
  |
5 | {macro_rules! m { ($($i:ident)*) => { use $($i)::*; } } m!(std cmp);}
  |                                                                ^^^
```

I can't say the span is wrong... but it also doesn't seem right. cc @jonathandturner
Repository: go
Issue: doc: document assembly calling convention
Labels: Documentation,help wanted,NeedsFix

We should probably specify the Go calling convention in doc/asm.html, at least to a degree.

Might be especially useful as a reference when we get around to changing it.

@cherrymui @dr2chase @nigeltao
Repository: opencv
Issue: medianBlur slowness with grayscale images
Labels: bug,category: core,affected: 3.4

<!--
If you have a question rather than reporting a bug please go to http://answers.opencv.org where you get much faster responses.
If you need further assistance please read [How To Contribute](https://github.com/opencv/opencv/wiki/How_to_contribute).

This is a template helping you to create an issue which can be processed as quickly as possible. This is the bug reporting section for the OpenCV library.
-->
##### System information (version)
- OpenCV => 3.1
- Operating System / Platform => Windows 64 Bit
- Compiler => Visual Studio 2015
##### Detailed description

src image: 2000x2000 bmp color image 
median blur with ksize = 5
time elapsed ~70ms

src image: 2000x2000 bmp grayscale image
median blur with ksize = 5
time elapsed ~3700ms
##### Steps to reproduce

``` .cpp
    // C++ code example
        Mat src = imread(imageFileName);
        Mat out;
        medianBlur(src, out, 5); //70ms

        Mat src2 = imread(imageFileName, IMREAD_GRAYSCALE);
        medianBlur(src2, out, 5); //3700ms

        Mat src3 = imread(imageFileName, IMREAD_GRAYSCALE);
        cvtColor(src3, src3, CV_GRAY2BGR);
        medianBlur(src3, out, 5); //70ms
        cvtColor(out, out, CV_BGR2GRAY); //total process ~100ms 
```
Repository: go
Issue: cmd/compile: move most (*Type).IsFoo methods to (EType).IsFoo
Labels: NeedsFix,early-in-cycle

In type.go, we have a bunch of helper methods like IsInteger, IsSigned, IsPtrShaped, etc. that currently can only be used on specific types (i.e., `*Type`), but many of these are really properties of type kinds (`EType`).  This is annoying in parts of the compiler where we don't care about type identity anymore, but would still care about properties like signedness/etc.

I think we should change Type's `Etype EType` field into an embedding of EType and change these method's receiver parameters from `*Type` to `EType`.

Some need to stay on `*Type` though; notably IsEmptyInterface and IsUntyped, because they depend on properties of the specific type.

It's a bit redundant for the single-kind methods like IsMap to be moved to EType, but for consistency we might as well move them too.

Filing as an issue in case anyone objects or has alternative proposals.
Repository: rust
Issue: "mod lib" in lib.rs produces incorrect error message
Labels: A-diagnostics,A-parser,T-compiler,C-bug

lib.rs:

```
mod a1;
mod lib;
```

a1.rs - empty file.

Error:

```
error: cannot declare a new module at this location
 --> src/lib.rs:1:5
  |
1 | mod a1;
  |     ^^
  |
note: maybe move this module `lib` to its own directory via `lib/mod.rs`
 --> src/lib.rs:1:5
  |
1 | mod a1;
  |     ^^
note: ... or maybe `use` the module `a1` instead of possibly redeclaring it
 --> src/lib.rs:1:5
  |
1 | mod a1;
  |     ^^
```

Error location and some of the messages incorrectly refer to a1 module instead of lib. Module a1 itself is declared correctly. If I write lib before a1, the error starts making more sense:

lib.rs:

```
mod lib;
mod a1;
```

Error:

```
error: cannot declare a new module at this location
 --> src/lib.rs:1:5
  |
1 | mod lib;
  |     ^^^
  |
note: maybe move this module `lib` to its own directory via `lib/mod.rs`
 --> src/lib.rs:1:5
  |
1 | mod lib;
  |     ^^^
note: ... or maybe `use` the module `lib` instead of possibly redeclaring it
 --> src/lib.rs:1:5
  |
1 | mod lib;
  |     ^^^
```
Repository: flutter
Issue: "flutter" tool poorly handles there being a file called "build" in the project directory
Labels: tool,a: quality,P3,team-tool,triaged-tool

If a project directory contains a file named 'build', there will be a name collision with Flutter's build directory.

To my understanding, there also exists a system-level configuration to specify the name of the build directory, but this would be impractical to configure on a team with a large number of people switching between projects based out of different version control systems.

Is there or can there be a way to avoid this name collision on a project scale?

(if you would like additional clarification, feel free to ping me)
Repository: opencv
Issue: Python binding for `findChessboardCorners` adds an extra dimension
Labels: RFC

##### System information (version)
- OpenCV => 3.1.0
- Operating System / Platform => OS X 10.11.6
- Compiler => clang 7.3.0
- Python => 3.5.2
##### Detailed description

Calling `cv2.findChessboardCorners` returns a 3-dimensional array, including a redundant empty dimension. 

This behavior does not exist in the C++ API if a `std::vector<cv::Vec2f>` is passed as the output parameter, but is replicated if a `cv::Mat` is passed as an output parameter.
##### Steps to reproduce

``` .py
import cv2
_, img = cv2.imread('my_7x9_chessboard.jpg', cv2.IMREAD_GRAYSCALE)
chessboard_shape = 7, 9
pattern_found, image_corners = cv2.findChessboardCorners(img, chessboard_shape)
print(image_corners.shape)  # prints (63, 1, 2); should be (63, 2)
```
Repository: angular
Issue: UseCapture:true event handlers
Labels: feature,freq1: low,area: core,core: event listeners,P3,feature: under consideration

**I'm submitting a ...**  (check one with "x")

```
[ ] bug report => search github for a similar issue or PR before submitting
[X ] feature request
[ ] support request => Please do not submit support request here, instead see https://github.com/angular/angular/blob/master/CONTRIBUTING.md#question
```

**Current behavior**
All events (click, keys, etc) are registered with a `addEventListener(...,()=>{...},false)` in the browser_adapter. If we want to "cancel" them ahead, by capturing the event and calling stopPropagation(), we have to use a non-angular native JS.

```
element.nativeElement.addEventListener('click', (event: MouseEvent) => {
            if (someCondition)
                event.stopImmediatePropagation();
        }, true);
```

**Desired behavior**
A way to add a handler to an element that adds the event listener to the capture phase. I leave the syntax to you, but something like `@HostListener('~click',['$event'])` seems logical to me (and similarly `(~click)="..."`).

**What is the motivation / use case for changing the behavior?**
Creating directives that disables clicks/key events/etc. If the element has a custom handler on it, we need to cancel the event BEFORE it gets there.

**Please tell us about your environment:**
- **Angular version:** 2.0.0-rc.4
Repository: vscode
Issue: Remove whitespace and indent to the right spot when the line has more whitespace than necessary
Labels: feature-request,editor-autoindent

Extracted from https://github.com/Microsoft/vscode/issues/2938#issuecomment-235987405

---

From @chrmarti 

Works, except when there is already the full indentation (or more) on the line. It would make sense to make it work the same way in that case:

![indent](https://cloud.githubusercontent.com/assets/9205389/17225083/5eadbb98-54b8-11e6-8b28-21bba9fde257.gif)
Repository: TypeScript
Issue: Recursively Resolving Modules
Labels: Suggestion,Needs Proposal

<!-- BUGS: Please use this template. -->

<!-- QUESTIONS: This is not a general support forum! Ask Qs at http://stackoverflow.com/questions/tagged/typescript -->

<!-- SUGGESTIONS: See https://github.com/Microsoft/TypeScript-wiki/blob/master/Writing-Good-Design-Proposals.md -->

**TypeScript Version:**  2.1.0

I'm using ts-loader and Webpack to compile my .ts files. In My Webpack config I have the following configuration:

```
resolve: {
  modulesDirectories: ['shared', 'node_modules']
}
```

This allows me to import a component that lives in the shared directory without spelling out the full relative path. Example: 
`import Button from 'components/Button'`

Webpack will walk up the directory tree and use the first `shared` directory it finds (the same way it does with the `node_modules` directories). This way, the component can live in the `../../shared/components/Buttton.tsx` and Webpack will find it and bundle it.

My files compile fine because I am using ts-loader but I am getting `can not find module` errors in my editor.

Is there a way to tell the TS compiler to recursively look for the component in the shared directories?

I noticed the new `baseUrl` and `paths` configuration option but to my knowledge you can not use `paths` to recursively look for a directory.
Repository: go
Issue: x/net/websocket: fails to Receive a single frame sent in chunks from Browser
Labels: NeedsInvestigation

Please answer these questions before submitting your issue. Thanks!
### What version of Go are you using (`go version`)?

1.5 to 1.7
### What operating system and processor architecture are you using (`go env`)?

GOARCH="amd64"
GOBIN=""
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/matthew/code/go:/home/matthew/code/go"
GORACE=""
GOROOT="/usr/local/go"
GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64"
CC="gcc"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build629490277=/tmp/go-build -gno-record-gcc-switches"
CXX="g++"
CGO_ENABLED="1"
### What did you do?

This is a very difficult issue to reproduce, as the browsers themselves don't always exhibit the problem.
Reproducing in our environment means sending a large >120k websocket message from the Browser (tested on Chrome) to the Go program from a "clean" browser - meaning either all caches, cookies cleared, or a new Incognito mode browser.
When sent to the server, the browser will chunk the frame into multiple parts, setting the hybiFrameReader.header.Fin bit to false
### What did you expect to see?

I expected the whole frame to arrive.
### What did you see instead?

arbitrary cut off of string frame.

My fix was to change the Receive function to check if the frame Fin was false, and if so, goto Again:

``` go
// Receive receives single frame from ws, unmarshaled by cd.Unmarshal and stores in v.
func (cd Codec) Receive(ws *Conn, v interface{}) (err error) {
    ws.rio.Lock()
    defer ws.rio.Unlock()
    if ws.frameReader != nil {
        _, err = io.Copy(ioutil.Discard, ws.frameReader)
        if err != nil {
            return err
        }
        ws.frameReader = nil
    }
    var b bytes.Buffer
again:
    frame, err := ws.frameReaderFactory.NewFrameReader()
    if err != nil {
        return err
    }
    frame, err = ws.frameHandler.HandleFrame(frame)
    if err != nil {
        return err
    }
    if frame == nil {
        goto again
    }
    payloadType := frame.PayloadType()
    data, err := ioutil.ReadAll(frame)
    if err != nil {
        return err
    }
    _, err = b.Write(data)
    if err != nil {
        return err
    }
    if !frame.(*hybiFrameReader).header.Fin {
        goto again
    }
    return cd.Unmarshal(b.Bytes(), payloadType, v)
}

I have a feeling Read(...) also suffers from this problem.
```