Giter Club home page Giter Club logo

goscript's People

Contributors

cryze avatar makotoe avatar nnbnh avatar oxfeeefeee avatar tuqqu avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

goscript's Issues

Dot import does not work

The Dot import syntax brings the entire package into the current namespace. So, you don’t have to call the functions using the package name. You can directly call them.

Reproduction code

package main

import (
  . "fmt2"
)

func main() {
  Println("Hello, World!")
}

Expected Results

That it would print out "Hello, World!"

Actual Results

thread 'main' panicked at 'called `Option::unwrap()` on a `None` value', ...goscript/codegen/src/package.rs:47:60

member resolution fails with embedded structs

Hello! Wonderful project. I was playing around with embedded structs as they're a golang feature I quite like, and I found that fields and methods aren't promoted in goscript like they are in golang proper:

package main

import (
	"fmt"
)

type Base struct {
	name string
}
func (b Base) PrintField() {
	fmt.Println(b.name)
}

type Container struct {
	Base
}

func main() {
	t := Container{Base{"go"}}
        //t.PrintField() //error in goscript, but works in golang
	t.Base.PrintField() //have to use this instead
}

I'm not sure if this is an issue with the go specs, or simply this implementation. I'm not even sure if implementing field promotion is on the table. But I felt it was worth bringing up anyway.
The error specifically when trying to run this script is:
thread 'main' panicked at 'no entry found for key', ...\vm\src\metadata.rs:493:9
so it seems to be an error with field name resolution.

Chinese typo

The Chinese character "非" (non-) has to be added directly to "官方" (official) to mean "non-official," so it shoud be "Go语言规范的非官方实现" instead of "Go语言规范非的官方实现."

Creating a map from Rust-land

I don't know if this was intentional, but on the registered-based branch, creating a map was possible from ffi.

How do I do this while using the master branch? The new_map function is only available within goscript crate.

pub(crate) fn new_map(gcc: &GcContainer) -> GosValue {

How do I convert this MapObj to a GosValue?
Screenshot 2023-08-29 at 05 55 49

Type conversion issue

I am working from the register-based library, because that is where I have managed to use the FFI API extensively. But I am having a type conversion problem

I have this go script file

package main

import (
	"zflow"
	"fmt2"
)

var in = zflow.Inputs()  // this returns map[string]interface{} type

func main() {
	fmt2.Println(in) // this prints map[left:1 right:2]
	// get inputs
	data, ok := in.(map[string]interface{})
	fmt2.Println(ok) // this prints false
	fmt2.Println(data) // this prints <nil(map)>
	
	left := data["left"]
	fmt2.Println(left) // this prints <nil>
  
}

Output:

map[right:2 left:1]
false
<nil(map)>
<nil>

Expected output
https://go.dev/play/p/qPNzh1RmyiQ

map[left:1 right:2]
true
map[left:1 right:2]
2

How do I correctly read a map value that is sent into the runtime via FFI function call?

Type assertion fails

Unwrapping b.as_ref() is not guaranteed, and fails sometimes when you pass an interface{} value into an ffi function.

let meta = b.as_ref().unwrap().0;

I wonder what the general behavior would be if you applied this as a fix

let want_meta = want_meta.as_metadata();
if b.is_none() {
   return Ok((want_meta.zero(metas, gcc), false));
}
let meta = b.as_ref().unwrap().0;

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.