Skip to content

Commit

Permalink
Merge branch 'main' into fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Lycs-D committed Mar 21, 2024
2 parents 25d05d2 + 3439620 commit 2552589
Show file tree
Hide file tree
Showing 15 changed files with 1,375 additions and 782 deletions.
3 changes: 0 additions & 3 deletions .github/workflows/analyzer_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,4 @@ jobs:
submodules: true

- name: Run tests
run: cd tests && v run .

- name: Run other V tests
run: v test .
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Release Development Version
name: Release

on:
workflow_dispatch:
Expand All @@ -12,7 +12,7 @@ on:
- '**/*_test.v'
- '**/*.md'
- '.github/**'
- '!**/nightly_release.yml'
- '!**/release.yml'

permissions:
contents: write
Expand Down Expand Up @@ -51,7 +51,10 @@ jobs:
submodules: true

- name: Compile
run: v run build.vsh debug
shell: bash
run: |
[ $GITHUB_REF_TYPE == tag ] && mode="release" || mode="debug"
v run build.vsh $mode
- name: Upload artifact
uses: actions/upload-artifact@v4
Expand All @@ -62,23 +65,36 @@ jobs:
- name: Prepare release
shell: bash
run: |
now=$(date -u +'%Y-%m-%d %H:%M:%S UTC')
echo "BODY=Generated on <samp>$now</samp> from commit ${{ github.sha }}." >> $GITHUB_ENV
7z a -tzip ${{ env.ARTIFACT }}.zip ./bin/v-analyzer${{ matrix.bin_ext }}
if [ $GITHUB_REF_TYPE != tag ]; then
now=$(date -u +'%Y-%m-%d %H:%M:%S UTC')
echo "BODY=Generated on <samp>$now</samp> from commit ${{ github.sha }}." >> $GITHUB_ENV
fi
- name: Update nightly tag
if: github.ref_type != 'tag'
uses: richardsimko/update-tag@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: nightly

- name: Release
- name: Release development version
if: github.ref_type != 'tag'
uses: ncipollo/release-action@v1
with:
artifacts: ${{ env.ARTIFACT }}.zip
tag: nightly
body: ${{ env.BODY }}
name: v-analyzer development build
allowUpdates: true
prerelease: true

- name: Release latest version
if: github.ref_type == 'tag'
uses: ncipollo/release-action@v1
with:
artifacts: ${{ env.ARTIFACT }}.zip
allowUpdates: true
omitBodyDuringUpdate: true
omitNameDuringUpdate: true
14 changes: 9 additions & 5 deletions analyzer/psi/TypeInferer.v
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ pub fn (t &TypeInferer) infer_type(elem ?PsiElement) types.Type {

pub fn (t &TypeInferer) infer_type_impl(elem ?PsiElement) types.Type {
element := elem or { return types.unknown_type }

mut visited := map[string]types.Type{}

if element.node.type_name in [
.in_expression,
.not_in_expression,
Expand Down Expand Up @@ -179,7 +182,6 @@ pub fn (t &TypeInferer) infer_type_impl(elem ?PsiElement) types.Type {

if element is TypeInitializer {
type_element := element.find_child_by_type(.plain_type) or { return types.unknown_type }
mut visited := map[string]types.Type{}
return t.convert_type(type_element, mut visited)
}

Expand Down Expand Up @@ -252,6 +254,12 @@ pub fn (t &TypeInferer) infer_type_impl(elem ?PsiElement) types.Type {
}

if element is CallExpression {
if grand := element.expression() {
if grand is FunctionLiteral {
signature := grand.signature() or { return types.unknown_type }
return t.convert_type(signature.result(), mut visited)
}
}
return t.infer_call_expr_type(element)
}

Expand Down Expand Up @@ -347,21 +355,17 @@ pub fn (t &TypeInferer) infer_type_impl(elem ?PsiElement) types.Type {
}

if element is TypeReferenceExpression {
mut visited := map[string]types.Type{}
return t.infer_type_reference_type(element, mut visited)
}

if element is GlobalVarDefinition {
type_element := element.find_child_by_type_or_stub(.plain_type) or {
return types.unknown_type
}
mut visited := map[string]types.Type{}
return t.convert_type(type_element, mut visited)
}

if element is EmbeddedDefinition {
mut visited := map[string]types.Type{}

if qualified_type := element.find_child_by_type_or_stub(.qualified_type) {
return t.convert_type_inner(qualified_type, mut visited)
}
Expand Down
2 changes: 1 addition & 1 deletion editors/code/src/welcome.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ export class WelcomePanel {
this.update();

// Listen for when the panel is disposed
// This happens when the user closes the panel or when the panel is closed programatically
// This happens when the user closes the panel or when the panel is closed programmatically
this.panel.onDidDispose(() => this.dispose(), null, this.disposables);
}

Expand Down
5 changes: 3 additions & 2 deletions tests/main.v → tests/analyzer_test.v
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
module main
module tests

import os
import term
import testing

fn main() {
fn test_all() {
defer {
os.rmdir_all(testing.temp_path) or {
println('Failed to remove temp path: ${testing.temp_path}')
}
}
os.chdir(os.join_path(@VMODROOT, 'tests'))!

mut testers := []testing.Tester{}

Expand Down
2 changes: 1 addition & 1 deletion tests/bench.v
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module main
module tests

import testing

Expand Down
2 changes: 1 addition & 1 deletion tests/completion.v
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module main
module tests

import testing
import server.completion.providers
Expand Down
2 changes: 1 addition & 1 deletion tests/definitions.v
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module main
module tests

import testing

Expand Down
2 changes: 1 addition & 1 deletion tests/documenttion.v → tests/documentation.v
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module main
module tests

import testing

Expand Down
2 changes: 1 addition & 1 deletion tests/implementations.v
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module main
module tests

import testing

Expand Down
2 changes: 1 addition & 1 deletion tests/supers.v
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module main
module tests

import testing

Expand Down
Loading

0 comments on commit 2552589

Please sign in to comment.